/* =========================================================================
   ZeroNet v2 — Global stylesheet
   Design system: Emerald→Cyan accent, Slate neutrals, glassmorphism, 8px grid
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Brand */
  --brand-1: #10B981;     /* emerald-500 */
  --brand-2: #06B6D4;     /* cyan-500 */
  --brand-3: #0EA5E9;     /* sky-500, default solid */
  --brand-grad: linear-gradient(135deg, #10B981 0%, #06B6D4 60%, #0EA5E9 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(16,185,129,.12), rgba(14,165,233,.12));

  /* Semantic */
  --ok: #10B981;
  --warn: #F59E0B;
  --err: #EF4444;
  --info: #06B6D4;

  /* Light theme (default) */
  --bg: #F7F8FB;
  --bg-elev: #FFFFFF;
  --bg-mute: #F1F4F9;
  --border: #E5E9F2;
  --border-strong: #D6DCE8;
  --text: #0B1220;
  --text-2: #475569;
  --text-3: #94A3B8;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 4px 14px -4px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 24px 48px -16px rgba(15,23,42,.18), 0 8px 16px -8px rgba(15,23,42,.08);
  --glass-bg: rgba(255,255,255,.65);
  --glass-border: rgba(255,255,255,.7);
  --ring: 0 0 0 4px rgba(14,165,233,.18);

  /* Geometry */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;     /* default card */
  --r-xl: 18px;
  --r-pill: 999px;

  /* Density (overridden by [data-density]) */
  --space: 8px;
  --row-h: 56px;
  --pad-card: 22px;
  --pad-cell-y: 14px;
  --font-base: 14px;

  /* Card style (overridden by [data-card-style]) */
  --card-bg: var(--bg-elev);
  --card-border: 1px solid var(--border);
  --card-shadow: var(--shadow-sm);
}

[data-theme="dark"] {
  --bg: #070A12;
  --bg-elev: #0F1525;
  --bg-mute: #131A2C;
  --border: #1E2740;
  --border-strong: #2A3552;
  --text: #ECF0FA;
  --text-2: #94A3B8;
  --text-3: #64748B;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.5);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,.6);
  --shadow-lg: 0 30px 80px -20px rgba(0,0,0,.7);
  --glass-bg: rgba(15,21,37,.6);
  --glass-border: rgba(148,163,184,.12);
  --ring: 0 0 0 4px rgba(6,182,212,.22);
}

/* Density variants */
[data-density="compact"] {
  --space: 6px;
  --row-h: 44px;
  --pad-card: 16px;
  --pad-cell-y: 9px;
  --font-base: 13px;
}
[data-density="comfortable"] {
  --space: 10px;
  --row-h: 64px;
  --pad-card: 26px;
  --pad-cell-y: 18px;
  --font-base: 14.5px;
}

/* Card style variants */
[data-card-style="flat"]     { --card-shadow: none; --card-border: 1px solid var(--border); }
[data-card-style="outlined"] { --card-shadow: none; --card-border: 1px solid var(--border-strong); }
[data-card-style="elevated"] { --card-shadow: var(--shadow-md); --card-border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }

/* Accent color variants (just swaps the brand triplet) */
[data-accent="emerald"] { --brand-1:#10B981; --brand-2:#06B6D4; --brand-3:#0EA5E9; }
[data-accent="violet"]  { --brand-1:#8B5CF6; --brand-2:#A855F7; --brand-3:#7C3AED; }
[data-accent="orange"]  { --brand-1:#F97316; --brand-2:#F59E0B; --brand-3:#EA580C; }
[data-accent="rose"]    { --brand-1:#F43F5E; --brand-2:#EC4899; --brand-3:#E11D48; }
[data-accent="indigo"]  { --brand-1:#6366F1; --brand-2:#3B82F6; --brand-3:#4F46E5; }
[data-accent]           { --brand-grad: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 60%, var(--brand-3) 100%); }

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: var(--font-base);
  font-feature-settings: "cv11","ss01","ss03";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
  transition: background-color .25s ease, color .25s ease;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.mono, .num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* ---------- Layout shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w, 248px) 1fr; min-height: 100vh; transition: grid-template-columns .3s ease; }
[data-sidebar="icon"]   .shell { --sidebar-w: 72px; }
[data-sidebar="full"]   .shell { --sidebar-w: 248px; }
[data-sidebar="floating"] .shell { --sidebar-w: 0px; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width .3s ease;
}
[data-sidebar="floating"] .sidebar {
  position: fixed; left: 16px; top: 16px; bottom: 16px;
  width: 248px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transform: translateX(calc(-100% - 24px));
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
[data-sidebar="floating"] .sidebar.is-open { transform: translateX(0); }
[data-sidebar="floating"] .shell { grid-template-columns: 1fr; }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  height: 72px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand-grad);
  display: grid; place-items: center;
  color: white; flex-shrink: 0;
  box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--brand-2) 70%, transparent);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-text span { color: var(--text-2); font-size: 11.5px; }

