/* «Юридическая полка» — mobile-first styles, light/dark themes, no external assets. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eceef3;
  --text: #121620;
  --text-2: #394152;
  --muted: #616a7c;
  --border: #dfe3ea;
  --border-strong: #c6ccd7;
  --accent: #2b59ff;
  --accent-hover: #1f47e0;
  --accent-text: #2147d9;
  --accent-soft: #e9eeff;
  --on-accent: #ffffff;
  --ok: #157a42;
  --ok-bg: #1f9d55;
  --ok-soft: #e4f6ec;
  --warn: #8a5300;
  --warn-soft: #fff4dc;
  --danger: #c22a26;
  --danger-bg: #d63b36;
  --danger-soft: #fdeceb;
  --info: #155e8c;
  --info-soft: #e3f1fa;
  --overlay: rgba(12, 16, 26, .48);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 10px 30px rgba(16, 24, 40, .14);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --tap: 48px;
  --header-h: 56px;
  --tabbar-h: 64px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1015;
    --surface: #161a22;
    --surface-2: #1b2029;
    --surface-3: #242a35;
    --text: #e8ebf1;
    --text-2: #c5cbd6;
    --muted: #949db0;
    --border: #2a303c;
    --border-strong: #3a4252;
    --accent: #3f63f5;
    --accent-hover: #5677ff;
    --accent-text: #93a8ff;
    --accent-soft: #1c2546;
    --ok: #5fd394;
    --ok-bg: #1f8a4c;
    --ok-soft: #12291d;
    --warn: #f1b54a;
    --warn-soft: #2d2412;
    --danger: #ff8a85;
    --danger-bg: #c8322d;
    --danger-soft: #331716;
    --info: #7cc4f0;
    --info-soft: #11283a;
    --overlay: rgba(0, 0, 0, .6);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 12px 34px rgba(0, 0, 0, .5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1015;
  --surface: #161a22;
  --surface-2: #1b2029;
  --surface-3: #242a35;
  --text: #e8ebf1;
  --text-2: #c5cbd6;
  --muted: #949db0;
  --border: #2a303c;
  --border-strong: #3a4252;
  --accent: #3f63f5;
  --accent-hover: #5677ff;
  --accent-text: #93a8ff;
  --accent-soft: #1c2546;
  --ok: #5fd394;
  --ok-bg: #1f8a4c;
  --ok-soft: #12291d;
  --warn: #f1b54a;
  --warn-soft: #2d2412;
  --danger: #ff8a85;
  --danger-bg: #c8322d;
  --danger-soft: #331716;
  --info: #7cc4f0;
  --info-soft: #11283a;
  --overlay: rgba(0, 0, 0, .6);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 34px rgba(0, 0, 0, .5);
}

/* -------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img, svg, iframe, video { max-width: 100%; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
ul, ol { margin: 0; padding-left: 1.2em; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow-2); }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: .875rem; }
.h1 { font-size: 1.35rem; font-weight: 700; }
.h3 { font-size: 1rem; font-weight: 650; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.ico { flex: none; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }

/* ------------------------------------------------------------------ layout */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top, 0px);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 750; min-width: 0; }
.brand__icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); flex: none; }
.brand__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__title { display: none; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__spacer { flex: 1; }
.object-picker { position: relative; flex: none; max-width: 44vw; }
.object-picker__select {
  appearance: none; -webkit-appearance: none;
  min-height: 38px; max-width: 100%;
  padding: 6px 30px 6px 12px;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23808898' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-weight: 650; font-size: .95rem; text-overflow: ellipsis;
}
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border-strong); flex: none; position: relative; }
.live-dot[data-state="live"] { background: var(--ok-bg); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok-bg) 22%, transparent); }
.live-dot[data-state="connecting"] { background: #e3a008; animation: blink 1.2s infinite; }
.live-dot[data-state="offline"] { background: var(--danger-bg); }
@keyframes blink { 50% { opacity: .35; } }

.view {
  flex: 1;
  width: 100%; max-width: 860px; margin: 0 auto;
  padding: 16px var(--gutter) calc(var(--tabbar-h) + 28px + var(--safe-bottom));
  outline: none; min-width: 0;
}
.boot { display: grid; place-items: center; gap: 16px; padding: 18vh 0; color: var(--muted); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 0; border: 0; background: none; color: var(--muted); text-decoration: none;
  font-size: .72rem; font-weight: 600; padding: 6px 2px;
}
.tabbar__item__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabbar__item[aria-current="page"], .tabbar__item.is-active { color: var(--accent-text); }
.tabbar__item[aria-current="page"] .ico, .tabbar__item.is-active .ico { transform: translateY(-1px); }
.tabbar__item[data-nav="new"] .ico { color: var(--on-accent); background: var(--accent); border-radius: 12px; padding: 4px; width: 34px; height: 30px; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 45%, transparent); }
.sidenav { display: none; }

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 232px 1fr; grid-template-rows: var(--header-h) 1fr; }
  .topbar { grid-column: 1 / -1; }
  .topbar__title { display: block; padding-left: 64px; }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h));
    padding: 16px 12px; border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidenav__item {
    display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 14px;
    border-radius: 12px; color: var(--text-2); text-decoration: none; font-weight: 600;
  }
  .sidenav__item:hover { background: var(--surface-2); }
  .sidenav__item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }
  .tabbar { display: none; }
  .view { padding-bottom: 48px; }
}
@media (max-width: 420px) {
  .brand__name { display: none; }
}

