/* «Старое дело»: пожелтевшая бумага с зерном, картонная обложка папки, машинописный текст (PT Mono), заголовки
   антиквой (Old Standard TT), подписи узким гротеском (PT Sans Narrow), красные штампы. Графики — как от руки:
   штриховка вместо заливки, миллиметровка вместо сетки, пик обведён красным карандашом.
   Цвета событий проверены dataviz-валидатором на всех парах: красные чернила #9e2f28 и синие #2d5fa8 на бумаге #efe6d2. */
:root {
  color-scheme: light;
  --paper: #efe6d2;
  --sheet: #f6efdf;
  --card: #f1e8d4;
  --ink: #2a241d;
  --ink-soft: #4a4136;
  --muted: #7b6f5e;
  --line: rgba(42, 36, 29, .28);
  --faint: rgba(42, 36, 29, .07);
  --red: #9e2f28;
  --blue: #2d5fa8;
  --folder: #c7ad7f;
  --grid: rgba(45, 95, 168, .13);
  --h0: #e7ddc6; --h1: #d8c59e; --h2: #c1a372; --h3: #9b784a; --h4: #6c4f31; --h5: #3d2a18;
  --font-head: "Old Standard TT", "Times New Roman", serif;
  --font-type: "PT Mono", "Courier New", monospace;
  --font-label: "PT Sans Narrow", "Arial Narrow", sans-serif;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36  0 0 0 0 .28  0 0 0 0 .17  0 0 0 .055 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--font-type); font-size: 15px; }
button, input { font: inherit; color: inherit; }
button { border: 0; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-type); letter-spacing: 0; }

.app-shell { display: grid; grid-template-rows: 70px 1fr; height: 100dvh; transition: filter .5s ease; }

