/* MikaAI - Premium Dark/Light Theme */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
  /* Dark Theme (default) */
  --bg-primary: #080c14;
  --bg-secondary: #0d1424;
  --bg-tertiary: #111827;
  --bg-card: #131d2e;
  --bg-hover: #1a2640;
  --bg-input: #0d1829;

  --border: #1e2d45;
  --border-light: #253550;

  --text-primary: #e8edf5;
  --text-secondary: #8899b4;
  --text-muted: #4a5e7a;

  --accent: #4f8fff;
  --accent-hover: #3d7ef0;
  --accent-glow: rgba(79,143,255,0.15);
  --accent-soft: rgba(79,143,255,0.08);

  --success: #22d3a0;
  --success-bg: rgba(34,211,160,0.1);
  --warning: #f5a623;
  --warning-bg: rgba(245,166,35,0.1);
  --danger: #ff4d6a;
  --danger-bg: rgba(255,77,106,0.1);

  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

[data-theme="light"] {
  --bg-primary: #f0f4fa;
  --bg-secondary: #e8edf7;
  --bg-tertiary: #dde5f2;
  --bg-card: #ffffff;
  --bg-hover: #eaf0fb;
  --bg-input: #f5f8ff;

  --border: #d4deee;
  --border-light: #c5d3e8;

  --text-primary: #0d1829;
  --text-secondary: #4a6080;
  --text-muted: #8a9bb5;

  --accent: #2563eb;
  --accent-hover: #1d55d6;
  --accent-glow: rgba(37,99,235,0.12);
  --accent-soft: rgba(37,99,235,0.06);

  --success: #0ea472;
  --success-bg: rgba(14,164,114,0.08);
  --warning: #d97706;
  --warning-bg: rgba(217,119,6,0.08);
  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.08);

  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
button, input, select, textarea { font-family: inherit; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
  margin-top: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg, .nav-item:hover svg { opacity: 1; }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}
.user-info:hover { background: var(--bg-hover); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--text-primary);
}
.page-body {
  padding: 24px;
  flex: 1;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 7px;
}
.modal-title svg { width: 16px; height: 16px; flex-shrink: 0; }
.card-title svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
}

/* ===== GLOBAL SVG ICON SIZES — comprehensive fix ===== */
/* All SVGs default to 16px unless specifically overridden */
svg { max-width: 100%; }

/* Context-specific sizes */
.nav-item svg,
.nav-item > svg          { width: 16px; height: 16px; flex-shrink: 0; }

.card-header svg,
.card-header .card-title svg,
.card-title svg          { width: 15px !important; height: 15px !important; flex-shrink: 0; opacity: .75; vertical-align: middle; }

.modal-title svg         { width: 16px !important; height: 16px !important; flex-shrink: 0; }

.btn svg                 { width: 14px; height: 14px; flex-shrink: 0; }
.btn-sm svg              { width: 13px; height: 13px; }
.btn-lg svg              { width: 16px; height: 16px; }

.badge svg               { width: 11px; height: 11px; flex-shrink: 0; }
.alert svg               { width: 15px; height: 15px; flex-shrink: 0; }
.copy-btn svg            { width: 14px; height: 14px; }
.conv-delete svg         { width: 12px; height: 12px; }
.user-info svg           { width: 14px; height: 14px; }
.tab svg                 { width: 13px; height: 13px; }
.form-check svg          { width: 14px; height: 14px; }
.page-header svg         { width: 16px; height: 16px; }

/* stat-icon — intentionally larger in its container */
.stat-icon svg           { width: 18px !important; height: 18px !important; }

/* Inline icons used in text — force small */
p svg, span svg, div > svg, td svg, th svg, label svg {
  width: 15px;
  height: 15px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Exception — don't shrink decorative large SVGs that have explicit size via style attr */
svg[style*="width:"],
svg[width],
canvas        { /* leave alone */ }

/* ===== STAT CARDS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.stat-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat-card:hover::before { opacity: 1; }
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.stat-icon {
  position: absolute;
  right: 16px; top: 16px;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.stat-icon svg { width: 18px; height: 18px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--bg-tertiary); }
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success {
  background: var(--success-bg);
  color: var(--success);
}
.btn-success:hover { background: var(--success); color: #fff; }
.btn-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid transparent;
}
.btn-warning:hover { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead tr {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}
th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--bg-hover); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s;
  box-shadow: var(--shadow);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ===== CHAT ===== */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
}
.chat-sidebar {
  width: 240px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.conv-item {
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.conv-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.conv-item.active { background: var(--accent-soft); color: var(--accent); }
.conv-item svg { width: 14px; height: 14px; flex-shrink: 0; opacity: 0.6; }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-delete {
  opacity: 0;
  transition: opacity 0.15s;
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 2px;
}
.conv-item:hover .conv-delete { opacity: 1; }

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-secondary);
}
.model-selector select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.message {
  display: flex;
  gap: 12px;
  max-width: 820px;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.user { flex-direction: row-reverse; align-self: flex-end; }
.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  align-self: flex-start;
}
.msg-avatar.ai { background: var(--accent); color: #fff; }
.msg-avatar.user { background: var(--bg-hover); color: var(--text-primary); }
.msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
  max-width: 680px;
}
.message.ai .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
}
.message.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-radius: 14px 4px 14px 14px;
}
.msg-bubble pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
}
.msg-bubble code {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  background: var(--bg-primary);
  padding: 2px 6px;
  border-radius: 4px;
}
.msg-bubble pre code { background: none; padding: 0; }
.msg-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
/* ── THINKING ANIMATION (Neural Pulse) ── */
.typing-indicator {
  padding: 6px 4px 6px 0;
  display: flex;
  align-items: center;
  min-width: 120px;
  min-height: 48px;
}
/* Legacy dots — hidden when neural is active */
.typing-dot { display: none; }

