/* ============================================================
   Rumah AI — Design System (app shell)
   Modern SaaS: dark-first, premium, responsive. Light mode via [data-theme=light].
   ============================================================ */

/* ---------- Tokens ---------- */
:root, [data-theme="dark"] {
  --bg: #0a0b12;
  --bg-soft: #0e1018;
  --surface: #12141f;
  --surface-2: #171a28;
  --surface-3: #1d2131;
  --border: #232839;
  --border-soft: #1b1f2e;
  --text: #e8eaf2;
  --text-2: #a3a8bd;
  --text-3: #6b7189;
  --accent: #6d5efc;
  --accent-2: #8b7bff;
  --accent-soft: rgba(109, 94, 252, .14);
  --cyan: #22d3ee;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --rose: #fb7185;
  --violet: #a78bfa;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.45), 0 24px 48px rgba(0,0,0,.35);
  --glow: 0 0 0 1px rgba(109,94,252,.35), 0 8px 40px rgba(109,94,252,.18);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
  --sidebar-w: 262px;
  --topbar-h: 64px;
}

[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef0f7;
  --border: #e4e7f0;
  --border-soft: #eef0f7;
  --text: #12141f;
  --text-2: #565d73;
  --text-3: #8a90a6;
  --accent: #5b4df0;
  --accent-2: #6d5efc;
  --accent-soft: rgba(91, 77, 240, .1);
  --cyan: #0891b2;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --rose: #e11d48;
  --violet: #7c3aed;
  --shadow: 0 1px 2px rgba(23,25,35,.05), 0 8px 24px rgba(23,25,35,.07);
  --shadow-lg: 0 4px 12px rgba(23,25,35,.08), 0 24px 48px rgba(23,25,35,.12);
  --glow: 0 0 0 1px rgba(91,77,240,.25), 0 8px 40px rgba(91,77,240,.12);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; margin-left: var(--sidebar-w); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--bg-soft);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; z-index: 60;
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 18px; border-bottom: 1px solid var(--border-soft); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; color: var(--text); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: var(--glow);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-accent { color: var(--accent-2); }
.sidebar-close { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-3); padding: 0 12px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin-bottom: 2px;
  border-radius: 10px; color: var(--text-2); font-weight: 500; font-size: 13.5px;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft); color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(109,94,252,.22);
}
.nav-item.active .nav-icon { color: var(--accent-2); }
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-soft); }
.sidebar-plan {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.sidebar-plan strong { display: block; font-size: 12.5px; }
.sidebar-plan small { color: var(--text-3); font-size: 11px; }
.plan-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.sidebar-overlay { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px; padding: 0 26px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-title h1 { font-size: 17px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.topbar-title p { margin: 0; font-size: 12px; color: var(--text-3); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text-2); display: grid; place-items: center;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn svg { width: 19px; height: 19px; }
#themeToggle .icon-moon { display: none; }
[data-theme="dark"] #themeToggle .icon-sun { display: none; }
[data-theme="dark"] #themeToggle .icon-moon { display: block; }
.notif-dot {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); display: none; box-shadow: 0 0 0 2px var(--bg);
}

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color: var(--text); transition: border-color .18s ease, background .18s ease;
}
.user-chip:hover { border-color: var(--accent); }
.user-chip svg { width: 14px; height: 14px; color: var(--text-3); }
.avatar {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--violet)); color: #fff;
  font-weight: 700; font-size: 13px;
}
.user-chip-name { font-weight: 600; font-size: 13px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 8px; display: none; z-index: 80;
  animation: pop .16s ease;
}
.dropdown.open { display: block; }
.dropdown-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.dropdown-head strong { display: block; font-size: 13px; }
.dropdown-head small { color: var(--text-3); font-size: 12px; }
.dropdown-item {
  display: block; padding: 8px 12px; border-radius: 9px; color: var(--text-2);
  font-size: 13px; font-weight: 500; transition: background .15s ease, color .15s ease;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item.danger { color: var(--red); }
.dropdown-item.danger:hover { background: rgba(248,113,113,.1); color: var(--red); }
.dropdown-sep { height: 1px; background: var(--border-soft); margin: 6px 4px; }

/* ---------- Page content ---------- */
.page-content { flex: 1; padding: 26px; max-width: 1440px; width: 100%; margin: 0 auto; animation: fadeUp .35s ease; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.card-hover:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); box-shadow: var(--glow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card-head .card-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.card-body { padding: 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border-soft); font-size: 12.5px; color: var(--text-3); }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  position: relative; overflow: hidden; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); box-shadow: var(--glow); }
.stat-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--stat-c, var(--accent)), transparent 70%);
  opacity: .8;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 12px;
  background: var(--stat-soft, var(--accent-soft)); color: var(--stat-c, var(--accent));
}
.stat-icon svg { width: 19px; height: 19px; }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--text-3); }
.stat-trend { font-size: 11.5px; margin-top: 4px; font-weight: 600; }
.stat-trend.up { color: var(--green); }
.stat-trend.down { color: var(--red); }
.stat-trend.flat { color: var(--text-3); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: rgba(52,211,153,.12); color: var(--green); }
.badge-warning { background: rgba(251,191,36,.12); color: var(--amber); }
.badge-danger  { background: rgba(248,113,113,.12); color: var(--red); }
.badge-info    { background: rgba(34,211,238,.12); color: var(--cyan); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.badge-accent  { background: var(--accent-soft); color: var(--accent-2); }
.badge[data-pulse]::before { animation: pulse 1.6s ease infinite; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13px; font-weight: 600; transition: all .18s ease; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 2px 12px rgba(109,94,252,.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(109,94,252,.5); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-3); }
.btn-danger { background: rgba(248,113,113,.1); color: var(--red); border-color: rgba(248,113,113,.25); }
.btn-danger:hover { background: rgba(248,113,113,.18); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 90px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7189' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-3);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .mono { font-family: var(--mono); font-size: 12px; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.tbl-cell-user { display: flex; align-items: center; gap: 10px; }
.tbl-cell-user .avatar { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.tbl-cell-user strong { display: block; font-size: 13px; }
.tbl-cell-user small { color: var(--text-3); font-size: 11.5px; }

/* ---------- Progress ---------- */
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .6s cubic-bezier(.4,0,.2,1); }
.progress.warn > span { background: linear-gradient(90deg, var(--amber), #f59e0b); }
.progress.crit > span { background: linear-gradient(90deg, var(--red), var(--rose)); }
.progress.ok > span { background: linear-gradient(90deg, var(--green), #10b981); }
.quota-row { margin-bottom: 18px; }
.quota-row:last-child { margin-bottom: 0; }
.quota-row .q-head { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12.5px; }
.quota-row .q-head strong { font-weight: 600; }
.quota-row .q-head span { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab {
  padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-3);
  border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .16s ease, border-color .16s ease; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 220px; }
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 22px; }
@media (max-width: 1100px) { .chart-grid { grid-template-columns: 1fr; } }

/* ---------- Grid utilities ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } }

/* ---------- Page hero / header row ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--text-3); font-size: 13.5px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Skeleton ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
  animation: shimmer 1.4s infinite;
}
[data-theme="light"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(0,0,0,.05), transparent); }
@keyframes shimmer { 0% { transform: translateX(-100%);} 100% { transform: translateX(100%);} }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-3);
}
.empty svg { width: 44px; height: 44px; margin-bottom: 12px; opacity: .5; }
.empty h4 { margin: 0 0 4px; color: var(--text-2); font-size: 15px; }
.empty p { margin: 0 0 16px; font-size: 13px; }

/* ---------- Toasts ---------- */
.toast {
  position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 16px; box-shadow: var(--shadow-lg); max-width: 380px;
  animation: toastIn .3s cubic-bezier(.21,1.02,.73,1); font-size: 13px; font-weight: 500;
}
.toast svg { width: 17px; height: 17px; flex-shrink: 0; }
.toast-success svg { color: var(--green); } .toast-success { border-color: rgba(52,211,153,.4); }
.toast-error svg { color: var(--red); } .toast-error { border-color: rgba(248,113,113,.4); }
.toast-warning svg { color: var(--amber); } .toast-warning { border-color: rgba(251,191,36,.4); }
.toast-info svg { color: var(--cyan); } .toast-info { border-color: rgba(34,211,238,.4); }
.toast-close { margin-left: 4px; background: none; border: none; color: var(--text-3); font-size: 16px; line-height: 1; }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px);} to { opacity: 1; transform: translateX(0);} }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px);} }

