/* «Регистр» — стили интерфейса. Перенос макета из design/ (React + CSS Modules) в обычный CSS.
   Палитра и геометрия — в :root, меняйте там. */

/* ============================================================ Токены */
:root {
  --font-ui: 'Golos Text', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Bitter', Georgia, serif;

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-muted: #fbfbfc;
  --surface-head: #fafafb;
  --line: #e3e6ea;
  --line-soft: #e9ebef;
  --line-softer: #eff1f4;
  --line-row: #f0f2f5;

  --ink: #14181f;
  --ink-2: #3c4450;
  --ink-3: #4a545f;
  --ink-4: #6b7580;
  --ink-5: #8a929b;
  --ink-6: #9aa2ac;

  --brand: #eca700;
  --brand-deep: #8f5f00;
  --brand-ink: #101113;
  --brand-dark: #16171a;

  --accent: #17181b;
  --accent-hover: #34373c;
  --accent-soft: color-mix(in srgb, var(--brand) 16%, #ffffff);
  --accent-softer: color-mix(in srgb, var(--brand) 8%, #ffffff);

  --dir-in: #0b6e62;
  --dir-in-soft: #e3f1ef;
  --dir-out: #6b3fb8;
  --dir-out-soft: #efe9fa;

  --st-work: #8a5206;
  --st-work-soft: #fbf0dd;
  --st-done: #14663f;
  --st-done-soft: #e2f1e8;
  --st-late: #b02e1c;
  --st-late-soft: #fbe8e4;
  --st-late-line: #f0dad5;
  --st-idle: #4a545f;
  --st-idle-soft: #eff1f4;

  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 9px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow-tab: 0 1px 2px rgba(20, 24, 31, 0.09);
  --shadow-card: 0 6px 18px rgba(20, 24, 31, 0.09);
  --shadow-pop: 0 18px 44px rgba(17, 26, 43, 0.18);
  --shadow-modal: 0 30px 70px rgba(10, 16, 28, 0.34);

  --sidebar-w: 248px;
  --topbar-h: 64px;
  --toolbar-h: 60px;
  --row-h: 68px;
  --gutter: 28px;
  --backdrop: rgba(17, 26, 43, 0.42);
}

/* ============================================================ База */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-deep); text-decoration: none; }
a:hover {
  color: var(--brand-ink);
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-underline-offset: 3px;
}
h1, h2, h3 { margin: 0; }
p { margin: 0; }
input, button, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
body.is-locked { overflow: hidden; }

.ic { flex-shrink: 0; display: block; }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-5); }
.text-late { color: var(--st-late); }