/* ----------------------------------------------------------------- buttons */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 650; font-size: 1rem; line-height: 1.15; text-decoration: none; text-align: center;
  transition: background-color .15s, border-color .15s, transform .08s, box-shadow .15s;
  user-select: none; -webkit-user-select: none; max-width: 100%;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn__label { overflow: hidden; text-overflow: ellipsis; }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--accent-text); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--danger { background: var(--danger-bg); color: #fff; }
.btn--success { background: var(--ok-bg); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--ok-bg) 30%, transparent); }
.btn--danger-text { color: var(--danger); }
.btn--danger-text:hover { background: var(--danger-soft); }
.btn--sm { min-height: 40px; padding: 0 12px; font-size: .92rem; border-radius: 12px; }
.btn--lg { min-height: 56px; font-size: 1.05rem; padding: 0 22px; }
.btn--xl { min-height: 64px; font-size: 1.15rem; padding: 0 24px; border-radius: 18px; }
.btn--block { width: 100%; }
.btn--icon { flex: none; padding: 0; width: var(--tap); }
.btn--icon.btn--sm { width: 40px; }
.btn--icon.btn--lg { width: 56px; }
.btn--icon.btn--xl { width: 64px; }
.btn--grow { flex: 1; }
.btn.is-busy { color: transparent !important; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent;
  animation: spin .8s linear infinite;
}
.btn--primary.is-busy::after, .btn--danger.is-busy::after, .btn--success.is-busy::after { border-color: #fff transparent #fff transparent; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: transparent; color: var(--text-2); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn--sm { width: 36px; height: 36px; }
.linklike { border: 0; background: none; padding: 0; color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }

/* ------------------------------------------------------------------ inputs */
.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 1rem; /* ≥16px avoids iOS zoom */
  transition: border-color .15s, box-shadow .15s;
  min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea.input { resize: vertical; line-height: 1.45; min-height: 88px; }
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23808898' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  text-overflow: ellipsis;
}
.input--lg { min-height: 56px; font-size: 1.08rem; font-weight: 650; }
.input--sm { min-height: 40px; padding: 6px 10px; font-size: .95rem; width: auto; }
select.input--sm { padding-right: 30px; }
.search-box { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.search-box > .ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input--search { padding-left: 42px; border-radius: 14px; }
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input { padding-right: 36px; }
.input-affix__suffix { position: absolute; right: 14px; color: var(--muted); pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: .88rem; font-weight: 650; color: var(--text-2); }
.field__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; }
.field__hint { font-size: .82rem; color: var(--muted); }
.field__hint--ok { color: var(--ok); }
.field__hint--error { color: var(--danger); font-weight: 600; }
.field__error { color: var(--danger); font-size: .85rem; }
.field__missing { display: none; align-items: center; gap: 4px; font-size: .8rem; font-weight: 650; color: var(--warn); }
.field.is-missing .field__missing { display: inline-flex; }
.field.is-missing .input, .field.is-missing .chip-select, .field.is-missing .list-editor { border-color: #e0a106; box-shadow: 0 0 0 3px color-mix(in srgb, #e0a106 20%, transparent); }
.field.is-invalid .input { border-color: var(--danger); }
.req { color: var(--danger); }
.fieldgrid { display: grid; grid-template-columns: 1fr; gap: 14px; min-width: 0; }
.fieldgrid--loc { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.field--compact .input { min-height: 44px; }
@media (min-width: 640px) {
  .fieldgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fieldgrid--loc { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field--wide { grid-column: 1 / -1; }
}
.fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0; min-width: 0; }
.fieldset > legend { display: flex; align-items: center; gap: 6px; padding: 0 6px; font-weight: 700; font-size: .92rem; color: var(--text-2); }
.docform { display: flex; flex-direction: column; gap: 14px; }
.inline-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: .92rem; color: var(--text-2); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; min-height: 44px; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track { width: 50px; height: 30px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none; transition: background .2s; }
.switch__track::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,.3); transition: transform .2s; }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.switch__text { line-height: 1.3; }
.switch--row { display: flex; }

