:root {
  --ink: #1d2a2e;
  --muted: #64737a;
  --bg: #f5f3ee;
  --card: #fff;
  --line: #e4e0d6;
  --brand: #16353c;
  --accent: #e9c46a;
  --good: #2a9d5c;
  --warn: #e0a100;
  --bad: #d1495b;
  --radius: 12px;
  color-scheme: light;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
code { background: #efece4; padding: 1px 5px; border-radius: 4px; font-size: .85em; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100dvh; }
.sidebar { background: var(--brand); color: #e8eeef; padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100dvh; }
.sidebar a { color: inherit; text-decoration: none; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 1.15rem; padding: 0 8px; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar nav a { display: block; padding: 9px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: rgb(255 255 255 / .08); }
.sidebar nav a[aria-current="page"] { background: var(--accent); color: var(--brand); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 0 8px; opacity: .85; }
.sidebar-foot p { margin: 0 0 6px; }
.sidebar-foot a { text-decoration: underline; }

main#view { padding: 28px clamp(16px, 3vw, 40px); max-width: 1400px; width: 100%; outline: none; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.7rem; font-weight: 700; margin: 4px 0; }
.up { color: var(--good); }
.down { color: var(--bad); }
.flat { color: var(--muted); }

.btn, button { font: inherit; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; }
button.secondary, .btn.secondary { background: transparent; color: var(--brand); }
button:disabled { opacity: .5; cursor: progress; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; padding: 11px 18px; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group button { border-radius: 0; background: transparent; color: var(--brand); }
.btn-group button:first-child { border-radius: 8px 0 0 8px; }
.btn-group button:last-child { border-radius: 0 8px 8px 0; }
.btn-group button[aria-pressed="true"] { background: var(--brand); color: #fff; }

input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: inherit; }
textarea { width: 100%; min-height: 110px; }
label { display: grid; gap: 4px; font-size: .9rem; }
form.inline, .toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 14px; display: grid; gap: 12px; }
legend { font-weight: 600; padding: 0 6px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
th[data-sort] { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.url { max-width: 420px; overflow-wrap: anywhere; }
tr:hover td { background: #faf8f3; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: #eee; }
.badge.high, .badge.bad { background: #fbe3e6; color: var(--bad); }
.badge.medium, .badge.warn { background: #fdf1d0; color: #8a6400; }
.badge.low, .badge.good { background: #dff3e7; color: var(--good); }
.badge.info { background: #e3eef5; color: #2a5d7c; }

.share { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; min-width: 80px; }
.share > span { display: block; height: 100%; background: var(--brand); width: calc(var(--w, 0) * 100%); }
.spark { display: inline-flex; gap: 2px; align-items: end; height: 22px; }
.spark span { width: 6px; background: var(--brand); opacity: .7; height: calc(var(--h, 0) * 100%); min-height: 1px; border-radius: 1px; }

details { border-top: 1px solid var(--line); padding: 10px 0; }
details summary { cursor: pointer; font-weight: 600; }

.empty { text-align: center; padding: 40px 20px; }
.empty p { max-width: 560px; margin: 8px auto 16px; }
progress { width: 100%; height: 10px; accent-color: var(--brand); }
.chart-box { position: relative; height: 280px; }

#map { height: 560px; border-radius: var(--radius); border: 1px solid var(--line); }
.rank-pin { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; font-size: 13px; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / .35); background: var(--c, #888); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .8rem; margin-top: 8px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-right: 5px; vertical-align: -2px; }

.status-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.notice { background: #fff8e6; border: 1px solid #f0dca0; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; }

#toast { position: fixed; inset: auto 20px 20px auto; margin: 0; border: 0; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; max-width: 420px; }
#toast.error { background: var(--bad); }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 36px; max-width: 420px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.login-card .logo { width: 48px; height: 48px; }
.login-card p { margin: 0; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav ul { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
