:root {
  --bg: #0a0a0b;
  --surface: #141417;
  --surface2: #1c1c21;
  --border: #2a2a30;
  --text: #f0f0f2;
  --text-muted: #8b8b95;
  --muted: #8b8b95;
  --accent: #3b9eff;
  --accent-dim: rgba(59,158,255,.12);
  --ok: #2dd4a8;
  --warn: #f5b942;
  --err: #ff5c6a;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --radius: 14px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--text); font-family:Inter,system-ui,sans-serif; line-height:1.5; -webkit-font-smoothing:antialiased; }
a { color:var(--accent); text-decoration:none; }
a:hover { text-decoration:underline; }

/* ── Shell ── */
.app-shell { display:flex; min-height:100vh; }

/* ── Sidebar ── */
.sidebar {
  width:var(--sidebar-w); flex-shrink:0;
  background:var(--surface); border-right:1px solid var(--border);
  padding:20px 14px; display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh; overflow-y:auto;
  transition:transform .28s cubic-bezier(.4,0,.2,1);
  z-index:200;
}
.sidebar-close { display:none; }

/* ── Brand ── */
.brand { display:flex; gap:12px; align-items:center; padding:4px 8px 28px; }
.brand-icon {
  width:40px; height:40px; border-radius:12px;
  background:linear-gradient(135deg,var(--accent),#6366f1);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:14px; color:#fff; flex-shrink:0;
}
.brand-title { font-weight:800; font-size:16px; letter-spacing:-.02em; }
.brand-sub { font-size:11px; color:var(--muted); margin-top:1px; }

/* ── Nav ── */
.nav-group { margin-bottom:20px; }
.nav-label { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); padding:0 12px 8px; }
.nav-item {
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border-radius:10px; color:var(--text);
  font-weight:600; font-size:14px; margin-bottom:2px; text-decoration:none;
  transition:background .15s, color .15s;
}
.nav-item:hover { background:var(--surface2); text-decoration:none; }
.nav-item.active { background:var(--accent-dim); color:var(--accent); }
.nav-ico { width:18px; text-align:center; opacity:.85; font-size:15px; flex-shrink:0; }

/* ── Sidebar footer ── */
.sidebar-foot { margin-top:auto; padding:12px; font-size:11px; color:var(--muted); line-height:1.6; }
.foot-pill { display:inline-block; background:var(--surface2); border:1px solid var(--border); border-radius:999px; padding:3px 10px; margin-bottom:6px; font-size:10px; color:var(--accent); }

/* ── Backdrop (mobile) ── */
.nav-backdrop {
  display:none; position:fixed; inset:0; z-index:190;
  background:rgba(0,0,0,.55); backdrop-filter:blur(2px);
  opacity:0; transition:opacity .25s;
}
.nav-backdrop.visible { opacity:1; }

/* ── Hamburger ── */
.hamburger {
  display:none; flex-direction:column; justify-content:center; gap:5px;
  background:none; border:none; cursor:pointer; padding:6px;
  border-radius:8px; color:var(--text); flex-shrink:0;
}
.hamburger:hover { background:var(--surface2); }
.hamburger span {
  display:block; width:22px; height:2px;
  background:currentColor; border-radius:2px;
  transition:transform .2s, opacity .2s;
}

/* ── Topbar ── */
.topbar {
  display:flex; align-items:center; justify-content:space-between;
  padding:0 24px; height:var(--topbar-h);
  border-bottom:1px solid var(--border);
  background:rgba(10,10,11,.88); backdrop-filter:blur(10px);
  position:sticky; top:0; z-index:100; gap:12px;
}
.topbar-left { display:flex; align-items:center; gap:12px; min-width:0; }
.topbar-actions { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.page-title { font-size:18px; font-weight:800; letter-spacing:-.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ── Main content ── */
.main-wrap { flex:1; min-width:0; display:flex; flex-direction:column; }
.content { flex:1; padding:24px 28px 48px; max-width:1280px; width:100%; }

/* ── Typography ── */
h1 { margin:0 0 6px; font-size:24px; font-weight:800; }
h2 { margin:0 0 14px; font-size:16px; font-weight:700; }
h3 { margin:0 0 10px; font-size:14px; font-weight:700; }
.lead { color:var(--muted); font-size:14px; margin:0 0 20px; }
.muted { color:var(--muted); }
.small { font-size:12px; }
.mono { font-family:ui-monospace,monospace; }

/* ── Stats grid ── */
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:12px; margin-bottom:20px; }
.stat { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:16px; }
.stat-val { font-size:26px; font-weight:800; line-height:1.1; }
.stat-lbl { font-size:10px; color:var(--muted); text-transform:uppercase; letter-spacing:.06em; margin-top:4px; font-weight:600; }
.stat.accent .stat-val { color:var(--accent); }
.stat.highlight .stat-val { color:var(--ok); }

/* ── Card ── */
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:20px; margin-bottom:16px; }
.card-header { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; flex-wrap:wrap; }
.card-title { font-size:14px; font-weight:700; }
.card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:16px; }