[data-sidebar="icon"] .brand-text,
[data-sidebar="icon"] .nav-label,
[data-sidebar="icon"] .nav-section,
[data-sidebar="icon"] .user-meta { display: none; }
[data-sidebar="icon"] .sidebar-brand { justify-content: center; padding: 18px 0; }
[data-sidebar="icon"] .nav-item { justify-content: center; padding: 10px 0; }
[data-sidebar="icon"] .sidebar-user { justify-content: center; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--bg-mute); color: var(--text); }
.nav-item.active {
  background: color-mix(in srgb, var(--brand-3) 12%, transparent);
  color: var(--text);
  font-weight: 600;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--brand-grad);
  border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item.active svg { color: var(--brand-3); opacity: 1; }
.nav-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 600;
  background: color-mix(in srgb, var(--brand-3) 18%, transparent);
  color: var(--brand-3);
  padding: 2px 7px; border-radius: var(--r-pill);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-grad);
  color: white; font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.xs { width: 22px; height: 22px; font-size: 10.5px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta b { font-weight: 600; }
.user-meta span { font-size: 11.5px; color: var(--text-3); }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  height: 72px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em;
}
.topbar .crumb-sep { color: var(--text-3); padding: 0 4px; }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  display: grid; place-items: center;
  transition: all .15s ease;
}
.icon-btn:hover { background: var(--bg-mute); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text);
  font-weight: 500;
  transition: background .15s ease;
}
.user-chip:hover { background: var(--bg-mute); }