/* segmented & tabs */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-3); max-width: 100%; }
.segmented > button { border: 0; background: transparent; padding: 8px 14px; min-height: 40px; border-radius: 10px; font-weight: 600; color: var(--text-2); }
.segmented > button[aria-checked="true"], .segmented > button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented--sm > button { min-height: 34px; padding: 6px 10px; font-size: .86rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 8px 0 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs__tab { flex: none; border: 0; background: none; padding: 12px 14px; min-height: 46px; font-weight: 650; color: var(--muted); border-bottom: 3px solid transparent; display: inline-flex; align-items: center; gap: 6px; }
.tabs__tab[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }
.tabs__count { font-size: .75rem; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 1px 7px; }
@media (max-width: 480px) {
  .tabs { gap: 0; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .tabs__tab { padding: 10px 10px; font-size: .92rem; gap: 4px; }
  .tabs__tab:last-child { margin-right: 24px; }
}

/* ------------------------------------------------------------------- chips */
.chip {
  --chip: #7a8394;
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; white-space: nowrap; line-height: 1.5;
  color: color-mix(in srgb, var(--chip) 82%, #000);
  background: color-mix(in srgb, var(--chip) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--chip) 30%, transparent);
}
.chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip); flex: none; }
.chip--big { font-size: .88rem; padding: 5px 12px 5px 10px; }
.st-on_signing .chip__dot, .sst-sent .chip__dot, .sst-delivered .chip__dot { animation: blink 1.4s infinite; }
.chip--flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--chip) 70%, transparent); transform: scale(1.08); } 100% { box-shadow: 0 0 0 14px transparent; transform: scale(1); } }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip { color: color-mix(in srgb, var(--chip) 62%, #fff); background: color-mix(in srgb, var(--chip) 20%, var(--surface)); }
}
:root[data-theme="dark"] .chip { color: color-mix(in srgb, var(--chip) 62%, #fff); background: color-mix(in srgb, var(--chip) 20%, var(--surface)); }
@supports not (color: color-mix(in srgb, red, blue)) {
  .chip { color: var(--chip); background: var(--surface); border-color: var(--chip); }
}
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.chips-row--tight { gap: 6px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 8px; }
@media (min-width: 720px) { .preset-grid { grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); } }
.preset {
  display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 52px; padding: 8px; border-radius: 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: .84rem; font-weight: 650; line-height: 1.2; text-align: left; hyphens: auto;
}
.preset > .ico { color: var(--accent-text); }
.preset:hover { border-color: var(--accent); }
.preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.chip-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-size: .92rem; font-weight: 600; text-align: left; max-width: 100%;
}
.chip-toggle:hover { border-color: var(--accent); }
.chip-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.chip-filter {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 8px 4px 12px;
  border-radius: 999px; border: 0; background: var(--accent-soft); color: var(--accent-text); font-size: .88rem; font-weight: 600; max-width: 100%;
}
.chip-filter--static { padding: 4px 12px; }
.chip-filter__x { border: 0; background: none; color: inherit; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .82rem; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--danger { background: var(--danger-soft); color: var(--danger); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700; }
.badge--neutral { background: var(--surface-3); color: var(--text-2); }
.type-badge { flex: none; display: inline-grid; place-items: center; min-width: 44px; height: 26px; padding: 0 7px; border-radius: 8px; background: var(--text); color: var(--surface); font-size: .74rem; font-weight: 800; letter-spacing: .02em; }

/* ------------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-1); min-width: 0; }
.card--inset { background: var(--surface-2); box-shadow: none; padding: 14px; }
.card--flush { padding: 0; overflow: hidden; }
.card__title { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px; font-size: 1rem; overflow-wrap: anywhere; }
.screen { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.section-title h2 { font-size: 1.12rem; font-weight: 750; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-3); color: var(--text-2); font-size: .93rem; }
.notice > .ico { margin-top: 1px; }
.notice--warn { background: var(--warn-soft); color: var(--warn); }
.notice--info { background: var(--info-soft); color: var(--info); }
.notice--ok { background: var(--ok-soft); color: var(--ok); }
.notice--bad { background: var(--danger-soft); color: var(--danger); }
.notice a { color: inherit; font-weight: 700; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 36px 16px; color: var(--muted); }
.empty__icon { width: 64px; height: 64px; border-radius: 20px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-2); }
.empty__title { color: var(--text); font-size: 1.05rem; }
.empty__text { max-width: 36ch; }
.loading-block { display: grid; place-items: center; padding: 32px 0; }
.spinner-wrap { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 14px; margin: 0; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }
@media (max-width: 420px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; } }
.hash { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--surface-3); color: var(--text-2); font-family: var(--mono); font-size: .76rem; padding: 2px 8px; border-radius: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.link-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.link-list a, .link-list span { display: inline-flex; gap: 6px; align-items: flex-start; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------------------------------------------ toasts */
/* Phones: under the top bar, so toasts never cover the sticky action buttons. */
.toasts {
  position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%);
  top: calc(var(--header-h) + 8px + env(safe-area-inset-top, 0px));
  width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
@media (min-width: 960px) { .toasts { top: auto; bottom: 24px; } }
.toast {
  pointer-events: auto; cursor: pointer; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  padding: 8px 6px 8px 12px; border-radius: 14px; min-height: 48px;
  background: #1c2230; color: #f2f4f8; box-shadow: var(--shadow-2);
  animation: toast-in .22s ease-out;
}
.toast__icon { grid-column: 1; grid-row: 1; }
.toast__body { grid-column: 2; grid-row: 1; }
.toast__close { grid-column: 3; grid-row: 1; }
.toast--out { animation: toast-out .2s ease-in forwards; }
.toast__icon { display: grid; place-items: center; }
.toast--success .toast__icon { color: #58d68d; }
.toast--error .toast__icon { color: #ff7b75; }
.toast--warn .toast__icon { color: #f6c453; }
.toast--info .toast__icon { color: #8fb0ff; }
.toast__body { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.35; }
.toast__action { grid-column: 2; grid-row: 2; justify-self: start; margin: 6px 0 2px; border: 0; background: rgba(255,255,255,.12); color: #fff; font-weight: 700; border-radius: 10px; padding: 6px 14px; min-height: 36px; }
.toast__close { border: 0; background: none; color: rgba(255,255,255,.7); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-in-up { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out-down { to { opacity: 0; transform: translateY(8px); } }
@media (min-width: 960px) {
  .toast { animation-name: toast-in-up; }
  .toast--out { animation-name: toast-out-down; }
}

/* ----------------------------------------------------------------- dialogs */
.dlg {
  padding: 0; border: 0; color: var(--text); background: var(--surface);
  width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh;
  margin: auto auto 0; border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-2); overflow: hidden;
}
.dlg[open] { animation: sheet-up .24s cubic-bezier(.2,.8,.2,1); }
.dlg::backdrop { background: var(--overlay); }
.dlg__inner { display: flex; flex-direction: column; max-height: 92vh; max-height: 92dvh; }
.dlg__head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 8px 18px; border-bottom: 1px solid var(--border); }
.dlg__head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); transform: translateX(-50%); }
.dlg__title { flex: 1; font-size: 1.1rem; font-weight: 750; padding-top: 4px; overflow-wrap: anywhere; }
.dlg__body { padding: 16px 18px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.dlg__text { font-size: 1rem; }
.dlg__foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.dlg__foot .btn { flex: 1 1 auto; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 720px) {
  .dlg { margin: auto; width: min(560px, calc(100vw - 48px)); border-radius: 22px; }
  .dlg--wide { width: min(860px, calc(100vw - 48px)); }
  .dlg__head::before { display: none; }
  .dlg__foot .btn { flex: 0 0 auto; }
}
.dlg--lightbox .dlg__body { padding: 0; background: #000; }
.lightbox { position: relative; display: grid; place-items: center; min-height: 50vh; }
.lightbox__img { max-height: 72vh; width: auto; object-fit: contain; }
.lightbox__caption { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); font-size: .9rem; }
.lightbox__prev, .lightbox__next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.45); color: #fff; }
.lightbox__prev { left: 8px; } .lightbox__next { right: 8px; }
.dlg--viewer { height: 92dvh; }
.dlg--viewer .dlg__inner { height: 100%; }
.dlg--viewer .dlg__body { padding: 0; flex: 1; display: flex; }
.viewer-wrap { display: flex; flex-direction: column; flex: 1; min-height: 60vh; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.viewer-bar > :only-child { margin-left: auto; }
.viewer-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 60vh; }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 12px; min-height: 60px; border-radius: 14px; color: var(--text); text-decoration: none; background: var(--surface-2); }
.menu-item > span { display: flex; flex-direction: column; }
.menu-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }

/* ----------------------------------------------------------------- preview */
.preview {
  position: relative; overflow: hidden; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; height: 420px; cursor: zoom-in;
}
.preview__frame { position: absolute; left: 0; top: 0; border: 0; transform-origin: 0 0; background: #fff; pointer-events: none; height: 1100px; max-width: none; }
.preview__loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--surface-2); }
.preview.is-loaded .preview__loading { display: none; }
.preview::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 64px; background: linear-gradient(transparent, rgba(255,255,255,.95)); pointer-events: none; }
.preview__open { position: absolute; z-index: 2; right: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: rgba(18,22,32,.82); color: #fff; font-size: .85rem; font-weight: 650; }

/* ------------------------------------------------------------------ stepper */
.stepper { list-style: none; padding: 0; margin: 0 0 4px; display: grid; grid-template-columns: repeat(3, 1fr); }
.stepper__step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; color: var(--muted); font-size: .8rem; font-weight: 650; text-align: center; }
.stepper__step + .stepper__step::before { content: ""; position: absolute; top: 13px; left: calc(-50% + 20px); right: calc(50% + 20px); height: 2px; border-radius: 2px; background: var(--border-strong); }
.stepper__step.is-done::before, .stepper__step.is-current::before { background: var(--ok-bg); }
.stepper__label { white-space: nowrap; }
.stepper__btn { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 44px; padding: 0 6px; border: 0; border-radius: 10px; background: none; color: inherit; font: inherit; }
.stepper__btn:hover .stepper__label { text-decoration: underline; text-underline-offset: 3px; }
.stepper__num { position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); font-size: .82rem; font-weight: 750; }
.stepper__step.is-current { color: var(--accent-text); }
.stepper__step.is-current .stepper__num { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.stepper__step.is-done { color: var(--ok); }
.stepper__step.is-done .stepper__num { background: var(--ok-bg); border-color: var(--ok-bg); color: #fff; }

/* ----------------------------------------------------------------- capture */
.capture { display: flex; flex-direction: column; gap: 16px; }
.capture__lead { font-size: 1.02rem; color: var(--text-2); text-align: center; max-width: 34ch; margin: 4px auto 0; }
.mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0 4px; }
.mic {
  --level: 0;
  position: relative; width: 136px; height: 136px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 30% 25%, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent) 60%, color-mix(in srgb, var(--accent) 75%, #000));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--accent) 45%, transparent), inset 0 -4px 10px rgba(0,0,0,.18);
  transition: transform .15s, background .25s, box-shadow .25s;
  touch-action: manipulation;
}
.mic:active { transform: scale(.96); }
.mic__icon { position: relative; z-index: 2; display: grid; place-items: center; }
.mic__ring { position: absolute; inset: -10px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--accent) 35%, transparent); opacity: 0; pointer-events: none; }
.mic.is-live {
  background: radial-gradient(circle at 30% 25%, #ff7a76, #e5352f 60%, #a81d18);
  box-shadow: 0 14px 34px rgba(229, 53, 47, .45), inset 0 -4px 10px rgba(0,0,0,.18);
  transform: scale(calc(1 + var(--level) * .08));
}
.mic.is-live .mic__ring { border-color: rgba(229, 53, 47, .45); animation: ring 1.6s ease-out infinite; }
.mic.is-live .mic__ring--2 { animation-delay: .8s; }
.mic.is-busy { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.mic.is-busy::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 4px solid transparent; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes ring { 0% { transform: scale(.9); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }
.mic-status { min-height: 1.5em; text-align: center; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; max-width: 36ch; }
.mic-status--live { color: #d22f2a; }
.mic-status--busy { color: var(--accent-text); }
.mic-caption {
  width: min(100%, 40ch); margin: 0; padding: 10px 14px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-1); font-size: 1rem; line-height: 1.4; text-align: center;
  color: var(--text); overflow-wrap: anywhere;
}
.mic-caption__interim { color: var(--muted); font-style: italic; }
.transcript { min-height: 112px; font-size: 1.05rem; }
.transcript__interim { min-height: 1.2em; color: var(--muted); font-style: italic; font-size: .95rem; }
.examples summary, .legal summary, .collapsible summary, details.card > summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text-2); min-height: 40px; list-style: none; }
.examples summary::-webkit-details-marker, .legal summary::-webkit-details-marker, .collapsible summary::-webkit-details-marker, details.card > summary::-webkit-details-marker { display: none; }
.examples[open] summary, .legal[open] summary { margin-bottom: 8px; }
.express__signer { padding-left: 2px; }
.choice { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 14px; min-height: 72px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.choice > span { display: flex; flex-direction: column; gap: 2px; }
.choice:hover { border-color: var(--accent); }

.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + 8px + var(--safe-bottom)); z-index: 5;
  display: flex; gap: 8px; align-items: center;
  padding: 10px; margin: 0 -6px; border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
@media (min-width: 960px) { .sticky-actions { bottom: 12px; } }
.sticky-actions > .btn { min-width: 0; }
.sticky-actions .btn--lg, .sticky-actions .btn--xl { padding: 0 14px; font-size: 1rem; }
.sticky-actions .btn--icon { width: 52px; padding: 0; }
.sticky-actions .btn__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------- draft card */
.draft-card { display: flex; flex-direction: column; gap: 16px; }
.draft-card__head { display: flex; flex-direction: column; gap: 10px; }
.eyebrow { font-size: .78rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.draft-card__title { display: flex; align-items: flex-start; gap: 10px; font-size: 1.2rem; font-weight: 750; overflow-wrap: anywhere; }
.draft-card__title .type-badge { margin-top: 1px; }
.draft-card__desc { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; cursor: pointer; }
.draft-card__desc.is-open { display: block; -webkit-line-clamp: unset; line-clamp: none; }
.type-switch {
  position: relative; align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--accent-text); font-weight: 650; font-size: .92rem;
}
.type-switch:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.type-switch .doctype-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.alts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .92rem; }
.legal ul { color: var(--text-2); font-size: .92rem; display: flex; flex-direction: column; gap: 4px; }

