/* Визуальная система: спецификация дашборда, раздел 2.1 */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+20BD, U+2212; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+20BD, U+2212; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url(/static/fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+20BD, U+2212; }

:root {
  --ink: #1E2433; --fog: #EEF1F4; --sheet: #FFFFFF; --line: #D5DAE1; --muted: #5B6475;
  --cobalt: #2B4C9B; --cobalt-soft: #E4EAF6; --amber: #D98E04; --plus: #1F7A4D; --minus: #B3261E;
  --radius-s: 4px; --radius-m: 8px; --gap: 16px; --tabbar: 0px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 "IBM Plex Sans", system-ui, sans-serif; background: var(--fog); color: var(--ink);
       font-variant-numeric: tabular-nums; padding-bottom: var(--tabbar); }
a { color: var(--cobalt); }
:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 600; margin: 20px 0 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
small, .muted { color: var(--muted); font-size: 13px; }

header.top { display: flex; gap: var(--gap); align-items: center; padding: 8px 24px; background: var(--sheet); border-bottom: 1px solid var(--line); }
header.top .brand { font-weight: 600; white-space: nowrap; }
header.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
header.top nav a { padding: 8px 12px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; white-space: nowrap; }
header.top nav a.active { background: var(--cobalt-soft); color: var(--cobalt); font-weight: 500; }
header.top nav a:hover { color: var(--cobalt); }
header.top .me { white-space: nowrap; color: var(--muted); }
main { padding: 20px 24px 32px; max-width: 1440px; margin: 0 auto; }

