/* Shared look for every page. Dark workspace: a deep ink sidebar, slightly raised surfaces,
   hairline borders and one lapis accent. Onest everywhere (Cyrillic + Latin), tabular figures.
   Variable names are kept from the first theme so every page picks up the new look. */
@import url("https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #0d1016;           /* page */
  --side: #0a0c11;         /* sidebar, top bar */
  --paper: #141821;        /* raised surfaces: sections, cards, dialogs */
  --plaster: #1a1f29;      /* wells: inputs, hovers, bubbles */
  --hover: #1f2530;
  --ink: #e6e9f0;
  --muted: #969eae;
  --faint: #646c7c;
  --line: #232936;
  --line-strong: #303747;
  --indigo: #7d8bff;       /* lapis: the one accent */
  --indigo-ink: #0a0c14;
  --glaze: #7d8bff;
  --glaze-soft: #1d2343;
  --ochre: #e8ab52;  --ochre-soft: #2e2412;
  --ok: #5ccf91;     --ok-soft: #132a1f;
  --bad: #f2847f;    --bad-soft: #351b1d;
  --focus: #9aa5ff;
  --mark: linear-gradient(140deg, #a3adff 0%, #6c7bff 45%, #3f4fd6 100%);
  --shadow-pop: 0 0 0 1px rgb(255 255 255 / 3%), 0 20px 50px rgb(0 0 0 / 55%);
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: var(--font);
  --tile: none;
  --r: 8px;
  --r-lg: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14.5px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--glaze-soft); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.topbar, .scrim { display: none; }

.sidebar { position: relative; z-index: 5; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px 12px; }
.wordmark { display: flex; align-items: center; gap: 10px; font: 600 15px/1.2 var(--font); letter-spacing: -.015em; color: var(--ink); text-decoration: none; padding: 4px 8px 18px; }
.wordmark::before { content: ""; flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--mark); box-shadow: inset 0 1px 0 rgb(255 255 255 / 35%), inset 0 -7px 0 rgb(0 0 0 / 22%), 0 4px 14px rgb(108 123 255 / 30%); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { padding: 16px 10px 6px; font-size: 11.5px; font-weight: 500; color: var(--faint); letter-spacing: .01em; }
.nav-group:first-child { padding-top: 2px; }
.side-nav a { position: relative; display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: var(--r); color: var(--muted); text-decoration: none; font-weight: 500; font-size: 13.5px; white-space: nowrap; transition: background .14s, color .14s; }
.side-nav a svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: color .14s; }
.side-nav a:hover { color: var(--ink); background: var(--hover); }
.side-nav a[aria-current="page"] { color: var(--ink); background: linear-gradient(90deg, rgb(125 139 255 / 16%), rgb(125 139 255 / 4%)); }
.side-nav a[aria-current="page"] svg { color: var(--indigo); }
.side-nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--indigo); box-shadow: 0 0 12px var(--indigo); }
.side-nav .badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--indigo); color: var(--indigo-ink); font: 600 11px/18px var(--font); text-align: center; }

.side-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.side-actions { display: flex; flex-direction: column; gap: 6px; }
.tbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); border-radius: var(--r); padding: 7px 12px; font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .14s, border-color .14s; }
.tbtn:hover { background: var(--hover); border-color: var(--line-strong); }
.tbtn.primary { background: var(--indigo); border-color: var(--indigo); color: var(--indigo-ink); font-weight: 600; }
.tbtn.primary:hover { filter: brightness(1.08); background: var(--indigo); }

/* User card: avatar, name and role, language and sign-out */
.who-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--paper); }
.avatar { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--mark); color: #fff; font: 600 12.5px/1 var(--font); letter-spacing: .02em; text-shadow: 0 1px 1px rgb(0 0 0 / 25%); }
.who { flex: 1; min-width: 0; line-height: 1.3; }
.who b { display: block; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r); background: transparent; color: var(--muted); font: 600 11.5px/1 var(--font); transition: background .14s, color .14s; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.logout:hover { color: var(--bad); }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.main.scroll { overflow-y: auto; display: block; }

