:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --line: #e3e2de;
  --line-2: #cfcec9;
  --ink: #17181a;
  --ink-2: #52514e;
  --ink-3: #7c7b76;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e8f1fc;
  --seq: #2a78d6;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-soft: #e6f5e6;
  --warning-soft: #fef3da;
  --serious-soft: #fdece5;
  --critical-soft: #fbe7e7;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 8px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.hidden { display: none !important; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #1d2430; color: #d9dde4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { display: block; color: #fff; font-size: 15px; }
.brand span { font-size: 12px; color: #9aa3b2; }
.nav { padding: 8px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: #c7ccd5; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 8px 6px; }
.side-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #9aa3b2; }
.side-foot b { color: #fff; font-weight: 600; display: block; font-size: 13px; }
.side-foot select { width: 100%; margin-top: 6px; background: #2a3342; border: 1px solid #3a4557; color: #fff; border-radius: 6px; padding: 5px 6px; }
.side-foot button { margin-top: 8px; }
.main { min-width: 0; }
.demo-banner { background: #fff7e0; border-bottom: 1px solid #f1dfa6; padding: 7px 24px; font-size: 12.5px; color: #6b5310; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.demo-banner button { font-size: 12px; padding: 2px 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px 6px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.content { padding: 10px 24px 40px; }

/* ---------- фильтры ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--ink-3); gap: 3px; }
.filters select, .filters input { min-width: 150px; max-width: 240px; }
.filters .grow { flex: 1; }
.filters .reset { margin-left: auto; }

input[type=text], input[type=search], input[type=date], input[type=number], input[type=password], select, textarea {
  border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; background: #fff; min-height: 32px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 60px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); background: #fff; padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; min-height: 32px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--critical); border-color: #ebc3c3; }
.btn.danger:hover { background: var(--critical-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { padding: 3px 8px; min-height: 26px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.grid.kpi { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) { .grid.kpi { grid-template-columns: repeat(3, minmax(0,1fr)); } .grid.two { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .app { grid-template-columns: 1fr; } .side { position: static; height: auto; } .grid.kpi { grid-template-columns: 1fr 1fr; } }

.kpi-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: default; position: relative; }
.kpi-tile.click { cursor: pointer; }
.kpi-tile.click:hover { border-color: var(--line-2); background: #fcfcfb; }
.kpi-tile .label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.kpi-tile .value { font-size: 28px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi-tile .note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kpi-tile .stripe { position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; }

/* ---------- статусы ---------- */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 2px 8px 2px 6px; border-radius: 10px; white-space: nowrap; color: var(--ink); }
.st i { width: 14px; height: 14px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-size: 10px; font-weight: 700; color: #fff; flex: none; }
.st.CURRENT { background: var(--good-soft); } .st.CURRENT i { background: var(--good); }
.st.EXPIRING { background: var(--warning-soft); } .st.EXPIRING i { background: var(--warning); color: #4a3500; }
.st.EXPIRED { background: var(--critical-soft); } .st.EXPIRED i { background: var(--critical); }
.st.NOT_COMPLETED { background: var(--serious-soft); } .st.NOT_COMPLETED i { background: var(--serious); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.dot.CURRENT { background: var(--good); } .dot.EXPIRING { background: var(--warning); } .dot.EXPIRED { background: var(--critical); } .dot.NOT_COMPLETED { background: var(--serious); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { border: 1px solid var(--line-2); background: #fff; border-radius: 16px; padding: 4px 12px 4px 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* полоса распределения статусов */
.distbar { display: flex; height: 14px; gap: 2px; border-radius: 4px; overflow: hidden; margin: 6px 0 10px; }
.distbar div { min-width: 2px; cursor: pointer; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.legend b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- таблицы ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border-bottom: 1px solid var(--line); padding: 8px 10px; position: sticky; top: 0; z-index: 1; white-space: nowrap; font-size: 12.5px; }
table.t td { padding: 7px 10px; border-bottom: 1px solid #efeeea; vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f6f9fe; }
table.t td.num, table.t th.num { text-align: right; }
table.t input[type=checkbox] { width: 16px; height: 16px; vertical-align: middle; }
.card table.t th { position: static; }
.mini-bar { display: inline-block; width: 64px; height: 6px; background: #ecebe7; border-radius: 3px; vertical-align: middle; margin-left: 8px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--ink-3); border-radius: 3px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 2px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }

/* матрица */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.mx { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.mx th, table.mx td { border-bottom: 1px solid #efeeea; border-right: 1px solid #f3f2ef; }
table.mx thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; vertical-align: bottom; padding: 6px 2px; }
table.mx thead th.v { height: 150px; width: 34px; min-width: 34px; }
table.mx thead th.v div { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; font-weight: 600; color: var(--ink-2); max-height: 140px; overflow: hidden; text-overflow: ellipsis; margin: 0 auto; }
table.mx td.name, table.mx th.name { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 260px; max-width: 320px; padding: 5px 10px; }
table.mx thead th.name { z-index: 3; background: var(--surface-2); text-align: left; }
table.mx td.c { text-align: center; padding: 3px; }
table.mx td.c span { display: inline-block; width: 22px; height: 18px; border-radius: 4px; line-height: 18px; color: #fff; font-size: 10px; font-weight: 700; }
table.mx td.c span.CURRENT { background: var(--good); }
table.mx td.c span.EXPIRING { background: var(--warning); color: #4a3500; }
table.mx td.c span.EXPIRED { background: var(--critical); }
table.mx td.c span.NOT_COMPLETED { background: var(--serious); }
table.mx td.c.none { background: repeating-linear-gradient(135deg, #fafaf8 0 4px, #f1f0ec 4px 5px); }

/* план */
table.plan td.cell { text-align: center; cursor: pointer; font-variant-numeric: tabular-nums; }
table.plan td.cell:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
table.plan td.zero { color: #c9c8c3; cursor: default; }
table.plan td.zero:hover { outline: 0; }
table.plan th.now, table.plan td.now { background: #fdf1f1; }
table.plan tr.total td { font-weight: 650; background: var(--surface-2); }

/* столбчатая диаграмма */
.bars { position: relative; }
.bars svg { display: block; width: 100%; height: auto; overflow: visible; }
.bars .hit { cursor: pointer; fill: transparent; }
.bars .hit:hover + .bar, .bars g:hover .bar { opacity: .82; }

/* ---------- формы ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12.5px; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--ink-3); }
.field.wide { grid-column: 1 / -1; }
.check { display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.info-box { background: var(--accent-soft); border: 1px solid #c9dcf5; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: #1f3f66; }
.warn-box { background: var(--warning-soft); border: 1px solid #f1dc9f; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: #5c4500; }
.err-box { background: var(--critical-soft); border: 1px solid #efc4c4; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; color: #7a1f1f; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* модальное окно */
.modal-back { position: fixed; inset: 0; background: rgba(20,22,26,.38); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: min(680px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }

.toast-box { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #1d2430; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 420px; font-size: 13px; }
.toast.err { background: #8f2424; }

.tip { position: fixed; pointer-events: none; background: #1d2430; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 6px; z-index: 70; max-width: 320px; box-shadow: 0 4px 14px rgba(0,0,0,.2); white-space: pre-line; }

.empty { padding: 30px; text-align: center; color: var(--ink-3); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 360px; }
.spinner { padding: 40px; text-align: center; color: var(--ink-3); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 10px; background: #efeeea; font-size: 11.5px; color: var(--ink-2); }
.pill.blue { background: var(--accent-soft); color: var(--accent-ink); }
.sel-bar { position: sticky; bottom: 0; background: #1d2430; color: #fff; padding: 10px 14px; border-radius: 8px; display: flex; gap: 12px; align-items: center; margin-top: 10px; z-index: 5; flex-wrap: wrap; }
.sel-bar .btn { color: var(--ink); }
@media print { .side, .demo-banner, .filters, .btn { display: none !important; } .app { display: block; } }
