/* Device Monitor — mobile-first dark theme */
:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c232c;
  --border: #2a313a;
  --text: #e6edf3;
  --muted: #8a939d;
  --accent: #58a6ff;
  --warn: #d29922;
  --bad:  #f85149;
  --good: #3fb950;

  --radius: 10px;
  --tap-target: 44px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
a { color: var(--accent); text-decoration: none; }
a:active { opacity: .7; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 14px; }
.warn { color: var(--warn); }

/* ----- Topbar ----- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.topbar .brand {
  font-weight: 600;
  font-size: 17px;
  flex: 1;
}
.topbar nav {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.topbar nav a {
  display: inline-flex; align-items: center;
  min-height: 36px; padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.topbar nav a:active { background: var(--surface-2); }
.topbar .user { color: var(--muted); font-size: 13px; }
.topbar .logout { color: var(--muted); font-size: 14px; }

/* Op smal scherm: brand bovenaan, nav onder */
@media (max-width: 540px) {
  .topbar { flex-wrap: wrap; }
  .topbar nav { width: 100%; justify-content: space-between; }
  .topbar .user { display: none; }
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}
h1 { margin: 0 0 8px; font-size: 22px; }
h2 { margin: 24px 0 12px; font-size: 18px; }

/* ----- Flash ----- */
.flash {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 15px;
}
.flash-error { background: rgba(248,81,73,.18); color: #ffb4ad; }
.flash-info  { background: rgba(88,166,255,.15); color: var(--accent); }

/* ----- Login ----- */
.login-box {
  max-width: 380px;
  margin: 32px auto;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login-box h1 { margin-top: 0; }
form label {
  display: block;
  margin-bottom: 14px;
  font-size: 14px;
  color: var(--muted);
}
form input[type=text],
form input[type=password] {
  display: block; width: 100%;
  padding: 12px 14px;
  margin-top: 6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* 16px → geen iOS zoom-bij-focus */
  min-height: var(--tap-target);
  -webkit-appearance: none;
}
form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

form button, .btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px;
  min-height: var(--tap-target);
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  gap: 6px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
form button:active, .btn:active { opacity: .85; transform: translateY(1px); }

.actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 12px 0 20px;
}
@media (max-width: 540px) {
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
}

.install-steps { padding-left: 22px; }
.install-steps li { margin-bottom: 12px; }
.install-steps pre { margin-top: 6px; }

@media (min-width: 541px) {
  .login-box { margin-top: 80px; padding: 32px; }
}

/* ----- Tables: desktop-style boven 720px, kaart-stijl onder ----- */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data thead th {
  background: rgba(255,255,255,.03);
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:active { background: var(--surface-2); }

/* Mobiel: compacte kaartjes, 2 regels per item, niet 1 regel per veld */
@media (max-width: 720px) {
  table.data, table.data thead, table.data tbody, table.data tr {
    display: block;
    width: 100%;
  }
  table.data { border: 0; background: transparent; }
  table.data thead { display: none; }

  table.data tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    row-gap: 4px;
    align-items: start;
  }

  /* Eerste cel = titel linksboven */
  table.data td {
    border: 0;
    padding: 0;
    font-size: 14px;
    min-width: 0;
  }
  table.data td:first-child {
    grid-column: 1;
    grid-row: 1;
    font-size: 16px;
    font-weight: 500;
    word-wrap: break-word;
  }
  /* Status / belangrijkste cijfer rechtsboven */
  table.data td.mobile-status {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    font-weight: 500;
    white-space: nowrap;
  }
  /* Meta-cellen: eigen rij per cel onder de titel — geen overlap meer */
  table.data td.mobile-meta {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 13px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
  }
  /* Cellen die op desktop nuttig zijn maar mobiel overbodig */
  table.data td.hide-mobile { display: none; }
  /* data-label labels uit op mobiel — alleen waardes tonen */
  table.data td::before { display: none; }
}

/* ----- Badges / categorieën ----- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.live  { background: rgba(63,185,80,.18); color: var(--good); }
.badge.stale { background: rgba(210,153,34,.18); color: var(--warn); }
.badge.off   { background: rgba(255,255,255,.06); color: var(--muted); }
.badge.new   { background: rgba(88,166,255,.18); color: var(--accent); }

.cat {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.cat-gaming        { background: rgba(248,81,73,.18);  color: #ff8e7a; }
.cat-streaming     { background: rgba(210,153,34,.18); color: var(--warn); }
.cat-communicatie  { background: rgba(88,166,255,.18); color: var(--accent); }
.cat-school_werk   { background: rgba(63,185,80,.18);  color: var(--good); }
.cat-browsen       { background: rgba(255,255,255,.06); color: var(--muted); }
.cat-overig        { background: rgba(255,255,255,.04); color: var(--muted); }

/* ----- Token / install ----- */
.token-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 14px 0;
}
.token-box .token {
  display: block;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
  margin-top: 6px;
  line-height: 1.4;
}

pre.install-cmd {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 8px;
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.5;
}

/* ----- Server health ----- */
.health {
  margin-top: 28px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.health ul { margin: 0; padding-left: 18px; }
.health li { margin-bottom: 4px; }

/* ----- Algemeen ----- */
section { margin-top: 24px; }
.form { max-width: 480px; }

/* ----- Device detail rapportage ----- */
.device-header { margin-bottom: 16px; }

.range-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 16px;
}
.range-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  min-height: 38px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
}
.range-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.range-btn:active { transform: translateY(1px); }

