:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e3e2de;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #8a8984;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --bad-text: #b02a2a;
  --warn: #fab219;
  --good-bg: #e6f4e6;
  --bad-bg: #fbe9e9;
  --warn-bg: #fdf3dc;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #8a8984;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good-text: #4cc94c;
    --bad-text: #ef7a7a;
    --good-bg: #16301a;
    --bad-bg: #3a1d1d;
    --warn-bg: #3a3017;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #2e2e2b;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --text-3: #8a8984;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --good-text: #4cc94c;
  --bad-text: #ef7a7a;
  --good-bg: #16301a;
  --bad-bg: #3a1d1d;
  --warn-bg: #3a3017;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 7px 14px;
}
button:hover { border-color: var(--text-3); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */
body.auth { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; margin: 0; }
.auth-card { margin: auto; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 32px; width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 20px; margin: 8px 0 8px; }
.auth-card p { color: var(--text-2); }
.auth-card form { margin: 0; }
.auth-card button { display: block; width: 100%; padding: 11px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; margin-top: 8px; }
.brand { font-weight: 700; letter-spacing: .02em; color: var(--text-3); font-size: 12px; text-transform: uppercase; }

/* ---------- Layout ---------- */
.wrap { max-width: 1440px; margin: 0 auto; padding: 16px 16px 48px; }
header.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
header.top h1 { font-size: 20px; margin: 0; }
header.top .meta { color: var(--text-3); font-size: 13px; }
header.top .actions { margin-left: auto; display: flex; gap: 8px; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.kpi .label { color: var(--text-2); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { color: var(--text-3); font-size: 12px; }
.kpi.muted .value { color: var(--text-3); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(12,163,12,.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(12,163,12,0); } 100% { box-shadow: 0 0 0 0 rgba(12,163,12,0); } }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } }

section.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; min-width: 0; }
section.card > h2 { font-size: 14px; margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
section.card > h2 .hint { color: var(--text-3); font-weight: 400; font-size: 12px; }
section.card > h2 .right { margin-left: auto; font-weight: 400; }
.card-body { padding: 12px 16px; }
.empty { color: var(--text-3); padding: 16px; font-size: 13px; }

/* ---------- Delta's ---------- */
.delta { font-size: 12px; font-weight: 600; white-space: nowrap; border-radius: 5px; padding: 1px 6px; }
.delta.up { color: var(--good-text); background: var(--good-bg); }
.delta.down { color: var(--bad-text); background: var(--bad-bg); }
.delta.flat { color: var(--text-3); background: var(--surface-2); }

/* ---------- Insights ---------- */
.insights { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow: auto; }
.insights li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; padding: 9px 16px; border-bottom: 1px solid var(--border); align-items: start; }
.insights li:last-child { border-bottom: 0; }
.insights .ic { font-size: 13px; line-height: 20px; text-align: center; font-weight: 700; }
.insights .up .ic { color: var(--good-text); }
.insights .down .ic { color: var(--bad-text); }
.insights .alert { background: var(--bad-bg); }
.insights .alert .ic { color: var(--bad-text); }
.insights .info .ic { color: var(--text-3); }
.insights .t { font-weight: 550; overflow-wrap: anywhere; }
.insights .d { color: var(--text-2); font-size: 12px; overflow-wrap: anywhere; }
.insights .src { color: var(--text-3); font-size: 11px; white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
th { color: var(--text-3); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
th:first-child, td:first-child { text-align: left; padding-left: 16px; }
td:first-child { font-weight: 550; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.clickable td:first-child::before { content: "▸"; color: var(--text-3); display: inline-block; width: 14px; transition: transform .15s; }
tr.clickable.open td:first-child::before { transform: rotate(90deg); }
tr.detail td { background: var(--surface-2); white-space: normal; text-align: left; padding: 12px 16px; }
td.muted, .muted { color: var(--text-3); }
td .online { color: var(--good-text); font-weight: 600; }

.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.details h4 { margin: 0 0 6px; font-size: 12px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.details ol { margin: 0; padding: 0; list-style: none; }
.details li { display: flex; gap: 8px; justify-content: space-between; font-size: 13px; padding: 2px 0; }
.details li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.details li .v { font-variant-numeric: tabular-nums; color: var(--text-2); flex: none; }
.details li .v.up { color: var(--good-text); }
.details li .v.down { color: var(--bad-text); }

/* ---------- Sparkline + tooltip ---------- */
svg.spark { display: block; overflow: visible; }
svg.spark .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.spark .area { fill: var(--series-1); opacity: .12; }
svg.spark .bar { fill: var(--series-1); }
svg.spark .bar.last { fill: var(--series-2); }
svg.spark .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
svg.spark .hit { fill: transparent; }
#tip { position: fixed; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px; z-index: 10; display: none; white-space: nowrap; }

/* ---------- Uptime / status ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px 3px 8px; display: inline-flex; align-items: center; gap: 6px; background: var(--surface); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.chip.bad { background: var(--bad-bg); border-color: var(--bad); color: var(--bad-text); font-weight: 600; }
.chip.bad .dot { background: var(--bad); }
.chip.warn .dot { background: var(--warn); }
.chip .ms { color: var(--text-3); }

.sources { list-style: none; margin: 0; padding: 0; }
.sources li { display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.sources li:last-child { border-bottom: 0; }
.sources .st { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.sources .ok { background: var(--good); }
.sources .err { background: var(--bad); }
.sources .off { background: transparent; border: 2px solid var(--text-3); }
.sources .help { color: var(--text-3); font-size: 12px; overflow-wrap: anywhere; }
.sources .errtxt { color: var(--bad-text); font-size: 12px; overflow-wrap: anywhere; }

.reviews { list-style: none; margin: 0; padding: 0; }
.reviews li { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.reviews li:last-child { border-bottom: 0; }
.reviews .stars { color: var(--warn); letter-spacing: 1px; }
.reviews .low .stars { color: var(--bad); }
.reviews .rt { font-weight: 600; }
.reviews .rb { color: var(--text-2); font-size: 13px; }
.reviews .rm { color: var(--text-3); font-size: 12px; }

.banner { background: var(--warn-bg); border: 1px solid var(--warn); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 10px 12px; }
  .kpi .value { font-size: 20px; }
  .kpi .sub { font-size: 11px; }
  header.top .actions { margin-left: 0; width: 100%; }
}

/* ---------- Header-badge ---------- */
.badge { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
button.icon { border: 0; background: transparent; font-size: 18px; padding: 4px 8px; color: var(--text-2); }
button.icon:hover { color: var(--text); }
.banner.bad { background: var(--bad-bg); border-color: var(--bad); }
.banner .grow { flex: 1; min-width: 200px; }
.banner .small { color: var(--text-2); font-size: 12px; }

/* ---------- Klikbare rijen & meldingen ---------- */
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--surface-2); }
tr.link td:first-child::after { content: " ›"; color: var(--text-3); }
.insights li.clickable { cursor: pointer; }
.insights li.clickable:hover { background: var(--surface-2); }
.insights li.alert.clickable:hover { filter: brightness(.97); }

/* ---------- Verkeersbronnen (gestapelde balk) ---------- */
.src-bar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; gap: 2px; min-width: 110px; background: var(--surface); }
.src-bar span { display: block; height: 100%; }
.src-bar.lg { height: 18px; border-radius: 4px; }
.src-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.src-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.s-searches { background: #2a78d6; } .s-direct { background: #eb6834; } .s-links { background: #1baf7a; }
.s-social { background: #e87ba4; } .s-ai { background: #4a3aa7; } .s-email { background: #eda100; }
.s-ads { background: #008300; } .s-other { background: var(--text-3); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .s-searches { background: #3987e5; } :root:not([data-theme="light"]) .s-direct { background: #d95926; }
  :root:not([data-theme="light"]) .s-links { background: #199e70; } :root:not([data-theme="light"]) .s-social { background: #d55181; }
  :root:not([data-theme="light"]) .s-ai { background: #9085e9; } :root:not([data-theme="light"]) .s-email { background: #c98500; }
}

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(880px, 100vw); background: var(--bg); border-left: 1px solid var(--border); z-index: 21; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head h2 { margin: 0; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { overflow-y: auto; padding: 16px 20px 40px; }
.drawer-body section.card { margin-bottom: 14px; }
.drawer-body .kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.drawer-body .kpi .value { font-size: 22px; }
.sub-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; color: var(--text-2); font-size: 13px; }
.loading { color: var(--text-3); padding: 40px 0; text-align: center; }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }

/* Grote staafgrafiek */
.chart { padding: 12px 16px 10px; }
.chart .axis { display: flex; justify-content: space-between; color: var(--text-3); font-size: 11px; margin-top: 4px; }
.chart .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.chart .top b { font-size: 13px; }
.chart .top span { color: var(--text-3); font-size: 12px; }
svg.big { display: block; width: 100%; overflow: visible; }
svg.big .bar { fill: var(--series-1); }
svg.big .bar.partial { fill: var(--series-2); }
svg.big .grid { stroke: var(--border); stroke-width: 1; }
svg.big .hit { fill: transparent; }
svg.big .hit:hover + .bar, svg.big .bar:hover { opacity: .8; }
.charts-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 14px; }

/* Vergelijkingstabel vandaag/gisteren */
table.cmp td, table.cmp th { padding: 6px 12px; }
table.cmp td:first-child { font-weight: 450; max-width: 360px; }
table.cmp .share { width: 70px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 14px; }

/* Uitloggen in instellingen */
.settings-foot { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.badge[hidden], [hidden] { display: none !important; }
.grid-cards table.cmp td:first-child { max-width: 200px; }

/* ---------- Mobiel: compact, enkel de belangrijkste kolommen ---------- */
@media (max-width: 700px) {
  body { font-size: 13px; }
  .wrap { padding: 10px 10px 32px; }
  header.top { gap: 6px; margin-bottom: 10px; }
  header.top h1 { font-size: 18px; }
  header.top .meta { font-size: 11px; width: 100%; order: 3; }
  header.top .actions { margin-left: auto; width: auto; }
  header.top .actions button { padding: 5px 10px; font-size: 12px; }
  .kpis { gap: 6px; margin-bottom: 10px; }
  .kpi { padding: 8px 10px; }
  .kpi .label { font-size: 11px; }
  .kpi .value { font-size: 18px; margin: 0; }
  .kpi .sub { font-size: 10.5px; line-height: 1.35; }
  .grid-2 { gap: 10px; margin-bottom: 10px; }
  section.card { margin-bottom: 10px; }
  section.card > h2 { padding: 9px 12px; font-size: 13px; }
  section.card > h2 .hint { display: none; }
  .insights { max-height: 340px; }
  .insights li { padding: 7px 12px; grid-template-columns: 16px 1fr; }
  .insights .src { display: none; }
  .insights .d { font-size: 11.5px; }
  .reviews li { padding: 8px 12px; }
  th, td { padding: 6px 6px; }
  th:first-child, td:first-child { padding-left: 10px; }
  td:first-child { max-width: 140px; }
  th { font-size: 11px; white-space: normal; line-height: 1.2; }
  td:first-child { max-width: 120px; }
  .delta { font-size: 11px; padding: 1px 4px; }
  .src-legend { font-size: 11px; }
  .chips { gap: 4px; }
  .chip { font-size: 11px; padding: 2px 8px 2px 6px; }
  .chip .ms { display: none; }
  .banner { padding: 8px 10px; font-size: 12px; margin-bottom: 10px; }

  /* Verborgen kolommen per tabel */
  #web th:nth-child(4), #web td:nth-child(4),
  #web th:nth-child(7), #web td:nth-child(7),
  #web th:nth-child(8), #web td:nth-child(8),
  #web th:nth-child(9), #web td:nth-child(9),
  #web .src-legend,
  #apps th:nth-child(3), #apps td:nth-child(3),
  #apps th:nth-child(4), #apps td:nth-child(4),
  #apps th:nth-child(5), #apps td:nth-child(5),
  #apps th:nth-child(6), #apps td:nth-child(6),
  #apps th:nth-child(9), #apps td:nth-child(9),
  #apps th:nth-child(10), #apps td:nth-child(10),
  #apps th:nth-child(11), #apps td:nth-child(11),
  #gsc th:nth-child(3), #gsc td:nth-child(3),
  #gsc th:nth-child(5), #gsc td:nth-child(5),
  #adsense th:nth-child(4), #adsense td:nth-child(4),
  #adsense th:nth-child(5), #adsense td:nth-child(5),
  #cloudflare th:nth-child(4), #cloudflare td:nth-child(4),
  #cloudflare th:nth-child(5), #cloudflare td:nth-child(5),
  #cloudflare th:nth-child(6), #cloudflare td:nth-child(6),
  table.cmp:not(.src-table) th:nth-child(4), table.cmp:not(.src-table) td:nth-child(4),
  table.src-table th:nth-child(3), table.src-table td:nth-child(3), table.src-table th:nth-child(5), table.src-table td:nth-child(5) { display: none; }

  /* Detailpaneel */
  .drawer-head { padding: 10px 12px; }
  .drawer-head h2 { font-size: 16px; }
  .drawer-body { padding: 10px 10px 32px; }
  .drawer-body .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-body .kpi .value { font-size: 17px; }
  .chart { padding: 8px 12px; }
  .grid-cards, .charts-2 { grid-template-columns: 1fr; }
  .grid-cards table.cmp td:first-child, table.cmp td:first-child { max-width: 180px; }
  .details { grid-template-columns: 1fr; gap: 10px; }
  .sources li { padding: 8px 12px; }
}

/* ---------- Thema-schakelaar ---------- */
.theme-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.theme-switch button { border: 0; border-radius: 0; background: transparent; padding: 6px 10px; color: var(--text-3); font-size: 14px; line-height: 1; }
.theme-switch button + button { border-left: 1px solid var(--border); }
.theme-switch button[aria-checked="true"] { background: var(--surface-2); color: var(--text); }
.theme-switch button:hover { color: var(--text); }
@media (max-width: 700px) { .theme-switch button { padding: 5px 8px; font-size: 12px; } }

/* Donkere varianten van de bronkleuren ook bij handmatig gekozen donker thema */
:root[data-theme="dark"] .s-searches { background: #3987e5; } :root[data-theme="dark"] .s-direct { background: #d95926; }
:root[data-theme="dark"] .s-links { background: #199e70; } :root[data-theme="dark"] .s-social { background: #d55181; }
:root[data-theme="dark"] .s-ai { background: #9085e9; } :root[data-theme="dark"] .s-email { background: #c98500; }
