:root {
  color-scheme: dark;
  --bg: #111517;
  --sidebar: #171c1f;
  --panel: #1b2226;
  --panel-strong: #222b30;
  --line: #334047;
  --text: #eef2f3;
  --muted: #93a1a8;
  --accent: #df6b36;
  --accent-soft: #6a3d2b;
  --warning: #d4a94f;
  --critical: #d85c5c;
  --ok: #65a881;
  font-family: "Segoe UI Variable", "Aptos", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, select { font: inherit; }
input { font: inherit; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: 232px;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); font-weight: 800; letter-spacing: .08em; text-decoration: none; }
.brand-mark {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  background: var(--accent);
  -webkit-mask: url("/static/steelkont-mark.svg") center / contain no-repeat;
  mask: url("/static/steelkont-mark.svg") center / contain no-repeat;
}
.sidebar nav { display: grid; gap: 6px; margin-top: 54px; }
.sidebar nav a { padding: 11px 13px; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; }
.sidebar nav a:hover, .sidebar nav a.active { background: var(--panel-strong); color: var(--text); }
.sidebar-source { display: grid; gap: 4px; margin-top: auto; padding: 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; }
.sidebar-source strong { color: var(--text); font-size: 14px; }
main { margin-left: 232px; padding: 0 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 108px; border-bottom: 1px solid var(--line); }
.context { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: 30px; letter-spacing: -.03em; }
.topbar-meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }
.fixture-badge { padding: 6px 9px; border: 1px solid var(--accent-soft); border-radius: 6px; color: #f4a27d; font-weight: 800; text-transform: uppercase; }
.current-user { padding-left: 14px; border-left: 1px solid var(--line); color: var(--text); font-weight: 700; }
.logout-form { margin: 0; }
.logout-form button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.logout-form button:hover, .logout-form button:focus-visible { border-color: var(--muted); color: var(--text); }
.filters { display: flex; gap: 12px; padding: 22px 0; }
.filters label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.filters select { min-width: 150px; padding: 9px 34px 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); text-transform: none; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; }
.kpi { min-height: 154px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.kpi-primary { border-color: var(--accent-soft); background: #211e1c; }
.kpi-alert strong { color: #ef8a8a; }
.kpi-label { min-height: 34px; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi strong { display: block; margin-top: 10px; font-family: "Cascadia Mono", Consolas, monospace; font-size: clamp(29px, 3vw, 42px); letter-spacing: -.05em; }
.kpi strong small { margin-left: 3px; font-size: .48em; color: var(--muted); }
.kpi p { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr); gap: 12px; margin-top: 12px; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.panel-header { display: flex; justify-content: space-between; gap: 20px; padding: 19px 20px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 16px; }
.panel-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.legend { display: flex; gap: 13px; align-items: center; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 8px; }
.legend-actual { background: var(--accent); }
.legend-plan { border: 1px solid #687780; }
.bar-chart { display: flex; align-items: stretch; gap: clamp(4px, .7vw, 10px); height: 298px; padding: 28px 20px 16px; }
.bar-column { display: grid; grid-template-rows: 20px 1fr 18px; flex: 1; min-width: 7px; text-align: center; }
.bar-value { color: var(--muted); font: 10px "Cascadia Mono", Consolas, monospace; }
.bar-track { position: relative; align-self: stretch; border-bottom: 1px solid #536169; }
.bar-plan, .bar-actual { position: absolute; right: 12%; bottom: 0; left: 12%; }
.bar-plan { border: 1px solid #687780; border-bottom: 0; }
.bar-actual { right: 24%; left: 24%; background: var(--accent); }
.bar-column time { padding-top: 6px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.line-list { padding: 4px 20px 15px; }
.line-row { padding: 18px 0; border-bottom: 1px solid var(--line); }
.line-row:last-child { border-bottom: 0; }
.line-heading { display: flex; justify-content: space-between; gap: 12px; }
.line-heading strong, .line-heading span { display: block; }
.line-heading strong { font-size: 14px; }
.line-heading span, .line-meta { color: var(--muted); font-size: 10px; }
.line-heading b { font: 16px "Cascadia Mono", Consolas, monospace; }
.progress { height: 6px; margin: 13px 0 9px; background: #2a3439; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.line-meta { display: flex; justify-content: space-between; }
.route-section { scroll-margin-top: 20px; margin-top: 40px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 17px; }
.section-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.025em; }
.section-heading > div > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.route-heading-actions { display: flex; align-items: flex-end; gap: 10px; }
.route-product-picker { display: grid; gap: 6px; }
.route-product-picker label { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.route-product-picker select { max-width: 390px; min-width: 280px; padding: 8px 34px 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #181e21; color: var(--text); font: 11px "Cascadia Mono", Consolas, monospace; }
.route-version { flex: 0 0 auto; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font: 10px "Cascadia Mono", Consolas, monospace; }
.route-kpis { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; }
.route-kpis article { min-height: 128px; padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.route-kpis span, .route-kpis small { display: block; color: var(--muted); }
.route-kpis span { font-size: 11px; font-weight: 750; text-transform: uppercase; }
.route-kpis strong { display: block; margin-top: 15px; font: 25px "Cascadia Mono", Consolas, monospace; letter-spacing: -.04em; }
.route-kpis small { margin-top: 8px; font-size: 10px; }
.route-flow-panel { margin-top: 12px; }
.route-flow { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); overflow-x: auto; padding: 20px; }
.route-flow article { position: relative; min-height: 120px; padding: 15px 20px 15px 15px; border-top: 2px solid var(--accent); background: #181e21; }
.route-flow article:not(:last-child)::after { position: absolute; z-index: 1; top: -6px; right: -5px; width: 8px; height: 8px; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); content: ""; transform: rotate(45deg); }
.route-flow time, .route-flow span { display: block; color: var(--muted); font: 10px "Cascadia Mono", Consolas, monospace; }
.route-flow strong { display: block; min-height: 34px; margin: 13px 0 12px; font-size: 12px; line-height: 1.35; }
.route-flow small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; }
.route-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, .75fr); gap: 12px; margin-top: 12px; }
.route-grid > * { min-width: 0; }
.route-centers-scroll { max-height: 438px; }
.route-centers-scroll thead, .route-table-scroll thead { position: sticky; z-index: 2; top: 0; background: var(--panel-strong); }
.route-section-list { margin: 0; padding: 8px 20px 15px; list-style: none; }
.route-section-list li { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.route-section-list li:last-child { border-bottom: 0; }
.route-section-list span { color: var(--accent); font: 10px "Cascadia Mono", Consolas, monospace; }
.route-section-list strong { font-size: 12px; }
.route-section-list b { color: var(--muted); font: 11px "Cascadia Mono", Consolas, monospace; }
.route-table-panel { margin-top: 12px; }
.route-table-header { align-items: center; }
.route-visible-count { flex: 0 0 auto; color: var(--muted); font: 11px "Cascadia Mono", Consolas, monospace; }
.route-filters { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(220px, 1fr) minmax(260px, 1.3fr); gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #181e21; }
.route-filters label { display: grid; gap: 6px; }
.route-filters label > span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.route-filters select, .route-filters input { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--panel); color: var(--text); }
.route-filters input:focus, .route-filters select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(223 107 54 / .13); }
.route-table-scroll { max-height: 620px; }
.route-table td { vertical-align: top; }
.route-table td:nth-child(2) { min-width: 260px; }
.route-table td:nth-child(5) { min-width: 240px; }
.route-table td:nth-child(7) { min-width: 260px; white-space: normal; }
.route-table td small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.route-section-chip { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; color: #b8c4c9; font-size: 10px; }
.route-empty { margin: 0; text-align: center; }
.route-source-note { display: flex; justify-content: space-between; gap: 20px; padding: 13px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.reference-section { scroll-margin-top: 20px; margin-top: 40px; }
.reference-kpis { display: grid; grid-template-columns: repeat(6, minmax(140px, 1fr)); gap: 12px; }
.reference-kpis article { min-height: 118px; padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.reference-kpis span, .reference-kpis small { display: block; color: var(--muted); }
.reference-kpis span { font-size: 11px; font-weight: 750; text-transform: uppercase; }
.reference-kpis strong { display: block; margin-top: 13px; font: 25px "Cascadia Mono", Consolas, monospace; letter-spacing: -.04em; }
.reference-kpis small { margin-top: 7px; font-size: 10px; line-height: 1.35; }
.reference-table-panel { margin-top: 12px; }
.reference-table-header { align-items: center; }
.reference-filters { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(240px, 1fr) minmax(300px, 1.3fr); gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #181e21; }
.reference-filters label { display: grid; gap: 6px; }
.reference-filters label > span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.reference-filters select, .reference-filters input { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--panel); color: var(--text); }
.reference-filters input:focus, .reference-filters select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(223 107 54 / .13); }
.reference-table-scroll { max-height: 720px; }
.reference-table-scroll thead { position: sticky; z-index: 2; top: 0; background: var(--panel-strong); }
.reference-table td { vertical-align: middle; }
.reference-table td:nth-child(2) { min-width: 300px; white-space: normal; }
.reference-table td:nth-child(4) { min-width: 230px; white-space: normal; }
.reference-table td:nth-child(6) { min-width: 180px; white-space: normal; }
.reference-table td small, .reference-item-name { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.reference-item-name { color: #cbd3d6; font-size: 12px; }
.reference-image-link { display: grid; place-items: center; width: 82px; height: 66px; border: 1px solid var(--line); border-radius: 7px; background: #f5f6f4; overflow: hidden; }
.reference-image-link:hover, .reference-image-link:focus-visible { border-color: var(--accent); }
.reference-image-link img { width: 72px; height: 56px; object-fit: contain; }
.reference-no-image { display: grid; place-items: center; width: 82px; height: 66px; border: 1px dashed var(--line); color: var(--muted); }
.reference-kind, .reference-flag, .reference-ok, .reference-corrected { display: inline-flex; padding: 4px 7px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.reference-kind-make { background: #26343b; color: #9ab9c8; }
.reference-kind-buy { background: #3b3320; color: #e0bc6a; }
.reference-flag { background: #422525; color: #ef8a8a; }
.reference-ok { background: #20362b; color: #91c8a8; }
.reference-corrected { background: #243448; color: #93b9e4; }
.reference-empty-panel { padding: 24px; }
.reference-empty-panel p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.warehouse-section { scroll-margin-top: 20px; margin-top: 40px; }
.warehouse-kpis { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; }
.warehouse-kpis article { min-height: 118px; padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.warehouse-kpis span, .warehouse-kpis small { display: block; color: var(--muted); }
.warehouse-kpis span { font-size: 11px; font-weight: 750; text-transform: uppercase; }
.warehouse-kpis strong { display: block; margin-top: 13px; font: 25px "Cascadia Mono", Consolas, monospace; letter-spacing: -.04em; }
.warehouse-kpis small { margin-top: 7px; font-size: 10px; line-height: 1.35; }
.warehouse-kpi-alert { border-color: #653737 !important; background: #251c1c !important; }
.warehouse-kpi-alert strong { color: #ef8a8a; }
.warehouse-table-panel { margin-top: 12px; }
.warehouse-table-header { align-items: center; }
.warehouse-filters { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(220px, .8fr) minmax(320px, 1.4fr); gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: #181e21; }
.warehouse-filters label { display: grid; gap: 6px; }
.warehouse-filters label > span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.warehouse-filters select, .warehouse-filters input { width: 100%; min-width: 0; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--panel); color: var(--text); }
.warehouse-filters input:focus, .warehouse-filters select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(223 107 54 / .13); }
.warehouse-table-scroll { max-height: 680px; }
.warehouse-table-scroll thead { position: sticky; z-index: 2; top: 0; background: var(--panel-strong); }
.warehouse-table td { vertical-align: top; }
.warehouse-table td:first-child { min-width: 290px; white-space: normal; }
.warehouse-table td:last-child { min-width: 280px; max-width: 420px; white-space: normal; }
.warehouse-table td small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.warehouse-kind { display: inline-flex; padding: 4px 7px; border: 1px solid var(--line); border-radius: 5px; color: #b8c4c9; font-size: 10px; }
.supply-status { display: inline-flex; padding: 4px 7px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.supply-status-covered { background: #20362b; color: #91c8a8; }
.supply-status-shortage { background: #422525; color: #ef8a8a; }
.supply-status-review { background: #3b3320; color: #e0bc6a; }
.supply-status-unmatched { background: #26343b; color: #9ab9c8; }
.warehouse-negative { color: #ef8a8a; }
.table-panel { margin-top: 12px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 14px 20px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 10px; text-transform: uppercase; }
td { color: #cbd3d6; }
td strong { color: var(--text); }
.status, .severity { display: inline-flex; padding: 4px 7px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.status-normal { background: #20362b; color: #91c8a8; }
.status-warning { background: #3b3320; color: #e0bc6a; }
.status-critical { background: #422525; color: #ef8a8a; }
.incident-list { padding: 4px 20px; }
.incident-list article { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.incident-list article:last-child { border-bottom: 0; }
.incident-list strong { display: block; font-size: 13px; }
.incident-list p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.incident-list time { color: var(--muted); font: 11px "Cascadia Mono", Consolas, monospace; }
.severity-high { background: #422525; color: #ef8a8a; }
.severity-medium { background: #3b3320; color: #e0bc6a; }
.severity-low { background: #26343b; color: #9ab9c8; }
.empty-state { padding: 28px 0; color: var(--muted); }
.dashboard-footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px 0 36px; color: var(--muted); font-size: 10px; }

.login-page { min-height: 100dvh; background: var(--bg); }
.login-shell { display: grid; place-items: center; min-height: 100dvh; margin: 0; padding: 24px; }
.login-card { width: min(100%, 430px); padding: 34px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 24px 80px rgb(0 0 0 / .24); }
.login-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .08em; }
.login-heading { margin-top: 48px; }
.login-heading p { margin: 0 0 7px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.login-heading h1 { font-size: 30px; }
.login-heading span { display: block; margin-top: 10px; color: var(--muted); font-size: 13px; }
.login-error { margin-top: 22px; padding: 11px 13px; border: 1px solid #653737; border-radius: 7px; background: #3a2424; color: #f3a0a0; font-size: 12px; }
.login-form { display: grid; gap: 17px; margin-top: 28px; }
.login-form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-form input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--bg); color: var(--text); }
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(223 107 54 / .16); }
.login-form button { min-height: 44px; margin-top: 5px; border: 0; border-radius: 8px; background: var(--accent); color: #1a110d; font-weight: 800; cursor: pointer; }
.login-form button:hover { background: #ed7d4b; }
.login-note { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

@media (max-width: 1160px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .route-kpis { grid-template-columns: repeat(3, 1fr); }
  .reference-kpis { grid-template-columns: repeat(3, 1fr); }
  .warehouse-kpis { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .route-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: auto; padding: 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { display: flex; margin-top: 20px; overflow-x: auto; }
  .sidebar-source { display: none; }
  main { margin-left: 0; padding: 0 16px; }
  .topbar { align-items: flex-start; flex-direction: column; justify-content: center; gap: 14px; }
  .topbar-meta { flex-wrap: wrap; }
  .current-user { padding-left: 0; border-left: 0; }
  .filters { overflow-x: auto; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .route-heading-actions { align-items: stretch; flex-direction: column; }
  .route-product-picker select { width: 100%; max-width: none; min-width: 0; }
  .route-kpis { grid-template-columns: 1fr 1fr; }
  .route-filters { grid-template-columns: 1fr; }
  .reference-kpis { grid-template-columns: 1fr 1fr; }
  .reference-filters { grid-template-columns: 1fr; }
  .warehouse-kpis { grid-template-columns: 1fr 1fr; }
  .warehouse-filters { grid-template-columns: 1fr; }
  .route-source-note { flex-direction: column; }
  .bar-chart { height: 250px; padding-inline: 12px; }
  .bar-value { display: none; }
  .incident-list article { grid-template-columns: 70px 1fr; }
  .incident-list time { grid-column: 2; }
  .dashboard-footer { flex-direction: column; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .route-kpis { grid-template-columns: 1fr; }
  .reference-kpis { grid-template-columns: 1fr; }
  .warehouse-kpis { grid-template-columns: 1fr; }
  .filters label { min-width: 138px; }
  .filters select { min-width: 138px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
