/* SLA-трекер PAIrasat. Светлая тема, один акцент, сетка 8 px, радиус не больше 4 px,
   без теней и градиентов. Шрифты IBM Plex подключены локально (лицензия OFL). */

/* --- шрифты ------------------------------------------------------------------------ */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* --- переменные -------------------------------------------------------------------- */
:root {
  --bg: #f4f5f6;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #5a626b;
  --border: #d5d8dc;
  --border-soft: #e6e8eb;
  --accent: #1f3a5f;
  --accent-text: #ffffff;

  --ok: #2f6f4f;
  --warn: #8a5f0c;
  --bad: #a33a32;
  --nodata: #6b727b;

  --fill-up: #4f8f6b;
  --fill-down: #b44d44;
  --fill-nodata: #b9bec5;
  --shade-down: #f2d9d6;
  --shade-nodata: #e8eaed;
  --line-0: #1f3a5f;
  --line-1: #7a5c1e;
  --line-2: #4a6b85;

  --err-bg: #f6e3e1;
  --err-text: #7a2a22;
  --radius: 4px;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }

.container { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; }

/* --- шапка ------------------------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 16px; min-height: 48px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { font-weight: 600; letter-spacing: 0.01em; }
.nav { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.nav-link {
  display: inline-block; padding: 12px 8px; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--text); }
.nav-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 8px; }
.user-role { color: var(--muted); }
.inline-form { display: inline; margin: 0; }

/* --- строка предупреждений --------------------------------------------------------- */
.alert { border-bottom: 1px solid var(--border); }
.alert-inner { max-width: 1280px; margin: 0 auto; padding: 8px 16px; }
.alert-critical { background: #a33a32; color: #ffffff; border-bottom-color: #8a2f28; }
.alert-warning { background: #f3e2b3; color: #4a3508; border-bottom-color: #dcc78d; }
.alert-info { background: #e1e7ef; color: #1f3a5f; border-bottom-color: #c6d0de; }
.alert-text { font-weight: 500; }
.incident-ref { white-space: nowrap; text-decoration: underline; }
.alert-link { color: inherit; font-weight: 500; text-decoration: underline; white-space: nowrap; }

.refresh-note { max-width: 1280px; margin: 0 auto; padding: 0 16px; color: var(--bad); font-size: 12px; }
.refresh-note:not(:empty) { padding-top: 8px; }

/* --- общая разметка ---------------------------------------------------------------- */
.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-title { font-size: 20px; font-weight: 600; margin: 0; }
.updated { color: var(--muted); font-size: 12px; }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid > .panel { margin-bottom: 0; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px; min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
.subtitle { font-size: 13px; font-weight: 600; margin: 16px 0 8px; }
.caption { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.small { font-size: 11px; }

/* --- показатели -------------------------------------------------------------------- */
.metric { font-size: 32px; font-weight: 500; line-height: 1.2; margin: 8px 0; }
.metric .unit { font-family: "IBM Plex Sans", system-ui, sans-serif; font-size: 14px; color: var(--muted); margin-left: 8px; }
.verdict { margin: 8px 0; }

.status { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.status-mark { width: 16px; height: 16px; border-radius: 2px; background: var(--nodata); flex: none; }
.status-up .status-mark { background: var(--ok); }
.status-down .status-mark { background: var(--bad); }
.status-text { font-size: 24px; font-weight: 600; }
.status-up .status-text { color: var(--ok); }
.status-down .status-text { color: var(--bad); }
.status-nodata .status-text { color: var(--nodata); }

.state { font-weight: 500; white-space: nowrap; }
.state-ok { color: var(--ok); }
.state-warn { color: var(--warn); }
.state-bad { color: var(--bad); }
.state-nodata, .state-info { color: var(--nodata); }

/* --- бюджет ------------------------------------------------------------------------ */
.budget-bar { display: block; width: 100%; height: 8px; margin: 8px 0; }
.bar-track { fill: #e6e8eb; }
.bar-ok { fill: var(--fill-up); }
.bar-warn { fill: #b8902e; }
.bar-bad { fill: var(--fill-down); }

/* --- таблицы ----------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 8px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-soft);
}
.table th { font-weight: 600; color: var(--muted); font-size: 12px; border-bottom-color: var(--border); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }

.mini { width: 100%; border-collapse: collapse; margin-top: 8px; }
.mini caption { text-align: left; }
.mini td { padding: 4px 0; border-top: 1px solid var(--border-soft); }
.mini td { vertical-align: top; }
.mini td.num { padding-left: 8px; }
.mini .caption { margin: 0; }

/* --- полоса 90 дней ---------------------------------------------------------------- */
.strip { display: flex; gap: 2px; height: 32px; }
.day { flex: 1 1 0; min-width: 0; border-radius: 1px; background: var(--fill-nodata); }
.day-ok { background: var(--fill-up); }
.day-warn { background: #c9a24a; }
.day-bad { background: var(--fill-down); }
.day-nodata { background: var(--fill-nodata); }
.strip-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 4px; }

.legend { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); font-size: 12px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.sw { width: 12px; height: 12px; border-radius: 2px; display: inline-block; flex: none; }
.sw-ok { background: var(--fill-up); }
.sw-warn { background: #c9a24a; }
.sw-bad { background: var(--fill-down); }
.sw-nodata { background: var(--fill-nodata); }
.sw-shade-down { background: var(--shade-down); border: 1px solid #e3b9b4; }
.sw-line-0 { background: var(--line-0); height: 3px; }
.sw-line-1 { background: var(--line-1); height: 3px; }
.sw-line-2 { background: var(--line-2); height: 3px; }

/* --- вкладки периодов -------------------------------------------------------------- */
.tabs { display: flex; gap: 0; flex-wrap: wrap; }
.tab {
  padding: 4px 16px; border: 1px solid var(--border); margin-left: -1px; color: var(--text);
  text-decoration: none; background: var(--surface);
}
.tab:first-child { margin-left: 0; border-radius: var(--radius) 0 0 var(--radius); }
.tab:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.tab-active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* --- графики ----------------------------------------------------------------------- */
.chart-scroll { overflow-x: auto; }
.chart { display: block; width: 100%; min-width: 640px; height: auto; }
.chart .grid { stroke: var(--border-soft); stroke-width: 1; }
.chart .tick { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .seg-up { fill: var(--fill-up); }
.chart .seg-down { fill: var(--fill-down); }
.chart .seg-nodata { fill: var(--fill-nodata); }
.chart .shade-down { fill: var(--shade-down); }
.chart .shade-nodata { fill: var(--shade-nodata); }
.chart .line { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
.chart .line-0 { stroke: var(--line-0); }
.chart .line-1 { stroke: var(--line-1); }
.chart .line-2 { stroke: var(--line-2); }
.chart .hit { fill: transparent; }
.chart-strip { min-width: 640px; }
.chart-strip rect { stroke: none; }
.chart-strip rect:hover { opacity: 0.75; }
.chart .hit:hover { fill: rgba(31, 58, 95, 0.08); }

/* --- подсказки --------------------------------------------------------------------- */
.tooltip {
  position: fixed; z-index: 10; left: 0; top: 0; max-width: 360px; padding: 4px 8px;
  background: #1f2328; color: #ffffff; font-size: 12px; border-radius: var(--radius); pointer-events: none;
}
.tooltip[hidden] { display: none; }

/* --- форма входа и кнопки ---------------------------------------------------------- */
.login-panel {
  max-width: 360px; margin: 48px auto 0; padding: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.login-title { font-size: 18px; font-weight: 600; margin: 0 0 8px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 4px; color: var(--muted); }
.field input {
  width: 100%; padding: 8px; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.btn {
  font: inherit; padding: 8px 16px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }

.notice { padding: 8px 12px; margin: 0 0 16px; border-radius: var(--radius); }
.notice-error { background: var(--err-bg); color: var(--err-text); border: 1px solid #e3b9b4; }

/* --- узкие экраны ------------------------------------------------------------------ */
@media (max-width: 960px) {
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .container { padding: 16px 16px 32px; }
  .metric { font-size: 28px; }
  .strip { height: 24px; gap: 1px; }
  .topbar-inner { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
}
tr:target td { background: #fbf3dc; }

/* --- формы, фильтры, карточки (этап 6) --------------------------------------------- */
[hidden] { display: none !important; }

.form { max-width: 560px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field select, .field textarea {
  width: 100%; padding: 8px; font: inherit; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.field textarea { resize: vertical; }
.field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
fieldset.field { border: 0; padding: 0; margin: 0 0 16px; }
fieldset.field legend { padding: 0; margin-bottom: 4px; color: var(--muted); }
.radio { display: block; margin: 4px 0; }
.field .radio input { width: auto; padding: 0; margin: 0 8px 0 0; vertical-align: middle; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 8px; }
.field-inline { margin-bottom: 0; min-width: 200px; }

.facts { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.cat { display: inline-block; padding: 0 8px; border: 1px solid var(--border); border-radius: 2px; font-weight: 500; white-space: nowrap; }
.cat-unclassified { color: var(--warn); border-color: #d9c28a; background: #faf3df; }
.cat-emergency { color: var(--bad); border-color: #dcb3af; background: #f8ebea; }
.cat-provider { color: #7a4a12; border-color: #d9bf9a; background: #f8efe3; }
.cat-planned { color: var(--accent); border-color: #b7c4d6; background: #e9eef5; }
.cat-external, .cat-customer { color: #4a5560; border-color: #c4cad1; background: #eef0f2; }
.cat-false_positive { color: var(--nodata); border-color: #c4cad1; background: #f4f5f6; }

.notice-ok { background: #e4f0e9; color: #1f4a35; border: 1px solid #b9d6c5; }
.notice-warn { background: #f7edcf; color: #5a4208; border: 1px solid #e0cb8d; }
.notice-info { background: #e1e7ef; color: #1f3a5f; border: 1px solid #c6d0de; }
.row-inside td { background: #fbf3dc; }
.pager { display: flex; gap: 16px; margin: 8px 0 0; }
.gap-form summary { cursor: pointer; color: var(--accent); }
.gap-form .form { margin-top: 8px; }
.panel-head a { white-space: nowrap; }

@media (max-width: 960px) {
  .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .facts dd { margin-bottom: 8px; }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* --- отчёт за месяц и печать (этап 7) ----------------------------------------------- */
.filters-compact { margin: 0; align-items: flex-end; }
.btn { text-decoration: none; display: inline-block; }
a.btn { color: var(--text); }
.report-head { margin-bottom: 16px; }
.report-title { font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.report-num td:first-child { width: 48px; }
.report-table .num { white-space: nowrap; }
.report-minor td { color: var(--muted); }
.row-unclassified td { background: #faf3df; }
.signature { margin-top: 32px; padding-top: 8px; }
.signature p { margin: 24px 0 0; }

@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: #ffffff; color: #000000; }
  body { font-size: 10.5pt; line-height: 1.35; }
  .topbar, .alerts, .refresh-note, .no-print, .filters, .tabs, .btn, .tooltip { display: none !important; }
  .container { max-width: none; padding: 0; }
  .panel { border: 0; border-radius: 0; padding: 0; margin: 0 0 12pt; }
  .panel-title { font-size: 11.5pt; margin-bottom: 4pt; }
  .report-title { font-size: 14pt; }
  .caption, .legend { color: #333333; font-size: 9pt; }
  .table th, .table td { padding: 3pt 5pt; border-bottom: 0.5pt solid #888888; }
  .table th { color: #000000; border-bottom: 1pt solid #000000; }
  .report-table, .report-table td { border: 0.5pt solid #888888; }
  .report-table td { border-bottom: 0.5pt solid #888888; }
  tr, .keep-together { break-inside: avoid; page-break-inside: avoid; }
  .table-wrap, .chart-scroll { overflow: visible; }
  .chart, .chart-strip { min-width: 0; width: 100%; }
  .chart .seg-up, .chart .seg-down, .chart .seg-nodata, .sw, .row-unclassified td, .cat, .notice {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  a { color: #000000; text-decoration: none; }
  .signature { margin-top: 24pt; }
  .signature p { margin: 18pt 0 0; font-size: 11pt; }
  .notice { border-radius: 0; }
}