/* ── Grids ── */
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }

/* ── Toolbar ── */
.toolbar { display:flex; flex-wrap:wrap; gap:8px; margin:16px 0; align-items:center; }

/* ── Buttons ── */
.btn {
  background:var(--accent); color:#fff; border:none;
  padding:9px 16px; border-radius:10px; font-weight:700; font-size:13px;
  cursor:pointer; font-family:inherit; text-decoration:none;
  display:inline-flex; align-items:center; gap:6px; white-space:nowrap;
  transition:opacity .15s;
}
.btn:hover { opacity:.88; text-decoration:none; }
.btn:active { opacity:.75; }
.btn.ghost { background:transparent; color:var(--text); border:1px solid var(--border); }
.btn.ghost:hover { background:var(--surface2); }
.btn.btn-outline { background:transparent; color:var(--text); border:1px solid var(--border); }
.btn.danger { background:transparent; color:var(--err); border:1px solid rgba(255,92,106,.35); }
.btn.sm, .btn.btn-xs { padding:5px 11px; font-size:12px; border-radius:8px; }

/* ── Tables ── */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; border:1px solid var(--border); border-radius:var(--radius); }
.table, .data-table { width:100%; border-collapse:collapse; font-size:13px; }
.table th, .table td,
.data-table th, .data-table td { padding:11px 14px; border-bottom:1px solid var(--border); text-align:left; vertical-align:middle; }
.table th, .data-table th { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.06em; font-weight:700; background:var(--surface2); white-space:nowrap; }
.table tr:last-child td, .data-table tr:last-child td { border-bottom:none; }

/* ── Pills ── */
.pill { display:inline-flex; padding:3px 10px; border-radius:999px; font-size:11px; font-weight:600; background:var(--surface2); border:1px solid var(--border); }
.pill.ok { background:rgba(45,212,168,.12); color:var(--ok); border-color:rgba(45,212,168,.25); }
.pill.off { opacity:.55; }
.pill.warn { background:rgba(245,185,66,.12); color:var(--warn); }

/* ── Forms ── */
.form label { display:block; margin-bottom:14px; font-size:12px; font-weight:600; color:var(--muted); }
.form input, .form textarea, .form select,
input[type="text"], input[type="email"], input[type="password"], select, textarea {
  background:var(--bg); border:1px solid var(--border); color:var(--text);
  padding:10px 12px; border-radius:10px; font:inherit; font-size:14px;
}
.form input, .form textarea, .form select { width:100%; margin-top:5px; }
.form .check { display:flex; align-items:center; gap:8px; font-weight:500; color:var(--text); }
.form .check input { width:auto; margin:0; }
input:focus, select:focus, textarea:focus { outline:2px solid var(--accent); outline-offset:1px; border-color:var(--accent); }
.select { width:100%; background:var(--bg); border:1px solid var(--border); color:var(--text); padding:10px 12px; border-radius:10px; font:inherit; }

