:root {
  --bg: #f5f7f9;
  --panel: #ffffff;
  --ink: #15202b;
  --muted: #627084;
  --line: #dde4ec;
  --blue: #1e63b6;
  --teal: #0f8b8d;
  --green: #1f8a4c;
  --amber: #b56b00;
  --red: #bc2f2f;
  --violet: #7256b8;
  --shadow: 0 14px 34px rgba(24, 39, 75, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-weight: 800;
}

.brand strong, .brand span { display: block; }
.brand span { margin-top: 3px; color: var(--muted); font-size: 12px; }

nav { display: grid; gap: 8px; margin-top: 22px; }
nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: #314155;
  text-decoration: none;
  font-weight: 650;
  font-size: 14px;
}
nav a.active, nav a:hover { background: #eaf2fb; color: var(--blue); }

.shell {
  margin-left: 248px;
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 19px; line-height: 1.28; }
h1, h2, .panel, .kpi { min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.filters {
  display: flex;
  gap: 12px;
  align-items: center;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select, button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 0 12px;
}

button {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  flex-wrap: wrap;
}
.segmented button {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: #415166;
  padding: 0 12px;
}
.segmented button.active {
  background: var(--blue);
  color: #fff;
}

.sales-toolbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
  margin: 12px 0 16px;
}

.replenishment-toolbar {
  align-items: end;
}

.inline-filters {
  align-items: end;
}

.download-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.range-tabs button {
  min-width: 86px;
}

.range-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
  min-width: 430px;
}
.range-summary div {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfdff;
}
.range-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.range-summary strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 16px;
  border-left: 5px solid var(--blue);
}

.hero p:not(.eyebrow) {
  margin-top: 9px;
  color: var(--muted);
  max-width: 920px;
}
.hero h2 { max-width: 100%; white-space: normal; }

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
.hero-actions a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.inventory-kpis { margin-top: 14px; }

.kpi {
  min-height: 112px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}
.kpi span { color: var(--muted); font-size: 12px; font-weight: 750; }
.kpi strong { display: block; margin-top: 12px; font-size: 24px; line-height: 1; }
.kpi small { display: block; margin-top: 10px; color: var(--muted); }

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.grid.two { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); }
.grid.compact { margin-top: 14px; margin-bottom: 0; }
.wide { min-width: 0; }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.section-head > span {
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
}

canvas {
  width: 100%;
  max-height: 280px;
  border: 1px solid #edf1f5;
  border-radius: 8px;
}

.bars { display: grid; gap: 12px; }
.bar-row { display: grid; gap: 6px; }
.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.bar-track { height: 10px; background: #ecf1f5; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); border-radius: inherit; }

.table { overflow: auto; max-height: 430px; border: 1px solid #edf1f5; border-radius: 8px; }
.table.tall { max-height: 560px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 11px; border-bottom: 1px solid #edf1f5; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #f8fafc; color: #415166; z-index: 1; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.dense th, .dense td { padding: 8px 10px; }
td.warn-yellow { background: #fff7c7; color: #7d6500; font-weight: 800; }
td.warn-red { background: #fdeaea; color: var(--red); font-weight: 800; }

.donut-wrap { display: grid; gap: 16px; align-content: start; }
.donut {
  width: 210px;
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 8px auto 0;
}
.legend { display: grid; gap: 8px; }
.legend div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.swatch { width: 10px; height: 10px; display: inline-block; border-radius: 2px; margin-right: 7px; }

.cards-list { display: grid; gap: 10px; max-height: 520px; overflow: auto; }
.risk-card {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.risk-card strong { display: block; font-size: 14px; margin-bottom: 7px; }
.risk-card p { color: var(--muted); font-size: 13px; line-height: 1.45; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 750;
  margin-right: 8px;
}
.tag.red { color: var(--red); background: #fdeaea; }
.tag.orange { color: var(--amber); background: #fff2dc; }
.tag.yellow { color: #7d6500; background: #fff7c7; }
.tag.blue { color: var(--blue); background: #e8f1fb; }

.alerts { display: grid; gap: 10px; }
.alert {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 190px;
  gap: 12px;
  align-items: start;
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 12px;
}
.alert h3 { margin: 0 0 5px; font-size: 15px; }
.alert p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.alert .action { color: #314155; }

.plain-list {
  margin: 0;
  padding-left: 18px;
  color: #314155;
  line-height: 1.7;
}

.note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 1120px;
}

h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.cadence {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.cadence div {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 14px;
}
.cadence strong, .cadence span { display: block; }
.cadence span { color: var(--muted); margin-top: 6px; }

.coverage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.coverage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}
.coverage-card strong,
.coverage-card span {
  display: block;
}
.coverage-card strong { font-size: 14px; }
.coverage-card span {
  margin-top: 7px;
  font-size: 12px;
  font-weight: 800;
}
.coverage-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.coverage-card.ok { border-color: #b7dfc7; background: #f1fbf5; }
.coverage-card.ok span { color: var(--green); }
.coverage-card.pending { border-color: #f0d5a7; background: #fffaf0; }
.coverage-card.pending span { color: var(--amber); }

.flow-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.flow-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}
.flow-card strong,
.flow-card span {
  display: block;
}
.flow-card strong {
  font-size: 13px;
  line-height: 1.35;
}
.flow-card span {
  margin-top: 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}
.flow-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.policy-list {
  display: grid;
  gap: 10px;
}
.policy-list article {
  border: 1px solid #edf1f5;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
.policy-list strong {
  display: block;
  font-size: 14px;
}
.policy-list p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; }
  .shell { margin-left: 0; padding: 16px; }
  nav { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .coverage-grid { grid-template-columns: repeat(2, 1fr); }
  .flow-grid { grid-template-columns: repeat(2, 1fr); }
  .grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar, .hero { align-items: stretch; flex-direction: column; }
  .hero h2 { max-width: 290px; font-size: 18px; word-break: break-all; }
  .filters, .hero-actions { flex-wrap: wrap; }
  nav { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: 1fr; }
  .coverage-grid { grid-template-columns: 1fr; }
  .flow-grid { grid-template-columns: 1fr; }
  .alert { grid-template-columns: 1fr; }
  .cadence { grid-template-columns: 1fr; }
  .sales-toolbar { flex-direction: column; }
  .range-summary { min-width: 0; grid-template-columns: 1fr; }
}