/* ------------------------------------------------------------------ photos */
.photo-picker { display: flex; flex-direction: column; gap: 10px; }
.photo-picker__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.photo-picker__title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.photo-picker__count:not(:empty) { background: var(--accent); color: var(--on-accent); border-radius: 999px; font-size: .75rem; padding: 1px 7px; }
.photo-picker__buttons { display: flex; gap: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-grid:empty { display: none; }
.photo { position: relative; margin: 0; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-3); border: 0; padding: 0; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: .7rem; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); text-align: left; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.photo__cap:empty { display: none; }
.photo__actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; }
.photo__btn { width: 32px; height: 32px; border-radius: 10px; border: 0; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.photo__badge { position: absolute; top: 6px; left: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--ok-bg); color: #fff; display: grid; place-items: center; }
.photo-grid--view .photo { cursor: zoom-in; }

/* ------------------------------------------------------------------ signers */
.signer-list { display: flex; flex-direction: column; gap: 8px; }
.signer {
  display: grid; grid-template-columns: auto auto 1fr; grid-template-areas: "cb av body" "sel sel sel";
  align-items: center; gap: 8px 12px; padding: 12px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer;
}
.signer > input[type="checkbox"] { grid-area: cb; width: 22px; height: 22px; accent-color: var(--accent); }
.signer > .avatar { grid-area: av; }
.signer__body { grid-area: body; display: flex; flex-direction: column; min-width: 0; }
.signer > select { grid-area: sel; width: 100%; }
.signer.is-on { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.signer__name { font-weight: 700; overflow-wrap: anywhere; }
.signer__meta, .signer__snils { font-size: .85rem; color: var(--muted); }
.signer__warn { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--warn); font-weight: 650; }
@media (min-width: 640px) {
  .signer { grid-template-columns: auto auto 1fr auto; grid-template-areas: "cb av body sel"; }
  .signer > select { width: auto; }
}
.signer-picker { display: flex; flex-direction: column; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 750; font-size: .9rem; }
.avatar--sm { width: 34px; height: 34px; font-size: .8rem; }

/* ----------------------------------------------------------- progress/hero */
.progress-overlay { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; padding: 16px; background: var(--overlay); animation: fade-in .2s; }
.progress-card { width: min(380px, 100%); background: var(--surface); border-radius: 22px; padding: 24px; box-shadow: var(--shadow-2); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.progress-card__spinner { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: var(--accent-text); background: var(--accent-soft); animation: pulse 1.4s ease-in-out infinite; }
.progress-steps { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; align-self: stretch; }
.progress-steps__item { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; }
.progress-steps__dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.progress-steps__item.is-current { color: var(--text); }
.progress-steps__item.is-current .progress-steps__dot { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.progress-steps__item.is-done { color: var(--ok); }
.progress-steps__item.is-done .progress-steps__dot { background: var(--ok-bg); border-color: var(--ok-bg); }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes fade-in { from { opacity: 0; } }

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 24px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.hero__icon { position: relative; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; }
.hero__title { font-size: 1.35rem; font-weight: 800; }
.hero__text { color: var(--text-2); max-width: 40ch; }
.hero--ok { background: linear-gradient(180deg, var(--ok-soft), var(--surface)); border-color: color-mix(in srgb, var(--ok-bg) 40%, transparent); }
.hero--ok .hero__icon { color: #fff; background: var(--ok-bg); box-shadow: 0 12px 30px color-mix(in srgb, var(--ok-bg) 40%, transparent); }
.hero__icon--pop { animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.hero--wait .hero__icon { color: var(--accent-text); background: var(--accent-soft); }
.hero--bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger-bg) 30%, transparent); }
.hero--bad .hero__icon { color: var(--danger); background: var(--surface); }
.pulse-dot { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent); animation: ring 1.8s ease-out infinite; }

/* -------------------------------------------------------------- doc card */
.doc-head { display: flex; flex-direction: column; gap: 8px; }
.doc-head__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doc-head__number { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.doc-head__spacer { flex: 1; }
.doc-head__title { font-size: 1.2rem; font-weight: 750; overflow-wrap: anywhere; }
.doc-head__meta { color: var(--muted); font-size: .9rem; }
.doc-head__back { margin-left: -8px; }
.tab-body { min-width: 0; }

.timeline { list-style: none; padding: 0; position: relative; display: flex; flex-direction: column; gap: 12px; }
.timeline__item { position: relative; padding-left: 26px; }
.timeline__item::before { content: ""; position: absolute; left: 8px; top: 18px; bottom: -14px; width: 2px; background: var(--border); }
.timeline__item:last-child::before { display: none; }
.timeline__dot { position: absolute; left: 2px; top: 14px; width: 14px; height: 14px; border-radius: 50%; background: var(--border-strong); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.tl-signed .timeline__dot { background: var(--ok-bg); box-shadow: 0 0 0 1px var(--ok-bg); }
.tl-rejected .timeline__dot, .tl-error .timeline__dot { background: var(--danger-bg); box-shadow: 0 0 0 1px var(--danger-bg); }
.tl-sent .timeline__dot, .tl-delivered .timeline__dot, .tl-sending .timeline__dot { background: #e3a008; box-shadow: 0 0 0 1px #e3a008; animation: blink 1.4s infinite; }
.sig { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.sig__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sig__who { display: flex; flex-direction: column; flex: 1; min-width: 140px; font-size: .95rem; }
.sig__who .muted { font-size: .84rem; }
.sig__meta, .sig__provider { font-size: .85rem; color: var(--muted); }
.sig__error { display: flex; gap: 6px; align-items: flex-start; font-size: .88rem; color: var(--danger); background: var(--danger-soft); padding: 8px 10px; border-radius: 10px; overflow-wrap: anywhere; }
.sig__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cert summary { cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: .86rem; font-weight: 650; color: var(--accent-text); min-height: 32px; }
.cert .kv { margin-top: 8px; font-size: .84rem; }
.audit { list-style: none; padding: 0; display: flex; flex-direction: column; }
.audit__item { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.audit__head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .95rem; }
.audit__meta { font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.audit .hash { align-self: flex-start; }
.file-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.file__icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.file__body { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.file__name { font-weight: 650; overflow-wrap: anywhere; }
.file__meta { font-size: .82rem; color: var(--muted); }

/* ------------------------------------------------------------------- shelf */
.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar .btn { flex: none; }
@media (max-width: 400px) { .toolbar .btn__label { display: none; } .toolbar .btn { padding: 0 12px; } }
.list-summary { color: var(--muted); font-size: .9rem; font-weight: 600; }
.day-groups { display: flex; flex-direction: column; gap: 18px; }
.day { display: flex; flex-direction: column; gap: 8px; }
.day__label { position: sticky; top: calc(var(--header-h) + 4px); z-index: 2; align-self: flex-start; font-size: .82rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--bg); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); }
.day__items { display: flex; flex-direction: column; gap: 8px; }
.doc-card {
  display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
  box-shadow: var(--shadow-1); transition: border-color .15s, transform .08s;
}
.doc-card:hover { border-color: var(--border-strong); }
.doc-card:active { transform: scale(.995); }
.doc-card__top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-card__number { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.doc-card__spacer { flex: 1; }
.doc-card__title { font-weight: 600; overflow-wrap: anywhere; }
.doc-card__summary { color: var(--text-2); font-size: .92rem; overflow-wrap: anywhere; }
.doc-card__meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; flex-wrap: wrap; }
.doc-card__src { display: inline-grid; place-items: center; color: var(--accent-text); }
@media (max-width: 380px) { .doc-card__top { flex-wrap: wrap; } }

/* ----------------------------------------------------------------- folders */
.folder-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.folder-row:last-child { border-bottom: 0; }
.folder-row__main { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 4px; border: 0; background: none; text-align: left; min-width: 0; color: var(--text); }
.folder-row__icon { color: #c98a12; flex: none; }
.folder-row__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pick-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); min-height: 56px; }
.pick-row__body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick-doc { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding-right: 4px; transition: opacity .15s; }
.pick-doc.is-off { opacity: .55; }
.pick-doc__main { flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 12px; min-width: 0; min-height: 56px; cursor: pointer; }
.pick-doc__main input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--accent); }
.pick-doc__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pick-doc__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.collapsible > summary { margin-bottom: 8px; }
.collapsible__title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.collapsible__hint { font-size: .85rem; font-weight: 500; color: var(--muted); overflow-wrap: anywhere; }
.collapsible > summary > .ico:last-child { transition: transform .15s; }
.collapsible[open] > summary > .ico:last-child { transform: rotate(180deg); }

/* ---------------------------------------------------------------------- ИД */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stats--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: left; color: var(--text); }
.stat__value { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat--btn { cursor: pointer; }
.stat--btn.is-active { border-color: var(--accent); background: var(--accent-soft); }
.stat--blocked .stat__value { color: var(--danger); }
.stat--late .stat__value { color: var(--warn); }
.stat--signed .stat__value { color: var(--ok); }
.id-group { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.id-group__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; background: var(--surface-2); cursor: pointer; font-weight: 700; list-style: none; }
.id-group__head::-webkit-details-marker { display: none; }
.id-group__title { overflow-wrap: anywhere; }
.id-group__count { font-size: .82rem; color: var(--warn); white-space: nowrap; }
.id-group__count.is-ok { color: var(--ok); }
.id-list { list-style: none; padding: 0; }
.id-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; min-height: 56px; }
.id-row__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.id-row__head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.id-row > .type-badge { align-self: flex-start; margin-top: 1px; }
.id-row__schemes { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); margin-top: 2px; }
.id-row__pkg { display: inline-flex; align-items: center; gap: 3px; color: var(--ok); white-space: nowrap; }