/* Summary tegels */
.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.summary-card.summary-total {
  grid-column: 1 / -1;
  background: var(--surface-2);
  border-color: var(--accent);
}
.summary-card.summary-empty { opacity: .45; }
.summary-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}
.summary-value {
  font-size: 20px;
  font-weight: 600;
}
.summary-card.summary-total .summary-value { font-size: 24px; }

/* Chart container */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
  position: relative;
  height: 280px;
}
.chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  margin: 0;
}
@media (min-width: 720px) {
  .chart-wrap { height: 340px; }
}

/* Top apps */
.top-apps {
  list-style: none;
  padding: 0; margin: 0;
}
.top-app {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  position: relative;
  overflow: hidden;
}
.top-app::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--bar-pct, 0%);
  background: var(--bar-color, var(--accent));
  opacity: .14;
  pointer-events: none;
  transition: width .25s ease;
}
.top-app-label, .top-app-value { position: relative; }
.top-app-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.top-app-label strong { font-weight: 500; }
.top-app-value { font-variant-numeric: tabular-nums; color: var(--text); }

/* ----- Selects / inline-form ----- */
form select {
  display: block; width: 100%;
  padding: 12px 14px; margin-top: 6px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 16px; min-height: var(--tap-target);
}
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 4px 0 0;
}
.inline-form input[type=password] {
  width: 160px;
  padding: 6px 10px;
  margin: 0;
}
.btn.small {
  padding: 6px 12px;
  min-height: 32px;
  font-size: 13px;
}
.btn-danger {
  background: var(--bad);
  color: #fff;
}

details > summary {
  cursor: pointer;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }

/* ----- Viewer-page styling ----- */
.viewer-page { background: var(--bg); }
.viewer-login { margin-top: 60px; }
.viewer-intro {
  background: linear-gradient(135deg, rgba(88,166,255,.10), rgba(63,185,80,.06));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.viewer-intro h1 { margin-top: 0; }
.viewer-explainer {
  margin-top: 14px;
  background: var(--surface);
  border-radius: 8px;
  padding: 10px 14px;
}
.viewer-explainer summary {
  font-weight: 500;
  padding: 4px 0;
}
.viewer-explainer ul { margin: 10px 0 4px; padding-left: 22px; }
.viewer-explainer li { margin-bottom: 6px; font-size: 14px; }

/* Big "vandaag in 1 oogopslag" tegel */
.big-status {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0 20px;
  border-left: 4px solid var(--c, var(--accent));
}
.big-status-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.big-status-pct {
  font-size: 28px; font-weight: 700;
  color: var(--c, var(--accent));
  font-variant-numeric: tabular-nums;
}
.big-status-bar {
  width: 100%; height: 12px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.big-status-fill {
  height: 100%;
  background: var(--c, var(--accent));
  transition: width .4s ease;
}
.big-status-line {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: baseline;
  font-size: 16px;
}
.big-status-line strong { font-size: 22px; }

/* Puber regel-cards */
.rules-list { list-style: none; padding: 0; margin: 0; }
.rule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.rule-card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 8px;
}
.rule-card-meta { margin-top: 6px; }
.rule-bar {
  width: 100%; height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.rule-bar-fill {
  height: 100%; background: var(--good);
  transition: width .3s ease;
}
.rule-events { list-style: disc; padding-left: 22px; }
.rule-events li { margin-bottom: 4px; }

.install-help { margin-top: 14px; text-align: center; }
.install-instructions {
  margin-top: 12px;
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
}
.install-instructions summary { cursor: pointer; padding: 6px 0; }
.install-instructions p { margin: 6px 0; }

/* ----- Heatmap ----- */
.heatmap-controls {
  display: flex; flex-wrap: wrap; gap: 16px;
  margin: 6px 0 12px;
  align-items: flex-end;
}
.heatmap-controls label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.heatmap-controls select {
  padding: 6px 10px; min-height: 36px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px;
}
.heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.heatmap-grid {
  display: grid;
  grid-template-columns: 32px repeat(24, minmax(20px, 1fr));
  gap: 2px;
  min-width: 560px;
}
.hm-hour, .hm-day {
  font-size: 11px; color: var(--muted); text-align: center;
  line-height: 1; padding: 2px 0;
}
.hm-day { text-align: right; padding-right: 6px; font-weight: 500; }
.hm-corner { /* leeg */ }
.hm-cell {
  height: 22px;
  border-radius: 3px;
  background: rgb(88 166 255 / calc(var(--i, 0) * 0.85));
  border: 1px solid rgb(88 166 255 / calc(var(--i, 0) * 0.2));
  transition: transform .1s;
}
.hm-cell:hover { transform: scale(1.15); z-index: 2; }
.hm-cell[style*="--i: 0.000"] { background: rgba(255,255,255,.02); border: 1px solid var(--border); }

/* Top-apps die linken naar app-detail */
.top-app-link {
  color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; width: 100%; text-decoration: none;
}
.top-app-link:hover { text-decoration: none; opacity: .95; }
.top-app-link::after {
  content: "›";
  color: var(--muted);
  margin-left: 4px;
  font-size: 18px;
}
