:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e1e0d9;
  --border: rgba(11, 11, 11, .10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --ok-ink: #006300;
  --err: #d03b3b;
  --warn-bg: #fff4dc;
  --err-bg: #fdecec;
  --ok-bg: #e7f6e7;
  /* статусы: этапы от «не начат» к «передан» */
  --st-planned: #c3c2b7;
  --st-draft: #86b6ef;
  --st-review: #3987e5;
  --st-rework: #ec835a;
  --st-approved: #1c5cab;
  --st-signed: #104281;
  --st-handed: #0ca30c;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --line: #2c2c2a;
    --border: rgba(255, 255, 255, .10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --ok-ink: #0ca30c;
    --warn-bg: #3a2f12;
    --err-bg: #3b1a1a;
    --ok-bg: #12301a;
    --st-planned: #5c5b56;
    --st-draft: #86b6ef;
    --st-review: #3987e5;
    --st-approved: #256abf;
    --st-signed: #184f95;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* шапка */
.top { display: flex; align-items: center; gap: 20px; padding: 0 24px; height: 52px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top .brand { font-weight: 700; color: var(--ink); font-size: 15px; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: var(--ink-2); padding: 6px 10px; border-radius: 6px; }
.top nav a:hover, .top nav a.on { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.top .me { display: flex; gap: 10px; align-items: center; color: var(--ink-2); }
main { max-width: 1440px; margin: 0 auto; padding: 20px 24px 60px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* карточки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.side { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 1000px) { .g2, .g3, .side { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

/* стат-плитки */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .v { font-size: 28px; font-weight: 650; line-height: 1.1; }
.tile .l { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.tile .s { color: var(--muted); font-size: 12px; }
.tile.alert .v { color: var(--err); }

/* полоса статусов */
.sbar { display: flex; gap: 2px; height: 12px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.sbar.big { height: 18px; }
.sbar > span { display: block; min-width: 3px; height: 100%; cursor: default; }
.sbar > span:first-child { border-radius: 4px 0 0 4px; }
.sbar > span:last-child { border-radius: 0 4px 4px 0; }
.sbar > span:only-child { border-radius: 4px; }
.sbar.empty { background: var(--surface-2); }
.st-planned { background: var(--st-planned); } .st-draft { background: var(--st-draft); }
.st-review { background: var(--st-review); } .st-rework { background: var(--st-rework); }
.st-approved { background: var(--st-approved); } .st-signed { background: var(--st-signed); }
.st-handed { background: var(--st-handed); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); }
.pill.red { background: var(--err-bg); color: var(--err); }
.pill.ext { font-weight: 600; letter-spacing: .02em; }

/* проекты на дашборде */
.proj { display: grid; grid-template-columns: 220px minmax(0, 1fr) 90px 90px 90px; gap: 16px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line); }
.proj:first-of-type { border-top: 0; }
@media (max-width: 1200px) {
  .proj { grid-template-columns: minmax(0, 1fr) 70px 70px 70px; }
  .proj > div:nth-child(2) { grid-column: 1 / -1; order: 5; }
  .secs { grid-template-columns: 140px minmax(0, 1fr) 50px 40px; }
}
.proj .t { font-weight: 600; }
.proj .k { text-align: right; }
.proj .k b { display: block; font-size: 18px; font-weight: 650; }
.proj .k span { font-size: 11px; color: var(--muted); }
.secs { display: grid; grid-template-columns: 200px minmax(0, 1fr) 70px 60px; gap: 6px 14px; align-items: center; font-size: 13px; }
.secs .h { color: var(--muted); font-size: 12px; }

/* таблицы */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--ink-2); font-size: 12px; background: var(--surface); }
tbody tr:hover { background: var(--surface-2); }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; }
.doc-title { color: var(--ink); }
.scroll { overflow-x: auto; }

/* формы */
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; min-height: 32px; }
textarea { width: 100%; min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 3px; }
.f { margin-bottom: 10px; }
.f input[type=text], .f input[type=password], .f input[type=date], .f input[type=number], .f select { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .f { flex: 1; min-width: 140px; }
.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 6px 12px; border-radius: 6px; cursor: pointer; min-height: 32px; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.sm { padding: 3px 8px; min-height: 26px; font-size: 12px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; font: inherit; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
details > summary { cursor: pointer; color: var(--accent-ink); }
details[open] > summary { margin-bottom: 10px; }

.flash { padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; background: var(--ok-bg); }
.flash.err { background: var(--err-bg); color: var(--err); }
.flash.warn { background: var(--warn-bg); }

/* ревизии, замечания, журнал */
.rev { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.rev.cur { border-color: var(--accent); }
.rev .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.rev .files { margin: 6px 0 0; padding: 0; list-style: none; }
.rev .files li { display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.remark { border-left: 3px solid var(--st-rework); padding: 6px 10px; margin-bottom: 8px; background: var(--surface-2); border-radius: 0 6px 6px 0; }
.remark.closed { border-left-color: var(--st-handed); opacity: .75; }
.remark .meta { font-size: 12px; color: var(--muted); }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed .when { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; white-space: pre-wrap; }

.bulk { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 0; margin-top: 8px;
  display: none; gap: 8px; align-items: center; flex-wrap: wrap; }
.bulk.on { display: flex; }

#tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--page); padding: 5px 8px; border-radius: 6px;
  font-size: 12px; z-index: 100; display: none; white-space: nowrap; }

.login { max-width: 360px; margin: 12vh auto; }
.copy { font-family: ui-monospace, Consolas, monospace; font-size: 12px; width: 100%; }
