/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #21262d;
  --glass:       rgba(255,255,255,0.05);
  --glass-border:rgba(255,255,255,0.10);
  --blue:        #0078D4;
  --blue-light:  #2196f3;
  --blue-dark:   #005A9E;
  --green:       #3fb950;
  --red:         #f85149;
  --yellow:      #e3b341;
  --purple:      #bc8cff;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --text-dim:    #484f58;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 8px 32px rgba(0,0,0,0.4);
  --sidebar-w:   220px;
  --topbar-h:    60px;
  --transition:  0.2s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }

/* ── Glassmorphism ────────────────────────────────────────────────────────── */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Login Overlay ────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 40% 30%, rgba(0,120,212,0.18) 0%, var(--bg) 70%);
}
.overlay.hidden { display: none; }

.login-card {
  width: 420px; padding: 40px; border-radius: 20px;
  box-shadow: var(--shadow), 0 0 80px rgba(0,120,212,0.15);
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo { text-align: center; margin-bottom: 16px; }
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 12px; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.field-group input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--glass-border); color: var(--text);
  font-size: 14px; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field-group input:focus {
  border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,120,212,0.20);
}
.field-group input::placeholder { color: var(--text-dim); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px;
  font-family: inherit; font-weight: 500; cursor: pointer;
  border: none; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-light); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,120,212,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--glass-border); }
.btn-secondary:hover { background: var(--glass); border-color: var(--blue); color: var(--blue-light); }
.btn-danger { background: rgba(248,81,73,0.15); color: var(--red); border: 1px solid rgba(248,81,73,0.3); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--glass); color: var(--text); }
.btn-full { width: 100%; margin-top: 8px; padding: 13px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }

.error-msg { font-size: 13px; color: var(--red); text-align: center; margin-top: 12px; }
.hidden { display: none !important; }

/* ── App Shell ────────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; }
.app.hidden { display: none; }

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; height: 100vh;
  display: flex; flex-direction: column; padding: 20px 12px;
  border-right: 1px solid var(--glass-border); overflow: hidden;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px; color: var(--text);
  padding: 0 8px; margin-bottom: 28px;
}
.nav-list { list-style: none; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-muted); cursor: pointer;
  transition: all var(--transition); user-select: none;
}
.nav-item:hover { background: var(--glass); color: var(--text); }
.nav-item.active { background: rgba(0,120,212,0.18); color: var(--blue-light); font-weight: 500; }
.nav-icon { font-size: 16px; }
.sidebar-logout { margin-top: 16px; font-size: 13px; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: var(--topbar-h); display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px;
  border-bottom: 1px solid var(--glass-border); flex-shrink: 0;
  background: rgba(13,17,23,0.6); backdrop-filter: blur(10px);
}
.page-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.status-badge { font-size: 12px; color: var(--green); }
.status-badge.error { color: var(--red); }
.time-display { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.page { flex: 1; overflow-y: auto; padding: 24px; }
.page.active { display: block; }
.page.hidden { display: none; }

/* ── Cards & Grid ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.card-title {
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 20px;
  position: relative; overflow: hidden; transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--blue); }
.stat-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,120,212,0.08) 0%, transparent 60%);
  pointer-events: none;
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-icon { position: absolute; right: 16px; top: 16px; font-size: 28px; opacity: 0.4; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.6px; border-bottom: 1px solid var(--glass-border); }
td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.mono { font-family: 'Courier New', monospace; font-size: 12px; color: var(--text-muted); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-green { background: rgba(63,185,80,0.15); color: var(--green); }
.badge-red   { background: rgba(248,81,73,0.15); color: var(--red); }
.badge-blue  { background: rgba(0,120,212,0.15); color: var(--blue-light); }
.badge-yellow{ background: rgba(227,179,65,0.15); color: var(--yellow); }
.badge-purple{ background: rgba(188,140,255,0.15); color: var(--purple); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.form-row .field-group { min-width: 160px; flex: 1; margin-bottom: 0; }
select {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--bg3); border: 1px solid var(--glass-border);
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  appearance: none; cursor: pointer;
  transition: border-color var(--transition);
}
select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,120,212,0.20); }

/* ── Code Chips ───────────────────────────────────────────────────────────── */
.code-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg3); border: 1px solid var(--glass-border);
  border-radius: 6px; padding: 4px 10px; font-family: monospace;
  font-size: 13px; letter-spacing: 1px; color: var(--yellow);
  cursor: pointer; transition: all var(--transition);
}
.code-chip:hover { border-color: var(--yellow); color: var(--text); }

.codes-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ── Section toolbar ──────────────────────────────────────────────────────── */
.section-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.section-bar h2 { font-size: 16px; font-weight: 600; }

/* ── Pricing table ────────────────────────────────────────────────────────── */
.pricing-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding: 14px; border-radius: var(--radius-sm); background: var(--bg3); border: 1px solid var(--glass-border); }
.pricing-label { flex: 1; font-weight: 500; }
.pricing-detail { flex: 2; }
.pricing-detail input { max-width: 160px; }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progress-bar { height: 4px; border-radius: 2px; background: var(--bg3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: linear-gradient(90deg, var(--blue), var(--blue-light)); transition: width 0.6s ease; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1px solid var(--glass-border);
  box-shadow: var(--shadow); font-size: 14px; max-width: 340px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
.toast-icon { font-size: 16px; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Loader ───────────────────────────────────────────────────────────────── */
.loader { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); gap: 10px; font-size: 14px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--bg3); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Highlight numbers ────────────────────────────────────────────────────── */
.num-ai     { color: var(--blue-light); font-weight: 600; }
.num-send   { color: var(--green); font-weight: 600; }
.num-zero   { color: var(--text-dim); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .brand span, .nav-item span:last-child, .sidebar-logout { display: none; }
  .nav-item { justify-content: center; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
