/* Retix Cloud — кабинет. Цвета — роли (токены), тёмная тема — свои шаги,
   а не автоматическое инвертирование. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: rgba(11, 11, 11, 0.10);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --series-1: #2a78d6;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #006300;
  --critical: #d03b3b;
  --serious: #ec835a;
  --warning: #fab219;
  --row-hover: #f3f2ee;
  --flag-bg: #fdecea;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: rgba(255, 255, 255, 0.10);
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --series-1: #3987e5;
    --accent: #3987e5;
    --good: #0ca30c;
    --row-hover: #222220;
    --flag-bg: #3a1d1c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* каркас */
.layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 2px; }
.brand-sub { color: var(--muted); font-size: 12px; padding: 0 10px 14px; }
.nav a {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2);
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: 16px; padding: 10px; border-top: 1px solid var(--border); font-size: 12px; }
.main { padding: 22px 26px 60px; min-width: 0; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 12px; }
.head .sub { color: var(--text-2); }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 8px 16px; }
  .brand-sub, .side-foot { display: none; }
  .nav { display: flex; gap: 2px; overflow-x: auto; width: 100%; }
  .nav a { white-space: nowrap; }
  .main { padding: 16px; }
}

/* панели */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.card + .card { margin-top: 16px; }
.grid2 > .card + .card { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

/* фильтры — одна строка над содержимым */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 16px; }
.presets { display: flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); border-radius: 9px; padding: 2px; }
.presets a { padding: 5px 10px; border-radius: 7px; color: var(--text-2); font-size: 13px; }
.presets a.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.presets a:hover { text-decoration: none; color: var(--text); }
input, select, button, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px;
}
input[type=checkbox] { width: 16px; height: 16px; padding: 0; vertical-align: middle; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button, .btn {
  cursor: pointer; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; display: inline-block;
}
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.danger { color: var(--critical); }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
.btn:hover { text-decoration: none; }
form.inline { display: inline; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; align-items: end; }

/* показатели */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.tile .k { color: var(--text-2); font-size: 12px; }
.tile .v { font-size: 20px; font-weight: 650; margin-top: 2px; white-space: nowrap; }
.tile .s { color: var(--muted); font-size: 12px; margin-top: 2px; }
a.tile:hover { text-decoration: none; border-color: var(--accent); }

/* таблицы */
.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; background: var(--surface); }
.tbl th, .tbl td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.tbl th { color: var(--text-2); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tfoot td { font-weight: 650; border-top: 2px solid var(--border); }
.tbl .storno td { color: var(--muted); text-decoration: line-through; }
.tbl .storno td.keep { text-decoration: none; }
.tbl td.flag { background: var(--flag-bg); font-weight: 650; }
.tbl .neg { color: var(--critical); font-weight: 650; }

/* метки */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.sev { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.sev i { font-style: normal; font-size: 11px; }
.sev-high i { color: var(--critical); }
.sev-medium i { color: var(--serious); }
.sev-low i { color: var(--warning); }
.msg { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--good); }
.msg.error { border-left-color: var(--critical); }
.token { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; word-break: break-all; user-select: all; }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; }
.pager { display: flex; gap: 6px; margin-top: 10px; align-items: center; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs a { padding: 5px 11px; border-radius: 999px; color: var(--text-2); background: var(--surface-2); font-size: 13px; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); }
.tabs a:hover { text-decoration: none; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.kv dt { color: var(--text-2); }
dl.kv dd { margin: 0; }
details > summary { cursor: pointer; color: var(--accent); margin-top: 8px; }

/* график */
.chart { width: 100%; height: auto; max-height: 260px; display: block; }
.chart .bar { fill: var(--series-1); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--text); fill-opacity: 0.05; }
#tip {
  position: fixed; pointer-events: none; z-index: 10; display: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.12);
  font-variant-numeric: tabular-nums;
}

/* вход */
.login { max-width: 360px; margin: 12vh auto; padding: 0 16px; }
.login .card { padding: 24px; }
.login h1 { margin-bottom: 14px; }
.login form { display: grid; gap: 12px; }