/* ---------- штампы ---------- */
.stamp { position: absolute; padding: 3px 9px; border: 2.5px solid var(--red); border-radius: 4px; color: var(--red); font-family: var(--font-label); font-size: .78rem; font-weight: 700; letter-spacing: .16em; transform: rotate(-7deg); opacity: .78; pointer-events: none; mix-blend-mode: multiply;
         -webkit-mask-image: var(--noise), linear-gradient(#000, #000); mask-image: linear-gradient(#000 0 0); }

/* ---------- форма допуска ---------- */
body.locked .app-shell { filter: blur(8px) sepia(.2); pointer-events: none; user-select: none; }
.gate { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 20px; background: rgba(239,230,210,.35); transition: opacity .45s ease; }
body:not(.locked) .gate { opacity: 0; pointer-events: none; }
.gate-card { position: relative; display: grid; gap: 13px; width: min(380px, 100%); padding: 28px 28px 24px; background: var(--sheet) var(--noise); border: 1px solid var(--line); border-radius: 2px;
             box-shadow: 3px 4px 0 rgba(42,36,29,.14), inset 0 0 40px rgba(120,90,50,.14); }
.gate-mark { font-family: var(--font-head); font-size: 2rem; font-weight: 700; letter-spacing: .06em; line-height: 1; }
.gate-kicker { font-family: var(--font-label); font-size: .82rem; font-weight: 700; letter-spacing: .16em; color: var(--ink-soft); border-bottom: 3px double var(--ink); padding-bottom: 6px; }
.gate-text { margin: 0 0 2px; color: var(--ink-soft); font-size: .8rem; line-height: 1.5; }
.gate-card label { display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 10px; color: var(--ink-soft); font-family: var(--font-label); font-size: .82rem; font-weight: 700; letter-spacing: .1em; }
.gate-card input { height: 30px; padding: 0 4px; border: 0; border-bottom: 1.5px dotted var(--ink); background: transparent; color: var(--ink); font-family: var(--font-type); font-size: 1rem; outline: 0; }
.gate-card input:focus { border-bottom-style: solid; }
.gate-error { color: var(--red); font-family: var(--font-label); font-size: .8rem; font-weight: 700; letter-spacing: .1em; }
.gate-go { justify-self: end; display: flex; align-items: center; gap: 14px; height: 42px; margin-top: 6px; padding: 0 18px; border: 2.5px solid var(--red); border-radius: 4px; background: transparent; color: var(--red); cursor: pointer; font-family: var(--font-label); font-size: .95rem; font-weight: 700; letter-spacing: .16em; transform: rotate(-1.5deg); }
.gate-go:hover { background: rgba(158,47,40,.08); }
.gate-go b { font-size: 1.3rem; font-weight: 400; }
.gate-go:disabled { opacity: .5; cursor: progress; }
.gate-card.shake { animation: shake .35s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.gate-card .stamp { top: auto; bottom: 30px; left: 26px; transform: rotate(-9deg); }

/* ---------- обложка папки ---------- */
.topbar { position: relative; z-index: 1000; display: grid; grid-template-columns: auto minmax(140px, 1fr) auto auto auto; align-items: stretch; min-width: 0;
          background: var(--folder) var(--noise); border-bottom: 2px solid rgba(42,36,29,.45); box-shadow: 0 3px 0 rgba(42,36,29,.12); }
.wordmark { position: relative; display: grid; align-content: center; gap: 2px; padding: 0 26px 0 30px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.wordmark b { font-family: var(--font-head); font-size: clamp(1.4rem, 2vw, 2rem); font-weight: 700; letter-spacing: .06em; line-height: 1; }
.wordmark small { font-family: var(--font-type); font-size: .66rem; color: var(--ink-soft); letter-spacing: .04em; }
.wordmark .stamp { position: static; display: inline-block; margin-left: 8px; font-size: .56rem; padding: 1px 6px; border-width: 2px; transform: rotate(-4deg); vertical-align: middle; }
.search-form { display: grid; grid-template-columns: 26px 1fr 26px; align-items: center; min-width: 0; max-width: 420px; margin: 13px 12px 13px 0; padding: 0 8px 0 12px; border: 1px solid rgba(42,36,29,.4); border-radius: 2px; background: rgba(246,239,223,.75); }
.search-form svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.search-form input { min-width: 0; height: 40px; border: 0; outline: 0; background: transparent; font-family: var(--font-type); font-size: .84rem; }
.search-form input::placeholder { color: #8a7d69; }
.search-form input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 24px; height: 24px; border-radius: 2px; background: transparent; cursor: pointer; font-size: .8rem; color: var(--muted); }
.search-clear:hover { background: var(--faint); color: var(--ink); }
.seg { display: flex; align-items: stretch; margin: 13px 8px 13px 0; overflow: hidden; border: 1px solid rgba(42,36,29,.4); border-radius: 2px; background: rgba(246,239,223,.6); }
.seg button { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; padding: 0 11px; background: transparent; cursor: pointer; font-family: var(--font-label); font-size: .86rem; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.seg button + button { border-left: 1px solid rgba(42,36,29,.18); }
.seg button:hover { background: var(--faint); }
.seg button.active { background: var(--ink); color: var(--sheet); }
.year-presets button { min-width: 52px; }
/* кнопка графа связей в шапке */
.graph-btn { display: flex; align-items: center; gap: 8px; margin: 13px 8px 13px 0; padding: 0 14px; border: 1px solid rgba(42,36,29,.4); border-radius: 2px; background: rgba(246,239,223,.6); color: var(--ink); cursor: pointer; font-family: var(--font-label); font-size: .86rem; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.graph-btn:hover { border-color: var(--blue); color: var(--blue); }
.graph-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.graph-btn svg circle { fill: currentColor; stroke: none; }

/* модалка графа */
.graph-modal { position: fixed; inset: 0; z-index: 2500; display: flex; flex-direction: column; background: var(--paper) var(--noise); }
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 2px solid rgba(42,36,29,.4); background: var(--folder) var(--noise); flex-wrap: wrap; }
.graph-title b { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; letter-spacing: .06em; }
.graph-title small { display: block; color: var(--ink-soft); font-family: var(--font-type); font-size: .68rem; }
.graph-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.graph-seg { margin: 0; }
.graph-seg button { height: 30px; padding: 0 10px; font-size: .74rem; }
.graph-slider { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-family: var(--font-label); font-size: .74rem; font-weight: 700; letter-spacing: .06em; }
.graph-slider input { width: 90px; accent-color: var(--red); }
.graph-body { position: relative; flex: 1; min-height: 0; }
#graph-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#graph-canvas.grabbing { cursor: grabbing; }
.graph-legend { position: absolute; left: 14px; bottom: 14px; display: flex; flex-wrap: wrap; gap: 10px; padding: 7px 11px; background: var(--sheet); border: 1px solid var(--line); border-radius: 2px; font-family: var(--font-label); font-size: .72rem; font-weight: 700; color: var(--ink-soft); box-shadow: 2px 2px 0 rgba(42,36,29,.12); }
.graph-legend span { display: flex; align-items: center; gap: 5px; }
.graph-legend i { width: 11px; height: 11px; border-radius: 50%; }
/* панель сведений о человеке */
.graph-info { position: absolute; top: 14px; right: 14px; width: 300px; max-height: calc(100% - 28px); overflow-y: auto; padding: 14px 16px 16px; background: var(--card) var(--noise); border: 1px solid var(--line); border-radius: 2px; box-shadow: 2px 3px 0 rgba(42,36,29,.16); }
.graph-info-x { position: absolute; top: 8px; right: 10px; width: 24px; height: 24px; border-radius: 2px; background: transparent; cursor: pointer; color: var(--muted); font-size: .85rem; }
.graph-info-x:hover { background: var(--faint); color: var(--ink); }
.gi-head { display: flex; align-items: flex-start; gap: 12px; padding-right: 20px; border-bottom: 3px double rgba(42,36,29,.4); padding-bottom: 10px; }
.gi-head h3 { margin: 0; font-family: var(--font-head); font-size: 1.1rem; font-weight: 700; letter-spacing: .04em; }
.gi-head small { display: block; color: var(--ink-soft); font-family: var(--font-type); font-size: .68rem; line-height: 1.35; }
.gi-head .gi-trait { color: var(--red); margin-top: 2px; }
.gi-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; margin: 10px 0; }
.gi-stats > div { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; border-bottom: 1px dotted rgba(42,36,29,.3); padding: 2px 0; font-family: var(--font-type); font-size: .72rem; }
.gi-stats span { color: var(--muted); }
.gi-stats b { font-weight: 700; }
.gi-links { margin-top: 8px; }
.gi-links > small { display: block; color: var(--muted); font-family: var(--font-label); font-size: .66rem; font-weight: 700; letter-spacing: .08em; margin-bottom: 4px; }
.gi-link { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 3px 4px; background: transparent; cursor: pointer; font-family: var(--font-type); font-size: .72rem; border-radius: 2px; }
.gi-link:hover { background: var(--faint); }
.gi-link b { font-weight: 700; }
.gi-btns { display: flex; gap: 6px; margin-top: 12px; }
.gi-btns .tool { flex: 1; text-align: center; font-size: .68rem; padding: 0 6px; }
.gi-full { text-align: center; }
.tool.active { border-color: var(--red); color: var(--red); background: rgba(158,47,40,.1); }
.graph-seg button.active { background: var(--ink); color: var(--sheet); }
.graph-hint { position: fixed; z-index: 2600; padding: 5px 9px; border: 1px solid var(--ink); border-radius: 2px; background: var(--sheet); box-shadow: 2px 2px 0 rgba(42,36,29,.15); font-family: var(--font-type); font-size: .72rem; line-height: 1.35; pointer-events: none; white-space: nowrap; }
.graph-hint b { font-weight: 700; }

.hot-button { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 13px 22px 13px 4px; padding: 0 16px; border: 2.5px solid var(--red); border-radius: 4px; background: rgba(246,239,223,.5); color: var(--red); cursor: pointer; font-family: var(--font-label); font-size: .9rem; font-weight: 700; letter-spacing: .12em; white-space: nowrap; transform: rotate(-1deg); }
.hot-button:hover { background: rgba(158,47,40,.08); }
.hot-button b { font-size: 1.3rem; font-weight: 400; }

/* ---------- стол ---------- */
.board { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--noise), var(--paper); }
.data-card, .status-pill, .cal-card, .main-card, .hint { position: absolute; z-index: 500; background: var(--card) var(--noise); border: 1px solid var(--line); border-radius: 2px;
            box-shadow: 2px 3px 0 rgba(42,36,29,.12), inset 0 0 36px rgba(120,90,50,.12); }
.data-card { width: 300px; padding: 12px 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; padding-bottom: 5px; border-bottom: 3px double rgba(42,36,29,.55); }
.card-head h2 { margin: 0; font-family: var(--font-head); font-size: 1.08rem; font-weight: 700; line-height: 1.05; letter-spacing: .08em; }
.card-head span { color: var(--muted); font-family: var(--font-label); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-align: right; }
.status-pill { top: 16px; left: 46px; width: 300px; min-height: 34px; padding: 7px 10px; color: var(--ink-soft); font-family: var(--font-type); font-size: .64rem; line-height: 1.45; display: flex; align-items: center; justify-content: space-between; gap: 8px; overflow: visible; }
.status-pill > span { min-width: 0; }
.reset-filters { flex: none; padding: 3px 7px; border: 1px solid var(--red); border-radius: 2px; background: rgba(158,47,40,.06); color: var(--red); cursor: pointer; font-family: var(--font-label); font-size: .62rem; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.reset-filters:hover { background: rgba(158,47,40,.14); }

/* фотокарточки из дела: ч/б с сепией, белое поле, чернильная рамка */
.av { position: relative; display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none; overflow: visible; border: 2px solid #fbf6ea; outline: 1px solid rgba(42,36,29,.55); border-radius: 1px; background: #d9ccb0; font: 700 .62rem/1 var(--font-label); color: var(--ink-soft); vertical-align: middle; box-shadow: 1px 1px 0 rgba(42,36,29,.18); }
.av img { width: 100%; height: 100%; object-fit: cover; display: block; filter: grayscale(1) sepia(.45) contrast(1.15) brightness(.97); }
.av.group { background: var(--sheet); }
.av.shot img { filter: grayscale(1) sepia(.2) contrast(.95) brightness(1.05); opacity: .75; }
.av.shot::after { content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; background: var(--red); transform: rotate(-38deg); opacity: .85; }
.av.left { opacity: .82; }
.av.left::after { content: ""; position: absolute; inset: -2px; border: 1.5px dashed var(--blue); border-radius: 2px; opacity: .7; }

/* слева: сводка | досье | выбывшие — закладки папки */
.side-card { top: 58px; left: 46px; bottom: 25px; overflow-y: auto; padding-top: 0; }
.tabs { position: sticky; top: 0; z-index: 2; margin: 0 -14px 8px; padding: 8px 10px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: var(--card); gap: 3px; overflow: visible; }
.tabs button { flex: 1; height: 30px; padding: 0 6px; border: 1px solid var(--line) !important; border-bottom: 0 !important; border-radius: 6px 6px 0 0; background: var(--folder); font-size: .8rem; }
.tabs button.active { background: var(--sheet); color: var(--ink); margin-bottom: -1px; box-shadow: 0 1px 0 var(--sheet); }
.fact { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1px 10px; width: 100%; padding: 8px 6px; border-top: 1px dotted rgba(42,36,29,.4); background: transparent; cursor: pointer; text-align: left; }
.fact:first-child { border-top: 0; }
.fact:hover { background: var(--faint); }
.fact .avs { grid-row: 1 / span 2; display: flex; gap: 2px; }
.fact .avs .av { width: 28px; height: 32px; }
.fact small { grid-column: 2; color: var(--muted); font-family: var(--font-label); font-size: .68rem; font-weight: 700; letter-spacing: .1em; }
.fact b { grid-column: 2; font-family: var(--font-type); font-size: .82rem; font-weight: 700; line-height: 1.3; }
.fact em { grid-column: 3; grid-row: 1 / span 2; font-style: normal; font-size: 1rem; color: var(--muted); }
.fact:hover em { color: var(--red); }
.fact.static { cursor: default; }
.fact.static:hover { background: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.chips span, .chips button { padding: 3px 7px; border: 1px solid var(--line); background: var(--sheet); font-family: var(--font-type); font-size: .68rem; }
.chips .emoji { font-size: .9rem; padding: 1px 5px; filter: grayscale(.6) sepia(.3); }
.chips button { cursor: pointer; }
.chips button:hover { border-color: var(--ink); color: var(--red); }
.sub { margin: 12px 0 6px; padding-top: 6px; border-top: 3px double rgba(42,36,29,.4); color: var(--muted); font-family: var(--font-label); font-size: .7rem; font-weight: 700; letter-spacing: .1em; }
.sub b { color: var(--ink); }
.sub .t-in { color: var(--blue); } .sub .t-out { color: var(--red); }

.people { display: grid; gap: 2px; }
.person { display: grid; grid-template-columns: 24px 1fr 50px 38px; align-items: center; gap: 8px; width: 100%; padding: 3px 4px; background: transparent; cursor: pointer; text-align: left; font-family: var(--font-type); font-size: .72rem; }
.person:hover { background: var(--faint); }
.person.active { background: rgba(158,47,40,.10); box-shadow: inset 3px 0 0 var(--red); }
.person > span:nth-child(2) { line-height: 1.2; }
.person i { height: 6px; overflow: hidden; background: repeating-linear-gradient(90deg, rgba(42,36,29,.14) 0 1px, transparent 1px 4px); }
.person i b { display: block; height: 100%; background: var(--ink-soft); }
.person.active i b { background: var(--red); }
.person strong { text-align: right; font-size: .68rem; }
.pick { margin-top: 10px; padding-top: 9px; border-top: 3px double rgba(42,36,29,.4); }
.pick small { display: block; color: var(--muted); font-family: var(--font-label); font-size: .68rem; font-weight: 700; letter-spacing: .1em; }
.pick b { display: block; margin-top: 3px; font-family: var(--font-type); font-size: .8rem; line-height: 1.35; }

.gone-chart { display: block; width: 100%; height: 70px; }
.gone-chart rect.out { fill: url(#hatch-red); stroke: var(--red); stroke-width: .6; }
.gone-chart rect.in { fill: url(#hatch-blue); stroke: var(--blue); stroke-width: .6; }
.gone-chart text { fill: var(--muted); font: 8px var(--font-type); }

/* центр: хроника / дело / день */
.main-card { top: 16px; left: 366px; right: 336px; bottom: 190px; display: grid; grid-template-rows: auto auto minmax(170px, 1fr) auto; padding: 14px 18px 12px; overflow: hidden auto; }
.main-card > .stamp { top: 14px; right: 18px; }
.main-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; min-width: 0; padding-right: 150px; padding-bottom: 8px; border-bottom: 3px double rgba(42,36,29,.55); }
.main-title { display: grid; gap: 4px; min-width: 0; }
.main-title h1 { margin: 0; font-family: var(--font-head); font-size: 1.45rem; font-weight: 700; letter-spacing: .06em; line-height: 1.1; }
.main-title small { color: var(--ink-soft); font-family: var(--font-type); font-size: .7rem; line-height: 1.4; }
.main-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.main-tools .seg { margin: 0; }
.main-tools .seg button { height: 30px; font-size: .8rem; padding: 0 10px; }
.tool { height: 32px; padding: 0 11px; border: 1px solid rgba(42,36,29,.45); border-radius: 2px; background: var(--sheet); cursor: pointer; font-family: var(--font-label); font-size: .82rem; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.tool:hover { border-color: var(--red); color: var(--red); }
.tool:disabled { opacity: .4; cursor: default; }
.who-head { display: flex; align-items: center; gap: 16px; min-width: 0; }
.photo { position: relative; flex: none; width: 62px; height: 80px; padding: 4px 4px 12px; background: #fbf6ea; outline: 1px solid rgba(42,36,29,.4); box-shadow: 2px 3px 0 rgba(42,36,29,.18); transform: rotate(-2.5deg); }
.photo img, .photo span { display: block; width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) sepia(.45) contrast(1.18) brightness(.96); background: #d9ccb0; }
.photo span { display: grid; place-items: center; font: 700 1.2rem var(--font-head); color: var(--ink-soft); filter: none; }
.photo::before { content: ""; position: absolute; top: -9px; right: 12px; width: 10px; height: 30px; border: 2px solid #8e9296; border-radius: 6px; z-index: 2; }
.photo.shot img { opacity: .75; }
.photo.left::after { content: "НА ВОЛЕ"; position: absolute; left: -6px; bottom: 16px; padding: 0 4px; border: 2px solid var(--blue); color: var(--blue); font: 700 .6rem var(--font-label); letter-spacing: .12em; transform: rotate(-12deg); background: rgba(251,246,234,.7); }
.photo.left img { opacity: .85; }
.photo.shot.f::after { content: "РАССТРЕЛЯНА"; }
.photo.shot::after { content: "РАССТРЕЛЯН"; position: absolute; left: -6px; bottom: 16px; padding: 0 4px; border: 2px solid var(--red); color: var(--red); font: 700 .6rem var(--font-label); letter-spacing: .12em; transform: rotate(-12deg); background: rgba(251,246,234,.7); }
/* график живёт в своей рамке: всё, что выходит за неё, обрезается, под таблицы не лезет */
.chart-box { position: relative; min-height: 170px; margin-top: 6px; overflow: hidden; contain: paint; }
.chart-box > .main-chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.main-chart { display: block; width: 100%; overflow: hidden; }
.fig { margin: 2px 0 0; color: var(--ink-soft); font-size: .68rem; text-align: center; }
.main-chart .grid { stroke: var(--grid); stroke-width: 1; }
.main-chart .grid-minor { stroke: var(--grid); stroke-width: .5; opacity: .6; }
.main-chart .axis { fill: var(--ink-soft); font: 9.5px var(--font-type); }
.main-chart .area { fill: url(#hatch); }
.main-chart .line { fill: none; stroke: var(--ink); stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.main-chart .bar { fill: url(#hatch); stroke: var(--ink-soft); stroke-width: .8; }
.main-chart .bar.peak { fill: url(#hatch-red); stroke: var(--red); }
.main-chart .ev-out { stroke: var(--red); stroke-width: 1.8; }
.main-chart .ev-in { stroke: var(--blue); stroke-width: 1.8; }
.main-chart .ev-dead { stroke: var(--red); stroke-width: 1.6; }
.main-chart .ev-left { stroke: var(--blue); stroke-width: 1.6; }
.main-chart .mile { stroke: var(--ink); stroke-width: .8; stroke-dasharray: 3 3; opacity: .5; }
.main-chart .mile-t { fill: var(--ink-soft); font: 700 8.5px var(--font-type); }
.main-chart .peak-ring { fill: none; stroke: var(--red); stroke-width: 1.6; }
.main-chart .peak-t { fill: var(--red); font: 700 10px var(--font-type); }
.main-chart .quiet { fill: url(#hatch-red); opacity: .35; }
.main-chart .cross { stroke: var(--red); stroke-width: 1; stroke-dasharray: 2 2; }
.main-chart .lane-t { fill: var(--muted); font: 700 9px var(--font-label); letter-spacing: .08em; }
.main-foot { display: grid; gap: 10px; margin-top: 8px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0; border-top: 3px double rgba(42,36,29,.5); padding-top: 9px; }
.kpi { display: grid; gap: 2px; padding: 0 10px; border-right: 1px dotted rgba(42,36,29,.4); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi b { font-family: var(--font-type); font-size: .98rem; font-weight: 700; line-height: 1.2; }
.kpi small { color: var(--muted); font-family: var(--font-label); font-size: .66rem; font-weight: 700; letter-spacing: .08em; }
.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.col h3 { margin: 0 0 6px; color: var(--ink-soft); font-family: var(--font-label); font-size: .7rem; font-weight: 700; letter-spacing: .08em; }
.row { display: grid; grid-template-columns: 24px 1fr 44px 36px; align-items: center; gap: 7px; width: 100%; padding: 2px 3px; background: transparent; text-align: left; font-family: var(--font-type); font-size: .7rem; }
button.row { cursor: pointer; }
button.row:hover { background: var(--faint); }
.row.nav { grid-template-columns: 1fr 60px 38px; }
.row i { height: 6px; background: repeating-linear-gradient(90deg, rgba(42,36,29,.14) 0 1px, transparent 1px 4px); overflow: hidden; }
.row i b { display: block; height: 100%; background: var(--ink-soft); }
.row strong { text-align: right; }
.evline { display: grid; grid-template-columns: 24px 1fr; align-items: center; gap: 8px; padding: 3px 0; font-size: .7rem; line-height: 1.3; }
.evline em { font-style: normal; color: var(--muted); }
.evline .tag-out { color: var(--red); font-family: var(--font-label); font-weight: 700; letter-spacing: .06em; }
.evline .tag-in { color: var(--blue); font-family: var(--font-label); font-weight: 700; letter-spacing: .06em; }
.none { color: var(--muted); font-size: .7rem; line-height: 1.4; }

/* справа колонкой: каналы связи, донос, режим; донос забирает свободную высоту */
.right-col { position: absolute; top: 16px; right: 23px; bottom: 25px; width: 290px; z-index: 500; display: flex; flex-direction: column; gap: 14px;
             overflow: hidden auto; scrollbar-width: thin; padding: 0 4px 4px 0; margin-right: -4px; }
.right-col > .data-card { position: relative; width: auto; flex: none; }
/* донос забирает свободную высоту, но не меньше своего содержимого: три строки текста и кнопка всегда видны */
.right-col > .donos-card { flex: 1 0 auto; display: flex; flex-direction: column; }
.donos-form { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.donos-form textarea { flex: 1; min-height: 68px; resize: none; padding: 4px 9px; border: 1px solid rgba(42,36,29,.4); border-radius: 2px; color: var(--ink);
  background: repeating-linear-gradient(transparent 0 19px, rgba(42,36,29,.14) 19px 20px) 0 4px / 100% 20px, rgba(251,246,234,.7); background-attachment: local;
  font: .76rem/20px var(--font-type); }
.donos-form textarea:focus { outline: 1px solid var(--red); border-color: var(--red); }
.donos-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.donos-row small { color: var(--muted); font-family: var(--font-type); font-size: .66rem; line-height: 1.3; }
.donos-row small.ok { color: var(--blue); } .donos-row small.bad { color: var(--red); }

/* справа: каналы связи (легенда = фильтр) */
.mix-card { width: 290px; }
.legend { display: grid; gap: 3px; }
.leg { display: grid; grid-template-columns: 1fr 70px 38px; align-items: center; gap: 8px; width: 100%; padding: 3px 5px; background: transparent; cursor: pointer; text-align: left; font-family: var(--font-type); font-size: .72rem; }
.leg:hover { background: var(--faint); }
.leg u { text-decoration: none; height: 6px; background: repeating-linear-gradient(90deg, rgba(42,36,29,.14) 0 1px, transparent 1px 4px); overflow: hidden; }
.leg u b { display: block; height: 100%; background: var(--ink-soft); }
.leg strong { text-align: right; }
.leg.off { opacity: .45; }
.leg.off span { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 2px; }
.insight { margin-top: 10px; padding-top: 9px; border-top: 3px double rgba(42,36,29,.4); font-family: var(--font-type); font-size: .76rem; line-height: 1.4; }
.insight small { display: block; color: var(--muted); font-family: var(--font-label); font-size: .68rem; font-weight: 700; letter-spacing: .1em; margin-bottom: 2px; }

/* справа снизу: режим */
.rhythm-card { width: 290px; }
.punch { display: block; width: 100%; height: auto; }
.punch text { fill: var(--ink-soft); font: 7.5px var(--font-type); }
.punch rect { stroke: rgba(246,239,223,.9); stroke-width: .6; }
.punch rect:hover { stroke: var(--red); stroke-width: 1.4; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 8px; padding-top: 8px; border-top: 3px double rgba(42,36,29,.4); }
.metrics > div { display: grid; gap: 2px; padding: 0 8px; border-right: 1px dotted rgba(42,36,29,.4); }
.metrics > div:first-child { padding-left: 0; }
.metrics > div:last-child { padding-right: 0; border-right: 0; }
.metrics b { font-family: var(--font-type); font-size: .86rem; font-weight: 700; }
.metrics small { color: var(--muted); font-family: var(--font-label); font-size: .64rem; font-weight: 700; line-height: 1.2; letter-spacing: .06em; }

/* снизу по центру: журнал наблюдения */
.cal-card { left: 366px; right: 336px; bottom: 25px; height: 150px; padding: 9px 14px 10px; }
.cal-scroll { overflow-x: auto; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.cal-head strong { font-family: var(--font-head); font-size: .9rem; font-weight: 700; letter-spacing: .06em; }
.cal-legend { display: flex; align-items: center; gap: 3px; color: var(--muted); font-family: var(--font-label); font-size: .64rem; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.cal-legend i { width: 10px; height: 10px; }
.cal-legend i:nth-child(1) { background: var(--h1); } .cal-legend i:nth-child(2) { background: var(--h2); }
.cal-legend i:nth-child(3) { background: var(--h3); } .cal-legend i:nth-child(4) { background: var(--h4); } .cal-legend i:nth-child(5) { background: var(--h5); }
.cal-legend .dot-out { width: 9px; height: 9px; margin: 0 3px 0 10px; background: none; position: relative; }
.cal-legend .dot-out::before, .cal-legend .dot-out::after { content: ""; position: absolute; left: 4px; top: -1px; width: 2px; height: 11px; background: var(--red); transform: rotate(45deg); }
.cal-legend .dot-out::after { transform: rotate(-45deg); }
#cal-svg { display: block; }
#cal-svg text { fill: var(--ink-soft); font: 8.5px var(--font-type); }
#cal-svg rect.cell { cursor: pointer; stroke: rgba(246,239,223,.9); stroke-width: .6; }
#cal-svg rect.cell:hover { stroke: var(--red); stroke-width: 1.2; }
#cal-svg rect.sel { stroke: var(--red); stroke-width: 2; }
#cal-svg .out { stroke: var(--red); stroke-width: 1.5; pointer-events: none; }

.hint { z-index: 2000; padding: 6px 9px; border-color: var(--ink); background: var(--sheet); box-shadow: 3px 3px 0 rgba(42,36,29,.15); font-family: var(--font-type); font-size: .7rem; line-height: 1.45; pointer-events: none; white-space: nowrap; }
.hint b { font-weight: 700; }
.sheet-bar { display: none; }

@media (max-width: 1280px) {
  .main-card, .cal-card { right: 16px; }
  .right-col { display: contents; }
  .right-col > .data-card, .mix-card, .rhythm-card, .donos-card { position: absolute; display: none; left: 46px; right: auto; top: auto; bottom: 72px; width: 300px; z-index: 700; }
  .mix-card.open, .rhythm-card.open { display: block; }
  .right-col > .donos-card.open { display: flex; height: 260px; }
  .side-card { bottom: 72px; }
  .sheet-bar { display: flex; position: absolute; left: 46px; bottom: 25px; width: 300px; margin: 0; background: var(--sheet); z-index: 800; }
  .sheet-bar button { flex: 1; height: 36px; }
  .sheet-bar .m-only { display: none; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-rows: auto 1fr; }
  .topbar { grid-template-columns: 1fr auto; }
  .wordmark { padding: 8px 14px; }
  .wordmark b { font-size: 1.25rem; }
  .hot-button { min-width: 0; margin: 10px 10px 10px 0; padding: 0 10px; gap: 8px; font-size: .78rem; }
  .search-form { grid-column: 1 / -1; order: 5; max-width: none; margin: 0 10px 8px; }
  .year-presets { grid-column: 1 / -1; order: 6; margin: 0 10px 8px; overflow-x: auto; }
  .year-presets button { flex: 1; padding: 8px 6px; min-width: 44px; }
  .status-pill { left: 10px; right: 10px; top: 10px; width: auto; }
  .main-card { left: 10px; right: 10px; top: 46px; bottom: 214px; padding: 10px 12px; grid-template-rows: auto auto 210px auto; overflow-y: auto; }
  .chart-box { height: 210px; }
  .wordmark small { display: none; }
  .hot-button span { font-size: .72rem; letter-spacing: .06em; }
  .main-head { padding-right: 0; flex-wrap: wrap; }
  .main-card > .stamp { display: none; }
  .cols { grid-template-columns: 1fr; }
  .cal-card { left: 10px; right: 10px; bottom: 58px; }
  .side-card, .right-col > .data-card, .mix-card, .rhythm-card { display: none; left: 10px; right: 10px; top: auto; bottom: 58px; width: auto; max-height: 62%; overflow-y: auto; z-index: 700; }
  .side-card.open, .mix-card.open, .rhythm-card.open { display: block; }
  .sheet-bar { left: 10px; right: 10px; bottom: 10px; width: auto; }
  .sheet-bar .m-only { display: flex; }
  .sheet-bar button { padding: 0 3px; font-size: .7rem; }
}

/* ---------- машинописные таблицы, как в книге Шубина (1986) ---------- */
.tcap { display: grid; gap: 2px; margin: 10px 0 4px; font-family: var(--font-type); }
.tcap span { justify-self: end; font-size: .72rem; }
.tcap b { justify-self: center; text-align: center; font-size: .76rem; font-weight: 400; line-height: 1.35; }
.tbl { width: 100%; border-collapse: collapse; font-family: var(--font-type); font-size: .74rem; }
.tbl thead th { padding: 4px 6px; font-weight: 400; font-size: .66rem; line-height: 1.25; text-align: center; vertical-align: bottom;
                border-top: 1.5px dashed var(--ink); border-bottom: 1.5px dashed var(--ink); }
.tbl td { padding: 3px 6px; vertical-align: middle; }
.tbl th + th, .tbl td + td { border-left: 1px solid rgba(42,36,29,.55); }
.tbl tbody tr:last-child td { border-bottom: 1.5px dashed var(--ink); }
.tbl .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl .c { text-align: center; }
.tbl .who { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tbl .who > span { min-width: 0; }
.tbl .who .unit { display: block; color: var(--muted); font-size: .66rem; line-height: 1.1; }
.tbl .sub td:first-child { padding-left: 22px; }
.tbl tr.go { cursor: pointer; }
.tbl tr.go:hover td { background: rgba(42,36,29,.07); }
.tbl tr.sel td { background: rgba(158,47,40,.10); }
.tbl tr.sel td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.tbl tr.off td { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--red); }
.tbl .bar { display: block; height: 7px; min-width: 2px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Cpath d='M0 4L4 0' stroke='%234a4136' stroke-width='1.2'/%3E%3C/svg%3E"); border: 1px solid rgba(42,36,29,.6); }
.tbl tr.sel .bar { background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Cpath d='M0 4L4 0' stroke='%239e2f28' stroke-width='1.3'/%3E%3C/svg%3E"); border-color: var(--red); }
.tbl .chips { margin: 0; }
.tbl .red { color: var(--red); } .tbl .blue { color: var(--blue); }

/* ---------- рапорт: сухо, по-военному, машинописью ---------- */
.report { margin: 8px 0 0; padding: 7px 10px; border-left: 3px solid var(--red); background: rgba(246,239,223,.7); font-family: var(--font-type); font-size: .74rem; line-height: 1.5; color: var(--ink); }
/* доска почёта: номинация под названием, значки-штампы в деле */
.tbl .nom { display: block; color: var(--muted); font-size: .64rem; line-height: 1.2; }
#tab-board .tbl { table-layout: fixed; }
#tab-board .tbl col:first-child, #tab-board .tbl th:first-child { width: 46%; }
#tab-board .tbl td { word-break: break-word; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { padding: 1px 6px; border: 1px solid var(--red); border-radius: 2px; color: var(--red); font-family: var(--font-label); font-size: .6rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; transform: rotate(-1.5deg); background: rgba(251,246,234,.6); }
.report b { font-weight: 700; }
.foot2 { display: grid; grid-template-columns: minmax(230px, 1fr) 2fr; gap: 18px; align-items: start; }
.figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .foot2 { grid-template-columns: 1fr; } }