/* ============================================================ Кнопки */
.btn {
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: default; pointer-events: none; }
.btn-primary { border-color: transparent; background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-in { border-color: transparent; background: var(--dir-in); color: #fff; font-weight: 600; }
.btn-in:hover { background: color-mix(in srgb, var(--dir-in) 88%, #000); color: #fff; }
.btn-out { border-color: transparent; background: var(--dir-out); color: #fff; font-weight: 600; }
.btn-out:hover { background: color-mix(in srgb, var(--dir-out) 88%, #000); color: #fff; }
.btn-ok { border-color: transparent; background: var(--st-done); color: #fff; font-weight: 600; }
.btn-ok:hover { background: color-mix(in srgb, var(--st-done) 88%, #000); color: #fff; }
.btn-soft { border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn-soft:hover { background: color-mix(in srgb, var(--brand) 24%, #fff); }
.btn-danger { color: var(--st-late); }
.btn-sm { height: 34px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { height: 40px; padding: 0 18px; border-radius: 10px; font-size: 14px; }
.btn-dashed { border-style: dashed; border-color: #c9cfd6; color: var(--ink-3); }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-in):not(.btn-out):not(.btn-ok).is-busy::after { border-color: var(--line); border-top-color: var(--ink-3); }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.icon-btn-sm { width: 30px; height: 30px; border-radius: var(--r-sm); }
.icon-btn-bare { border-color: transparent; background: transparent; }
.icon-btn-filled { border-color: transparent; background: var(--st-idle-soft); color: var(--ink-3); }
.icon-btn.is-danger { color: var(--st-late); }
.relative { position: relative; }

/* ============================================================ Поля */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 11.5px; color: var(--ink-5); }
.field-error { font-size: 11.5px; color: var(--st-late); font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13.5px;
}
.input, .select { height: 38px; padding: 0 12px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-lg { height: 46px; padding: 0 14px; font-size: 14.5px; border-radius: 10px; }
.textarea { padding: 9px 12px; line-height: 1.45; resize: vertical; }
.readonly, .input[readonly] { background: #f7f8fa; font-weight: 600; }
.input:disabled, .select:disabled, .textarea:disabled { background: #f7f8fa; color: var(--ink-3); cursor: default; }
.has-error .input, .has-error .select, .has-error .textarea, .input.has-error { border-color: var(--st-late); }
.select-wrap { position: relative; }
.select { padding-right: 36px; appearance: none; -webkit-appearance: none; }
.select-caret {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: #7a838f; pointer-events: none; display: flex;
}
.input-row { display: flex; gap: 8px; }
.input-row > .input, .input-row > .select-wrap { flex-grow: 1; min-width: 0; }
.input-row > .btn { height: 38px; flex-shrink: 0; font-size: 12.5px; }
input[type='date'].input { padding-right: 8px; }

.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-5); display: flex; pointer-events: none;
}
.search {
  width: 100%; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface-muted); font-size: 13px;
}
.search:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.checkbox, .radio { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.checkbox-sm { width: 15px; height: 15px; }
.check-field { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; color: var(--ink-3); }

/* Селект в виде кнопки для панели фильтров */
.pill-select { position: relative; display: inline-flex; }
.pill-select select {
  height: 34px; padding: 0 32px 0 13px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: 13px; font-weight: 500;
  appearance: none; -webkit-appearance: none; cursor: pointer; max-width: 230px;
}
.pill-select select:hover { background: var(--surface-muted); }
.pill-select.is-set select { border-color: var(--accent); background: var(--accent-softer); font-weight: 600; }
.pill-select .ic { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-4); }

.date-range {
  height: 34px; display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 11px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink-3);
}
.date-range.is-set { border-color: var(--accent); background: var(--accent-softer); }
.date-range input {
  border: 0; background: transparent; font-size: 12.5px; font-weight: 500; width: 118px; padding: 0 2px; height: 30px;
  font-variant-numeric: tabular-nums;
}
.date-range input:focus { outline: none; }
.date-range .sep-dash { color: var(--ink-5); }

/* ============================================================ Контейнеры */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); }
.card-pad { padding: 18px; }
.card-danger { border-color: var(--st-late-line); }
.divider { height: 1px; background: var(--line-softer); }
.vdivider { width: 1px; align-self: stretch; background: var(--line-softer); }

/* Сегменты */
.seg { display: flex; padding: 3px; background: #f1f2f5; border-radius: var(--r-md); gap: 2px; }
.seg-item {
  padding: 6px 13px; border: 0; border-radius: 7px; background: transparent;
  color: var(--ink-3); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg-item:hover { color: var(--ink); text-decoration: none; }
.seg-item.is-active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-tab); }
.seg-count { color: var(--ink-5); font-weight: 500; }
.seg-grow { flex-grow: 1; justify-content: center; text-align: center; }

/* Чипы */
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 7px; background: var(--st-idle-soft); color: var(--ink-3);
  font-size: 11.5px; font-weight: 600; white-space: nowrap; max-width: 100%;
}
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-in { background: var(--dir-in-soft); color: var(--dir-in); }
.chip-out { background: var(--dir-out-soft); color: var(--dir-out); }
.chip-lg { height: 34px; padding: 0 12px; font-size: 13px; }
.chip-x {
  width: 18px; height: 18px; border: 0; padding: 0; background: transparent; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 4px;
}
.chip-x:hover { background: rgba(0, 0, 0, 0.06); color: inherit; }

/* Табы */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 11px 13px; font-size: 13.5px; font-weight: 500; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); border-bottom-width: 2.5px; }
.tab-badge { padding: 1px 6px; border-radius: 5px; background: var(--st-idle-soft); font-size: 11px; font-weight: 600; color: var(--ink-3); }

/* Переключатель */
.toggle {
  width: 38px; height: 22px; border: 0; border-radius: 11px; background: var(--line);
  padding: 2px; display: inline-flex; cursor: pointer; flex-shrink: 0;
}
.toggle.is-on { background: var(--accent); justify-content: flex-end; }
.toggle-knob { width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(20, 24, 31, 0.2); }

/* ============================================================ Атомы */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 7px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-work { background: var(--st-work-soft); color: var(--st-work); }
.tone-done { background: var(--st-done-soft); color: var(--st-done); }
.tone-late { background: var(--st-late-soft); color: var(--st-late); }
.tone-idle { background: var(--st-idle-soft); color: var(--st-idle); }
.tone-sent { background: var(--accent-soft); color: var(--accent); }

.dir { display: inline-flex; align-items: center; gap: 7px; }
.dir-icon { width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dir-icon.is-sm { width: 22px; height: 22px; }
.dir-in .dir-icon, .dir-icon.dir-in { background: var(--dir-in-soft); color: var(--dir-in); }
.dir-out .dir-icon, .dir-icon.dir-out { background: var(--dir-out-soft); color: var(--dir-out); }
.dir-label { font-size: 12px; font-weight: 600; }
.dir-in .dir-label { color: var(--dir-in); }
.dir-out .dir-label { color: var(--dir-out); }

.cdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.cdot-8 { width: 8px; height: 8px; }
.cdot-6 { width: 6px; height: 6px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #e7e9ee; color: var(--ink-3);
  font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.avatar-24 { width: 24px; height: 24px; font-size: 10px; }
.avatar-34 { width: 34px; height: 34px; }
.avatar-accent { background: var(--accent-soft); color: var(--accent); }

.caption { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-5); }
.caption-lg { font-size: 11.5px; letter-spacing: 0.06em; }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-text { display: flex; flex-direction: column; gap: 3px; }
.section-title { font-size: 15px; font-weight: 600; }
.section-desc { font-size: 12.5px; color: var(--ink-4); }

/* Логотип */
.logo-plate {
  width: 32px; height: 32px; border-radius: var(--r-md); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; padding: 3px;
}
.logo-plate img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-plate.is-dark { background: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14); }
.logo-fallback {
  border-radius: var(--r-md); background: var(--accent); color: #fff; font-family: var(--font-display);
  font-weight: 700; letter-spacing: 0.02em; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lockup { display: inline-flex; align-items: center; gap: 12px; min-width: 0; color: inherit; }
.lockup:hover { text-decoration: none; color: inherit; }
.lockup-text { display: flex; flex-direction: column; min-width: 0; }
.lockup-product { font-family: var(--font-display); font-size: 16px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.lockup-caption { font-size: 9.5px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-5); white-space: nowrap; }
.lockup.is-dark .lockup-product { font-size: 19px; color: #fff; }
.lockup.is-dark .lockup-caption { font-size: 10.5px; color: #8b97ae; }

/* ============================================================ Каркас */
.shell { position: relative; min-height: 100vh; display: flex; background: var(--bg); }
.main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 40;
}
.sb-brand { padding: 16px 16px 12px; display: flex; align-items: center; gap: 10px; }
.sb-scope { position: relative; padding: 0 12px 12px; }
.scope-btn {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-muted); display: flex; align-items: center; justify-content: space-between;
  gap: 8px; cursor: pointer; text-align: left; color: var(--ink-4);
}
.scope-btn.is-open { border-color: var(--accent); background: var(--accent-softer); color: var(--accent); }
.scope-btn.is-static { cursor: default; }
.scope-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scope-caption { font-size: 9.5px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: inherit; }
.scope-value { font-size: 13.5px; font-weight: 600; color: var(--ink); }

.sb-group { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-title { padding: 14px 10px 6px; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-6); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md);
  color: var(--ink-3); font-size: 13.5px; font-weight: 500;
}
.nav-item:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.is-active .nav-icon, .nav-item.is-active .nav-count { color: currentColor; }
.nav-icon { color: var(--ink-4); display: flex; }
.nav-label { flex-grow: 1; }
.nav-count { font-size: 11.5px; font-weight: 500; color: var(--ink-5); }
.nav-count.is-late { color: var(--st-late); font-weight: 600; }

.sb-user { margin-top: auto; border-top: 1px solid var(--line-softer); padding: 12px; display: flex; align-items: center; gap: 10px; }
.sb-user-text { display: flex; flex-direction: column; min-width: 0; flex-grow: 1; }
.sb-user-name { font-size: 13px; font-weight: 600; }
.sb-user-role { font-size: 11.5px; color: var(--ink-5); }
.sb-user form { margin: 0; }
.sidebar-backdrop { display: none; }

/* Всплывающий выбор области */
.scope-pop {
  position: absolute; left: 224px; top: 8px; z-index: 50; width: 384px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-pop); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px;
}
.scope-pop-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.scope-pop-title { font-size: 14.5px; font-weight: 600; }
.scope-pop-sub { font-size: 12px; color: var(--ink-4); }
.scope-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.scope-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-md); cursor: pointer; }
.scope-row:hover { background: var(--surface-muted); }
.scope-row.is-active { background: color-mix(in srgb, var(--brand) 12%, #ffffff); }
.scope-row-text { display: flex; flex-direction: column; gap: 1px; flex-grow: 1; min-width: 0; }
.scope-row-name { font-size: 13px; font-weight: 500; }
.scope-row.is-active .scope-row-name { font-weight: 600; }
.scope-row-meta { font-size: 11.5px; color: var(--ink-5); }
.scope-toggle-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.scope-toggle-text { display: flex; flex-direction: column; gap: 2px; }
.scope-toggle-title { font-size: 12.5px; font-weight: 600; }
.scope-pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.scope-pop-foot a { font-size: 12.5px; font-weight: 500; }
.scope-pop-btns { display: flex; gap: 8px; }
.scope-list.is-all .scope-row { cursor: default; }

/* Верхняя панель */
.topbar {
  min-height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line-soft);
  padding: 10px var(--gutter); display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.topbar-title { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-sub { font-size: 12px; color: var(--ink-5); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-search { width: 268px; }
.burger { display: none; }

/* Панель фильтров */
.toolbar {
  min-height: var(--toolbar-h); background: var(--surface); border-bottom: 1px solid var(--line-soft);
  padding: 10px var(--gutter); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-shrink: 0;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.toolbar-sep { width: 1px; height: 24px; background: #e6e9ed; }
.numbering-note { font-size: 12.5px; color: var(--ink-5); }
.numbering-note strong { font-weight: 600; color: var(--ink); }

.content { padding: 20px var(--gutter) 28px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Плитки сводки */
.tiles { display: flex; gap: 12px; flex-shrink: 0; }
.tile {
  flex-grow: 1; flex-basis: 0; min-width: 0; background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--r-lg); padding: 13px 16px; display: flex; flex-direction: column; gap: 5px; color: inherit;
}
a.tile:hover { text-decoration: none; color: inherit; border-color: var(--line); box-shadow: var(--shadow-tab); }
.tile-danger { border-color: var(--st-late-line); }
.tile-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-5); }
.tile-value { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; }
.tile-hint { font-size: 11.5px; color: var(--ink-4); }
.tone-in-text { color: var(--dir-in) !important; }
.tone-out-text { color: var(--dir-out) !important; }
.tone-work-text { color: var(--st-work) !important; }
.tone-done-text { color: var(--st-done) !important; }
.tone-late-text { color: var(--st-late) !important; }

/* ============================================================ Таблица журнала */
.tbl { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); overflow: hidden; }
.tbl-head {
  height: 40px; background: var(--surface-head); border-bottom: 1px solid var(--line-soft); padding: 0 14px;
  display: grid; align-items: center; font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-5);
}
.tbl-head > span { padding-right: 12px; }
.tbl-group {
  height: 32px; background: var(--surface-muted); border-bottom: 1px solid var(--line-row); padding: 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.tbl-group-title { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.tbl-group-count { font-size: 11.5px; color: var(--ink-5); }
.tbl-row {
  min-height: var(--row-h); border-bottom: 1px solid var(--line-row); padding: 8px 14px;
  display: grid; align-items: center; cursor: pointer; color: inherit;
}
.tbl-row:hover { background: #fcfcfd; }
.tbl-row.is-overdue { box-shadow: inset 3px 0 0 var(--st-late); }
.tbl-row.is-draft .stack-1 { color: var(--ink-4); }
.tbl-cell { display: flex; align-items: center; min-width: 0; padding-right: 12px; }
.tbl-cell.is-end { justify-content: flex-end; padding-right: 0; }
.stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stack-1 { font-size: 13px; font-weight: 500; }
.stack-2 { font-size: 11.5px; color: var(--ink-5); }
.tbl-empty { padding: 48px 16px; text-align: center; font-size: 13.5px; color: var(--ink-5); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tbl-foot { min-height: 52px; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.tbl-foot-text { font-size: 12.5px; color: var(--ink-4); }
.tbl-foot-text strong { font-weight: 600; color: var(--ink); }
.pager { display: flex; align-items: center; gap: 6px; }
.page {
  min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
}
.page:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.page.is-active { border-color: transparent; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.page.is-disabled { opacity: 0.45; pointer-events: none; }
.pager-gap { font-size: 12.5px; color: var(--ink-5); padding: 0 2px; }

.subject-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.subject-link { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.subject-link:hover { color: var(--accent); }
.subject-meta { font-size: 11.5px; color: var(--ink-5); }
.company-cell { display: flex; align-items: center; gap: 7px; min-width: 0; }
.company-name { font-size: 12.5px; font-weight: 500; }
.num-cell, .person-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.case-chip {
  display: inline-block; max-width: 100%; padding: 3px 8px; border-radius: var(--r-xs); background: #f1f2f5;
  font-size: 11.5px; font-weight: 500; color: var(--ink-3);
}
.files-cell { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-5); font-size: 11.5px; font-weight: 500; }
.files-cell.is-empty { opacity: 0.4; }

/* Карточка компании над журналом */
.company-card { padding: 16px 18px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.company-mark {
  width: 48px; height: 48px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.company-info { display: flex; flex-direction: column; gap: 4px; width: 320px; min-width: 0; }
.company-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.company-title { font-size: 15.5px; font-weight: 600; }
.company-state { padding: 2px 7px; border-radius: 5px; background: var(--st-done-soft); color: var(--st-done); font-size: 10.5px; font-weight: 600; }
.company-state.is-archive { background: var(--st-idle-soft); color: var(--st-idle); }
.company-meta { font-size: 12px; color: var(--ink-4); }
.company-link { font-size: 12.5px; font-weight: 500; }
.company-stats { display: flex; gap: 28px; flex-grow: 1; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-value { font-size: 21px; font-weight: 600; }
.next-numbers {
  display: flex; flex-direction: column; gap: 6px; padding: 10px 14px; border: 1px dashed var(--line);
  border-radius: 10px; background: var(--surface-muted);
}
.next-value { font-size: 12.5px; font-weight: 600; }

/* ============================================================ Модальные окна */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: var(--backdrop); padding: 40px 24px;
  display: flex; align-items: center; justify-content: center; animation: fade 0.12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-height: 100%; background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-modal);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  padding: 16px 22px 14px; border-bottom: 1px solid var(--line-softer); display: flex; align-items: flex-start;
  justify-content: space-between; gap: 20px; flex-shrink: 0;
}
.modal-head-left { min-width: 0; }
.modal-titles { display: flex; flex-direction: column; gap: 4px; }
.modal-title { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.modal-sub { font-size: 13px; color: var(--ink-4); }
.modal-head-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.modal-body { flex-grow: 1; min-height: 0; display: flex; overflow: auto; margin: 0; }
.modal-foot {
  min-height: 72px; border-top: 1px solid var(--line-softer); background: #fcfcfd; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-shrink: 0; flex-wrap: wrap;
}
.foot-note { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-4); min-width: 0; }
.foot-note strong { font-weight: 600; color: var(--ink); }
.foot-btns { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.modal-sm .modal-body { display: block; padding: 20px 22px; }

.dir-btn { height: 32px; }
.dir-btn.is-active.is-in { color: var(--dir-in); }
.dir-btn.is-active.is-out { color: var(--dir-out); }

/* --- Окно регистрации: левая панель с файлами */
.files-pane {
  width: 440px; flex-shrink: 0; border-right: 1px solid var(--line-softer); background: #fcfcfd;
  padding: 20px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.dropzone {
  border: 2px dashed #c2cbd5; border-radius: var(--r-lg); background: var(--surface); padding: 22px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; transition: border-color 0.12s, background 0.12s;
}
.dropzone.is-over { border-color: var(--dir-in); background: var(--dir-in-soft); }
.drop-icon {
  width: 44px; height: 44px; border-radius: var(--r-lg); background: var(--dir-in-soft); color: var(--dir-in);
  display: flex; align-items: center; justify-content: center;
}
.drop-text { display: flex; flex-direction: column; gap: 3px; font-size: 14px; }
.file-pick { position: relative; cursor: pointer; }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  border: 1px solid #e6e9ed; border-radius: 10px; background: var(--surface); padding: 11px 12px;
  display: flex; align-items: center; gap: 11px;
}
.file-row.is-error { border-color: var(--st-late-line); background: var(--st-late-soft); }
.file-type {
  width: 34px; height: 40px; border-radius: 5px; display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 700; flex-shrink: 0; background: var(--st-idle-soft); border: 1px solid var(--line); color: var(--ink-3);
}
.ft-pdf { background: var(--st-late-soft); border-color: #f0d3cc; color: var(--st-late); }
.ft-img { background: var(--accent-soft); border-color: #eedba8; color: var(--brand-deep); }
.ft-doc { background: #e8eef9; border-color: #d0dcf2; color: #1f5fa8; }
.file-info { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; min-width: 0; }
.file-name { font-size: 13px; font-weight: 500; color: var(--ink); }
a.file-name:hover { color: var(--accent); }
.file-meta { font-size: 11.5px; color: var(--ink-5); }
.file-ok { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--st-done); }
.progress { height: 5px; border-radius: 3px; background: var(--line-softer); display: block; overflow: hidden; }
.progress-bar { display: block; height: 5px; width: 0; border-radius: 3px; background: var(--accent); transition: width 0.15s; }
.file-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.files-empty { font-size: 12.5px; color: var(--ink-5); }

.info-box {
  border: 1px solid #dce6e3; border-radius: 10px; background: #f3f9f7; padding: 13px 14px;
  display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: #0b5a50;
}
.info-box-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.info-box ul { margin: 0; padding-left: 18px; color: var(--ink-3); display: flex; flex-direction: column; gap: 4px; }

/* --- Форма документа */
.form-pane { flex-grow: 1; min-width: 0; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid2i { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: 96px 110px minmax(0, 1fr); gap: 12px; }
.grid2b { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 12px; }
.link-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-chips { display: contents; }
.link-search { position: relative; flex-grow: 1; min-width: 220px; }
.dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 80; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 4px; max-height: 280px; overflow-y: auto;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13px; width: 100%; border: 0; background: transparent; text-align: left;
}
.dropdown-item:hover, .dropdown-item.is-focus { background: var(--surface-muted); }
.dropdown-item .stack { flex-grow: 1; }
.dropdown-empty { padding: 10px; font-size: 12.5px; color: var(--ink-5); }

/* --- Карточка документа */
.doc-head { display: flex; align-items: flex-start; gap: 14px; }
.doc-head-icon { width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.doc-head-icon.is-in { background: var(--dir-in-soft); color: var(--dir-in); }
.doc-head-icon.is-out { background: var(--dir-out-soft); color: var(--dir-out); }
.doc-head-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.doc-head-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-num { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.doc-head-meta { font-size: 12.5px; color: var(--ink-4); }
.card-wrap { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.card-tabs { padding: 0 22px; flex-shrink: 0; }
.panes { flex-grow: 1; min-height: 0; display: flex; }
.pane { display: none; flex-grow: 1; min-height: 0; min-width: 0; }
.pane.is-active { display: flex; }
.card-form { width: 636px; flex-shrink: 0; padding: 18px 22px; border-right: 1px solid var(--line-softer); display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.card-form .grid3 { grid-template-columns: 88px 104px minmax(0, 1fr); }
.pane-full { flex-grow: 1; padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }

.exec { border: 1px solid #e6e9ed; border-radius: 11px; padding: 14px; background: #fcfcfd; display: flex; flex-direction: column; gap: 12px; }
.exec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.exec-title { font-size: 13.5px; font-weight: 600; }
.exec-row { display: flex; align-items: center; gap: 12px; }
.exec-person { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.exec-name { font-size: 13px; font-weight: 500; }
.exec-note { font-size: 11.5px; color: var(--ink-5); }
.exec-due { display: flex; flex-direction: column; gap: 2px; align-items: flex-end; flex-shrink: 0; }
.exec-due-label { font-size: 11.5px; color: var(--ink-5); }
.exec-due-value { font-size: 13px; font-weight: 600; }
.exec-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.links { display: flex; flex-direction: column; gap: 7px; }
.link-item { border: 1px solid #e6e9ed; border-radius: var(--r-md); padding: 9px 11px; display: flex; align-items: center; gap: 10px; }
.link-num { font-size: 12.5px; font-weight: 600; flex-shrink: 0; }
.link-note { font-size: 12.5px; color: var(--ink-3); flex-grow: 1; }
.link-open { font-size: 12px; font-weight: 500; flex-shrink: 0; }

/* Просмотр скана */
.viewer { flex-grow: 1; min-width: 0; background: #f5f6f8; display: flex; flex-direction: column; }
.viewer-bar {
  height: 46px; border-bottom: 1px solid #e6e9ed; background: var(--surface); padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
}
.viewer-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.viewer-file { font-size: 12.5px; font-weight: 600; }
.viewer-pages { font-size: 12px; color: var(--ink-5); white-space: nowrap; }
.viewer-tools { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.zoom { font-size: 12px; font-weight: 500; min-width: 38px; text-align: center; }
.viewer-stage { flex-grow: 1; min-height: 360px; position: relative; overflow: auto; display: flex; align-items: flex-start; justify-content: center; padding: 18px; }
.viewer-stage.is-frame { padding: 0; overflow: hidden; }
.viewer-stage iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; position: absolute; inset: 0; }
.viewer-stage img { max-width: none; box-shadow: var(--shadow-card); border: 1px solid #dfe3e8; background: #fff; transform-origin: center center; transition: transform 0.15s; }
.viewer-empty {
  margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  font-size: 13px; color: var(--ink-4); max-width: 320px;
}
.viewer-empty .drop-icon { width: 52px; height: 52px; }
.viewer.is-over .viewer-stage { background: var(--dir-in-soft); outline: 2px dashed var(--dir-in); outline-offset: -10px; }
.thumbs {
  min-height: 84px; border-top: 1px solid #e6e9ed; background: var(--surface); padding: 12px 16px;
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; overflow-x: auto;
}
.thumb {
  width: 58px; height: 60px; background: var(--surface); border: 1px solid #dfe3e8; border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px;
  font-size: 9.5px; font-weight: 700; color: var(--ink-5); cursor: pointer; flex-shrink: 0; overflow: hidden;
}
.thumb span:last-child { font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.thumb.is-active { border: 2px solid var(--accent); color: var(--accent); }
.thumb-side { display: flex; flex-direction: column; gap: 6px; }
.thumb-note { font-size: 12px; color: var(--ink-4); }

/* История */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-row); }
.tl-item:last-child { border-bottom: 0; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex-shrink: 0; }
.tl-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-meta { font-size: 11.5px; color: var(--ink-5); }
.tl-changes { margin: 4px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--ink-3); }
.tl-changes b { font-weight: 600; color: var(--ink-2); }
.tl-changes s { color: var(--ink-5); }

/* Меню «ещё» */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 90; min-width: 220px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 4px;
}
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: 0; background: transparent;
  border-radius: var(--r-sm); font-size: 13px; cursor: pointer; color: var(--ink); text-align: left;
}
.menu-item:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.menu-item.is-danger { color: var(--st-late); }

/* ============================================================ Уведомления */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: var(--accent); color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-pop);
  font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px; max-width: 420px; animation: toast-in 0.18s ease-out;
}
.toast.is-error { background: var(--st-late); }
.toast .ic { color: var(--brand); }
.toast.is-error .ic { color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ============================================================ Настройки */
.settings { padding: 20px var(--gutter) 28px; display: flex; gap: 20px; align-items: flex-start; }
.list-card { width: 316px; flex-shrink: 0; overflow: hidden; }
.list-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line-softer); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-title { font-size: 14px; font-weight: 600; }
.list-search { padding: 12px 12px 6px; }
.list { padding: 6px 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: var(--ink); }
.list-row:hover { background: var(--surface-muted); color: var(--ink); text-decoration: none; }
.list-row.is-active { background: color-mix(in srgb, var(--brand) 14%, #ffffff); }
.list-row-text { display: flex; flex-direction: column; gap: 2px; flex-grow: 1; min-width: 0; }
.list-row-name { font-size: 13px; font-weight: 500; }
.list-row.is-active .list-row-name { font-weight: 600; }
.list-row-meta { font-size: 11.5px; color: var(--ink-5); }
.list-row-count { font-size: 11.5px; font-weight: 500; color: var(--ink-5); flex-shrink: 0; }
.list-row.is-inactive .list-row-name { color: var(--ink-5); }
.list-foot { border-top: 1px solid var(--line-softer); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.list-foot-title { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.detail { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.block { display: flex; flex-direction: column; gap: 14px; }
.template-row { display: flex; gap: 16px; flex-wrap: wrap; }
.grow { flex-grow: 1; flex-basis: 220px; }
.prefix-field { width: 152px; flex-shrink: 0; }
.stbl { border: 1px solid var(--line-softer); border-radius: 10px; overflow: hidden; }
.stbl-head, .stbl-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px 190px 160px; align-items: center; padding: 0 14px; gap: 0; }
.stbl-head { height: 36px; background: var(--surface-head); border-bottom: 1px solid var(--line-softer); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-5); }
.stbl-row { min-height: 48px; border-bottom: 1px solid #f3f4f7; padding-top: 6px; padding-bottom: 6px; }
.stbl-row:last-child { border-bottom: 0; }
a.stbl-row { color: inherit; }
a.stbl-row:hover { background: var(--surface-muted); text-decoration: none; }
.stbl-name { font-size: 13.5px; font-weight: 500; }
.stbl-value { font-size: 13.5px; font-weight: 600; }
.stbl-text { font-size: 13px; color: var(--ink-3); padding-right: 12px; }
.stbl-action { text-align: right; display: flex; justify-content: flex-end; gap: 6px; align-items: center; }
.roles-grid { grid-template-columns: 220px minmax(0, 1fr) 180px 130px; }
.users-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 170px 130px 90px; }
.dict-grid { grid-template-columns: 110px minmax(0, 1fr) minmax(0, 0.8fr) 90px 150px; }
.corr-grid { grid-template-columns: minmax(0, 1fr) 130px 90px 110px 110px; }
.access-grid { grid-template-columns: minmax(0, 1fr) 120px 120px 150px; }
.choice-row { display: flex; gap: 14px; flex-wrap: wrap; }
.choice {
  flex-grow: 1; flex-basis: 260px; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.choice.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--brand) 10%, #ffffff); }
.choice-text { display: flex; flex-direction: column; gap: 2px; }
.choice-title { font-size: 13px; font-weight: 500; }
.choice.is-active .choice-title { font-weight: 600; }
.choice-hint { font-size: 12px; color: var(--ink-4); }
.scope-chip-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scope-chip { background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-weight: 500; cursor: pointer; }
.scope-chip.is-active { border-color: var(--accent); background: color-mix(in srgb, var(--brand) 12%, #ffffff); font-weight: 600; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.counter-edit { display: flex; gap: 6px; align-items: center; }
.counter-edit .input { height: 28px; width: 90px; padding: 0 8px; font-size: 13px; }
.history-list { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 9px; align-items: flex-start; }
.alert-error { background: var(--st-late-soft); color: var(--st-late); border: 1px solid var(--st-late-line); }
.alert-info { background: var(--accent-softer); color: var(--ink-2); border: 1px solid color-mix(in srgb, var(--brand) 25%, #fff); }
.page-wrap { padding: 20px var(--gutter) 28px; display: flex; flex-direction: column; gap: 16px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 14px; background: var(--surface-muted); border-bottom: 1px solid var(--line-softer); }
.inline-form .field { flex: 1 1 160px; }
.inline-form .field.is-narrow { flex: 0 0 110px; }
.muted-row { opacity: 0.55; }
.color-input { width: 46px; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; cursor: pointer; }

/* ============================================================ Вход */
.login { min-height: 100vh; display: flex; background: var(--surface); }
.brand-pane {
  position: relative; flex: 1.15 1 0; min-width: 0; background: var(--brand-dark); padding: 52px 64px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px; overflow: hidden;
}
.brand-grid {
  position: absolute; inset: 0; opacity: 0.5;
  background-image: linear-gradient(to right, rgba(236, 167, 0, 0.07) 1px, transparent 1px), linear-gradient(to bottom, rgba(236, 167, 0, 0.07) 1px, transparent 1px);
  background-size: 48px 48px;
}
.brand-glow { position: absolute; left: -120px; bottom: -160px; width: 520px; height: 520px; border-radius: 50%; background: rgba(236, 167, 0, 0.1); filter: blur(60px); }
.brand-top { position: relative; display: flex; flex-direction: column; gap: 38px; }
.pitch { display: flex; flex-direction: column; gap: 18px; max-width: 540px; }
.pitch-title { font-family: var(--font-display); font-size: 40px; line-height: 1.16; font-weight: 600; color: #fff; letter-spacing: -0.015em; text-wrap: pretty; }
.accent-word { color: var(--brand); }
.pitch-text { font-size: 16px; line-height: 1.55; color: #a9adb6; text-wrap: pretty; }
.bullets { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 14px; max-width: 480px; }
.bullet { display: flex; align-items: flex-start; gap: 12px; font-size: 14.5px; line-height: 1.5; color: #c8ccd3; }
.bullet-icon { width: 22px; height: 22px; border-radius: 50%; background: rgba(236, 167, 0, 0.16); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.deco-cards { position: relative; display: flex; align-items: flex-end; gap: 22px; }
.deco-card { border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 9px; }
.deco-one { width: 196px; height: 148px; background: #1e2024; border: 1px solid #2c2f35; transform: rotate(-3deg); }
.deco-two { width: 196px; height: 172px; background: #23262b; border: 1px solid #383c43; transform: rotate(2deg); }
.deco-head { display: flex; align-items: center; gap: 8px; }
.deco-icon { width: 22px; height: 22px; border-radius: var(--r-xs); display: flex; align-items: center; justify-content: center; }
.deco-icon.is-in { background: rgba(28, 167, 145, 0.18); color: #3fc3a8; }
.deco-icon.is-out { background: rgba(236, 167, 0, 0.18); color: var(--brand); }
.deco-num { font-size: 11px; font-weight: 600; color: #9aa0aa; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.deco-line, .deco-line-dim { height: 8px; border-radius: 4px; display: block; }
.deco-line { background: #383c43; }
.deco-line-dim { background: #2c2f35; }
.deco-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 11px; color: #9aa0aa; }
.deco-foot-dot { width: 7px; height: 7px; border-radius: 50%; background: #3fc3a8; }
.deco-drop {
  width: 148px; height: 120px; border-radius: var(--r-lg); background: #1b1d21; border: 1px dashed #464a52; color: #8b9099;
  font-size: 11.5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; transform: rotate(-1.5deg); text-align: center;
}
.login-pane { flex: 1 1 0; max-width: 648px; padding: 44px 88px; display: flex; flex-direction: column; justify-content: center; gap: 32px; }
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-logo-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.login-logo-name { font-size: 14.5px; font-weight: 600; }
.login-logo-sub { font-size: 12px; color: var(--ink-5); }
.login-form { display: flex; flex-direction: column; gap: 22px; }
.login-head { display: flex; flex-direction: column; gap: 7px; }
.login-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.login-sub { font-size: 14px; color: var(--ink-4); }
.pass-row { display: flex; align-items: baseline; justify-content: space-between; }
.small-link { font-size: 12.5px; font-weight: 500; }
.pass-input { padding-right: 46px; }
.pass-input[type='password'] { letter-spacing: 0.18em; }
.eye-btn {
  position: absolute; right: 6px; top: 6px; width: 34px; height: 34px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-4); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.remember { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-3); cursor: pointer; }
.login-submit { height: 48px; border-radius: 10px; font-size: 15px; }
.login-note { font-size: 12.5px; line-height: 1.6; color: var(--ink-4); }
.login-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink-5); }
.login-footer-links { display: flex; align-items: center; gap: 8px; }
.login-footer-links a { color: var(--ink-4); }
.login-footer-links a:hover { color: var(--ink); }
.footer-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-6); }

/* Страница ошибки */
.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.error-card { max-width: 520px; width: 100%; padding: 32px; display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.error-code { font-family: var(--font-display); font-size: 44px; font-weight: 700; color: var(--brand); line-height: 1; }
.error-trace { font-size: 11px; white-space: pre-wrap; background: #f7f8fa; padding: 10px; border-radius: 8px; max-height: 300px; overflow: auto; width: 100%; }

/* ============================================================ Адаптив */
@media (max-width: 1280px) {
  .card-form { width: 520px; }
  .topbar-search { width: 220px; }
}
@media (max-width: 1100px) {
  .brand-pane { display: none; }
  .login-pane { max-width: none; padding: 40px 24px; margin: 0 auto; width: 100%; max-width: 560px; }
  .files-pane { width: 340px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .settings { flex-direction: column; }
  .list-card { width: 100%; }
  .tiles { flex-wrap: wrap; }
  .tile { flex-basis: calc(33% - 12px); }
  .tbl-head { display: none; }
  .tbl-row {
    display: flex !important; flex-wrap: wrap; gap: 6px 12px; padding: 12px 14px; min-height: 0;
  }
  .tbl-cell { padding-right: 0; }
  .tbl-cell.c-subject { order: -1; flex-basis: 100%; }
  .tbl-cell.c-files, .tbl-cell.c-case { display: none; }
  .tbl-cell.c-status { margin-left: auto; }
}
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow-modal);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: var(--backdrop); z-index: 35; }
  .scope-pop { left: 8px; right: 8px; top: 60px; width: auto; }
  .burger { display: inline-flex; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar-right { flex-wrap: wrap; width: 100%; }
  .topbar-search { flex-grow: 1; width: auto; }
  .topbar-title { font-size: 19px; white-space: normal; }
  .topbar-chip { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: flex-start; }
  .tile { flex-basis: calc(50% - 12px); }
  .modal-backdrop { padding: 0; }
  .modal { border-radius: 0; height: 100%; max-width: none !important; }
  .modal-body, .panes, .pane.is-active { flex-direction: column; }
  .files-pane, .card-form { width: 100%; border-right: 0; border-bottom: 1px solid var(--line-softer); overflow: visible; }
  .viewer-stage { min-height: 420px; }
  .modal-head { flex-wrap: wrap; }
  .grid3, .card-form .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :last-child { grid-column: 1 / -1; }
  .grid2b { grid-template-columns: minmax(0, 1fr) 140px; }
  .company-info { width: 100%; }
  .stbl { overflow-x: auto; }
  .stbl-head, .stbl-row { min-width: 640px; }
  .detail { min-width: 0; width: 100%; }
  .btn-label-long { display: none; }
}
@media (max-width: 560px) {
  .tile { flex-basis: 100%; }
  .grid2i { grid-template-columns: 1fr; }
  .foot-btns { width: 100%; }
  .foot-btns .btn { flex-grow: 1; }
}

/* ============================================================ Печать */
@media print {
  body { background: #fff; }
}
.icon-btn.is-disabled, .icon-btn:disabled { opacity: 0.4; pointer-events: none; }
body.is-loading { cursor: progress; }

/* Карточка: прокручиваются только форма и просмотрщик, не всё окно */
.modal-body.is-fixed { overflow: hidden; }
.modal-body.is-fixed .card-wrap, .modal-body.is-fixed .panes, .modal-body.is-fixed .pane { min-height: 0; }
.modal-body.is-fixed .viewer-stage { min-height: 0; }
@media (max-width: 900px) {
  .modal-body.is-fixed { overflow: auto; }
  .modal-body.is-fixed .viewer-stage { min-height: 420px; }
}
.date-range input { width: 112px; }
.topbar-titles { overflow: hidden; }
.topbar-title { overflow: hidden; text-overflow: ellipsis; }
.topbar-chip { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1280px) { .topbar-chip { display: none; } }
/* Поиск связей стоит внизу формы — список открываем вверх, чтобы он не уходил под край */
[data-links] .dropdown { top: auto; bottom: calc(100% + 4px); }
.tabs { overflow-y: hidden; }
/* Меню прокручивается — окно области выносим из его потока, иначе обрезается */
.scope-pop { position: fixed; left: calc(var(--sidebar-w) - 24px); top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; }
.sidebar { overflow-x: hidden; }
@media (max-width: 900px) { .scope-pop { left: 8px; right: 8px; top: 60px; } }
@media (max-width: 900px) {
  .sidebar { box-shadow: none; }
  body.sidebar-open .sidebar { box-shadow: var(--shadow-modal); }
  .toolbar-sep { display: none; }
  .toolbar-left { gap: 8px; }
}
@media (max-width: 560px) {
  .tiles { gap: 8px; }
  .tile { flex-basis: calc(50% - 4px); padding: 10px 12px; }
  .tile-value { font-size: 21px; }
  .tile-hint { display: none; }
  .date-range { width: 100%; }
  .date-range input { flex: 1 1 0; width: auto; min-width: 0; }
}