/* ---------- Page ---------- */
.page { padding: 28px; max-width: 1480px; width: 100%; }
.page-head { margin-bottom: 24px; display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.page-head h2 { margin: 0 0 4px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--text-2); font-size: 14px; }
.page-head .head-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent;
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--border);
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-mute); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--brand-grad);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--brand-2) 60%, transparent);
}
.btn-primary:hover { filter: brightness(1.05); background: var(--brand-grad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-mute); color: var(--text); }
.btn-danger { background: var(--err); color: white; border-color: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--err) 88%, black); }
.btn-warn { background: var(--warn); color: white; border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { padding: 7px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.card-pad { padding: var(--pad-card); }
.card-head {
  padding: 18px var(--pad-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.005em; }
.card-head p { margin: 2px 0 0; color: var(--text-2); font-size: 12.5px; }
.card-head .ch-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* Stat card */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat {
  position: relative;
  padding: 18px 20px;
  background: var(--card-bg);
  border: var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; inset: 0;
  background: var(--brand-grad-soft);
  opacity: 0; transition: opacity .25s ease;
  pointer-events: none;
}
.stat:hover::after { opacity: 1; }
.stat-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; letter-spacing: .01em; }
.stat-value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.stat-icon {
  position: absolute; top: 16px; right: 16px;
  width: 38px; height: 38px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand-3) 14%, transparent);
  color: var(--brand-3);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat.tone-ok .stat-icon { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.stat.tone-warn .stat-icon { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.stat.tone-info .stat-icon { background: color-mix(in srgb, var(--info) 14%, transparent); color: var(--info); }
.stat.tone-rose .stat-icon { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-size: 11.5px; font-weight: 600;
  border-radius: var(--r-pill);
  background: var(--bg-mute);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge.solid::before { display: none; }
.badge.no-dot::before { display: none; }
.badge.ok    { color: var(--ok);   background: color-mix(in srgb, var(--ok) 14%, transparent); border-color: transparent; }
.badge.warn  { color: var(--warn); background: color-mix(in srgb, var(--warn) 18%, transparent); border-color: transparent; }
.badge.err   { color: var(--err);  background: color-mix(in srgb, var(--err) 14%, transparent); border-color: transparent; }
.badge.info  { color: var(--info); background: color-mix(in srgb, var(--info) 14%, transparent); border-color: transparent; }
.badge.brand { color: var(--brand-3); background: color-mix(in srgb, var(--brand-3) 14%, transparent); border-color: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 12px; font-weight: 500;
  border-radius: var(--r-pill);
  background: var(--bg-mute);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.chip.active { background: var(--text); color: var(--bg-elev); border-color: var(--text); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-mute); border-radius: var(--r-md); border: 1px solid var(--border); width: fit-content; }
.tabs button {
  background: transparent; border: 0;
  padding: 6px 14px; border-radius: 7px;
  color: var(--text-2); font-weight: 500; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s ease;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 600; }
.tabs button .count { font-size: 11px; padding: 1px 6px; background: var(--bg); border-radius: var(--r-pill); color: var(--text-3); }
.tabs button.active .count { background: color-mix(in srgb, var(--brand-3) 14%, transparent); color: var(--brand-3); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field label .req { color: var(--err); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand-3); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-group { position: relative; }
.input-group .input { padding-left: 38px; }
.input-group .ig-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }
.textarea { resize: vertical; min-height: 96px; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left;
  padding: 12px var(--pad-card);
  font-weight: 600; font-size: 11.5px;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-mute);
  position: sticky; top: 0;
}
.tbl tbody td {
  padding: var(--pad-cell-y) var(--pad-card);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s ease; }
.tbl tbody tr:hover { background: var(--bg-mute); cursor: pointer; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-actions { display: flex; gap: 4px; justify-content: flex-end; }
.tbl-actions .icon-btn { width: 30px; height: 30px; }
.tbl-actions .icon-btn svg { width: 15px; height: 15px; }
.tbl .ix { color: var(--text-3); font-size: 12px; width: 38px; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell .avatar { width: 32px; height: 32px; font-size: 13px; }
.user-cell .um { display: flex; flex-direction: column; line-height: 1.2; }
.user-cell .um b { font-weight: 600; }
.user-cell .um span { font-size: 11.5px; color: var(--text-3); }

/* ---------- Drawer ---------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(2,6,15,.5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 60; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 92vw);
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 70; transform: translateX(100%); transition: transform .25s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.kvp { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kvp:last-child { border-bottom: 0; }
.kvp .k { color: var(--text-2); }
.kvp .v { font-weight: 600; }
.progress { height: 6px; background: var(--bg-mute); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand-grad); border-radius: inherit; }
.progress.warn > i { background: linear-gradient(90deg, var(--warn), #FB923C); }
.progress.err > i { background: linear-gradient(90deg, var(--err), #FB7185); }
.progress.ok > i { background: linear-gradient(90deg, var(--ok), #34D399); }

/* Live dot */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ok); font-weight: 500; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 30%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 0%, transparent); } }

/* Glass surface utility */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
}

/* Skeleton helper for placeholder content */
.skeleton { background: linear-gradient(90deg, var(--bg-mute) 0%, color-mix(in srgb, var(--bg-mute) 60%, transparent) 50%, var(--bg-mute) 100%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Tweaks panel positioning */
.tweaks-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--brand-grad);
  color: white; border: 0;
  display: grid; place-items: center;
  box-shadow: 0 12px 24px -8px color-mix(in srgb, var(--brand-2) 60%, transparent);
  transition: transform .18s ease;
}
.tweaks-fab:hover { transform: translateY(-2px) scale(1.04); }

/* Scrollbar minimal */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-track { background: transparent; }