/* Neural canvas container */
.neural-thinking {
  position: relative;
  width: 160px;
  height: 48px;
  display: flex;
  align-items: center;
}
.neural-thinking canvas {
  display: block;
}
.neural-label {
  position: absolute;
  bottom: -3px;
  left: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  animation: neuralLabelFade 0.6s 0.4s ease forwards;
}
.neural-label svg {
  animation: serverPulse 2s ease-in-out infinite;
}
@keyframes serverPulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}
@keyframes neuralLabelFade {
  to { opacity: 0.7; }
}

/* Fallback simple dots if canvas disabled */
.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 4px 0;
}
.thinking-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinkDot 1.4s ease-in-out infinite;
}
.thinking-dot:nth-child(2){ animation-delay:.2s; background: var(--cyan, #06b6d4); }
.thinking-dot:nth-child(3){ animation-delay:.4s; background: var(--success, #22d3a0); }
@keyframes thinkDot {
  0%,80%,100%{ transform:scale(0.6); opacity:0.4; }
  40%{ transform:scale(1.2); opacity:1; }
}
.chat-input-area {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.chat-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.2s;
}
.chat-input-wrap:focus-within { border-color: var(--accent); }
.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  padding-top: 3px;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-send-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: var(--accent-hover); }
.chat-send-btn:active { transform: scale(0.95); }
.chat-send-btn svg { width: 16px; height: 16px; }
.token-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.token-progress {
  flex: 1;
  height: 3px;
  background: var(--bg-hover);
  border-radius: 99px;
  overflow: hidden;
}
.token-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.5s ease;
}
.token-fill.warning { background: var(--warning); }
.token-fill.danger { background: var(--danger); }

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79,143,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(79,143,255,0.04) 0%, transparent 60%);
  pointer-events: none;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  justify-content: center;
}
.auth-logo .logo-icon {
  width: 42px; height: 42px;
  background: var(--accent);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  color: #fff;
  font-size: 18px;
}
.auth-logo .logo-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  color: var(--text-primary);
}
.auth-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}
.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 20px;
}

/* ===== TOKEN DISPLAY ===== */
.token-display {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.token-numbers {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== PACKAGE CARDS ===== */
.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.pkg-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.2s;
  position: relative;
}
.pkg-card.current { border-color: var(--accent); }
.pkg-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow); }
.pkg-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.pkg-price { font-size: 28px; font-weight: 700; color: var(--accent); margin: 12px 0; }
.pkg-price span { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.pkg-features { list-style: none; margin: 12px 0 20px; }
.pkg-features li { font-size: 13px; color: var(--text-secondary); padding: 4px 0; display: flex; gap: 6px; align-items: center; }
.pkg-features li::before { content: '✓'; color: var(--success); font-weight: 700; }
.pkg-badge {
  position: absolute; top: -1px; right: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 0 0 8px 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  width: fit-content;
}
.tab {
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
  background: none;
}
.tab.active { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-sm); }
.tab:hover:not(.active) { color: var(--text-primary); }

/* ===== MISC ===== */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== HAMBURGER (mobile) ===== */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-primary);
  padding: 6px;
}

/* ===== API TOKEN DISPLAY ===== */
.api-token-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  word-break: break-all;
}
.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.2s;
}
.copy-btn:hover { color: var(--accent-hover); }

/* ===== PROGRESS / SKELETON ===== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 16px;
}
@keyframes skeleton { to { background-position: -200% 0; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .hamburger { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
  .chat-sidebar { display: none; }
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 99px;
  display: flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  cursor: pointer;
}
.theme-btn {
  width: 28px; height: 26px;
  border-radius: 99px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}
.theme-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.theme-btn svg { width: 14px; height: 14px; }

/* ===== TOOLTIP ===== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 99;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slide-up { animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== GLOW EFFECTS (dark mode only) ===== */
body:not([data-theme="light"]) .stat-card.accent { box-shadow: 0 0 20px rgba(79,143,255,0.08); }
body:not([data-theme="light"]) .btn-primary { box-shadow: 0 2px 12px rgba(79,143,255,0.2); }
