:root {
  color-scheme: light;
  --brand: #00bf6f;
  --brand-ink: #00804a;
  --ink: #111312;
  --ink-2: #4d5550;
  --ink-3: #7c847f;
  --line: #e4e8e6;
  --line-2: #f0f3f1;
  --surface: #ffffff;
  --page: #f6f8f7;
  --neg: #c62f3a;
  --s1: #00a862;
  --s2: #6250d6;
  --s3: #eda100;
  --s4: #2a78d6;
  --s5: #eb6834;
  --radius: 12px;
  --font-head: "Montserrat", system-ui, sans-serif;
  --font-body: "Roboto", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 400 14px/1.45 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); margin: 0; }

/* Header */
.topbar {
  background: #000;
  color: #fff;
  border-bottom: 3px solid var(--brand);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.topbar img { height: 34px; width: auto; display: block; }
.topbar .title { display: flex; flex-direction: column; }
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.topbar .subtitle { font-size: 12px; color: #b8c0bb; }
.topbar .spacer { flex: 1; }
.sync { font-size: 12px; color: #b8c0bb; display: flex; align-items: center; gap: 8px; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.sync.stale .dot { background: #eda100; }
.sync.error .dot { background: var(--neg); }
.btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid #3a3f3c;
  border-radius: 8px;
  padding: 7px 14px;
  font: 500 13px var(--font-body);
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

main { max-width: 1280px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-top: 3px solid var(--brand);
}
.kpi .label { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .5px; font-weight: 500; }
.kpi .value { font: 700 24px/1.2 var(--font-head); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.kpi .value.neg { color: var(--neg); }

/* Cards */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card h2 { font-size: 15px; font-weight: 700; }
.card .meta { font-size: 12px; color: var(--ink-3); }
.card .total { font: 600 13px var(--font-head); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 300px; }
.card.wide .chart-box { height: 280px; }

/* DRE */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.dre { border-collapse: collapse; width: 100%; min-width: 1100px; font-variant-numeric: tabular-nums; }
.dre th, .dre td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-2); }
.dre th { font: 600 12px var(--font-head); color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--line); }
.dre th:first-child, .dre td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
  min-width: 250px;
}
.dre .fy { border-left: 2px solid var(--line); font-weight: 600; }
.dre tr.total td { font-weight: 700; background: #f1faf5; }
.dre tr.total td:first-child { background: #f1faf5; box-shadow: inset 3px 0 0 var(--brand); }
.dre tr.sub td { color: var(--ink-2); font-size: 13px; }
.dre tr.sub td:first-child { padding-left: 28px; }
.dre tr.margin td { color: var(--ink-3); font-style: italic; font-size: 13px; }
.dre td.neg { color: var(--neg); }
.dre tbody tr:hover td { background: #f7fbf9; }
.dre tbody tr.total:hover td { background: #e8f6ee; }

.error-banner {
  background: #fdecee; color: #8c1d26; border: 1px solid #f5c2c7;
  border-radius: var(--radius); padding: 12px 16px; display: none;
}
.error-banner.show { display: block; }
.footnote { font-size: 12px; color: var(--ink-3); text-align: center; padding: 8px 0 24px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #000; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 32px 28px;
  border-top: 4px solid var(--brand);
}
.login-card .logo-wrap { background: #000; border-radius: 10px; padding: 14px; display: flex; justify-content: center; margin-bottom: 22px; }
.login-card img { height: 48px; }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card p { color: var(--ink-2); margin: 0 0 20px; font-size: 13px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.field input {
  font: 400 15px var(--font-body); padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0, 191, 111, .18); }
.btn-primary {
  width: 100%; background: var(--brand); color: #000; border: 0; border-radius: 8px; padding: 12px;
  font: 700 14px var(--font-head); cursor: pointer; margin-top: 6px;
}
.btn-primary:hover { background: #00a862; }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.login-error { color: var(--neg); font-size: 13px; min-height: 18px; margin-top: 10px; }

@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  main { padding: 16px; gap: 16px; }
  .topbar-inner { padding: 12px 16px; gap: 12px; flex-wrap: wrap; }
  .topbar img { height: 28px; }
  .topbar .subtitle { display: none; }
  .sync { order: 5; width: 100%; }
  .kpi .value { font-size: 20px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .chart-box, .card.wide .chart-box { height: 260px; }
  .card-head { flex-direction: column; gap: 2px; }
  .dre th:first-child, .dre td:first-child { min-width: 168px; max-width: 168px; white-space: normal; }
  .dre tr.sub td:first-child { padding-left: 18px; }
  table.dre { font-size: 13px; }
}
