:root {
  --paper: #F3F5EF;
  --surface: #FFFFFF;
  --ink: #15221A;
  --muted: #5A685F;
  --line: #D8DFD4;
  --leaf: #2D6A4A;
  --leaf-soft: #E2EDE5;
  --turmeric: #B5780E;
  --turmeric-soft: #F6E8CC;
  --chili: #A6372A;
  --chili-soft: #F5E0DC;
  --slate: #6A7887;
  --radius: 10px;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--leaf); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75em; }
code { font-size: .88em; background: var(--leaf-soft); padding: .1em .35em; border-radius: 4px; word-break: break-all; }
pre { background: var(--ink); color: #E8EFE9; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }
pre code { background: none; color: inherit; padding: 0; }
:focus-visible { outline: 3px solid var(--turmeric); outline-offset: 2px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.lead { font-size: 1.05rem; max-width: 70ch; }
.strong { font-weight: 700; }
.is-bad { color: var(--chili); }
.is-good { color: var(--leaf); }

/* Topbar */
.topbar { background: var(--ink); color: #fff; }
.topbar-in { display: flex; align-items: center; gap: 28px; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: -0.02em; }
.leaf { width: 16px; height: 16px; background: var(--turmeric); border-radius: 0 60% 0 60%; display: inline-block; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: #C9D6CD; text-decoration: none; padding: 6px 10px; border-radius: 6px; font-weight: 600; font-size: .92rem; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255,255,255,.12); }
.who { font-size: .88rem; color: #C9D6CD; display: flex; gap: 12px; }
.who a { color: #fff; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: .92rem; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--leaf); color: #fff; border-color: var(--leaf); }
.btn-primary:hover { background: #24573C; border-color: #24573C; }
.btn-quiet { background: transparent; }
.btn:disabled { opacity: .6; cursor: progress; }
.link { background: none; border: 0; color: var(--chili); font: inherit; font-size: .88rem; cursor: pointer; padding: 0; text-decoration: underline; }
form.inline { display: inline; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-height: 38px; }
input:focus, select:focus { border-color: var(--leaf); outline: none; box-shadow: 0 0 0 3px var(--leaf-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; align-items: start; }
.form-actions { grid-column: 1 / -1; margin-top: 4px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.flash { padding: 10px 14px; border-radius: 8px; margin: 16px 0 0; font-weight: 600; }
.flash-ok { background: var(--leaf-soft); color: #1E4B33; }
.flash-error { background: var(--chili-soft); color: #7D2419; }

/* Pages */
.page { padding: 28px 20px 60px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 0 0 20px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
details.panel summary { cursor: pointer; font-weight: 700; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.split .panel { margin: 0 0 20px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; margin: 16px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; text-align: right; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-bottom: 12px; }
.conn { border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.status { font-weight: 700; font-size: .88rem; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.add-user { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.demo { border-style: dashed; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-weight: 700; color: var(--muted); font-size: .82rem; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
td.msg { color: var(--muted); font-size: .85rem; max-width: 420px; }
.sku-name { display: block; font-weight: 600; }
.sku-cost input { width: 110px; text-align: right; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.pill-ok { background: var(--leaf-soft); color: var(--leaf); }
.pill-error { background: var(--chili-soft); color: var(--chili); }
.pill-running { background: var(--turmeric-soft); color: #7A520A; }
.pill-skipped { background: var(--paper); color: var(--muted); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { color: var(--ink); }
.login-card h1 { font-size: 1.4rem; margin: 6px 0 0; }

/* Dashboard */
.dash { padding: 24px 20px 60px; }
.dash-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dash-head h1 { margin-bottom: 2px; }
.fresh { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: .85rem; margin: 10px 0 20px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--leaf); box-shadow: 0 0 0 0 rgba(45,106,74,.5); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(45,106,74,.45); } 70% { box-shadow: 0 0 0 8px rgba(45,106,74,0); } 100% { box-shadow: 0 0 0 0 rgba(45,106,74,0); } }
.fresh-bad { color: var(--chili); font-weight: 700; }
.fresh-note { color: #7A520A; }

.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px 24px 12px; display: grid; grid-template-columns: auto 1fr; gap: 8px 36px; margin-bottom: 20px; border-top: 6px solid var(--slate); }
.hero.is-good { border-top-color: var(--leaf); }
.hero.is-warn { border-top-color: var(--turmeric); }
.hero.is-bad { border-top-color: var(--chili); }
.hero-num { display: flex; flex-direction: column; }
.hero-kicker { font-weight: 700; color: var(--muted); font-size: .9rem; }
.hero-value { font-size: clamp(3.5rem, 9vw, 6rem); font-weight: 800; line-height: 1; letter-spacing: -0.04em; color: var(--turmeric); }
.hero.is-bad .hero-value { color: var(--chili); }
.hero-verdict { align-self: center; max-width: 62ch; }
.hero-verdict h2 { font-size: 1.35rem; font-weight: 800; }
.hero.is-good .hero-verdict h2 { color: var(--leaf); }
.hero.is-bad .hero-verdict h2 { color: var(--chili); }
.hero.is-warn .hero-verdict h2 { color: #8A5B08; }
.ruler { grid-column: 1 / -1; margin: 4px 0 0; }
.ruler svg { width: 100%; height: auto; display: block; overflow: visible; }
.ruler .zone-bad { fill: var(--chili-soft); }
.ruler .zone-good { fill: var(--leaf-soft); }
.ruler .gap { fill: var(--turmeric); opacity: .35; }
.ruler .tick { stroke: var(--muted); stroke-width: 1; }
.ruler .baseline { stroke: var(--ink); stroke-width: 1.5; }
.ruler .tick-label { font-size: 15px; fill: var(--muted); font-weight: 600; }
.ruler .be-line { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 4; }
.ruler .be-label { font-size: 15px; font-weight: 700; fill: var(--ink); }
.ruler .lead { stroke-width: 1; stroke: var(--line); }
.ruler .mark-label { font-size: 16px; font-weight: 600; fill: var(--muted); }
.ruler .mark-val { font-weight: 800; fill: var(--ink); }
.ruler .mark-proj { fill: var(--turmeric); }
.ruler .mark-proj .mark-val { fill: var(--turmeric); }
.ruler .dot { stroke-width: 2.5; }
.ruler .dot-tt { fill: #fff; stroke: var(--slate); }
.ruler .dot-live { fill: #fff; stroke: var(--leaf); }
.ruler .dot-proj { fill: var(--turmeric); stroke: #fff; }
.gap-note { font-size: .88rem; color: var(--muted); margin: 6px 0 0; display: flex; gap: 8px; align-items: baseline; }
.swatch { width: 14px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.swatch-gap { background: var(--turmeric); opacity: .45; }

.stats { display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 20px; }
.stats > div { padding: 14px 16px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stats dt { font-size: .82rem; font-weight: 700; color: var(--muted); }
.stats dd { margin: 4px 0 0; display: flex; flex-direction: column; }
.stat-val { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-sub { font-size: .78rem; color: var(--muted); }

.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { font-size: 11.5px; fill: var(--muted); }
.chart .shade { fill: var(--paper); }
.chart .shade-label { font-size: 11.5px; fill: var(--muted); font-weight: 600; }
.chart .be-line { stroke: var(--ink); stroke-width: 1.25; stroke-dasharray: 4 4; }
.chart .series { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-tt { stroke: var(--slate); stroke-dasharray: 2 4; }
.chart .series-live { stroke: var(--leaf); }
.chart .series-proj { stroke: var(--turmeric); stroke-width: 3; }
.chart .end-tt { fill: var(--slate); }
.chart .end-live { fill: var(--leaf); }
.chart .end-proj { fill: var(--turmeric); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: rgba(21,34,26,.04); }
.chart-empty { padding: 40px; text-align: center; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--muted); margin: 8px 0 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 18px; height: 0; border-top: 3px solid; display: inline-block; }
.key-tt { border-color: var(--slate); border-top-style: dotted; }
.key-live { border-color: var(--leaf); }
.key-proj { border-color: var(--turmeric); }
.key-be { border-color: var(--ink); border-top-style: dashed; border-top-width: 2px; }

.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tab { white-space: nowrap; font: inherit; font-size: .85rem; font-weight: 700; padding: 6px 12px; border: 0; background: #fff; color: var(--muted); cursor: pointer; border-right: 1px solid var(--line); }
.tab:last-child { border-right: 0; }
.tab[aria-pressed="true"] { background: var(--ink); color: #fff; }
.loss { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.loss-bar { width: 54px; height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.loss-bar span { display: block; height: 100%; background: var(--chili); opacity: .7; }
abbr { text-decoration: none; color: var(--turmeric); font-weight: 800; cursor: help; }
.sop { margin-top: 8px; }

@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stats > div:nth-child(3) { border-right: 0; }
  .stats > div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; padding: 18px 16px 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .stats > div:nth-child(odd) { border-right: 1px solid var(--line); }
  .dash-head { flex-direction: column; }
  .topbar-in { gap: 8px 12px; padding-top: 10px; }
  .who { margin-left: auto; }
  .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .nav a { white-space: nowrap; }
  .sku-name { min-width: 150px; }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