/* ---------------------------------------------------------------- schedule */
.pkg-group { display: flex; flex-direction: column; gap: 8px; }
.pkg-group__title { font-size: .98rem; font-weight: 750; }
.pkg-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 760px) { .pkg-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pkg { display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border-strong); min-width: 0; }
.pkg--in_progress { border-left-color: #2f6fd6; }
.pkg--blocked { border-left-color: var(--danger-bg); background: color-mix(in srgb, var(--danger-soft) 45%, var(--surface)); }
.pkg--done { border-left-color: var(--ok-bg); opacity: .85; }
.pkg__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pkg__name { overflow-wrap: anywhere; }
.pkg__meta { font-size: .86rem; color: var(--muted); }
.pkg__dates { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .88rem; font-variant-numeric: tabular-nums; }
.pkg__blocked { display: flex; gap: 6px; align-items: flex-start; font-size: .85rem; color: var(--danger); overflow-wrap: anywhere; }
.pkg__actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.gantt { position: relative; height: 8px; border-radius: 999px; background: var(--surface-3); margin: 4px 0; overflow: hidden; }
.gantt__bar { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: #8a94a6; }
.gantt__bar--in_progress { background: #2f6fd6; }
.gantt__bar--blocked { background: var(--danger-bg); }
.gantt__bar--done { background: var(--ok-bg); }
.gantt__bar.is-late { box-shadow: inset 0 0 0 2px #e3a008; }
.gantt__today { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .7; }

/* ---------------------------------------------------------------- RD sheets */
.sheet-list { display: flex; flex-direction: column; }
.sheet-list--dialog { max-height: 55vh; overflow-y: auto; gap: 2px; }
.sheet-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 56px; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); text-decoration: none; text-align: left; width: 100%; }
.sheet-list--dialog .sheet-row { border-radius: 10px; border-top: 0; padding: 10px; }
.sheet-row:hover { background: var(--surface-2); }
.sheet-row__no { flex: none; min-width: 42px; height: 32px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); font-weight: 800; font-size: .85rem; font-variant-numeric: tabular-nums; }
.sheet-row__body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sheet-row__title { overflow-wrap: anywhere; font-weight: 550; }
.sheet-row__code { font-size: .8rem; color: var(--muted); }
.sheet-picker { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.sheet-chips { display: flex; flex-direction: column; gap: 6px; align-self: stretch; }
.sheet-chips:empty { display: none; }
.sheet-chip { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); font-size: .88rem; font-weight: 600; min-width: 0; }
.sheet-chip__text { flex: 1; overflow-wrap: anywhere; }
.sheet-chip__x { border: 0; background: none; color: inherit; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; flex: none; }

.screen--sheet { gap: 8px; }
.sheet-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sheet-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sheet-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-head__actions { display: flex; align-items: center; gap: 8px; flex: none; }
@media (max-width: 480px) { .sheet-head__actions .btn__label { display: none; } .sheet-head__actions .btn { padding: 0 12px; } }
.sheet-toolbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.tool-group { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.tool { width: 42px; height: 42px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; }
.tool:hover { background: var(--surface-3); }
.tool[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.tool--text { font-weight: 800; font-size: .8rem; width: 46px; }
.tool.is-loading { animation: blink 1s infinite; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); background: var(--swatch); margin: 0 3px; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text); }
.zoom-label { min-width: 48px; text-align: center; font-size: .8rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-host {
  position: relative; height: calc(100dvh - var(--header-h) - var(--tabbar-h) - 190px); min-height: 320px;
  border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: #e9ecf1;
}
@media (min-width: 960px) { .sheet-host { height: calc(100vh - var(--header-h) - 190px); } }
.sheet-loading { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; background: var(--surface-2); }
.sheet-viewer { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; outline: none; }
.sheet-viewer[data-tool="rect"], .sheet-viewer[data-tool="arrow"], .sheet-viewer[data-tool="cloud"] { cursor: crosshair; }
.sheet-viewer[data-tool="text"] { cursor: text; }
.sheet-viewer[data-tool="select"] { cursor: pointer; }
.sheet-viewer:focus-visible { box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent) 60%, transparent); }
.sheet-viewer__stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.sheet-viewer__img { display: block; max-width: none; background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.2); pointer-events: none; }
.sheet-viewer__svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.mk.is-selected { stroke-dasharray: 8 6; filter: drop-shadow(0 0 3px rgba(43, 89, 255, .9)); }
.mk.is-preview { opacity: .85; }
.sheet-hint { text-align: center; }

