/* ============================================================
   HidePulsa AI Dashboard — dark theme, modern, mobile-ready
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #0b1220;
  --surface: #111a2e;
  --surface-2: #0f172a;
  --surface-3: #1a2540;
  --border: #1f2a44;
  --border-strong: #2a3855;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --muted-2: #94a3b8;  /* boosted from #64748b for WCAG readability */
  --accent-1: #60a5fa;
  --accent-2: #a78bfa;
  --accent-gradient: linear-gradient(90deg, #60a5fa, #a78bfa);
  --accent-gradient-br: linear-gradient(135deg, #60a5fa, #a78bfa);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --orange: #f97316;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  --nav-width: 240px;
}

html, body { margin: 0; padding: 0; }
html { background: var(--bg); }
body {
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(96, 165, 250, 0.08), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(167, 139, 250, 0.08), transparent 40%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-1); text-decoration: none; }
a:hover { color: var(--accent-2); }

code, pre {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
}
code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  color: #cbd5e1;
  border: 1px solid var(--border);
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.55;
  margin: 8px 0;
}
pre code { background: transparent; border: 0; padding: 0; }

h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p  { margin: 6px 0; }
.muted { color: var(--muted); }
.text-small { font-size: 0.88rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--nav-width);
  background: linear-gradient(180deg, #0c1528 0%, #0b1220 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 4px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand:hover { opacity: 0.85; }
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px; object-fit: cover;
  background: white; padding: 2px;
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.25);
}
.brand-name {
  font-weight: 800; font-size: 1.05rem; color: var(--text);
  letter-spacing: -0.01em;
}
.brand-name em {
  font-style: normal;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.nav {
  display: flex; flex-direction: column;
  gap: 2px; flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500; font-size: 0.95rem;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-link.active {
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.18), rgba(167, 139, 250, 0.12));
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent-1);
}
.nav-link.admin {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}
.nav-icon { font-size: 1.1em; width: 22px; text-align: center; }

.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }
.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient-br);
  color: white; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.userinfo { flex: 1; min-width: 0; }
