@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f0f2f5;
  --ink: #17191f;
  --muted: #68707d;
  --line: #dfe3e8;
  --graphite: #252933;
  --red: #e32636;
  --red-soft: #fff0f1;
  --amber: #e99200;
  --amber-soft: #fff7e5;
  --blue: #2374e8;
  --blue-soft: #edf5ff;
  --green: #17854b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(25, 31, 42, .07);
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: "Onest", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
a { color: inherit; }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(35, 116, 232, .35);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  color: #fff;
  background: rgba(25, 28, 35, .96);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand > span:last-child { display: grid; line-height: 1.15; }
.brand strong { font-size: 1rem; }
.brand small { margin-top: 4px; color: #aeb4bf; font-size: .76rem; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; background: var(--red); font-weight: 800;
}
.nav { display: flex; gap: 6px; }
.nav a {
  padding: 10px 14px; border-radius: 9px; color: #bfc5cf;
  text-decoration: none; font-size: .88rem; font-weight: 600;
}
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.09); }

.page { max-width: 1440px; margin: 0 auto; padding: 30px 24px 48px; }
.title-row { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 20px; }
.eyebrow {
  margin: 0 0 7px; color: var(--red); font-size: .76rem; line-height: 1.2;
  font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
h1, h2, h3 { margin: 0; letter-spacing: -.025em; line-height: 1.15; }
h1 { font-size: clamp(1.8rem, 3vw, 2.55rem); }
h2 { font-size: 1.22rem; }
h3 { font-size: 1rem; }
.period { text-align: right; color: var(--muted); font-size: .78rem; white-space: nowrap; }
.period strong { display: block; color: var(--ink); font-size: .95rem; }
.period span { display: block; margin-top: 3px; }

.scope-panel {
  display: grid;
  grid-template-columns: minmax(145px, .7fr) minmax(190px, 1fr) minmax(260px, 1.35fr) auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  background: var(--graphite);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.field label { display: block; margin-bottom: 6px; color: #c8cdd5; font-size: .76rem; font-weight: 600; }
.field input, .field select, .inline-controls select {
  width: 100%; min-height: 44px; padding: 9px 11px;
  color: var(--ink); background: #fff; border: 1px solid #d6dbe2; border-radius: 9px;
}
.button {
  min-height: 44px; padding: 9px 14px; border: 1px solid #cad0d9; border-radius: 9px;
  background: #fff; color: var(--ink); font-weight: 600; cursor: pointer;
}
.button:hover { border-color: #9fa8b5; }
.button.ghost { background: transparent; color: inherit; }
.scope-panel .button.ghost { color: #fff; border-color: #515866; }
.button.toggle { color: #fff; background: #3a404c; border-color: #515866; white-space: nowrap; }
.button.toggle span { display: block; color: #b8bec8; font-size: .66rem; font-weight: 500; }
.button:disabled { cursor: not-allowed; opacity: .58; }

.scope-line {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 2px 10px; color: var(--muted); font-size: .82rem;
}
.scope-line strong { color: var(--ink); font-size: .92rem; text-transform: capitalize; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 8px 0 20px; }
.kpi-card {
  min-height: 190px; padding: 22px; background: var(--surface);
  border: 1px solid var(--line); border-top: 4px solid var(--graphite);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.kpi-card.danger { border-top-color: var(--red); }
.kpi-card.warning { border-top-color: var(--amber); }
.kpi-card.info { border-top-color: var(--blue); }
.kpi-code { color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.kpi-card h2 { margin-top: 7px; font-size: 1rem; font-weight: 600; }
.kpi-value { display: block; margin: 19px 0 9px; font-size: clamp(2.4rem, 5vw, 4rem); line-height: .95; letter-spacing: -.055em; }
.kpi-card.danger .kpi-value { color: var(--red); }
.kpi-card.warning .kpi-value { color: #b86f00; }
.kpi-card.info .kpi-value { color: var(--blue); }
.kpi-card p { margin: 0; color: var(--muted); font-size: .82rem; }

.split-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; }
.panel {
  min-width: 0; padding: 20px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 18px; }
.panel-head p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-soft); border-radius: 9px; }
.segmented button {
  min-height: 34px; padding: 6px 10px; border: 0; border-radius: 7px;
  color: var(--muted); background: transparent; font-size: .76rem; font-weight: 700; cursor: pointer;
}
.segmented button.active { color: #fff; background: var(--graphite); }
.inline-controls { display: grid; grid-template-columns: minmax(190px, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.inline-controls select { min-height: 40px; }

.ranking { display: grid; gap: 5px; max-height: 690px; overflow: auto; padding-right: 4px; }
.rank-item {
  display: grid; grid-template-columns: 28px 50px minmax(80px, 1fr) 58px;
  align-items: center; gap: 9px; min-height: 38px; padding: 3px 7px;
  text-decoration: none; border-radius: 8px;
}
.rank-item:hover { background: var(--surface-soft); }
.rank-number { color: var(--muted); font-size: .72rem; }
.rank-item strong { font-size: .85rem; }
.rank-track { height: 9px; background: #eceef2; border-radius: 999px; overflow: hidden; }
.rank-track i { display: block; height: 100%; background: linear-gradient(90deg, #ff939a, var(--red)); border-radius: inherit; }
.rank-item b { text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { padding: 10px 9px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-weight: 600; white-space: nowrap; }
td { padding: 11px 9px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.sku-link { color: var(--ink); font-weight: 700; text-decoration: none; }
.sku-link:hover { color: var(--red); }
.cell-main { display: block; max-width: 430px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { display: block; margin-top: 4px; color: var(--muted); font-size: .71rem; line-height: 1.35; }
.compact-table .table-wrap, .compact-table { max-height: 620px; }

.method-note {
  display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 14px 16px;
  color: #674f18; background: var(--amber-soft); border: 1px solid #f1d89c; border-radius: 11px; font-size: .82rem;
}
.method-note strong { white-space: nowrap; }
.method-note a { color: #8a5700; font-weight: 700; }

.mini-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.mini-kpis article { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.mini-kpis span, .mini-kpis small { display: block; color: var(--muted); }
.mini-kpis span { font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.mini-kpis strong { display: block; margin: 5px 0 3px; font-size: 1.8rem; letter-spacing: -.04em; }
.mini-kpis small { font-size: .74rem; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; color: var(--muted); font-size: .8rem; }
.pager div { display: flex; gap: 7px; }
.pager .button { min-height: 38px; }

.installation-panel { margin-top: 20px; border-top: 4px solid var(--amber); }
.installation-summary { display: flex; gap: 8px; align-items: baseline; margin: -4px 0 14px; color: var(--muted); font-size: .82rem; }
.installation-summary strong { color: var(--ink); font-size: 1.2rem; }
.badge { display: inline-flex; margin-right: 6px; padding: 3px 7px; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.badge.confirmed { color: #0f6639; background: #e7f6ed; }
.badge.pilot { color: #865500; background: var(--amber-soft); }
.definitions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; }
.definitions article { padding: 16px; background: var(--surface-soft); border-radius: 11px; }
.definitions p { margin: 6px 0 0; color: var(--muted); font-size: .8rem; }

.footer { margin-top: 24px; padding-top: 18px; color: var(--muted); border-top: 1px solid var(--line); font-size: .76rem; }
.loading, .empty { padding: 28px; color: var(--muted); text-align: center; }
.error-card { padding: 20px; color: #8f1721; background: var(--red-soft); border-left: 4px solid var(--red); }

@media (max-width: 1100px) {
  .scope-panel { grid-template-columns: repeat(3, 1fr); }
  .scope-panel .button { width: 100%; }
  .split-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app-header { padding: 0 14px; }
  .brand small { display: none; }
  .nav a { padding: 9px 8px; font-size: .73rem; }
  .page { padding: 22px 14px 34px; }
  .title-row { display: block; }
  .period { margin-top: 12px; text-align: left; }
  .scope-panel { grid-template-columns: 1fr; }
  .kpi-grid, .mini-kpis, .definitions { grid-template-columns: 1fr; }
  .kpi-card { min-height: 160px; }
  .inline-controls { grid-template-columns: 1fr; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .method-note { align-items: flex-start; flex-direction: column; }
}