/* ── Interval presets ── */
.interval-presets { display:flex; flex-wrap:wrap; gap:8px; margin-top:6px; }
.interval-presets label { display:flex; align-items:center; gap:6px; padding:8px 12px; border:1px solid var(--border); border-radius:10px; cursor:pointer; font-size:13px; color:var(--text); margin:0; font-weight:500; }
.interval-presets input { display:none; }
.interval-presets label:has(input:checked) { border-color:var(--accent); background:var(--accent-dim); }

/* ── Toasts ── */
.toast { padding:12px 16px; border-radius:10px; margin-bottom:12px; font-size:14px; font-weight:500; }
.toast-ok { background:rgba(45,212,168,.12); border:1px solid rgba(45,212,168,.25); color:var(--ok); }
.toast-err { background:rgba(255,92,106,.12); border:1px solid rgba(255,92,106,.25); color:var(--err); }

/* ── Misc ── */
.hidden { display:none !important; }
.accent-text { color:var(--accent); font-weight:600; }
.user-handle { font-weight:700; font-size:15px; }
.user-id { font-size:11px; color:var(--muted); font-family:ui-monospace,monospace; }
.actions { display:flex; flex-wrap:wrap; gap:6px; }
.live-head { display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
.viewer-frame { width:100%; height:calc(100vh - 140px); border:1px solid var(--border); border-radius:var(--radius); background:#000; }
pre#exportBox { white-space:pre-wrap; font-size:12px; max-height:400px; overflow:auto; }
details.edit-panel summary::-webkit-details-marker { display:none; }

/* ── ════════════════════════════════════════ ──
         MOBILE  (≤ 768 px)
── ════════════════════════════════════════ ── */
@media (max-width: 768px) {

  /* Sidebar: off-canvas overlay */
  .sidebar {
    position:fixed; left:0; top:0; height:100%; width:min(var(--sidebar-w), 88vw);
    transform:translateX(-100%); z-index:200; overflow-y:auto;
    border-right:1px solid var(--border); box-shadow:4px 0 24px rgba(0,0,0,.5);
  }
  .sidebar.open { transform:translateX(0); }
  .nav-backdrop { display:block; }

  /* Sidebar close button (top-right inside sidebar) */
  .sidebar-close {
    display:flex; align-items:center; justify-content:center;
    position:absolute; top:14px; right:14px;
    width:34px; height:34px; border-radius:8px;
    background:var(--surface2); border:1px solid var(--border);
    color:var(--text); font-size:16px; cursor:pointer;
    transition:background .15s;
  }
  .sidebar-close:hover { background:var(--border); }

  /* Hamburger visible */
  .hamburger { display:flex; }

  /* Topbar tighter */
  .topbar { padding:0 16px; }
  .page-title { font-size:16px; }

  /* Content: smaller padding */
  .content { padding:16px 14px 40px; }

  /* Headings */
  h1 { font-size:20px; }
  h2 { font-size:15px; }

  /* Cards */
  .card { padding:14px; }

  /* Grids → single column */
  .grid2 { grid-template-columns:1fr; }

  /* Stats grid: smaller min */
  .stats { grid-template-columns:repeat(auto-fit,minmax(100px,1fr)); gap:8px; }
  .stat { padding:12px; }
  .stat-val { font-size:22px; }

  /* Tables: horizontal scroll */
  .table-wrap, .card .table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .table, .data-table { min-width:520px; }

  /* Buttons: touch-friendly */
  .btn { padding:10px 14px; font-size:13px; }
  .btn.sm, .btn.btn-xs { padding:7px 12px; }

  /* Toolbar: wrap */
  .toolbar { gap:6px; }

  /* Forms */
  .form input, .form textarea, .form select,
  input[type="text"], input[type="email"], input[type="password"], select, textarea {
    font-size:16px; /* Voorkomt zoom op iOS */
  }

  /* Interval presets: scroll */
  .interval-presets { flex-wrap:nowrap; overflow-x:auto; padding-bottom:4px; }
  .interval-presets label { white-space:nowrap; flex-shrink:0; }
}

/* ── Tablet  (769 – 1024 px) ── */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 210px; }
  .content { padding:20px 20px 40px; }
  .grid2 { gap:12px; }
}