.uname { font-weight: 600; color: var(--text); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.utg { color: var(--muted-2); font-size: 0.75rem; }
.logout-btn {
  display: block; text-align: center;
  margin-top: 8px; padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5 !important;
  font-size: 0.85rem; font-weight: 500;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.2); color: #fecaca !important; }

/* ============ MAIN ============ */
.main {
  margin-left: var(--nav-width);
  min-height: 100vh;
  padding: 22px 28px 40px;
  max-width: calc(100vw - var(--nav-width));
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px;
}
.page-title {
  font-size: 1.5rem; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.tg-link {
  padding: 8px 14px; border-radius: 999px;
  background: rgba(96, 165, 250, 0.12);
  border: 1px solid rgba(96, 165, 250, 0.28);
  color: var(--accent-1) !important;
  font-size: 0.88rem; font-weight: 500;
}
.tg-link:hover { background: rgba(96, 165, 250, 0.2); }

.content { display: block; }
.footer {
  margin-top: 40px; padding: 18px 0;
  border-top: 1px solid var(--border);
  text-align: center; color: var(--muted-2);
  font-size: 0.85rem;
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent-1); }

/* ============ DRAWER (MOBILE) ============ */
.drawer-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 1.3rem;
  width: 40px; height: 40px; border-radius: 10px;
  cursor: pointer; z-index: 30;
}
.drawer-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5); z-index: 15;
}
body.drawer-open .drawer-backdrop { display: block; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  body.drawer-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; max-width: 100vw; padding: 64px 16px 40px; }
  .drawer-toggle { display: block; }
  .page-title { font-size: 1.2rem; }
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-pad-lg { padding: 28px; }
.card-sub { color: var(--muted); font-size: 0.9rem; margin: 2px 0 14px; }
.card-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title h2 { margin: 0; }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-pkg { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent-gradient-br);
  opacity: 0.06; filter: blur(10px);
}
.stat-label { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-value {
  font-size: 1.65rem; font-weight: 700;
  margin-top: 6px;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.stat-hint { color: var(--muted-2); font-size: 0.8rem; margin-top: 4px; }
.stat-icon { position: absolute; top: 16px; right: 16px; font-size: 1.5rem; opacity: 0.7; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600;
  background: color-mix(in srgb, var(--c, #94a3b8) 12%, transparent);
  color: var(--c, #94a3b8);
  border: 1px solid color-mix(in srgb, var(--c, #94a3b8) 30%, transparent);
  white-space: nowrap;
}
.chip {
  display: inline-block;
  padding: 4px 10px; margin: 2px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 999px; font-size: 0.82rem; color: var(--muted);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer; border: 1px solid transparent;
  transition: transform .1s, box-shadow .15s, background .15s;
  text-decoration: none !important;
  line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent-gradient-br); color: white !important;
  box-shadow: 0 4px 14px rgba(96, 165, 250, 0.3);
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-outline {
  background: transparent; color: var(--text) !important;
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background: var(--surface-3); }
.btn-success { background: var(--success); color: white !important; }
.btn-warning { background: var(--warning); color: #1f1305 !important; }
.btn-danger  { background: var(--danger); color: white !important; }
.btn-ghost   { background: transparent; color: var(--muted) !important; }
.btn-ghost:hover { background: rgba(255,255,255,0.04); color: var(--text) !important; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table.t {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
}
table.t th, table.t td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
table.t th {
  background: var(--surface-2); color: var(--muted);
  font-weight: 600; text-transform: uppercase;
  font-size: 0.75rem; letter-spacing: 0.04em;
}
table.t tr:last-child td { border-bottom: 0; }
table.t tr:hover td { background: rgba(255,255,255,0.02); }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); }

/* ============ FORM ============ */
label { display: block; font-weight: 500; color: var(--muted); margin-bottom: 6px; font-size: 0.88rem; }
.input, select, textarea {
  width: 100%; padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}
.input::placeholder, textarea::placeholder { color: var(--muted-2); }
.form-row { margin-bottom: 14px; }
.form-hint { color: var(--muted-2); font-size: 0.82rem; margin-top: 4px; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

/* ============ KEY REVEAL ============ */
.key-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.88rem;
}
.key-box code { background: transparent; border: 0; padding: 0; flex: 1; overflow-x: auto; white-space: nowrap; }
.key-box button { flex-shrink: 0; }

/* ============ INVOICE / QR ============ */
.invoice-box {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 24px; align-items: start;
}
@media (max-width: 700px) {
  .invoice-box { grid-template-columns: 1fr; }
}
.qr-wrap {
  background: white; padding: 16px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.qr-wrap img { width: 100%; height: auto; display: block; }
.qr-amount { margin-top: 12px; color: #111; font-weight: 700; font-size: 1.2rem; }
.countdown {
  display: inline-block; padding: 6px 14px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 999px; font-weight: 700; font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
}
.countdown.warn { color: var(--warning); border-color: var(--warning); }
.countdown.danger { color: var(--danger); border-color: var(--danger); }

/* ============ PACKAGE CARDS ============ */
.pkg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  position: relative;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.pkg-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-1);
  box-shadow: 0 10px 30px rgba(96, 165, 250, 0.15);
}
.pkg-emoji { font-size: 2rem; }
.pkg-name { font-weight: 700; font-size: 1.1rem; margin: 6px 0 2px; }
.pkg-dur { color: var(--muted); font-size: 0.85rem; }
.pkg-price {
  margin: 12px 0 16px; font-weight: 800; font-size: 1.4rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.pkg-free { color: var(--success); }

/* ============ FLASH ============ */
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-weight: 500; font-size: 0.9rem;
  border: 1px solid;
}
.flash-info   { background: rgba(96,165,250,0.1); color: #bfdbfe; border-color: rgba(96,165,250,0.3); }
.flash-success{ background: rgba(16,185,129,0.1); color: #a7f3d0; border-color: rgba(16,185,129,0.3); }
.flash-warning{ background: rgba(245,158,11,0.1); color: #fde68a; border-color: rgba(245,158,11,0.3); }
.flash-error  { background: rgba(239,68,68,0.1); color: #fecaca; border-color: rgba(239,68,68,0.3); }

/* ============ LOGIN PAGE ============ */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-wrap { max-width: 420px; width: 100%; text-align: center; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 84px; height: 84px;
  border-radius: 20px; margin: 0 auto 16px;
  background: white; padding: 4px; display: block;
  box-shadow: 0 8px 24px rgba(96, 165, 250, 0.3);
}
.login-card h1 {
  font-size: 1.8rem; letter-spacing: -0.02em;
  margin: 0 0 2px;
}
.login-card h1 em {
  font-style: normal;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-card .sub { color: var(--muted); margin: 0 0 20px; font-size: 0.95rem; }
.login-desc { margin: 10px 0 20px; color: var(--muted); font-size: 0.92rem; }
.tg-widget { display: flex; justify-content: center; margin: 12px 0 16px; min-height: 44px; }
.login-hint { color: var(--muted-2); font-size: 0.82rem; margin-top: 18px; }
.login-footer { margin-top: 18px; }
.login-footer a { color: var(--muted); font-size: 0.85rem; }

/* ============ ERROR PAGE ============ */
.err-wrap {
  text-align: center; padding: 40px 20px;
}
.err-code {
  font-size: 5rem; font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: -0.03em;
}

/* ============ PROGRESS BAR ============ */
.progress {
  height: 8px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
  border: 1px solid var(--border);
}
.progress-bar {
  height: 100%; background: var(--accent-gradient-br);
  transition: width .3s;
}
.progress.warn .progress-bar { background: var(--warning); }
.progress.danger .progress-bar { background: var(--danger); }

/* ============ TABS ============ */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 14px; flex-wrap: wrap;
}
.tab {
  padding: 8px 14px; border-radius: 6px;
  color: var(--muted); font-weight: 500; font-size: 0.88rem;
  cursor: pointer; border: 0; background: transparent;
  transition: background .15s, color .15s;
}
.tab:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); }

/* ============ COPY TOAST (legacy) ============ */
.toast {
  position: fixed; bottom: 30px; left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 500;
  box-shadow: var(--shadow);
  pointer-events: none; opacity: 0;
  transition: transform .3s, opacity .3s;
  z-index: 50;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ============ TOAST CONTAINER v2 (stacked, animated) ============ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column-reverse;
  gap: 8px; z-index: 999;
  max-width: 420px; width: calc(100vw - 48px);
  pointer-events: none;
}
.toast-container .toast {
  position: static; transform: none;
  opacity: 0; pointer-events: auto;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  transition: opacity .25s, transform .25s;
  transform: translateX(40px);
  border: 1px solid;
  cursor: default;
}
.toast-container .toast.show { opacity: 1; transform: translateX(0); }
.toast-icon { font-size: 1.1em; flex-shrink: 0; }
.toast-success { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.4); color: #a7f3d0; }
.toast-error   { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #fecaca; }
.toast-warning { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); color: #fde68a; }
.toast-info    { background: rgba(96,165,250,0.12); border-color: rgba(96,165,250,0.35); color: #bfdbfe; }

@media (max-width: 640px) {
  .toast-container { right: 12px; bottom: 16px; max-width: calc(100vw - 24px); }
  .toast-container .toast { font-size: 0.85rem; padding: 10px 14px; }
}

/* ============ SKELETON LOADING ============ */
.skeleton, .skeleton-text, .skeleton-block {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
.skeleton-text { height: 1em; margin: 4px 0; border-radius: 4px; }
.skeleton-block { min-height: 60px; }
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============ STICKY TABLE HEADERS ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table-wrap thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2);
}

/* ============ TOGGLE SWITCH ============ */
.toggle-switch {
  display: inline-flex; align-items: center;
  width: 44px; height: 24px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background .2s, border-color .2s;
  position: relative;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: ""; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--muted);
  top: 2px; left: 2px;
  transition: transform .2s, background .2s;
}
.toggle-switch.toggle-on {
  background: rgba(16,185,129,0.25);
  border-color: var(--success);
}
.toggle-switch.toggle-on::after {
  transform: translateX(20px);
  background: var(--success);
}
.toggle-switch.toggle-loading { opacity: 0.6; pointer-events: none; }

/* ============ INLINE STATUS BADGE (for AJAX updates) ============ */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--muted-2); }

/* ============ RESPONSIVE TABLE (sticky first column) ============ */
@media (max-width: 640px) {
  .table-wrap.responsive-table td:first-child,
  .table-wrap.responsive-table th:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface);
    box-shadow: 2px 0 6px rgba(0,0,0,0.2);
  }
  .table-wrap.responsive-table th:first-child {
    background: var(--surface-2);
    z-index: 3;
  }
}

/* ============ UTILS ============ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 6px; }
.gap { gap: 12px; }
.gap-lg { gap: 20px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.mt-sm { margin-top: 8px; }
.mt { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide-mobile { }
@media (max-width: 640px) { .hide-mobile { display: none !important; } }

/* ============ MOBILE RESPONSIVE — comprehensive ============ */
@media (max-width: 640px) {
  /* Tighter padding on small screens */
  .main { padding: 56px 12px 32px; }
  .card { padding: 14px; margin-bottom: 12px; }
  .card-pad-lg { padding: 18px; }

  /* Headings */
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 1rem; }

  /* Hero card on mobile */
  .hero { padding: 16px; }
  .hero h2 { font-size: 1.2rem; }

  /* Stat grid: smaller cards, allow 2 columns on small screens */
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }
  .stat { padding: 12px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: 0.72rem; }

  /* Tables: smaller font + horizontal scroll smoother */
  table.t th, table.t td {
    padding: 8px 10px;
    font-size: 0.82rem;
  }
  table.t th {
    font-size: 0.68rem;
    letter-spacing: 0.02em;
  }

  /* Live request page tweaks */
  .live-stat-bar {
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }
  .live-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .live-filters label {
    margin-right: 0;
    margin-bottom: 2px;
    font-weight: 600;
  }
  .live-filters select,
  .live-filters input {
    width: 100%;
    box-sizing: border-box;
  }

  /* Detail page kv-grid — stack vertically */
  .kv-grid {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }
  .kv-grid .lbl {
    margin-top: 8px;
    font-weight: 600;
    font-size: 0.78rem;
  }

  /* Timeline more compact */
  .timeline {
    grid-template-columns: auto 1fr;
    gap: 6px 10px;
  }

  /* Tabs: scroll horizontally instead of wrap-cluttering */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: thin;
  }
  .tabs::-webkit-scrollbar { height: 4px; }
  .tab { white-space: nowrap; padding: 8px 12px; font-size: 0.82rem; }

  /* Buttons: smaller, less padding */
  .btn { padding: 8px 12px; font-size: 0.82rem; }
  .btn-sm { padding: 5px 10px; font-size: 0.76rem; }
  .btn-lg { padding: 12px 18px; font-size: 0.92rem; }

  /* Form: full-width, larger touch targets */
  .input, select, textarea {
    padding: 10px 12px;
    font-size: 16px; /* prevent iOS auto-zoom on focus */
  }
  .form-actions { gap: 6px; }
  .form-actions .btn { flex: 1; min-width: 0; }

  /* Key reveal box: better wrap */
  .key-box {
    flex-wrap: wrap;
    gap: 6px;
  }
  .key-box code {
    width: 100%;
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.78rem;
  }

  /* Card title: stack title + action button */
  .card-title {
    flex-wrap: wrap;
    gap: 8px;
  }
  .card-title h2,
  .card-title h3 {
    flex: 1 1 100%;
  }

  /* Topbar (logo + tg-link) */
  .topbar { flex-wrap: wrap; gap: 8px; }
  .tg-link { font-size: 0.78rem; padding: 6px 10px; }

  /* Pricing/package grid: 1 column kalau super sempit */
  .grid-pkg {
    grid-template-columns: 1fr;
  }
  .pkg-card { padding: 16px; }
  .pkg-price { font-size: 1.2rem; }

  /* Pager smaller */
  .pager a, .pager span { padding: 4px 9px; font-size: 0.8rem; }

  /* Sidebar on drawer-open: full width covers content */
  .sidebar { width: min(280px, 85vw); }
  .nav-link { padding: 11px 12px; font-size: 0.95rem; }

  /* Login card */
  .login-card { padding: 22px 16px; }
  .login-card h1 { font-size: 1.4rem; }

  /* Pre/code blocks: smaller font + better scroll */
  pre {
    padding: 10px 12px;
    font-size: 0.78rem;
    -webkit-overflow-scrolling: touch;
  }

  /* Flash messages: tighter */
  .flash { padding: 10px 12px; font-size: 0.85rem; }
}

/* Extra-small: <=380px (e.g. iPhone SE 1st gen) */
@media (max-width: 380px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .stat-value { font-size: 1.15rem; }
  table.t th, table.t td {
    padding: 6px 8px;
    font-size: 0.76rem;
  }
}

/* ============ INSPECTOR MODAL (mobile-friendly) ============ */
@media (max-width: 640px) {
  /* Trace viewer modal — fill more screen, smaller padding */
  #trace-modal > div {
    margin: 0 auto !important;
    padding: 16px !important;
    border-radius: 8px !important;
    max-height: 100vh;
  }
  #trace-modal h2 { font-size: 1.05rem; }
  #trace-modal h3 { font-size: 0.95rem; }
  #trace-modal pre {
    font-size: 0.72rem !important;
    max-height: 240px !important;
    padding: 8px !important;
  }
  /* kv-grid inline style override — stack vertical */
  #trace-modal .kv-grid {
    grid-template-columns: 1fr !important;
    gap: 2px !important;
  }
  #trace-modal .kv-grid > div:nth-child(odd) {
    margin-top: 6px;
    font-weight: 600;
  }
}

/* ============ LIVE STAT BAR — wrap better on small screens ============ */
@media (max-width: 640px) {
  .live-stat-bar {
    padding: 10px 12px;
    gap: 8px;
    font-size: 0.85em;
  }
  .live-stat { font-size: 0.85em; }
  .live-stat b { font-size: 1em; }
}


/* Touch device hover-less interactions */
@media (hover: none) {
  .pkg-card:hover { transform: none; box-shadow: none; }
  .nav-link:hover { background: transparent; color: var(--muted); }
  table.t tr:hover td { background: transparent; }
}


/* ============ PAGINATION ============ */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pager a, .pager span {
  padding: 6px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 0.88rem; text-decoration: none;
}
.pager a:hover { background: var(--surface-3); }
.pager .active { background: var(--accent-gradient-br); color: white; border-color: transparent; }

/* ============ LOADER ============ */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-1);
  border-radius: 50%; display: inline-block;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Fancy hero card (overview welcome) */
.hero {
  background: linear-gradient(135deg, rgba(96,165,250,0.12), rgba(167,139,250,0.08));
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  position: relative; overflow: hidden;
}
.hero h2 { font-size: 1.5rem; margin-bottom: 6px; }
.hero .hello em { background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; font-style: normal; }
