/* PRIVÉ. Чёрное с золотом — только в знаке, кнопках и экране входа; обложки документов — единственный цветной элемент. */

:root {
  --paper: #EEECE7;
  --surface: #FFFFFF;
  --surface-2: #F6F4F0;
  --ink: #1B1813;
  --ink-2: #5E584E;
  --ink-3: #8F887C;
  --line: #DEDAD2;
  --accent: #17140F;
  --accent-hover: #2B251B;
  --on-accent: #EACB86;
  --gold: #D6B670;
  --gold-ink: #85651B;
  --blue: #7A5C17;
  --hero: #0E0C0A;
  --ok: #1F6E45;   --ok-bg: #E1EFE6;
  --warn: #8F5A0B; --warn-bg: #F6EBD6;
  --bad: #B3261E;  --bad-bg: #F8E2DF;
  --shadow: 0 1px 2px rgba(18, 30, 24, .06), 0 6px 18px rgba(18, 30, 24, .06);
  --r-group: 16px;
  --r-btn: 12px;
  --r-chip: 999px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --top-h: 56px;
  --tab-h: 58px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E0C0A;
    --surface: #1A1714;
    --surface-2: #231F1A;
    --ink: #EFE9DE;
    --ink-2: #ADA595;
    --ink-3: #7A7264;
    --line: #332D25;
    --accent: #D8B56C;
    --accent-hover: #E6C687;
    --on-accent: #17120A;
    --gold-ink: #D8B56C;
    --blue: #D8B56C;
    --ok: #5DC08B;   --ok-bg: #16281E;
    --warn: #E3AA4E; --warn-bg: #2B2114;
    --bad: #F2766B;  --bad-bg: #2E1816;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: .01em; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 12px 20px; }
.pad-x { padding: 0 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.boot { min-height: 100vh; background: var(--paper); }

/* ------------------------------------------------------------ кнопки и поля */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px;
  border-radius: var(--r-btn); border: 1px solid transparent;
  font-weight: 600; font-size: 16px; text-align: center;
  background: var(--surface); color: var(--ink);
}
.btn .ic { width: 20px; height: 20px; flex: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--blue); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-text, .danger-text { color: var(--bad); }
.btn.wide { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.is-busy { opacity: .7; }
a.btn { color: inherit; }
a.btn.primary { color: var(--on-accent); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .ic { width: 22px; height: 22px; }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255, 255, 255, .12); }
.ic { width: 22px; height: 22px; flex: none; }

.input {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--r-btn);
  background: var(--surface); color: var(--ink);
  font-size: 17px;
}
textarea.input { resize: vertical; min-height: 64px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 20%, transparent); }
.input::placeholder { color: var(--ink-3); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 52px; }
.icon-btn.in-input { position: absolute; right: 2px; top: 2px; }
.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.lbl > .input, .lbl > .seg, .lbl > .chips { color: var(--ink); font-weight: 400; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--gold-ink); flex: none; }
.form-error { color: var(--bad); font-size: 15px; min-height: 0; }
.form-error:empty { display: none; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.row-btns > .btn { flex: 1 1 140px; }

.seg { display: flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-btn); }
.seg-btn { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.seg-btn.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }

