/* ═══════════════════════════════════════════════════════════════
   Waviosapp Key Dashboard — Design System
   Aesthetic: dark minimal, teal accent, developer-tool inspired
   Reference: Cosmoshub, Vercel, Linear, Stripe dark
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:            #0a0a0a;
  --bg-elevated:   #111113;
  --surface:       #17181c;
  --surface-hover: #1e1f24;
  --border:        rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);

  --text:          #e6e6e6;
  --text-dim:      #a1a1aa;
  --text-muted:    #6b6b73;

  /* Waviosapp signature: teal (deliberately different from Cosmoshub orange) */
  --accent:        #14b8a6;
  --accent-dim:    #0d9488;
  --accent-glow:   rgba(20,184,166,0.15);

  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  --radius:        12px;
  --radius-sm:     8px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Geist", "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Fira Code", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure [hidden] attribute always wins over display: flex/grid */
[hidden] { display: none !important; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══ LOGIN SCREEN ═══════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 30% 20%, var(--accent-glow), transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(59,130,246,0.08), transparent 50%),
              var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%; max-width: 400px;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand-mark { font-size: 36px; }
.brand-mark.small { font-size: 20px; }
.brand-name { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.brand-tag { color: var(--text-dim); margin-bottom: 32px; font-size: 13px; }

.login-form { display: flex; flex-direction: column; gap: 12px; }
.field-label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}
.login-form input {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color 0.15s;
}
.login-form input:focus { outline: none; border-color: var(--accent); }

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.inline { display: inline-block; text-decoration: none; margin-top: 8px; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); background: var(--surface-hover); }

.error-msg {
  color: var(--danger); font-size: 12px;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2);
  padding: 8px 12px; border-radius: var(--radius-sm);
}
.login-hint { text-align: center; margin-top: 24px; color: var(--text-muted); font-size: 12px; }

/* ═══ APP LAYOUT ══════════════════════════════════════════ */
.app-wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.header-brand { font-weight: 700; letter-spacing: -0.01em; }
.key-badge {
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 3px 10px; font-family: var(--font-mono);
  font-size: 11px; color: var(--text-dim);
}

.tabs { display: flex; gap: 4px; }
.tab {
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 13px;
  transition: all 0.15s; text-decoration: none;
}
.tab:hover { color: var(--text); background: var(--surface-hover); text-decoration: none; }
.tab.active { color: var(--accent); background: var(--accent-glow); }

.tab-content { display: flex; flex-direction: column; gap: 20px; }
.tab-content[hidden] { display: none; }

/* ═══ CARDS ═══════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.section-title {
  font-size: 15px; font-weight: 600; margin-bottom: 16px;
  letter-spacing: -0.01em;
}
.section-sub { margin-top: -12px; margin-bottom: 16px; font-size: 12px; }

.uppercase-label {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
}

/* ═══ HERO BALANCE ════════════════════════════════════════ */
.hero-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-elevated) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
}
.hero-labels { margin-bottom: 12px; }
.hero-balance {
  font-size: 42px; font-weight: 700; letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent) 0%, var(--info) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}
.progress-bar-wrap {
  height: 6px; background: var(--bg-elevated); border-radius: 3px;
  overflow: hidden; margin-bottom: 12px;
}
.progress-bar {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--info));
  border-radius: 3px; transition: width 0.4s ease;
}
.hero-meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-dim);
}

/* ═══ RANGE PICKER ════════════════════════════════════════ */
.filter-row { display: flex; justify-content: flex-end; }
.range-picker {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.range-btn {
  background: transparent; border: none; color: var(--text-muted);
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 500; transition: all 0.15s;
}
.range-btn:hover { color: var(--text); }
.range-btn.active { color: var(--text); background: var(--surface-hover); }

/* ═══ KPI GRID ════════════════════════════════════════════ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.kpi-label {
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600; margin-bottom: 8px;
}
.kpi-value { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ═══ META STRIP ══════════════════════════════════════════ */
.meta-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 20px;
}
.meta-item { display: flex; flex-direction: column; }
.meta-item .uppercase-label { margin-bottom: 4px; }
.meta-item-value { font-size: 13px; font-family: var(--font-mono); color: var(--text); }

/* ═══ MODEL USAGE BARS ════════════════════════════════════ */
.model-bars { display: flex; flex-direction: column; gap: 10px; }
.model-bar-row { display: grid; grid-template-columns: 220px 1fr 70px; gap: 12px; align-items: center; }
.model-bar-name { font-size: 12px; font-family: var(--font-mono); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-bar-track { height: 6px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; }
.model-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.model-bar-count { font-size: 11px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ═══ DATA TABLES ═════════════════════════════════════════ */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 8px;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 8px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table th.num, .data-table td.num { text-align: right; }
.model-cell { font-family: var(--font-mono); font-size: 12px; }

.status-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.status-pill.healthy, .status-pill.success { background: rgba(16,185,129,0.15); color: var(--success); }
.status-pill.degraded { background: rgba(245,158,11,0.15); color: var(--warning); }
.status-pill.down, .status-pill.failed { background: rgba(239,68,68,0.15); color: var(--danger); }
.status-pill.unknown { background: rgba(107,107,115,0.15); color: var(--text-muted); }

.tier-pill {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  font-weight: 600;
}
.tier-pill.basic { background: rgba(59,130,246,0.15); color: var(--info); }
.tier-pill.premium { background: rgba(20,184,166,0.15); color: var(--accent); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }

/* ═══ MISC ════════════════════════════════════════════════ */
.muted { color: var(--text-muted); }
.code-block {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: var(--font-mono); font-size: 12px;
  overflow-x: auto; margin-bottom: 16px;
}
.doc-heading { font-size: 13px; font-weight: 600; margin: 20px 0 8px; color: var(--text); }
.doc-heading:first-of-type { margin-top: 0; }
code { font-family: var(--font-mono); font-size: 12px; }

.redeem-form { display: flex; gap: 12px; }
.redeem-form input {
  flex: 1; background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-family: var(--font-mono); font-size: 13px;
}
.redeem-form input:focus { outline: none; border-color: var(--accent); }
.redeem-result {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px;
}
.redeem-result.success { background: rgba(16,185,129,0.1); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.redeem-result.error { background: rgba(239,68,68,0.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

/* Responsive */
@media (max-width: 720px) {
  .app-header { flex-wrap: wrap; gap: 12px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .hero-balance { font-size: 32px; }
  .model-bar-row { grid-template-columns: 140px 1fr 50px; }
}
