:root {
  --bg: #f6f8fa;
  --card: #ffffff;
  --ink: #1a2230;
  --muted: #5b6675;
  --line: #e3e8 ef;
  --line: #e3e8ef;
  --brand: #1f6f54;
  --brand-ink: #0f4433;
  --ok: #2f855a;
  --watch: #b7791f;
  --high: #c0392b;
  --info: #2b6cb0;
  --chip: #eef2f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--brand-ink); }
button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 0.5rem 0.9rem;
}
button.secondary { background: #fff; color: var(--brand-ink); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #9ecbb9; outline-offset: 1px;
}
input, select, textarea {
  font: inherit; padding: 0.5rem; border: 1px solid var(--line);
  border-radius: 8px; width: 100%; background: #fff; color: var(--ink);
}
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0.6rem 0 0.2rem; }

header.top {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0.75rem 1rem; position: sticky; top: 0; z-index: 5;
}
header.top .brand { font-weight: 700; color: var(--brand-ink); font-size: 1.15rem; }
header.top nav { display: flex; gap: 0.5rem; }
header.top nav a { padding: 0.35rem 0.7rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
header.top nav a.active { background: var(--chip); color: var(--ink); }
header.top .spacer { flex: 1; }
.demo-badge { background: #fff4e5; color: #92400e; border: 1px solid #fed7aa; padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; }

main { max-width: 1040px; margin: 0 auto; padding: 1rem; }
.center { max-width: 380px; margin: 6vh auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 1rem; }
h1 { font-size: 1.5rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.2rem 0 0.6rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0.9rem; box-shadow: var(--shadow); }
.kpi .n { font-size: 1.7rem; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 0.85rem; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th { background: #fbfcfe; color: var(--muted); font-weight: 600; }
tr.clickable:hover { background: #f2f7f5; cursor: pointer; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.ok { background: #e6f4ec; color: var(--ok); }
.badge.watch { background: #fdf3e3; color: var(--watch); }
.badge.high_priority { background: #fdecea; color: var(--high); }
.badge.irregular { background: #eef2fb; color: var(--info); }
.badge.insufficient_data { background: #eef1f4; color: var(--muted); }
.badge.seasonal { background: #eaf6f0; color: #2c7a7b; }
.badge.paused, .badge.excluded { background: #eef1f4; color: var(--muted); }

.signal { border-left: 3px solid var(--line); padding: 0.4rem 0.7rem; margin: 0.4rem 0; background: #fbfcfe; border-radius: 0 8px 8px 0; }
.signal.high_priority { border-color: var(--high); }
.signal.watch, .signal.late { border-color: var(--watch); }
.signal.revenue_decline { border-color: var(--info); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 0.5rem; }
.bar { flex: 1; background: #cfe6db; border-radius: 3px 3px 0 0; min-height: 2px; }
.error { background: #fdecea; color: var(--high); border: 1px solid #f5c6c0; padding: 0.6rem 0.8rem; border-radius: 8px; margin: 0.5rem 0; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.back { background: none; border: none; color: var(--brand-ink); padding: 0; text-decoration: underline; }

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  header.top nav a span { display: none; }
  table.responsive thead { display: none; }
  table.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 0.4rem 0; }
  table.responsive td { display: flex; justify-content: space-between; border: none; padding: 0.25rem 0.7rem; }
  table.responsive td::before { content: attr(data-l); color: var(--muted); font-size: 0.8rem; }
}