.chips { display: flex; gap: 8px; padding: 4px 20px 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 6px 14px; border-radius: var(--r-chip);
  border: 1px solid var(--line); background: var(--surface); font-size: 15px; color: var(--ink);
}
.chip .ic { width: 16px; height: 16px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.add { color: var(--blue); border-style: dashed; }

/* ------------------------------------------------------------ экран входа */

.gate { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.gate-hero {
  position: relative; overflow: hidden;
  padding: calc(env(safe-area-inset-top) + 18px) 24px 54px;
  display: flex; align-items: center; justify-content: center;
  background: var(--hero);
}
.gate-logo { display: block; width: auto; height: min(36vh, 300px); max-width: 100%; object-fit: contain; user-select: none; }
.gate-card {
  position: relative; margin: -36px auto 0; width: min(100% - 24px, 460px);
  background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  padding: 28px 22px calc(env(safe-area-inset-bottom) + 28px);
  display: flex; flex-direction: column; gap: 16px; flex: 1;
}
.gate-card h1 { font-size: 26px; font-weight: 700; }
@media (min-width: 640px) { .gate-card { border-radius: 22px; flex: none; margin-bottom: 40px; } }

.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: -4px; }
.meter-bar { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s, background .2s; }
.meter[data-score="1"] .meter-bar { width: 25%; background: var(--bad); }
.meter[data-score="2"] .meter-bar { width: 55%; background: var(--warn); }
.meter[data-score="3"] .meter-bar { width: 80%; background: var(--ok); }
.meter[data-score="4"] .meter-bar { width: 100%; background: var(--ok); }
.meter-text { font-size: 14px; margin-top: -6px; min-height: 20px; }
.key-show {
  padding: 16px; border-radius: var(--r-btn); background: var(--surface-2); border: 1px dashed var(--ink-3);
  font-size: 18px; line-height: 1.6; text-align: center; overflow-wrap: anywhere; user-select: all; font-weight: 600;
}
.key-input { text-transform: uppercase; font-size: 16px; }

/* ------------------------------------------------------------ каркас приложения */

.app { max-width: 760px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px); }
body.editing .app { padding-bottom: 40px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px;
  min-height: calc(var(--top-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.top-lead { display: flex; align-items: center; min-width: 44px; }
.top-mark { display: grid; place-items: center; width: 44px; height: 44px; }
.top-emblem { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.top-title { font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.top-right { display: flex; align-items: center; }
.top-actions { display: flex; align-items: center; gap: 4px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; margin: 0 6px; background: var(--ink-3); }
.sync-dot.ok { background: var(--ok); }
.sync-dot.syncing { background: var(--blue); animation: pulse 1s infinite alternate; }
.sync-dot.offline, .sync-dot.relogin { background: var(--warn); }
.sync-dot.error { background: var(--bad); }
@keyframes pulse { to { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .sync-dot.syncing { animation: none; } }

.main { padding: 8px 0 16px; }
.main > h1 { padding: 8px 20px; font-size: 28px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px max(8px, calc((100vw - 760px) / 2)) env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px; min-height: var(--tab-h); font-size: 11px; color: var(--ink-3); font-weight: 500; white-space: nowrap; }
.tab .ic { width: 24px; height: 24px; }
.tab.on { color: var(--gold-ink); }

.banner-slot:empty { display: none; }
.banner { display: flex; gap: 12px; align-items: center; margin: 8px 16px; padding: 12px 14px; border-radius: var(--r-group); background: var(--surface); box-shadow: var(--shadow); font-size: 15px; }
.banner.warn { background: var(--warn-bg); }
.banner > span { flex: 1; }

/* ------------------------------------------------------------ группы и строки */

.group { margin: 18px 16px 0; }
.group-title { font-size: 14px; font-weight: 600; color: var(--ink-2); padding: 0 4px 8px; }
.group-box { background: var(--surface); border-radius: var(--r-group); box-shadow: var(--shadow); overflow: hidden; }
.form-group { display: flex; flex-direction: column; gap: 14px; }
.form-group > .group-title { padding-bottom: 0; }
.row {
  display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 56px; padding: 10px 14px 10px 16px;
  background: transparent; border: 0; text-align: left; color: var(--ink);
}
.group-box > .row + .row, .group-box > * + .row, .group-box > .row + * { border-top: 1px solid var(--line); }
a.row:hover, button.row:hover { background: var(--surface-2); }
.row-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); flex: none; }
.row-ic .ic { width: 20px; height: 20px; }
.row-ic.warn { background: var(--warn-bg); color: var(--warn); }
.row-ic.bad { background: var(--bad-bg); color: var(--bad); }
.row-ic.ok { background: var(--ok-bg); color: var(--ok); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-title { font-weight: 550; overflow-wrap: break-word; hyphens: auto; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.row-sub { font-size: 14px; color: var(--ink-2); overflow-wrap: break-word; }
.row-right { color: var(--ink-2); font-size: 15px; }
.ic.chevron { width: 18px; height: 18px; color: var(--ink-3); }
.row.danger-text .row-title { color: var(--bad); }

.switch-row { cursor: pointer; position: relative; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch-row input:checked + .switch { background: var(--ok); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--blue); outline-offset: 2px; }

.pill { flex: none; font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: var(--r-chip); white-space: nowrap; }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

.notice { display: flex; gap: 14px; margin: 12px 16px 0; padding: 14px 16px; border-radius: var(--r-group); background: var(--surface); box-shadow: var(--shadow); }
.notice > .ic { margin-top: 2px; color: var(--ink-2); }
.notice > div { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.notice p { font-size: 15px; color: var(--ink-2); }
.notice.ok > .ic { color: var(--ok); }
.notice.warn { background: var(--warn-bg); box-shadow: none; }
.notice.warn > .ic { color: var(--warn); }
.notice.bad { background: var(--bad-bg); box-shadow: none; }
.notice.bad > .ic { color: var(--bad); }

.hint { display: flex; gap: 10px; margin: 8px 16px 0; padding: 12px 14px; border-radius: var(--r-group); background: var(--surface-2); font-size: 15px; color: var(--ink-2); }
.hint .ic { color: var(--blue); width: 20px; height: 20px; margin-top: 1px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 28px 8px; }
.empty-ic { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); color: var(--gold-ink); }
.empty-ic .ic { width: 30px; height: 30px; }
.empty h2 { font-size: 22px; margin-top: 6px; }
.empty .muted { max-width: 34ch; }
.empty-actions { display: flex; flex-direction: column; gap: 10px; width: min(100%, 320px); margin-top: 10px; }

.action-bar { display: flex; flex-direction: column; gap: 10px; margin: 20px 16px 0; }
.danger-zone { margin: 24px 16px 0; display: flex; justify-content: center; }

.spinner { display: block; width: 26px; height: 26px; margin: 30px auto; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold-ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ обложки документов */

.cover {
  --bg: #3A3F45; --em: var(--gold); --pat: rgba(255, 255, 255, .07);
  position: relative; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background-color: var(--bg);
  background-image: repeating-radial-gradient(circle at 50% 42%, var(--pat) 0 1px, transparent 1px 4px);
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 3px 0 0 rgba(0, 0, 0, .18), inset -1px 0 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .15);
  color: var(--em);
}
.cover-sm { width: 34px; height: 46px; }
.cover-emblem { width: 40%; aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--em); position: relative; }
.cover-emblem::after { content: ""; position: absolute; left: 50%; top: 22%; width: 26%; height: 56%; transform: translateX(-50%); background: var(--em); border-radius: 50% 50% 2px 2px / 40% 40% 2px 2px; }
.cover-lg { width: min(220px, 58vw); aspect-ratio: 88 / 125; gap: 18px; border-radius: 4px 12px 12px 4px; box-shadow: inset 6px 0 0 rgba(0, 0, 0, .2), 0 10px 30px rgba(20, 20, 20, .22); }
.cover-lg .cover-emblem { width: 42%; border-width: 2px; }
.cover-name { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; text-align: center; padding: 0 14px; line-height: 1.4; }
.cover-burgundy { --bg: #6E1A2A; }
.cover-burgundy-gold { --bg: #7A1F30; --pat: rgba(214, 182, 112, .10); }
.cover-burgundy-gold .cover-emblem { box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px var(--em); }
.cover-olive { --bg: #3E4A2B; }
.cover-paper-green { --bg: #DCE8D1; --em: #3C6A3A; --pat: rgba(60, 106, 58, .12); }
.cover-green { --bg: #2B6F4D; --em: #E7F2EA; }
.cover-paper { --bg: #EBE5D3; --em: #6B5A35; --pat: rgba(107, 90, 53, .10); }
.cover-blue { --bg: #D2E1F2; --em: #24467A; --pat: rgba(36, 70, 122, .10); }
.cover-rose { --bg: #E7C6D0; --em: #7A2B45; --pat: rgba(122, 43, 69, .10); }
.cover-grey { --bg: #7F878F; --em: #F2F2F2; }
.cover-paper-rose { --bg: #F1DDE1; --em: #8A3B4E; --pat: rgba(138, 59, 78, .10); }
.cover-stamp { --bg: #F3F1E8; --em: #2B4F8F; --pat: rgba(43, 79, 143, .09); }
.cover-navy { --bg: #1F355C; --em: #E3EAF6; }
.cover-graphite { --bg: #3A3F45; --em: #D9DDE1; }
.cover-teal { --bg: #1E6767; --em: #DDF2F0; }

/* ------------------------------------------------------------ список документов */

.search-bar { padding: 4px 16px 10px; }
.search { min-height: 44px; padding-left: 14px; background: var(--surface); }
.doc-row { min-height: 66px; }
.list-area .group:first-child { margin-top: 8px; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 8px 16px; }
.type-tile { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 15px; font-weight: 500; line-height: 1.25; min-height: 70px; }
.type-tile:hover { background: var(--surface-2); }

/* ------------------------------------------------------------ карточка документа */

.pages { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 8px 16px 12px; scrollbar-width: none; }
.pages::-webkit-scrollbar { display: none; }
.page { position: relative; flex: none; width: min(88%, 520px); scroll-snap-align: center; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.pages > .page:only-child { width: 100%; }
.page-img { display: block; width: 100%; min-height: 120px; object-fit: cover; background: var(--surface-2); }
.page.missing .page-img { opacity: .3; }
.page-missing { position: absolute; inset: auto 12px 12px; font-size: 14px; color: var(--ink-2); background: var(--surface); padding: 6px 10px; border-radius: 8px; }
.hero-cover { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px 16px 4px; }
.doc-head { padding: 12px 20px 0; display: flex; flex-direction: column; gap: 4px; }
.doc-head h1 { font-size: 26px; font-weight: 700; }
.deadline-card { display: flex; gap: 14px; margin: 16px 16px 0; padding: 14px 16px; border-radius: var(--r-group); }
.deadline-card strong { display: block; font-weight: 650; }
.deadline-card p { font-size: 15px; }
.deadline-card .small { margin-top: 4px; opacity: .85; }
.deadline-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; }
.tone-ok { background: var(--ok-bg); } .tone-ok .deadline-ic { color: var(--ok); }
.tone-warn { background: var(--warn-bg); } .tone-warn .deadline-ic { color: var(--warn); }
.tone-bad { background: var(--bad-bg); } .tone-bad .deadline-ic { color: var(--bad); }

.field-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px 8px 16px; min-height: 60px; }
.group-box > .field-row + .field-row { border-top: 1px solid var(--line); }
.field-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.field-label { font-size: 13px; color: var(--ink-2); }
.field-value { font-size: 17px; overflow-wrap: anywhere; white-space: pre-line; user-select: text; }
.field-value.mono { font-size: 18px; font-weight: 550; }
.field-value.latin { letter-spacing: .03em; }
.notes { padding: 14px 16px; white-space: pre-line; }

/* просмотр страниц */
dialog { padding: 0; border: 0; color: var(--ink); }
dialog::backdrop { background: rgba(8, 10, 12, .5); }
.viewer { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; background: #0B0D0F; color: #fff; }
.viewer-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 6px) 8px 6px 18px; background: linear-gradient(rgba(0,0,0,.5), transparent); }
.viewer-count { font-size: 15px; opacity: .8; }
.viewer-strip { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.viewer-strip::-webkit-scrollbar { display: none; }
.viewer-cell { flex: none; width: 100%; height: 100%; scroll-snap-align: center; display: grid; place-items: center; overflow: auto; }
.viewer-cell img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; }
.viewer-cell.zoom { place-items: start; }
.viewer-cell.zoom img { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }
.viewer-hint { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 14px); left: 0; right: 0; text-align: center; font-size: 13px; opacity: .55; pointer-events: none; }
.viewer-err { color: #fff; opacity: .7; }

/* ------------------------------------------------------------ редактор */

.edit-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.edit-page { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.edit-page img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--surface-2); display: block; }
.pdf-tile { display: grid; place-items: center; aspect-ratio: 3 / 4; background: var(--surface-2); color: var(--ink-2); font-weight: 600; gap: 4px; align-content: center; }
.edit-page-tools { display: flex; justify-content: space-around; border-top: 1px solid var(--line); }
.edit-page-tools .icon-btn { width: 40px; height: 40px; }
.edit-add { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.edit-add .btn { flex: 1 1 110px; }
.extra-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; }
@media (max-width: 480px) { .extra-row { grid-template-columns: 1fr auto; } .extra-row > .input:nth-child(2) { grid-column: 1; } .extra-row > .icon-btn { grid-row: 1 / span 2; grid-column: 2; } }

.crop-stage { position: relative; touch-action: none; user-select: none; margin: 0 auto 14px; width: fit-content; max-width: 100%; }
.crop-img { display: block; max-width: 100%; max-height: 62vh; }
.crop-rect { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); cursor: move; }
.crop-h { position: absolute; width: 28px; height: 28px; background: #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.crop-h.nw { left: -14px; top: -14px; cursor: nwse-resize; }
.crop-h.ne { right: -14px; top: -14px; cursor: nesw-resize; }
.crop-h.sw { left: -14px; bottom: -14px; cursor: nesw-resize; }
.crop-h.se { right: -14px; bottom: -14px; cursor: nwse-resize; }

/* ------------------------------------------------------------ листы */

.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; background: var(--surface); max-height: 92vh; max-height: 92dvh; }
.sheet[open] { animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet[open] { animation: none; } }
@media (min-width: 640px) { .sheet { margin: auto; max-width: 480px; border-radius: 22px; } .sheet.wide { max-width: 680px; } }
.sheet.full { height: 100vh; height: 100dvh; max-height: none; margin: 0; border-radius: 0; max-width: none; }
.sheet-inner { display: flex; flex-direction: column; max-height: inherit; height: 100%; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 8px 4px 22px; }
.sheet-head h2 { font-size: 20px; }
.sheet-body { padding: 8px 20px calc(env(safe-area-inset-bottom) + 22px); overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.big-show { flex: 1; justify-content: center; align-items: center; text-align: center; gap: 24px; }
.big-text { font-size: clamp(30px, 8vw, 56px); line-height: 1.25; font-weight: 600; overflow-wrap: anywhere; }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 12px); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: min(92vw, 460px); padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--paper); font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.25); transition: opacity .3s, transform .3s; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* отправка */
.pick-pages { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.pick-page { position: relative; flex: none; width: 96px; }
.pick-page img { width: 96px; height: 128px; object-fit: cover; border-radius: 8px; display: block; background: var(--surface-2); }
.pick-page input { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; accent-color: var(--gold-ink); }
.link-box { padding: 12px; border-radius: var(--r-btn); background: var(--surface-2); word-break: break-all; font-size: 14px; user-select: all; }

/* сроки */
.date-row { gap: 14px; }
.date-badge { display: flex; flex-direction: column; align-items: center; width: 50px; flex: none; padding: 4px 0; border-radius: 10px; background: var(--surface-2); line-height: 1.1; }
.date-badge b { font-size: 20px; }
.date-badge span { font-size: 13px; color: var(--ink-2); }
.date-badge small { font-size: 11px; color: var(--ink-3); }
.date-row.warn .date-badge { background: var(--warn-bg); color: var(--warn); }
.date-row.bad .date-badge { background: var(--bad-bg); color: var(--bad); }

/* поездка */
.phrase { display: flex; align-items: center; gap: 4px; padding-right: 6px; }
.group-box > .phrase + .phrase { border-top: 1px solid var(--line); }
.phrase-main { flex: 1; display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 12px 8px 12px 16px; border: 0; background: transparent; }
.phrase-main:hover { background: var(--surface-2); }
.phrase-ru { font-size: 14px; color: var(--ink-2); }
.phrase-tr { font-size: 19px; font-weight: 550; }
.translation { padding: 16px; border-radius: var(--r-group); background: var(--surface); box-shadow: var(--shadow); font-size: 20px; }
.sos-card { margin: 12px 16px 0; padding: 18px; border-radius: var(--r-group); background: var(--surface); box-shadow: var(--shadow); border-top: 6px solid var(--bad); display: flex; flex-direction: column; gap: 12px; }
.sos-card h2 { font-size: 17px; }
.sos-name { font-size: 22px; font-weight: 650; }
.sos-line { display: flex; flex-direction: column; }
.sos-label { font-size: 13px; color: var(--ink-2); }
.sos-val { font-size: 18px; font-weight: 550; color: var(--ink); }
.contact-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.contact-edit > .input:nth-child(3) { grid-column: 1; }
.contact-edit > .icon-btn { grid-column: 2; justify-self: end; }
.steps { margin: 0; padding: 14px 18px 16px 40px; background: var(--surface); border-radius: var(--r-group); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.steps li::marker { color: var(--gold-ink); font-weight: 700; }

/* ------------------------------------------------------------ страница получателя ссылки */

.share-page { padding: 24px 12px; }
.share-card { max-width: 720px; margin: 0 auto; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.share-card h1 { font-size: 24px; }
.share-card figure { margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.share-card img { width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.share-file { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ аварийный лист */

.kit { display: none; }
@media print {
  body.printing-kit > :not(.kit) { display: none !important; }
  body.printing-kit { background: #fff; color: #000; font-size: 12pt; }
  body.printing-kit .kit { display: block; padding: 10mm 6mm; }
  .kit-head { display: flex; gap: 6mm; align-items: center; border-bottom: 1.5pt solid #9A7A2E; padding-bottom: 5mm; margin-bottom: 6mm; }
  .kit-emblem { width: 20mm; height: 20mm; border-radius: 4mm; }
  .kit h1 { font-size: 20pt; color: #000; }
  .kit h2 { font-size: 13pt; margin: 7mm 0 2mm; }
  .kit dl { display: grid; grid-template-columns: 38mm 1fr; gap: 4mm 6mm; margin: 0; }
  .kit dt { font-weight: 600; }
  .kit dd { margin: 0; }
  .kit-key { font-size: 17pt; font-weight: 700; letter-spacing: .04em; }
  .kit-blank { border-bottom: 1pt solid #000; min-height: 12mm; color: #888; font-size: 9pt; display: flex; align-items: flex-end; }
  .kit ol { padding-left: 6mm; margin: 0; }
}

/* ------------------------------------------------------------ финансы */

.row-ic.gold { background: #17140F; color: #E3C27E; }
.bar { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 7px; width: 100%; }
.bar-fill { display: block; height: 100%; border-radius: 2px; background: linear-gradient(90deg, #A9832F, #E5C783); }
.loan-row { align-items: center; }
.loan-right { display: flex; flex-direction: column; align-items: flex-end; flex: none; text-align: right; }
.loan-right b { font-size: 16px; font-weight: 650; white-space: nowrap; }
.loan-right small { font-size: 12px; color: var(--ink-3); }

.money-sum, .loan-hero {
  margin: 8px 16px 0; padding: 18px 18px 16px; border-radius: 20px;
  background: radial-gradient(120% 140% at 0% 0%, #2A231A 0%, #13110D 55%, #0D0B09 100%);
  color: #F3EBDC; box-shadow: 0 8px 26px rgba(10, 8, 5, .22);
}
.money-sum-label, .loan-hero-label { display: block; font-size: 14px; color: #BDAE92; }
.money-sum-value, .loan-hero-value { display: block; font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; color: #EBCF8E; margin-top: 2px; }
.money-sum-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(235, 207, 142, .18); }
.money-sum-grid span { display: block; font-size: 13px; color: #A99C83; }
.money-sum-grid b { font-size: 16px; font-weight: 600; }
.loan-hero .bar { background: rgba(255, 255, 255, .12); height: 6px; border-radius: 3px; margin-top: 12px; }
.loan-hero-sub { display: block; margin-top: 8px; font-size: 14px; color: #BDAE92; }
.loan-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #CDB98F; margin-bottom: 10px; }
.loan-kind .ic { width: 16px; height: 16px; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 16px 0; }
.fact { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); min-width: 0; }
.fact span { font-size: 13px; color: var(--ink-2); }
.fact b { font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.fact small { font-size: 12.5px; color: var(--ink-3); line-height: 1.35; }

.entry-row { gap: 12px; }
.entry-date { display: flex; flex-direction: column; align-items: center; width: 46px; flex: none; line-height: 1.15; }
.entry-date b { font-size: 15px; }
.entry-date small { font-size: 11px; color: var(--ink-3); }
.entry-amount { font-weight: 650; white-space: nowrap; }
.entry-amount.plus { color: var(--warn); }
.entry-row .icon-btn { width: 36px; height: 36px; }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lbl-wrap { display: flex; flex-direction: column; gap: 5px; }
.field-hint { font-size: 13px; color: var(--ink-3); font-weight: 400; line-height: 1.35; }
.money-input { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg-4 { flex-wrap: wrap; }
.seg-4 .seg-btn { flex: 1 1 40%; }
@media (min-width: 520px) { .seg-4 .seg-btn { flex: 1; } }

.bulk-input { font-size: 15px; min-height: 150px; }
.bulk-preview { display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.bulk-preview:empty { display: none; }
.bulk-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; padding: 8px 12px; font-size: 14px; align-items: center; }
.bulk-row + .bulk-row { border-top: 1px solid var(--line); }
.bulk-row.bad { color: var(--bad); background: var(--bad-bg); grid-template-columns: 92px 1fr; }
.bulk-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