/* ---------- Modal ---------- */
.modal-backdrop[hidden], .modal[hidden], [hidden] { display: none !important; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,5,10,.6); backdrop-filter: blur(4px);
  z-index: 150; animation: fadeIn .2s ease;
}
.modal {
  position: fixed; inset: 0; z-index: 160; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  animation: modalIn .25s cubic-bezier(.21,1.02,.73,1);
}
.modal-card.wide { max-width: 760px; }
.modal-x { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--surface-2); color: var(--text-2); font-size: 17px; }
.modal-x:hover { background: var(--surface-3); }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(.97);} to { opacity: 1; transform: translateY(0) scale(1);} }
@keyframes fadeIn { from { opacity: 0;} to { opacity: 1;} }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: translateY(0);} }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98);} to { opacity: 1; transform: translateY(0) scale(1);} }
@keyframes pulse { 0%,100% { opacity: 1;} 50% { opacity: .35;} }

/* ---------- KV list ---------- */
.kv { display: grid; grid-template-columns: minmax(0, 190px) 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Code blocks ---------- */
.code-block {
  position: relative; background: #0b0c13; border: 1px solid #1d2131; border-radius: 12px;
  margin: 12px 0; overflow: hidden;
}
[data-theme="light"] .code-block { background: #0d0e16; border-color: #232839; }
.code-block .code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: rgba(255,255,255,.03); border-bottom: 1px solid #1d2131;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #8b93ad;
  font-family: var(--mono);
}
.code-block pre { margin: 0; padding: 16px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.65; color: #d5d9e6; }
.code-block .copy-btn {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); color: #aab0c5;
  padding: 3px 9px; border-radius: 7px; font-size: 10.5px; font-weight: 600; cursor: pointer;
}
.code-block .copy-btn:hover { background: rgba(255,255,255,.14); color: #fff; }
.token-comment { color: #5c6370; }
.token-key { color: #c792ea; }
.token-str { color: #a5d6a7; }
.token-fn { color: #82aaff; }
.token-num { color: #f78c6c; }
.token-prop { color: #89ddff; }

/* ---------- Misc ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border-soft); margin: 18px 0; }

/* Pill / stat strip */
.pill-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-amber { background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.dot-red { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* Flow diagram (routing visual) */
.flow { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; }
.flow-node {
  padding: 9px 15px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 600; text-align: center; position: relative;
}
.flow-node.primary { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.flow-node.fallback { border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.08); color: var(--green); }
.flow-node.secondary { border-color: rgba(34,211,238,.4); background: rgba(34,211,238,.07); color: var(--cyan); }
.flow-node small { display: block; font-size: 10px; opacity: .75; font-weight: 500; }
.flow-arrow { color: var(--text-3); display: flex; flex-direction: column; align-items: center; font-size: 10px; font-weight: 700; }
.flow-arrow svg { width: 18px; height: 18px; }

/* Status banner for router connection */
.status-banner {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 20px; background: var(--surface);
}
.status-banner .status-orb { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.status-orb.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(52,211,153,.15), 0 0 14px var(--green); }
.status-orb.degraded { background: var(--amber); box-shadow: 0 0 0 4px rgba(251,191,36,.15), 0 0 14px var(--amber); }
.status-orb.offline { background: var(--red); box-shadow: 0 0 0 4px rgba(248,113,113,.15), 0 0 14px var(--red); }
.status-banner .sb-title { font-weight: 700; font-size: 14px; }
.status-banner .sb-sub { font-size: 12.5px; color: var(--text-3); }

/* Feature list */
.feature-list { list-style: none; margin: 0; padding: 0; }
.feature-list li { display: flex; gap: 9px; padding: 7px 0; font-size: 13px; color: var(--text-2); align-items: flex-start; }
.feature-list li svg { width: 16px; height: 16px; color: var(--green); flex-shrink: 0; margin-top: 2px; }

/* Alert */
.alert {
  display: flex; gap: 11px; padding: 13px 16px; border-radius: 12px; font-size: 13px;
  border: 1px solid var(--border); margin-bottom: 16px; align-items: flex-start;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-info { background: rgba(34,211,238,.07); border-color: rgba(34,211,238,.3); color: var(--text); }
.alert-info svg { color: var(--cyan); }
.alert-warning { background: rgba(251,191,36,.07); border-color: rgba(251,191,36,.3); }
.alert-warning svg { color: var(--amber); }
.alert-error { background: rgba(248,113,113,.07); border-color: rgba(248,113,113,.3); }
.alert-error svg { color: var(--red); }
.alert-success { background: rgba(52,211,153,.07); border-color: rgba(52,211,153,.3); }
.alert-success svg { color: var(--green); }

/* App footer */
.app-footer {
  padding: 16px 26px; border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-3);
}
.footer-links { display: flex; gap: 14px; }
.footer-links a { color: var(--text-3); }
.footer-links a:hover { color: var(--accent-2); }

/* Responsive */
@media (max-width: 900px) {
  .app-main { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-close { display: grid; }
  .sidebar-overlay.open { display: block; position: fixed; inset: 0; background: rgba(4,5,10,.55); z-index: 55; backdrop-filter: blur(3px); }
  .page-content { padding: 18px; }
  .topbar { padding: 0 16px; }
  .user-chip-name { display: none; }
}
@media (max-width: 560px) {
  .stat-value { font-size: 20px; }
  .page-head h2 { font-size: 19px; }
  .chart-box { height: 240px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
}

/* Print */
@media print {
  .sidebar, .topbar, .app-footer { display: none; }
  .app-main { margin-left: 0; }
}
