/* Look: warm neutral background, rounded white cards, big black numbers,
   a yellow highlight card for WhatsApp results and purple accents. */
:root {
  --bg: #ebe4dd;
  --bg-top: #f4efea;
  --card: #ffffff;
  --ink: #141414;
  --muted: #5f5852;           /* 6.6:1 on white: readable small text */
  --line: #ece5de;
  --yellow: #f6d15e;
  --yellow-ink: #221b04;
  --purple: #5b4bd6;          /* 6.3:1 on white */
  --purple-soft: #ebe8fd;
  --good: #17703f;
  --bad: #b3261e;
  --warn-bg: #fff4d6;
  --error-bg: #fde8e6;
  --info-bg: #ebe8fd;
  --nodata: #f1ece6;
  --radius: 28px;
  --radius-sm: 16px;
  --shadow: 0 1px 2px rgba(40, 30, 20, .04), 0 8px 24px rgba(40, 30, 20, .05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-top) 0, var(--bg) 480px) var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
code { font: 500 .85em ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--nodata); padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
a { color: var(--purple); }
:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; }
.skip:focus { left: 16px; z-index: 10; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  max-width: 1240px; margin: 16px auto 0; padding: 12px 14px 12px 22px;
  background: var(--card); border-radius: 999px; box-shadow: var(--shadow);
  width: calc(100% - 32px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.03em; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: conic-gradient(from 45deg, var(--yellow) 0 25%, var(--ink) 0 50%, var(--yellow) 0 75%, var(--ink) 0); }
.topbar-meta { flex: 1 1 auto; color: var(--muted); font-size: .95rem; text-align: center; min-width: 0; }
.status { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 999px; font-weight: 500; font-size: .95rem; background: var(--ink); color: #fff; }
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: #7ee0a6; }
.status.late { background: var(--yellow); color: var(--yellow-ink); }
.status.late .dot { background: var(--yellow-ink); }
.status.failed { background: var(--bad); }
.status.failed .dot { background: #fff; }
.status.never { background: var(--nodata); color: var(--ink); }
.status.never .dot { background: var(--muted); }

/* Page */
/* minmax(0, 1fr): a wide table scrolls inside its card instead of stretching the whole page on phones */
.wrap { max-width: 1240px; margin: 0 auto; padding: 32px 16px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.intro { padding: 8px 8px 4px; display: grid; gap: 6px; }
.intro h1 { font-size: clamp(2.4rem, 6vw, 4rem); letter-spacing: -0.045em; }
.intro-range { font-size: 1.15rem; }
.muted { color: var(--muted); font-size: .95rem; }

.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: grid; gap: 12px; align-content: start; min-width: 0; }

/* Filters */
.filters { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; gap: 14px; padding: 18px 20px; border-radius: var(--radius-sm); }
.filters label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); font-weight: 500; }
.filters select, .filters input, .login input {
  font: inherit; color: var(--ink); min-height: 44px; padding: 8px 14px;
  border: 1px solid #ddd4cb; border-radius: 999px; background: var(--bg-top); width: 100%;
}
.filters button, .login button {
  font: inherit; font-weight: 500; min-height: 44px; padding: 8px 26px; border: 0;
  border-radius: 999px; background: var(--ink); color: #fff; cursor: pointer;
}
.filters button:hover, .login button:hover { background: #333; }

/* Log out (top bar) */
.logout { margin: 0; }
.logout button {
  font: inherit; font-size: .9rem; font-weight: 500; min-height: 40px; padding: 8px 16px;
  border: 1px solid #ddd4cb; border-radius: 999px; background: transparent; color: var(--ink); cursor: pointer;
}
.logout button:hover { background: var(--bg-top); }

/* Password page */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(100%, 400px); gap: 18px; padding: 32px 28px; }
.login h1 { font-size: 2.4rem; letter-spacing: -0.04em; }
.login label { display: grid; gap: 6px; font-size: .9rem; color: var(--muted); font-weight: 500; }
.filters-hint { grid-column: 1 / -1; font-size: .85rem; color: var(--muted); }

/* Notices */
.notice { padding: 14px 20px; border-radius: var(--radius-sm); font-weight: 500; }
.notice.warn { background: var(--warn-bg); }
.notice.error { background: var(--error-bg); color: #6e1510; }
.notice.info { background: var(--info-bg); color: #2c2370; }

/* Key numbers */
.kpis { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) { .kpis { grid-template-columns: minmax(320px, 5fr) minmax(0, 7fr); } }
.kpi-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpi-label { font-size: .95rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-value { font-size: clamp(1.8rem, 3.2vw, 2.4rem); font-weight: 500; letter-spacing: -0.035em; line-height: 1.05; }
.kpi-compare { font-size: .88rem; color: var(--muted); }
.delta { font-weight: 600; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.neutral { color: var(--ink); }

.hero { background: var(--yellow); color: var(--yellow-ink); gap: 14px; }
.hero .kpi-label, .hero .kpi-compare, .hero-note { color: #4a3d0c; }
.hero .delta.neutral { color: var(--yellow-ink); }
.hero .delta.good { color: #0f5530; }
.hero .delta.bad { color: #8f1d17; }
.hero-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-value { font-size: clamp(4rem, 11vw, 7.5rem); font-weight: 500; letter-spacing: -0.06em; line-height: .95; }
.hero-value-empty { font-size: clamp(2.2rem, 6vw, 3.2rem); letter-spacing: -0.04em; }
.hero-split { border-top: 1px solid rgba(34, 27, 4, .18); padding-top: 14px; display: grid; gap: 6px; }
.hero-note { font-size: .85rem; }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--purple); color: #fff; font-size: .82rem; font-weight: 500; }

/* Charts */
.charts { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .bar.ink { fill: var(--ink); }
.chart .bar.purple { fill: var(--purple); }
.chart .nodata { fill: var(--nodata); }
details summary { cursor: pointer; color: var(--purple); font-weight: 500; font-size: .92rem; min-height: 32px; display: flex; align-items: center; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-weight: 500; color: var(--muted); font-size: .82rem; white-space: nowrap; }
tbody th { font-weight: 500; }
.data tbody th { min-width: 180px; }
.num { text-align: right; white-space: nowrap; }
tfoot th, tfoot td { font-weight: 600; border-bottom: 0; border-top: 2px solid var(--ink); }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.definitions td:last-child { min-width: 200px; }

/* Data status */
.sync dl { margin: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.sync dt { font-size: .85rem; color: var(--muted); }
.sync dd { margin: 2px 0 0; font-weight: 500; }
.errors { margin: 0; padding-left: 18px; display: grid; gap: 6px; font-size: .92rem; }
.errors time { color: var(--muted); margin-right: 6px; }
.empty-state { padding: 40px 28px; }

@media (max-width: 640px) {
  .topbar { border-radius: var(--radius-sm); padding: 12px 16px; }
  .topbar-meta { order: 3; flex-basis: 100%; text-align: left; }
  .card { padding: 20px; border-radius: 22px; }
}

@media (prefers-reduced-motion: no-preference) {
  .filters button { transition: background .15s ease; }
}