/* Sidebar hamburger button: hidden on desktop, shown on mobile / floating mode */
.sidebar-toggle-btn { display: none; }
[data-sidebar="floating"] .sidebar-toggle-btn { display: grid; }

/* ---------- Pagination (ZeroNet) ---------- */
.pgnt { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.pgnt-mobile { display: none; align-items: center; gap: 10px; width: 100%; justify-content: space-between; }
.pgnt-mobile .pgnt-arrow { width: 40px; height: 38px; padding: 0; justify-content: center; }
.pgnt-mobile .pgnt-arrow svg { width: 16px; height: 16px; }
.pgnt-mobile .pgnt-arrow.is-disabled { opacity: .45; pointer-events: none; }
.pgnt-info { color: var(--text-2); font-size: 13px; }
.pgnt-info b { color: var(--text); font-weight: 600; }

.pgnt-desktop { display: inline-flex; align-items: center; gap: 3px; }
.pgnt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 10px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: all .12s ease;
  text-decoration: none;
}
.pgnt-btn:hover { background: var(--bg-mute); color: var(--text); border-color: var(--border-strong); }
.pgnt-btn svg { width: 14px; height: 14px; }
.pgnt-btn.is-current { background: var(--brand-grad); color: white; border-color: transparent; font-weight: 600; }
.pgnt-btn.is-current:hover { color: white; }
.pgnt-btn.is-disabled { opacity: .4; pointer-events: none; }
.pgnt-btn.is-dots { background: transparent; border-color: transparent; }

@media (max-width: 880px) {
  .pgnt-mobile { display: flex; }
  .pgnt-desktop { display: none; }
}

/* =========================================================================
   Responsive — mobile-first overrides
   ========================================================================= */

/* Mobile drawer overlay (sidebar). Hidden on desktop. */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(2,6,15,.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 45;
  opacity: 0;
  transition: opacity .2s ease;
}
.sidebar-overlay.is-open { opacity: 1; }
body.lock-scroll { overflow: hidden; }

/* Tablet / small laptop */
@media (max-width: 1024px) {
  .page { padding: 22px 18px; max-width: 100%; }
  .topbar { padding: 0 18px; }
}