/* ---------------------------------------------------------------- settings */
.svc { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.svc:last-of-type { border-bottom: 0; }
.svc__icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.svc__icon.is-on { background: var(--ok-soft); color: var(--ok); }
.svc__icon.is-off { background: var(--warn-soft); color: var(--warn); }
.svc__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.svc__body > .pill { align-self: flex-start; margin-top: 4px; }
.people { list-style: none; padding: 0; display: flex; flex-direction: column; }
.person { border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person.is-inactive { opacity: .55; }
.person__main { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 2px; border: 0; background: none; text-align: left; color: var(--text); min-height: 60px; }
.person__body { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }

/* -------------------------------------------------------------- misc forms */
.radio-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; min-height: 52px; cursor: pointer; }
.radio-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.radio-row__body { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.radio-row:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.chip-select { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid transparent; border-radius: 12px; }
.list-editor { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 12px; padding: 10px; }
.list-editor__head { display: none; }
.list-editor__rows { display: flex; flex-direction: column; gap: 8px; }
.list-editor__row { display: flex; gap: 6px; align-items: flex-start; }
.list-editor__cells { flex: 1; display: grid; grid-template-columns: 1fr; gap: 6px; min-width: 0; }
.list-editor__cells .input { min-height: 42px; }
.list-editor__row + .list-editor__row { padding-top: 8px; border-top: 1px dashed var(--border); }
@media (min-width: 640px) {
  .list-editor__head { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; padding-right: 42px; font-size: .8rem; color: var(--muted); font-weight: 650; }
  .list-editor__cells { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
  .list-editor__row + .list-editor__row { padding-top: 0; border-top: 0; }
}

/* ------------------------------------------------------ сметы и графики */
.view.view--wide { max-width: none; }
.bk-screen { gap: 12px; }
.bk-screen--list { max-width: 1240px; width: 100%; margin: 0 auto; }
.bk-h2 { font-size: 1.12rem; font-weight: 750; margin: 8px 0 0; }
[data-k="p"] { --k: #16a34a; }
[data-k="s"] { --k: #0d9488; }
[data-k="d"] { --k: #2563eb; }
[data-k="r"] { --k: #7c3aed; }
[data-k="e"] { --k: #a8a29e; }
[data-k="f"] { --k: #94a3b8; }
[data-k="a"] { --k: #ea580c; }
.bk-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--k, var(--border-strong)); flex: none; }
.bk-kindlbl, .bk-kindtag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.bk-kindtag { padding: 4px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: .82rem; font-weight: 650; }
.bk-legendline { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .86rem; color: var(--text-2); }
.bk-books { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; }
.bk-books--docs { grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); }
.bk-card { display: flex; flex-direction: column; gap: 12px; }
.bk-card__main { display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none; min-width: 0; }
.bk-card__main:hover .bk-card__title { color: var(--accent-text); }
.bk-card__icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.bk-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bk-card__title { font-size: 1rem; overflow-wrap: anywhere; }
.bk-card__h { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1rem; }
.bk-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.bk-card__kinds { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; color: var(--muted); }
.bk-kinds { display: flex; flex-direction: column; gap: 6px; }
.bk-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.bk-bar > span { background: var(--k); min-width: 2px; }
.bk-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--text-2); }
.bk-facts li { display: flex; gap: 8px; align-items: flex-start; }
.bk-facts .ico { color: var(--ok); flex: none; margin-top: 2px; }
.bk-examples { display: flex; flex-direction: column; gap: 4px; }
.bk-examples__title { font-weight: 700; color: var(--text-2); }
.bk-example { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 8px; color: var(--accent-text); font-size: .9rem; text-decoration: none; }
.bk-example:hover { background: var(--accent-soft); }
.bk-example .ico { flex: none; margin-top: 2px; }
.bk-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.bk-stats .stat__value { font-size: 1.3rem; }

.bk-head { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.bk-head__title { flex: 1 1 260px; display: flex; flex-direction: column; min-width: 0; }
.bk-head__title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; }
.bk-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bk-tabs { margin: 0; }
.bk-tools, .bk-pagetools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.bk-legend { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 420px; min-width: 0; }
.bk-kind { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-size: .82rem; font-weight: 650; }
.bk-kind:hover { border-color: var(--k); }
.bk-kind[aria-pressed="true"] { border-color: var(--k); box-shadow: inset 0 0 0 1px var(--k); color: var(--text); background: color-mix(in srgb, var(--k) 14%, var(--surface)); }
.bk-kind__n { color: var(--muted); font-variant-numeric: tabular-nums; }
.bk-search { flex: 0 1 280px; }
.bk-search .input { width: 100%; }
.bk-findinfo { white-space: nowrap; }
.bk-hint { margin: 0; }

.bk-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
@media (min-width: 1180px) { .bk-layout { grid-template-columns: minmax(0, 1fr) 410px; } }
.bk-grid {
  position: relative; overflow: auto; overscroll-behavior: contain;
  height: calc(100dvh - var(--header-h) - var(--tabbar-h) - 250px); min-height: 380px;
  border: 1px solid var(--border); border-radius: 12px; background: #fff; color-scheme: light; outline: none;
}
@media (min-width: 960px) { .bk-grid { height: calc(100vh - var(--header-h) - 235px); } }
.bk-grid:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }
.bk-table { border-collapse: separate; border-spacing: 0; table-layout: fixed; font: 12.5px/1.35 var(--font); color: #121620; background: #fff; }
.bk-table td, .bk-table th { border-right: 1px solid #e2e5eb; border-bottom: 1px solid #e2e5eb; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; background-color: #fff; }
.bk-table td.is-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.bk-table .is-b { font-weight: 700; }
.bk-table .is-i { font-style: italic; }
.bk-table .is-right { text-align: right; font-variant-numeric: tabular-nums; }
.bk-table .is-center { text-align: center; }
.bk-table thead th { position: sticky; top: 0; z-index: 3; height: 22px; padding: 2px; background: #f1f3f6; color: #616a7c; font-size: 11px; font-weight: 600; text-align: center; }
.bk-table .bk-rh { position: sticky; left: 0; z-index: 2; background: #f1f3f6; color: #616a7c; font-size: 11px; font-weight: 600; text-align: right; }
.bk-table thead .bk-corner { left: 0; z-index: 5; }
.bk-table .is-frozen { position: sticky; z-index: 1; }
.bk-table thead th.is-frozen { z-index: 4; }
.bk-table tr.bk-hdr > td, .bk-table tr.bk-hdr > th { position: sticky; top: 22px; z-index: 2; box-shadow: 0 1px 0 #c6ccd7; }
.bk-table tr.bk-hdr > .bk-rh, .bk-table tr.bk-hdr > .is-frozen { z-index: 3; }
.bk-table td[data-k] { --kt: color-mix(in srgb, var(--k) 13%, transparent); cursor: pointer; background-image: linear-gradient(var(--kt), var(--kt)); box-shadow: inset 3px 0 0 var(--k); }
.bk-table td[data-k="f"], .bk-table td[data-k="e"] { --kt: color-mix(in srgb, var(--k) 9%, transparent); }
.bk-table td[data-k]:hover { --kt: color-mix(in srgb, var(--k) 26%, transparent); }
.bk-table td.is-sel { outline: 2px solid #2b59ff; outline-offset: -2px; --kt: color-mix(in srgb, var(--k) 30%, transparent); }
.bk-table tr.is-found > td { background-image: linear-gradient(rgba(250, 204, 21, .3), rgba(250, 204, 21, .3)); }
.bk-table tr.is-found > .bk-rh { background: #fde68a; color: #713f12; }
.bk-table.bk-dim td[data-k] { background-image: none; box-shadow: none; }
.bk-table[data-only="p"] td[data-k="p"], .bk-table[data-only="s"] td[data-k="s"], .bk-table[data-only="d"] td[data-k="d"],
.bk-table[data-only="r"] td[data-k="r"], .bk-table[data-only="e"] td[data-k="e"], .bk-table[data-only="f"] td[data-k="f"],
.bk-table[data-only="a"] td[data-k="a"] { --kt: color-mix(in srgb, var(--k) 34%, transparent); background-image: linear-gradient(var(--kt), var(--kt)); box-shadow: inset 3px 0 0 var(--k); font-weight: 700; }

.bk-panel { display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-1); }
@media (min-width: 1180px) { .bk-panel { position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100vh - var(--header-h) - 24px); } }
@media (max-width: 1179.98px) {
  .bk-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 74vh; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-2); padding-bottom: var(--safe-bottom); }
}
@media (min-width: 960px) and (max-width: 1179.98px) { .bk-panel { left: auto; width: 440px; right: 12px; bottom: 12px; border-radius: 18px; max-height: calc(100vh - var(--header-h) - 24px); } }
.bk-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border); }
.bk-panel__body { overflow: auto; padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.bk-panel__body h4 { margin: 0; font-size: .95rem; }
.bk-ref__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.bk-ref__title { margin: 0; font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.bk-ref__value { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.bk-ref__formula, .bk-ref__ev, .bk-ref__links { display: flex; flex-direction: column; gap: 8px; }
.bk-ref__evhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bk-formula { font-size: .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; overflow-wrap: anywhere; }
.bk-formula--src { font-family: var(--mono); font-size: .78rem; }
.bk-inputs { display: flex; flex-direction: column; gap: 4px; }
.bk-input { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); text-align: left; font-size: .88rem; }
.bk-input:hover { border-color: var(--accent); background: var(--accent-soft); }
.bk-input__t { overflow-wrap: anywhere; }
.bk-input__v { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bk-evlist { display: flex; flex-direction: column; gap: 10px; }
.bk-evi { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); min-width: 0; }
.bk-evi__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9rem; }
.bk-evi__title { overflow-wrap: anywhere; }
.bk-evi__marks { margin: 0; padding-left: 18px; font-size: .84rem; color: var(--text-2); display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.bk-evi__note { margin: 0; color: var(--text-2); }
.bk-evi__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bk-thumb { position: relative; display: block; max-width: 100%; padding: 0; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: #fff; cursor: zoom-in; }
.bk-thumb:hover { border-color: var(--accent); }
.bk-thumb__img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: fill; }
.bk-thumb__svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.bk-thumb__svg .ev-b { fill: rgba(217, 70, 239, .14); stroke: #c026d3; stroke-width: 2; vector-effect: non-scaling-stroke; }
.bk-thumb__svg .ev-f { fill: rgba(250, 204, 21, .45); stroke: #a16207; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.bk-thumb__svg .ev-l { stroke: #c026d3; stroke-width: 1.5; vector-effect: non-scaling-stroke; }

.bk-pagegroup { display: flex; flex-direction: column; gap: 8px; }
.bk-pagegroup__title { margin: 4px 0 0; font-size: 1rem; }
.bk-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 10px; }
.bk-pagecard { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-align: left; font-size: .85rem; cursor: pointer; }
.bk-pagecard:hover { border-color: var(--accent); box-shadow: var(--shadow-1); }
.bk-pagecard__imgwrap { position: relative; display: grid; place-items: center; height: 150px; border-radius: 8px; background: #fff; border: 1px solid var(--border); overflow: hidden; }
.bk-pagecard__img { max-width: 100%; max-height: 100%; aspect-ratio: var(--ar); object-fit: contain; }
.bk-pagecard__badge { position: absolute; right: 6px; top: 6px; padding: 2px 8px; border-radius: 999px; background: #c026d3; color: #fff; font-size: .75rem; font-weight: 750; }
.bk-pagecard__no { color: var(--muted); font-weight: 650; font-size: .78rem; }
.bk-pagecard__title { font-weight: 650; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-pagecard__meta { color: var(--text-2); font-size: .78rem; overflow-wrap: anywhere; }
.bk-pagecard__used { color: var(--accent-text); font-size: .78rem; font-weight: 650; }

body.pv-open { overflow: hidden; }
.pv { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: var(--bg); }
.pv__bar { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 6px 10px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); background: var(--surface); border-bottom: 1px solid var(--border); }
.pv__title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pv__title strong, .pv__title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv__nav { display: flex; align-items: center; gap: 2px; flex: none; }
.pv__page { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.pv__src { display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; padding: 6px 12px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, #c026d3 10%, var(--surface)); font-size: .88rem; }
.pv__src-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.pv__src-title { overflow-wrap: anywhere; }
.pv__src-value { font-weight: 800; white-space: nowrap; }
.pv__src-nav { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.pv__body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
@media (min-width: 900px) { .pv__body { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: minmax(0, 1fr); } }
.pv__stage { position: relative; min-height: 0; min-width: 0; background: #dfe3ea; }
.pv__host { position: absolute; inset: 0; }
.pv__zoom { position: absolute; right: 10px; bottom: 10px; z-index: 4; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-2); }
.pv__side { min-width: 0; overflow: auto; max-height: 40vh; background: var(--surface); border-top: 1px solid var(--border); }
@media (min-width: 900px) { .pv__side { max-height: none; border-top: 0; border-left: 1px solid var(--border); } }
.pv__side > summary { padding: 10px 14px; font-weight: 700; cursor: pointer; }
.pv__side-body { display: flex; flex-direction: column; gap: 12px; padding: 0 14px 18px; }
.pv-layers { display: flex; flex-direction: column; gap: 4px; }
.pv-layer, .pv-group { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: .9rem; cursor: pointer; }
.pv-layer input, .pv-group input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.pv-layer > span:nth-of-type(1) { font-weight: 650; }
.pv-groups { display: flex; flex-direction: column; padding-left: 26px; }
.pv-group { font-size: .84rem; min-height: 28px; }
.pv-group__label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pv-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--sw); flex: none; }
.pv-evlist h4 { margin: 0 0 4px; font-size: .9rem; }
.pv-evlist ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 2px; font-size: .84rem; }
.pv-kv { font-size: .84rem; }
.pv-tap { font-size: .88rem; }
.sheet-viewer__svg .pv-text rect { fill: rgba(37, 99, 235, .05); stroke: rgba(37, 99, 235, .5); stroke-width: .75; vector-effect: non-scaling-stroke; }
.sheet-viewer__svg .pv-grp rect { fill-opacity: .14; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sheet-viewer__svg .pv-ev { fill: rgba(217, 70, 239, .18); stroke: #c026d3; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.sheet-viewer__svg .pv-ev-f { fill: rgba(250, 204, 21, .5); stroke: #a16207; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sheet-viewer__svg .pv-ev-l { stroke: #c026d3; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sheet-viewer__svg .pv-ev-dot { fill: none; stroke: #c026d3; stroke-width: 8; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.sheet-viewer__svg .pv-evg { animation: pv-blink 1s ease-in-out 3; }
.sheet-viewer__svg .pv-hit { fill: none; stroke: #f59e0b; stroke-width: 3; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
@keyframes pv-blink { 50% { opacity: .35; } }

/* ----------------------------------------------------------- motion prefs */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