/* Phones: a slim top bar, the sidebar slides in as a drawer */
@media (max-width: 760px) {
  .shell { display: flex; flex-direction: column; }
  .topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--side); border-bottom: 1px solid var(--line); }
  .topbar .wordmark { margin-right: auto; padding: 0; font-size: 14.5px; }
  .topbar .wordmark::before { width: 22px; height: 22px; border-radius: 7px; }
  .topbar .icon-btn { width: 36px; height: 36px; color: var(--ink); }
  .topbar .icon-btn svg { width: 20px; height: 20px; }
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(292px, 86vw); padding-top: max(16px, env(safe-area-inset-top)); transform: translateX(-102%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); box-shadow: 20px 0 50px rgb(0 0 0 / 50%); }
  .nav-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(3 5 9 / 62%); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { flex: 1; }
}

/* ---------- Controls ---------- */
.btn { background: var(--indigo); color: var(--indigo-ink); border: 1px solid transparent; border-radius: var(--r); padding: 8px 16px; font-weight: 600; box-shadow: 0 4px 14px rgb(108 123 255 / 22%); transition: filter .14s; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; filter: none; box-shadow: none; }
.btn-ghost { background: var(--paper); border: 1px solid var(--line); color: var(--ink); border-radius: var(--r); padding: 8px 14px; font-weight: 500; }
.btn-ghost:hover { background: var(--hover); border-color: var(--line-strong); }
.field { width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--plaster); transition: border-color .14s, box-shadow .14s; }
.field::placeholder { color: var(--faint); }
.field:focus { border-color: var(--glaze); outline: none; box-shadow: 0 0 0 3px var(--glaze-soft); }
.pill { background: var(--paper); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 5px 12px; font-size: 13px; white-space: nowrap; }
.pill:hover { border-color: var(--line-strong); background: var(--hover); }
.pill.sel { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---------- Content pages ---------- */
.page { max-width: 1160px; margin: 0 auto; padding: 28px 24px 48px; }
.head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.head h1 { font: 600 22px/1.25 var(--font); letter-spacing: -.02em; margin: 0; }
.head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; max-width: 75ch; }
.section { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; margin-top: 16px; }
.section h2 { font: 600 14.5px/1.3 var(--font); letter-spacing: -.005em; margin: 0; }
.sec-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.sec-head .meta { color: var(--muted); font-size: 12.5px; }
.note { background: var(--ochre-soft); color: var(--ochre); border: 1px solid rgb(232 171 82 / 18%); border-radius: var(--r); padding: 10px 14px; font-size: 13.5px; margin-top: 16px; }
.err { color: var(--bad); padding: 16px 0; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 0 10px 8px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.tbl tr:first-child td { border-top: 0; }
.tbl tbody tr:hover td { background: var(--plaster); }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl th.num { text-align: right; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 6px; white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--ochre-soft); color: var(--ochre); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.none { background: var(--plaster); color: var(--muted); }
.tag.none::before { background: var(--faint); }
.tag.new { background: var(--glaze-soft); color: var(--glaze); }
.inp { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--plaster); min-width: 0; font-variant-numeric: tabular-nums; }
.inp:hover { border-color: var(--line-strong); }
.inp:focus { outline: none; border-color: var(--glaze); box-shadow: 0 0 0 3px var(--glaze-soft); }
.monthsw { display: flex; align-items: center; gap: 2px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 2px; }
.monthsw b { min-width: 132px; text-align: center; font-weight: 600; font-size: 13.5px; }
.monthsw button { border: 0; background: transparent; border-radius: 6px; width: 30px; height: 28px; font-size: 16px; color: var(--muted); }
.monthsw button:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.monthsw button:disabled { opacity: .3; cursor: default; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); }
.seg button { background: transparent; border: 0; border-radius: 6px; padding: 4px 10px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg button:hover { color: var(--ink); }
.seg button.sel { background: var(--hover); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }

/* Scores: one consistent number badge across the site */
.score { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r); font: 600 14.5px/1 var(--font); font-variant-numeric: tabular-nums; flex: none; }
.score.ok { background: var(--ok-soft); color: var(--ok); }
.score.warn { background: var(--ochre-soft); color: var(--ochre); }
.score.bad { background: var(--bad-soft); color: var(--bad); }
.score.na { background: var(--plaster); color: var(--muted); border: 1px dashed var(--line-strong); }