/* Mobile: sidebar collapses to an off-canvas drawer */
@media (max-width: 880px) {
  /* Single-column shell. Sidebar becomes a fixed off-canvas drawer. */
  .shell { grid-template-columns: 1fr !important; }

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: min(280px, 84vw);
    height: 100vh; height: 100dvh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
    display: flex !important;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay { display: block; pointer-events: none; }
  .sidebar-overlay.is-open { pointer-events: auto; }

  /* Force-show labels when drawer is open even if pref is "icon" */
  [data-sidebar="icon"] .sidebar .brand-text,
  [data-sidebar="icon"] .sidebar .nav-label,
  [data-sidebar="icon"] .sidebar .nav-section,
  [data-sidebar="icon"] .sidebar .user-meta { display: revert; }
  [data-sidebar="icon"] .sidebar .sidebar-brand { justify-content: flex-start; padding: 0 18px; }
  [data-sidebar="icon"] .sidebar .nav-item { justify-content: flex-start; padding: 9px 12px; }
  [data-sidebar="icon"] .sidebar .sidebar-user { justify-content: flex-start; }

  /* Topbar: compact + show hamburger */
  .topbar {
    padding: 0 14px;
    height: 56px;
    gap: 8px;
  }
  .topbar .sidebar-toggle-btn { display: grid; }
  .topbar h1 {
    font-size: 15px;
    min-width: 0; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }

  /* Page padding tighter */
  .page { padding: 16px 14px 28px; }

  /* Page head: stack actions below title, smaller h2 */
  .page-head { gap: 12px; margin-bottom: 18px; }
  .page-head h2 { font-size: 22px; }
  .page-head p { font-size: 13px; }
  .page-head .head-actions {
    margin-left: 0;
    width: 100%;
    gap: 8px;
  }
  .page-head .head-actions .btn { flex: 1 1 auto; justify-content: center; }

  /* Stat grid: tighter min, smaller numbers */
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .stat { padding: 14px 14px; }
  .stat-value { font-size: 24px; margin-top: 4px; }
  .stat-icon { top: 12px; right: 12px; width: 32px; height: 32px; }
  .stat-icon svg { width: 16px; height: 16px; }
  .stat-foot { font-size: 11px; }

  /* Card padding scaled down */
  :root { --pad-card: 16px; }
  .card-head { padding: 14px var(--pad-card); }
  .card-head h3 { font-size: 14px; }

  /* Tables: visual hint that horizontal scroll exists */
  .tbl-wrap {
    -webkit-overflow-scrolling: touch;
    background:
      linear-gradient(to right, var(--card-bg), var(--card-bg)) left center / 20px 100% no-repeat,
      linear-gradient(to right, var(--card-bg), var(--card-bg)) right center / 20px 100% no-repeat,
      linear-gradient(to right, rgba(15,23,42,.08), transparent) left center / 12px 100% no-repeat,
      linear-gradient(to left,  rgba(15,23,42,.08), transparent) right center / 12px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
  }
  .tbl thead th { padding: 10px 12px; font-size: 10.5px; }
  .tbl tbody td { padding: 10px 12px; font-size: 12.5px; }

  /* Drawer: full sheet on mobile */
  .drawer { width: 100vw; width: 100dvw; border-left: 0; }
  .drawer-head { padding: 14px 16px; }
  .drawer-body { padding: 16px; }
  .drawer-foot { padding: 12px 16px; flex-wrap: wrap; }
  .drawer-foot .btn { flex: 1 1 auto; justify-content: center; }

  /* User pop menu: anchor against viewport edge */
  .user-pop { right: 0; min-width: 180px; }

  /* Tabs scroll horizontally instead of wrapping awkwardly */
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { white-space: nowrap; flex-shrink: 0; }

  /* Tweaks FAB lebih kecil & jauh dari edge */
  .tweaks-fab { right: 14px; bottom: 14px; width: 44px; height: 44px; }

  /* Override common inline grids on mobile (router/whatsapp grids built with auto-fit minmax) */
  section[style*="minmax(420px"],
  section[style*="minmax(360px"],
  div[style*="minmax(420px"],
  div[style*="minmax(360px"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Generic filter toolbar inside .card → stack vertical, inputs fullwidth.
     Handles hotspot-logs, activity-logs, etc. that use inline flex+wrap. */
  .card > div > form[style*="flex-wrap:wrap"],
  .card > div > form[style*="flex-wrap: wrap"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  .card > div > form[style*="flex-wrap:wrap"] .input-group,
  .card > div > form[style*="flex-wrap: wrap"] .input-group,
  .card > div > form[style*="flex-wrap:wrap"] input[type="date"],
  .card > div > form[style*="flex-wrap: wrap"] input[type="date"],
  .card > div > form[style*="flex-wrap:wrap"] .select,
  .card > div > form[style*="flex-wrap: wrap"] .select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  /* The "—" separator between dates looks awkward when stacked */
  .card > div > form[style*="flex-wrap:wrap"] > span[style*="text-3"],
  .card > div > form[style*="flex-wrap: wrap"] > span[style*="text-3"] {
    display: none;
  }
  /* Router cards (manajemen router): tighten meta grid */
  .router-card { padding: 16px !important; }
  .router-card .rc-meta { grid-template-columns: 1fr 1fr; gap: 10px; padding: 12px; }
  .router-card .rc-meta > div:nth-child(3) { grid-column: 1 / -1; }
  .router-card .mb { grid-template-columns: 40px 1fr 40px; gap: 10px; }

  /* Generic 2-column inline grids stack on mobile when first column gets cramped */
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    /* Keep 2-col for small stat pairs, but tighten gap */
    gap: 10px !important;
  }

  /* Profile page: stack info + password cards (section.profile-row uses inline 1fr 1fr) */
  .profile-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-bottom: 16px !important;
  }
}

/* Very small phones */
@media (max-width: 420px) {
  .page-head h2 { font-size: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .btn-sm { padding: 5px 10px; font-size: 11.5px; }
}
