/* Админка UnLock. Светлая деловая тема, акцент — фирменный тёмно-синий UnLock.
   Раскладка: меню слева, справа рабочая область — сводка сверху, подробности ниже. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e4e6ed;
  --line-strong: #d0d4de;
  --text: #1b1d2b;
  --muted: #5e6476;
  --faint: #8a90a1;
  --brand: #23233b;
  --brand-2: #393a5e;
  --brand-soft: #ebebf4;
  --accent: #3b4dc4;
  --accent-soft: #e9ecfb;
  --ok: #1b8553;
  --ok-soft: #e4f3ea;
  --warn: #9a5f08;
  --warn-soft: #fbf0dc;
  --bad: #c03a3a;
  --bad-soft: #fae8e8;
  --chart: #23233b;
  --chart-2: #a3a9d4;
  --chart-fill: rgba(35, 35, 59, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 24px; font-weight: 600; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.strong { color: var(--text); font-weight: 500; }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-ok { color: var(--ok); }
.up { color: var(--ok); font-weight: 500; }
.down { color: var(--bad); font-weight: 500; }
.flat { color: var(--faint); }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* Каркас */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 18px 12px 14px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #f4f4f2; flex: none; }
.brand-mark svg { width: 15px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; font-weight: 600; }
.brand-text small { color: var(--faint); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--brand-soft); color: var(--brand); }
.nav-label { flex: 1; }
.badge { min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 11.5px; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.badge-warn { background: var(--warn); }
.badge-bad { background: var(--bad); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 8px 0; border-top: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; flex: none; }
.me { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { padding: 2px 4px; border: 0; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.link-btn:hover { color: var(--text); text-decoration: underline; }
.main { min-width: 0; max-width: 1360px; padding: 26px 32px 56px; display: flex; flex-direction: column; gap: 20px; }

/* Заголовок страницы */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sub { margin-top: 4px; color: var(--muted); }
.page-head .sub a { color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* Карточки и сетки */
.card { min-width: 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head .muted { font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.group-title { margin: 14px 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.group-title:first-child { margin-top: 0; }
.group-title.bad { color: var(--bad); }
.group-title.ok { color: var(--ok); }

/* Ключевые цифры */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
a.kpi:hover { border-color: var(--line-strong); text-decoration: none; }
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { font-size: 26px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12.5px; }
.kpi-row { display: flex; align-items: center; gap: 12px; }
.kpi-spark { flex: 0 1 96px; min-width: 56px; margin-left: auto; }
.kpi-warn { border-color: #efd9ae; background: #fffaf0; }
.kpi-warn .kpi-value { color: var(--warn); }
.kpi-bad { border-color: #efc5c5; background: #fff6f6; }
.kpi-bad .kpi-value { color: var(--bad); }

/* Сводка дня */
.summary { display: flex; flex-direction: column; gap: 12px; }
.summary-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.summary ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px 28px; }
.summary li { position: relative; padding-left: 16px; }
.summary li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.summary li.tone-ok::before { background: var(--ok); }
.summary li.tone-warn::before { background: var(--warn); }
.summary li.tone-bad::before { background: var(--bad); }

/* Таблицы и списки */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.t { width: 100%; border-collapse: collapse; }
.t th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--faint); font-size: 12px; font-weight: 500; text-align: left; white-space: nowrap; }
.t td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--surface-2); }
.t th:first-child, .t td:first-child { padding-left: 0; }
.t th:last-child, .t td:last-child { padding-right: 0; }
.t .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t .actions { text-align: right; white-space: nowrap; }
.t .actions form { display: inline; }
.t .actions > * + * { margin-left: 10px; }
.t.compact td { padding: 7px 8px; }
.t .contacts { max-width: 220px; color: var(--muted); }
.sub-line { display: block; color: var(--muted); font-size: 12.5px; }
.meter-cell { width: 40%; vertical-align: middle; }
.meter { display: block; height: 6px; min-width: 60px; border-radius: 3px; background: var(--brand-soft); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: 3px; background: var(--chart); }
.rows { margin: 0; padding: 0; list-style: none; }
.rows li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows li > :first-child { flex: 1; min-width: 0; }
.feed { margin: 0; padding: 0; list-style: none; }
.feed li { display: grid; grid-template-columns: 110px 70px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed-time { color: var(--faint); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.feed-who { color: var(--muted); font-weight: 500; }
.funnel { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.funnel li { display: grid; grid-template-columns: minmax(0, 1fr) 40px; gap: 4px 12px; align-items: center; }
.funnel li > span:first-child { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.funnel b { text-align: right; font-weight: 600; }
.dl { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.dl.meta { margin: 16px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; }
.margin { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.margin b { color: var(--text); }
.ok-line { display: flex; align-items: center; gap: 8px; color: var(--ok); }

/* Статусы */
.pill { display: inline-flex; align-items: center; padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill-ok { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.pill-warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.pill-bad { border-color: transparent; background: var(--bad-soft); color: var(--bad); }
.pill-info { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; padding: 0 6px; border-radius: 5px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 500; vertical-align: 1px; }
.tag-dir { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 500; white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); vertical-align: 1px; flex: none; }
.dot-up { background: var(--ok); }
.dot-down { background: var(--bad); }
.state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; }
.state-up { color: var(--ok); }
.state-down { color: var(--bad); font-weight: 500; }

/* Кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 500 14px/1 var(--font); white-space: nowrap; cursor: pointer; }
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn .i { width: 16px; height: 16px; }
.btn-primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.btn-primary:hover { border-color: var(--brand-2); background: var(--brand-2); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-wide { width: 100%; }
.copy { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-size: 12.5px; cursor: pointer; }
.copy .i { width: 13px; height: 13px; }

/* Переключатели */
.seg { display: inline-flex; align-items: stretch; overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.seg > a, .seg > button, .seg > .seg-label { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-right: 1px solid var(--line); background: none; color: var(--muted); font: 500 13px var(--font); white-space: nowrap; cursor: pointer; }
.seg > :last-child { border-right: 0; }
.seg > a:hover, .seg > button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.seg > .is-on, .seg > .is-on:hover { background: var(--brand); color: #fff; }
.seg > .seg-label { min-width: 130px; justify-content: center; color: var(--text); cursor: default; }
.seg .i { width: 16px; height: 16px; }
.seg-sm > button { height: 26px; padding: 0 8px; font-size: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: -4px 0 14px; border-bottom: 1px solid var(--line); }
.tabs a { margin-bottom: -1px; padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.is-on { border-bottom-color: var(--brand); color: var(--brand); }
.tabs .count { margin-left: 6px; color: var(--faint); font-weight: 400; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { flex: 1 1 260px; max-width: 420px; }
.filters select { width: auto; }

/* Задачи */
.task-list { margin: 0; padding: 0; list-style: none; }
.task { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task.prio-high { box-shadow: inset 3px 0 0 var(--bad); padding-left: 12px; }
.task-title { color: var(--text); font-weight: 500; }
.task.is-done .task-title { color: var(--faint); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.task-meta a { color: var(--muted); }
.overdue { color: var(--bad); font-weight: 500; }
.who { padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.comments { margin: 0 0 14px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.comments li { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; font-size: 13px; }
.comments p { white-space: pre-line; }
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* Формы */
.form-page { display: flex; flex-direction: column; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.inline-form .field { flex: 1 1 140px; }
.inline-form .field.grow { flex: 3 1 240px; }
.inline-form .check.full { flex-basis: 100%; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { color: var(--muted); font-size: 13px; font-weight: 500; }
.field small { color: var(--faint); font-size: 12px; }
input, select, textarea { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: 14px var(--font); }
input[type=checkbox] { width: 16px; height: 16px; padding: 0; accent-color: var(--brand); }
textarea { height: auto; min-height: 76px; padding: 8px 10px; line-height: 1.45; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.input-sm { height: 34px; width: auto; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; }
.form-actions { display: flex; align-items: center; gap: 8px; }
.form-error { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); }

/* Сообщения и пустые состояния */
.banner { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: #5f3b05; font-size: 13.5px; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ok-soft); color: #11583a; }
.flash-error { background: var(--bad-soft); color: #8b2626; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 24px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); text-align: center; }
.empty b { color: var(--text); font-weight: 600; }
.empty .btn { margin-top: 10px; }
.empty-big { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.error-card { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 520px; }

/* Графики */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--faint); font-family: var(--font); font-size: 11px; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .area { fill: var(--chart-fill); }
.chart .bar { fill: var(--chart); }
.chart .bar.alt { fill: var(--chart-2); }
.chart .hit { fill: transparent; }
.chart .dot { fill: var(--chart); stroke: var(--surface); stroke-width: 2; opacity: 0; }
.chart .pt:hover .dot { opacity: 1; }
.chart .col:hover .bar { fill: var(--brand-2); }
.chart .col:hover .bar.alt { fill: #8790c4; }
.chart .end { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart-empty { padding: 30px 0; color: var(--muted); text-align: center; }
.spark { display: block; width: 100%; height: auto; overflow: visible; }
.spark .line { fill: none; stroke: var(--chart-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .end { fill: var(--chart); }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; background: var(--chart); vertical-align: -1px; }
.legend i.alt { background: var(--chart-2); }
.tip { position: fixed; z-index: 50; padding: 5px 9px; border-radius: 6px; background: var(--brand); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none; }

/* Вход */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { display: flex; flex-direction: column; gap: 14px; width: min(380px, 100%); padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }

@media (max-width: 1100px) {
  .grid-2, .grid-2.even, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .main { padding: 20px 16px 40px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .feed li { grid-template-columns: 90px minmax(0, 1fr); }
  .feed-who { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