button, select, input { font: inherit; color: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--sheet); }
button { cursor: pointer; } button:hover { border-color: var(--cobalt); }
button[aria-pressed="true"] { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
button.primary { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.link-button { border: 0; background: none; color: var(--cobalt); padding: 4px 0; text-decoration: underline; text-underline-offset: 2px; }
.period .chips, .segmented { display: inline-flex; gap: 0; }
.period .chips button, .segmented button { border-radius: 0; margin-left: -1px; }
.period .chips button:first-child, .segmented button:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); margin-left: 0; }
.period .chips button:last-child, .segmented button:last-child { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; } .card-head .link-button { margin-left: auto; }
.chip-row { display: flex; gap: 12px; align-items: baseline; margin-bottom: 12px; }
ul.list li .reason { display: block; color: var(--muted); font-size: 13px; }
tr.key-row td { font-weight: 600; background: var(--cobalt-soft); }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 8px 0 12px; }
.facts > div { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; display: flex; flex-direction: column; }
.fact { font-size: 20px; font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.links a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; }
.links a:hover { border-color: var(--cobalt); }
h4 { font-size: 15px; font-weight: 600; margin: 12px 0 6px; }
.description { white-space: pre-wrap; max-height: 40vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px; margin-top: 8px; }
.chart.small { height: 220px; }
.toolbar { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period .chips { display: flex; gap: 6px; overflow-x: auto; }
.period details.dates summary { cursor: pointer; color: var(--cobalt); padding: 6px 4px; }
.period details.dates[open] { display: flex; gap: 6px; align-items: center; }

.headline { font-size: 32px; line-height: 1.25; font-weight: 500; max-width: 36ch; min-height: 2.5em; margin: 4px 0 24px; text-wrap: balance; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 24px; }
.tile { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px;
        display: flex; flex-direction: column; gap: 2px; min-height: 118px; min-width: 0; }
.tile .label, .tile-label { color: var(--muted); font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .value, .tile-value { font-size: 26px; font-weight: 600; line-height: 1.2; margin: 4px 0 2px; white-space: nowrap; }
.tile-delta { font-size: 13px; font-weight: 500; line-height: 1.3; }
.tile-usual { font-size: 13px; line-height: 1.3; color: var(--muted); margin-top: auto; }
.tile.is-loading .tile-label, .tile.is-loading .tile-value, .tile.is-loading .tile-delta { background: var(--fog); border-radius: 3px; color: transparent; }
.tile.is-loading .tile-label { width: 60%; } .tile.is-loading .tile-value { width: 75%; } .tile.is-loading .tile-delta { width: 45%; }
.good { color: var(--plus); } .bad { color: var(--minus); } .error { color: var(--minus); } .warn { color: #8A5A00; }
section.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 16px; }
section.card > h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.list li:last-child { border-bottom: 0; }
table.plain { border-collapse: collapse; width: 100%; }
table.plain td, table.plain th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
table.plain td:first-child, table.plain th:first-child { text-align: left; }
table.plain th { font-weight: 500; color: var(--muted); font-size: 13px; }
.chart { position: relative; height: 300px; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 8px; margin-bottom: 16px; }
.tabulator { border: 1px solid var(--line); border-radius: var(--radius-m); font-size: 14px; background: var(--sheet); }
.tabulator .tabulator-header { background: var(--sheet); border-bottom: 1px solid var(--line); }
.tabulator .tabulator-header .tabulator-col { background: var(--sheet); }
.tabulator-row.tabulator-row-even { background: #F7F8FA; }
.tabulator-row:hover { background: var(--cobalt-soft) !important; cursor: pointer; }
.tabulator-row.drr-bad, .swatch.drr-bad { background: #FBE4E1; }
.tabulator-row.drr-good, .swatch.drr-good { background: #E3F2E8; }
.swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.modal { position: fixed; inset: 0; background: rgba(30, 36, 51, .35); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal .dialog { background: var(--sheet); padding: 16px 20px 20px; border-radius: var(--radius-m); max-height: 88vh; overflow: auto;
                 width: min(520px, 94vw); box-shadow: 0 12px 32px rgba(30, 36, 51, .18); }
.modal .dialog.wide { width: min(820px, 96vw); }
.dialog-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.dialog-head h3 { margin: 0; font-size: 18px; flex: 1; }
.dialog-head .close { border: 0; background: none; font-size: 24px; line-height: 1; padding: 4px 8px; color: var(--muted); }
.dialog-head .close:hover { color: var(--ink); }
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--sheet); padding: 24px; border: 1px solid var(--line); border-radius: var(--radius-m); display: flex; flex-direction: column; gap: 12px; width: min(340px, 92vw); }
.login-box label { display: flex; flex-direction: column; gap: 4px; }
form.inline { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
textarea { width: 100%; min-height: 160px; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-s); }
nav.tabbar { display: none; }
.tabulator { max-width: 100%; }
section.card, .scroll-x { overflow-x: auto; }
table.plain td:not(:first-child), table.plain th:not(:first-child) { white-space: nowrap; }

@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  :root { --tabbar: 64px; }
  body { font-size: 15px; }
  header.top { padding: 8px 16px; } header.top nav, header.top .me button { display: none; }
  main { padding: 12px 16px 24px; }
  h1 { font-size: 20px; }
  .headline { font-size: 20px; max-width: none; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { min-height: 104px; padding: 12px; }
  .tile .value, .tile-value { font-size: 20px; }
  .headline { min-height: 3.75em; }
  .facts { grid-template-columns: 1fr 1fr; }
  .modal { align-items: flex-end; }
  .modal .dialog, .modal .dialog.wide { width: 100vw; max-height: 88vh; border-radius: var(--radius-m) var(--radius-m) 0 0; }
  .chart { height: 220px; }
  #pl td:nth-child(3), #pl th:nth-child(3) { display: none; }
  button, select, input, .period details.dates summary { min-height: 44px; }
  .period .chips { flex-wrap: nowrap; max-width: 100%; }
  nav.tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar); background: var(--sheet);
               border-top: 1px solid var(--line); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  nav.tabbar > a, nav.tabbar summary { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
               color: var(--ink); text-decoration: none; font-size: 13px; padding: 4px; list-style: none; cursor: pointer; }
  nav.tabbar > a[aria-current="page"] { color: var(--cobalt); font-weight: 600; }
  nav.tabbar details.more { flex: 1; display: flex; }
  nav.tabbar details.more > div { position: fixed; bottom: var(--tabbar); left: 0; right: 0; background: var(--sheet);
               border-top: 1px solid var(--line); display: flex; flex-direction: column; padding: 8px 16px; }
  nav.tabbar details.more > div a, nav.tabbar details.more > div button { padding: 12px 0; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
