/* ═══════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════ */
:root {
  --bg:          #060a12;
  --surface:     #0b1120;
  --surface-2:   #111827;
  --surface-3:   #1a2535;
  --surface-4:   #232f45;
  --border:      rgba(255,255,255,0.055);
  --border-2:    rgba(255,255,255,0.10);
  --text:        #e2e8f3;
  --text-2:      #8892a4;
  --text-3:      #4a5a72;
  --accent:      #4f8ef7;
  --accent-2:    #7cb4ff;
  --accent-bg:   rgba(79,142,247,0.10);
  --accent-glow: rgba(79,142,247,0.18);
  --success:     #34d399;
  --success-bg:  rgba(52,211,153,0.10);
  --warning:     #fbbf24;
  --warning-bg:  rgba(251,191,36,0.10);
  --danger:      #f87171;
  --danger-bg:   rgba(248,113,113,0.10);
  --purple:      #a78bfa;
  --pink:        #f472b6;
  --teal:        #2dd4bf;
  --orange:      #fb923c;

  --sidebar-w:   240px;
  --radius:      10px;
  --radius-lg:   14px;
  --radius-xl:   18px;

  --font-display: 'Syne', sans-serif;
  --font-body:    'Instrument Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-glow: 0 0 0 1px var(--accent-glow), 0 4px 24px var(--accent-glow);
}

/* ═══════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

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

/* Dot grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(79,142,247,0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}

/* Ambient glow top-left */
body::after {
  content: '';
  position: fixed;
  top: -200px; left: -200px;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(79,142,247,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* ═══════════════════════════════════════════════════
   LIGHT THEME
═══════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:          #f0f4f8;
  --surface:     #ffffff;
  --surface-2:   #f8fafc;
  --surface-3:   #edf2f7;
  --surface-4:   #e2e8f0;
  --border:      rgba(0,0,0,0.07);
  --border-2:    rgba(0,0,0,0.12);
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;
  --accent-bg:   rgba(79,142,247,0.09);
  --accent-glow: rgba(79,142,247,0.15);
  --success-bg:  rgba(52,211,153,0.12);
  --warning-bg:  rgba(251,191,36,0.12);
  --danger-bg:   rgba(248,113,113,0.12);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.05);
}

[data-theme="light"] body::before {
  background-image: radial-gradient(circle, rgba(79,142,247,0.12) 1px, transparent 1px);
}
[data-theme="light"] body::after { display: none; }
[data-theme="light"] .sidebar { box-shadow: 2px 0 12px rgba(0,0,0,0.06); }

/* ═══════════════════════════════════════════════════
   AUTH SCREEN
═══════════════════════════════════════════════════ */
.auth-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  background: var(--bg);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  animation: authSlideIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes authSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.auth-subtitle { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.auth-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  padding: 8px;
  background: var(--danger-bg);
  border-radius: var(--radius);
}

/* ═══════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════ */
#app-shell {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 20px 8px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-mark {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar-close { display: none; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-decoration: none;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item:hover { background: var(--surface-3); color: var(--text); }

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(79,142,247,0.2);
}

.nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-badge {
  margin-left: auto;
  background: var(--warning);
  color: #000;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.logout-btn { color: var(--text-3) !important; }
.logout-btn:hover { color: var(--danger) !important; background: var(--danger-bg) !important; }

/* ═══════════════════════════════════════════════════
   MOBILE HEADER
═══════════════════════════════════════════════════ */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  height: 56px;
}

.mobile-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 45;
  backdrop-filter: blur(2px);
}

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  min-height: 100vh;
  max-width: calc(1200px + var(--sidebar-w));
  position: relative;
  z-index: 1;
}

.page {
  animation: pageIn 0.2s ease;
}

@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 2px;
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

/* ═══════════════════════════════════════════════════
   STATS CARDS
═══════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover::before { opacity: 1; }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-value.accent  { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }

.stat-change {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════
   CHARTS
═══════════════════════════════════════════════════ */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 18px;
}

.chart-wrap { position: relative; }
.chart-wrap.donut { height: 200px; }
.chart-wrap.line   { height: 200px; }

/* ═══════════════════════════════════════════════════
   SECTION CARDS
═══════════════════════════════════════════════════ */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.section-card-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════
   TABLE
═══════════════════════════════════════════════════ */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

th:hover { color: var(--text-2); }

th.sorted { color: var(--accent); }

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  opacity: 0.6;
}

th.sorted .sort-icon { opacity: 1; }

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255,255,255,0.02); }

.td-name strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.td-name small {
  display: block;
  color: var(--text-3);
  font-size: 12px;
  margin-top: 1px;
}

.amount-mono {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════
   CHIPS / BADGES
═══════════════════════════════════════════════════ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chip-ok      { background: var(--success-bg); color: var(--success); }
.chip-warn    { background: var(--warning-bg); color: var(--warning); }
.chip-danger  { background: var(--danger-bg);  color: var(--danger);  }
.chip-muted   { background: var(--surface-3);  color: var(--text-3);  }
.chip-trial   { background: rgba(167,139,250,0.12); color: var(--purple); }
.chip-accent  { background: var(--accent-bg);  color: var(--accent);  }

.color-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

/* ═══════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: all 0.15s ease;
  position: relative;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--border-2);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
  border: none;
}
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.1); }

.btn-success {
  background: var(--success);
  color: #000;
  border: none;
  font-weight: 700;
}
.btn-success:hover:not(:disabled) { filter: brightness(1.1); }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }

.w-full { width: 100%; }

/* Button loading state */
.btn-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 5px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  line-height: 1;
  font-size: 13px;
}

.btn-icon:hover { color: var(--text); background: var(--surface-3); }

.actions-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

/* ═══════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.03em;
}

.form-input, .form-select, .form-textarea {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-input[type="color"] {
  padding: 4px 6px;
  height: 38px;
  cursor: pointer;
}

.form-select option { background: var(--surface-2); }
.form-textarea { resize: vertical; min-height: 70px; }

.form-hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ═══════════════════════════════════════════════════
   TOGGLE SWITCH
═══════════════════════════════════════════════════ */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px; height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--surface-4);
  border-radius: 999px;
  border: 1px solid var(--border-2);
  transition: all 0.2s;
}

.toggle-thumb {
  position: absolute;
  width: 16px; height: 16px;
  left: 2px; top: 2px;
  background: var(--text-3);
  border-radius: 50%;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track + .toggle-thumb,
.toggle input:checked ~ .toggle-thumb { transform: translateX(18px); background: #fff; }

/* ═══════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6,10,18,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  padding: 20px;
  animation: backdropIn 0.2s ease;
}

@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(79,142,247,0.08);
  animation: modalIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.confirm-modal { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-body {
  padding: 22px 26px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  position: relative;
  overflow: hidden;
  animation: toastIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.toast.out { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 80px; }
  to   { opacity: 0; transform: translateX(20px); max-height: 0; padding: 0; margin: 0; }
}

.toast-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  transform-origin: left;
  animation: toastBar linear forwards;
}

@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.toast-icon { font-size: 16px; flex-shrink: 0; line-height: 1; }
.toast-text { flex: 1; font-size: 13px; font-weight: 500; line-height: 1.4; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-3); padding: 2px; border-radius: 4px; flex-shrink: 0; font-size: 12px; }
.toast-close:hover { color: var(--text-2); }

.toast-success .toast-bar { background: var(--success); }
.toast-error   .toast-bar { background: var(--danger);  }
.toast-warning .toast-bar { background: var(--warning); }
.toast-info    .toast-bar { background: var(--accent);  }

/* ═══════════════════════════════════════════════════
   TOOLBAR
═══════════════════════════════════════════════════ */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 160px;
  max-width: 260px;
}

.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  font-size: 13px;
}

.search-input {
  padding-left: 30px !important;
  width: 100%;
}

/* ═══════════════════════════════════════════════════
   CMD+K PALETTE
═══════════════════════════════════════════════════ */
.cmdpalette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,10,18,0.65);
  z-index: 500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  backdrop-filter: blur(4px);
  animation: backdropIn 0.15s ease;
}

.cmdpalette {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 580px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(79,142,247,0.1);
  animation: modalIn 0.2s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}

.cmdpalette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.cmdpalette-search-icon {
  color: var(--text-3);
  font-size: 16px;
  flex-shrink: 0;
}

#cmdpalette-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}

#cmdpalette-input::placeholder { color: var(--text-3); }

.cmdpalette-esc {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.cmdpalette-results {
  overflow-y: auto;
  padding: 6px 0 8px;
  max-height: calc(70vh - 60px);
}

.cmdpalette-group {
  padding: 8px 16px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
}

.cmdpalette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 0;
}

.cmdpalette-item:hover,
.cmdpalette-item.active {
  background: var(--accent-bg);
}

.cmdpalette-item.active .cmdpalette-item-label { color: var(--accent); }

.cmdpalette-item-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.cmdpalette-item-label {
  flex: 1;
  font-size: 13.5px;
  font-weight: 500;
}

.cmdpalette-item-meta {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
}

.cmdpalette-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-3);
  font-size: 13px;
}

/* ═══════════════════════════════════════════════════
   BULK ACTIONS BAR
═══════════════════════════════════════════════════ */
.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(79,142,247,0.1);
  z-index: 90;
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
}

.bulk-bar-count {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding-right: 8px;
  border-right: 1px solid var(--border-2);
  margin-right: 2px;
}

/* Row checkbox */
.row-check {
  width: 15px; height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

tr.selected td { background: rgba(79,142,247,0.06) !important; }

/* Archive row style */
tr.archived-row td { opacity: 0.45; }

/* Bulk count alias */
.bulk-count {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  padding-right: 8px;
  border-right: 1px solid var(--border-2);
  margin-right: 2px;
}

/* Cmdpalette extensions */
.cmdpalette-category {
  padding: 8px 16px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
}
.cmdpalette-item.selected { background: var(--accent-bg); }
.cmdpalette-item.selected .cmdpalette-item-label { color: var(--accent); }
.cmdpalette-item-desc {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.cmdpalette-item-shortcut {
  font-size: 10px;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: auto;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════
   DOCS PAGE
═══════════════════════════════════════════════════ */
.docs-layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 32px;
  align-items: start;
}

.docs-nav {
  position: sticky;
  top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 0;
}

.docs-nav-item {
  display: block;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.docs-nav-item:hover { color: var(--text); border-left-color: var(--border-2); }
.docs-nav-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-bg); }

.docs-nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 12px 18px 4px;
}

.docs-content { min-width: 0; }

.docs-section {
  margin-bottom: 48px;
  scroll-margin-top: 24px;
}

.docs-section h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.docs-section h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text);
}

.docs-section p {
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 12px;
  font-size: 14px;
}

.docs-section ul {
  color: var(--text-2);
  padding-left: 20px;
  margin-bottom: 12px;
  line-height: 1.8;
  font-size: 14px;
}

.docs-section li { margin-bottom: 3px; }

.docs-code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  margin: 12px 0;
  overflow-x: auto;
  line-height: 1.6;
}

.docs-code .comment { color: var(--text-3); }
.docs-code .key     { color: var(--accent-2); }
.docs-code .val     { color: var(--success); }
.docs-code .method  { color: var(--warning); }

.docs-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.docs-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.docs-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
  vertical-align: top;
}
.docs-table tr:last-child td { border-bottom: none; }
.docs-table code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent-2);
}

.docs-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.docs-badge-get    { background: rgba(52,211,153,0.15); color: var(--success); }
.docs-badge-post   { background: rgba(79,142,247,0.15); color: var(--accent);  }
.docs-badge-put    { background: rgba(251,191,36,0.15); color: var(--warning); }
.docs-badge-delete { background: rgba(248,113,113,0.15);color: var(--danger);  }

.docs-tip {
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px;
  margin: 14px 0;
  font-size: 13px;
  color: var(--text-2);
}

.docs-tip strong { color: var(--text); }

.docs-tip-warning { background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.25); }
.docs-tip-warning .docs-tip-icon { color: var(--warning); }
.docs-tip-icon { font-size: 15px; color: var(--accent); flex-shrink: 0; }

/* Nav link aliases */
.docs-nav-link {
  display: block;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.docs-nav-link:hover { color: var(--text); border-left-color: var(--border-2); }
.docs-nav-link.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-bg); }
.docs-nav-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 12px 18px 4px;
}

/* Heading helpers */
.docs-h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.docs-h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--text);
}

/* Inline code in docs */
.docs-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-2, var(--accent));
}

/* Keyboard key */
.docs-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  box-shadow: 0 1px 0 var(--border-2);
}

/* Badge variants for docs */
.docs-badge-success { background: rgba(52,211,153,0.12); color: #34d399; }
.docs-badge-info    { background: rgba(79,142,247,0.12); color: var(--accent); }
.docs-badge-warning { background: rgba(251,191,36,0.12); color: var(--warning); }
.docs-badge-danger  { background: rgba(248,113,113,0.12); color: var(--danger); }

/* Docs ordered list */
.docs-section ol {
  color: var(--text-2);
  padding-left: 20px;
  margin-bottom: 12px;
  line-height: 1.8;
  font-size: 14px;
}

@media (max-width: 768px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-nav { position: static; }
}

/* ═══════════════════════════════════════════════════
   BUDGET BAR
═══════════════════════════════════════════════════ */
.budget-bar-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 20px;
}

.budget-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.budget-bar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.budget-bar-amounts {
  font-size: 13px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 4px;
}

.budget-bar-pct {
  font-weight: 700;
  margin-left: 6px;
}

.budget-bar-track {
  height: 7px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.budget-bar-warn {
  font-size: 12px;
  color: var(--warning);
  margin-top: 8px;
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════
   CALENDAR
═══════════════════════════════════════════════════ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0 8px;
}

.cal-day {
  min-height: 52px;
  border-radius: 8px;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background 0.1s;
}

.cal-day:not(.empty):hover { background: var(--surface-2); }
.cal-day.empty { pointer-events: none; }

.cal-day.today .cal-day-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-day.has-renewal { background: var(--accent-bg); }
.cal-day.has-renewal.today { background: rgba(79,142,247,0.18); }

.cal-day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 0 1px;
}

.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cal-dot-more {
  font-size: 9px;
  color: var(--text-3);
  font-weight: 600;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

.cal-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px 3px 6px;
}

.cal-legend-name { color: var(--text-2); font-weight: 500; }
.cal-legend-date { color: var(--text-3); font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════
   RENEWAL LIST (Dashboard)
═══════════════════════════════════════════════════ */
.renewal-list { padding: 0 20px; }

.renewal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.renewal-item:last-child { border-bottom: none; }

.renewal-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

.renewal-info { flex: 1; min-width: 0; }
.renewal-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.renewal-meta { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.renewal-amount { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text); }

/* ═══════════════════════════════════════════════════
   HISTORY PAGE
═══════════════════════════════════════════════════ */
.timeline { padding: 0; }

.timeline-item {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background 0.1s;
}

.timeline-item:last-child { border-bottom: none; }
.timeline-item:hover { background: rgba(255,255,255,0.02); }

.timeline-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin-top: 2px;
}

.timeline-content { flex: 1; }
.timeline-name { font-weight: 600; font-size: 14px; }
.timeline-meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.timeline-amount {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  font-size: 15px;
  white-space: nowrap;
}

.history-stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════
   SETTINGS PAGE
═══════════════════════════════════════════════════ */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-section-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }

.settings-label {
  font-weight: 500;
  min-width: 180px;
  flex-shrink: 0;
  font-size: 14px;
}

.settings-desc { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.settings-control { flex: 1; max-width: 340px; }
.settings-actions { display: flex; gap: 8px; margin-left: auto; }

/* ═══════════════════════════════════════════════════
   ADDY.IO ALIASES
═══════════════════════════════════════════════════ */
/* ═══════════════════════════════════════════════════
   ADDY.IO TABS
═══════════════════════════════════════════════════ */
.addy-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.addy-tab {
  flex-shrink: 0;
  padding: 7px 16px;
  border-radius: calc(var(--radius-lg) - 4px);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.addy-tab:hover  { background: var(--surface-2); color: var(--text); }
.addy-tab.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

/* ═══════════════════════════════════════════════════
   ADDY.IO ACCOUNT BAR
═══════════════════════════════════════════════════ */
.addy-account-bar {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
}

.addy-account-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 20px;
  border-right: 1px solid var(--border);
  flex: 1;
}
.addy-account-stat:last-child { border-right: none; }

.addy-account-label {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.addy-account-value {
  font-size: 20px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

/* ═══════════════════════════════════════════════════
   FILTER PILLS
═══════════════════════════════════════════════════ */
.filter-pills {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.filter-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.filter-pill:hover  { border-color: var(--border-2); color: var(--text); }
.filter-pill.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* ═══════════════════════════════════════════════════
   ADDY BADGES & CHIPS
═══════════════════════════════════════════════════ */
.addy-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.addy-badge-active   { background: var(--success-bg); color: var(--success); }
.addy-badge-inactive { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.addy-badge-pin      { background: rgba(251,191,36,0.12); color: var(--warning); font-size: 12px; }

.addy-chips { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.addy-chip  {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-2);
}

/* ═══════════════════════════════════════════════════
   ALIAS CARDS
═══════════════════════════════════════════════════ */
.aliases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.alias-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alias-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.alias-card.inactive { opacity: 0.5; }
.alias-card.pinned   { border-color: rgba(251,191,36,0.3); }

.alias-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.alias-badges { display: flex; gap: 4px; flex-shrink: 0; }

.alias-email {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.4;
  cursor: pointer;
}
.alias-email:hover { text-decoration: underline; }

.alias-desc { color: var(--text-2); font-size: 12px; line-height: 1.4; }

.alias-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.alias-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }

/* Chip statuts */
.chip-active   { background: var(--success-bg); color: var(--success); }
.chip-inactive { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════
   ADDY.IO PAGINATION
═══════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
}

.page-info { font-size: 13px; color: var(--text-2); margin: 0 8px; }

/* ═══════════════════════════════════════════════════
   EMPTY STATES
═══════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-3);
  text-align: center;
  gap: 10px;
}

.empty-state-icon { font-size: 32px; opacity: 0.4; }
.empty-state-text { font-size: 14px; font-weight: 500; color: var(--text-2); }
.empty-state-hint { font-size: 12px; }

/* ═══════════════════════════════════════════════════
   SPINNER
═══════════════════════════════════════════════════ */
.spinner-large {
  width: 36px; height: 36px;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ═══════════════════════════════════════════════════
   MISC UTILITIES
═══════════════════════════════════════════════════ */
.text-muted  { color: var(--text-2); }
.text-faint  { color: var(--text-3); }
.text-accent { color: var(--accent); }
.text-success{ color: var(--success); }
.text-warning{ color: var(--warning); }
.text-danger { color: var(--danger); }
.text-mono   { font-family: var(--font-mono); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    border-right: none;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-close { display: flex; }

  .sidebar-overlay.visible { display: block; }

  .mobile-header { display: flex; }

  .main-content {
    margin-left: 0;
    padding: 16px;
    margin-top: 56px;
  }

  .page-title { font-size: 20px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .form-grid { grid-template-columns: 1fr; }

  .modal { max-width: 100%; margin: 0 8px; }
  .modal-body { padding: 16px 20px; }
  .modal-header, .modal-footer { padding: 16px 20px; }

  .settings-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .settings-label { min-width: unset; }
  .settings-control { max-width: 100%; width: 100%; }

  .toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { min-width: unset; max-width: 100%; }
}

/* ═══════════════════════════════════════════════════
   TAGS
═══════════════════════════════════════════════════ */
.tag-selector { display:flex;flex-wrap:wrap;gap:6px;min-height:32px;padding:4px 0; }
.tag-option { cursor:pointer; }
.tag-option.selected .tag-chip { box-shadow:0 0 0 2px var(--accent); }
.tag-chip { display:inline-flex;align-items:center;padding:3px 10px;border-radius:20px;font-size:12px;font-weight:500;cursor:pointer;transition:box-shadow .15s; }
.row-tags { display:flex;flex-wrap:wrap;gap:3px;margin-top:3px; }
.row-tag { display:inline-flex;align-items:center;padding:1px 7px;border-radius:12px;font-size:11px;font-weight:500; }

/* ═══════════════════════════════════════════════════
   VALUE SCORE STARS
═══════════════════════════════════════════════════ */
.star-picker { display:flex;gap:3px;cursor:pointer;user-select:none; }
.star-picker .star { font-size:20px;color:var(--text-3);transition:color .1s,transform .1s; }
.star-picker .star.on,
.star-picker .star.hover { color:#fbbf24; }
.star-picker .star:hover { transform:scale(1.2); }
.value-stars { font-size:12px;color:#fbbf24;letter-spacing:1px; }

/* ═══════════════════════════════════════════════════
   DUPLICATE DETECTION
═══════════════════════════════════════════════════ */
.dupe-banner { display:flex;align-items:center;gap:10px;padding:10px 14px;background:rgba(251,191,36,0.08);border:1px solid rgba(251,191,36,0.25);border-radius:10px;font-size:13px;color:var(--text-2);margin-bottom:16px; }
.dupe-icon { font-size:16px;color:var(--warning);flex-shrink:0; }
.dupe-pair { display:flex;align-items:center;gap:10px;padding:10px 12px;background:var(--surface-2);border-radius:8px; }
.dupe-item { display:flex;flex-direction:column;gap:2px;flex:1; }

/* ═══════════════════════════════════════════════════
   CSV IMPORT
═══════════════════════════════════════════════════ */
.csv-suggestion:hover { background:var(--accent-bg); }

/* ═══════════════════════════════════════════════════
   TIMELINE
═══════════════════════════════════════════════════ */
.tl-wrap { display:flex;flex-direction:column;gap:0; }
.tl-month { margin-bottom:32px; }
.tl-month-header { display:flex;align-items:center;justify-content:space-between;padding:0 0 12px;border-bottom:1px solid var(--border);margin-bottom:16px; }
.tl-month-label { font-family:var(--font-display);font-size:16px;font-weight:700;color:var(--text);text-transform:capitalize; }
.tl-month-total { font-family:var(--font-mono);font-size:13px;color:var(--accent);font-weight:600; }
.tl-events { display:flex;flex-direction:column;gap:2px; }
.tl-event { display:grid;grid-template-columns:52px 24px 1fr auto;align-items:center;gap:12px;padding:6px 0;position:relative; }
.tl-event.tl-today { background:var(--accent-bg);border-radius:10px;padding:6px 10px;margin:0 -10px; }
.tl-date-col { display:flex;flex-direction:column;align-items:center;gap:0; }
.tl-day-num { font-family:var(--font-display);font-size:20px;font-weight:700;line-height:1;color:var(--text); }
.tl-day-name { font-size:10px;color:var(--text-3);text-transform:uppercase;letter-spacing:.05em; }
.tl-dot-col { display:flex;flex-direction:column;align-items:center;position:relative;height:100%;min-height:44px; }
.tl-line { flex:1;width:2px;background:var(--border);position:absolute;top:0;bottom:0;left:50%;transform:translateX(-50%); }
.tl-dot { width:12px;height:12px;border-radius:50%;position:relative;z-index:1;border:2px solid var(--bg);box-shadow:0 0 0 2px currentColor; }
.tl-card { display:flex;flex-direction:column;gap:2px; }
.tl-card-name { font-weight:600;font-size:14px;color:var(--text); }
.tl-card-meta { font-size:12px;color:var(--text-2);display:flex;align-items:center;gap:6px; }
.tl-card-desc { font-size:11px;color:var(--text-3); }
.tl-sep { color:var(--text-3); }
.tl-amount { font-family:var(--font-mono);font-size:13px;font-weight:600;color:var(--text);white-space:nowrap; }

/* ═══════════════════════════════════════════════════
   INLINE EDITING
═══════════════════════════════════════════════════ */
td[data-edit] { cursor:text; transition:background .12s; }
td[data-edit]:hover { background:var(--accent-bg); }
.inline-edit-input {
  width:100%;min-width:80px;
  background:var(--input-bg);
  border:1.5px solid var(--accent);
  border-radius:6px;
  padding:3px 8px;
  color:var(--text);
  font:inherit;font-size:13px;
  outline:none;
  box-shadow:0 0 0 3px rgba(79,142,247,.15);
}

/* ═══════════════════════════════════════════════════
   PRINT / PDF EXPORT
═══════════════════════════════════════════════════ */
/* ── Service autocomplete ── */
.service-suggestions {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-height: 220px; overflow-y: auto; margin-top: 4px;
}
.service-suggestion-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  transition: background .12s;
}
.service-suggestion-item:hover { background: var(--hover); }

/* ── Optimization page ── */
.opt-list { display: flex; flex-direction: column; gap: 6px; }
.opt-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; background: var(--surface-2);
  font-size: 13px;
}
.opt-name { font-weight: 600; color: var(--text); }
.opt-meta { color: var(--text-3); font-size: 11px; margin-left: 6px; }
.opt-amount { font-family: var(--font-mono); font-size: 13px; color: var(--text); white-space: nowrap; }
.opt-rank { font-weight: 700; color: var(--accent); width: 20px; text-align: center; flex-shrink: 0; font-size: 15px; }
.opt-desc { color: var(--text-2); font-size: 13px; margin-bottom: 12px; line-height: 1.5; }
.opt-categories { display: flex; flex-direction: column; gap: 10px; }
.opt-cat-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.opt-cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.opt-cat-label { width: 90px; flex-shrink: 0; color: var(--text-2); }
.opt-cat-bar-wrap { flex: 1; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.opt-cat-bar { height: 100%; border-radius: 4px; transition: width .4s ease; min-width: 2px; }
.opt-cat-amount { font-family: var(--font-mono); font-size: 12px; color: var(--text); white-space: nowrap; min-width: 90px; text-align: right; }
.opt-cat-pct { font-size: 11px; color: var(--text-3); width: 32px; text-align: right; }

/* ── Calendar full page ── */
.cal-nav {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.cal-month-title { font-size: 18px; font-weight: 700; flex: 1; text-align: center; }
.cal-summary {
  display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.cal-summary-item {
  flex: 1; min-width: 130px; background: var(--surface-2);
  border-radius: 8px; padding: 12px 16px;
}
.cal-summary-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.cal-summary-value { font-size: 18px; font-weight: 700; margin-top: 4px; }
.calendar-grid-full {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.cal-day-full {
  min-height: 90px; padding: 6px 8px; background: var(--surface-2);
  border-radius: 6px; display: flex; flex-direction: column; gap: 2px;
  transition: background .15s;
}
.cal-day-full.today { background: var(--accent-bg); border: 1px solid var(--accent)40; }
.cal-day-full.has-renewal { cursor: pointer; }
.cal-day-full.has-renewal:hover { background: var(--hover); }
.cal-day-full.empty { background: transparent; }
.cal-day-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.cal-day-total { font-size: 10px; color: var(--accent); font-family: var(--font-mono); }
.cal-event {
  display: flex; align-items: center; gap: 4px; padding: 2px 5px;
  border-radius: 3px; background: var(--surface-3); font-size: 10px;
  overflow: hidden; white-space: nowrap;
}
.cal-event-name { flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.cal-event-amount { font-family: var(--font-mono); color: var(--text-3); flex-shrink: 0; }
.cal-more { font-size: 10px; color: var(--text-3); padding: 1px 4px; }

/* ── Annual report ── */
.annual-hero {
  position: relative; border-radius: 12px; overflow: hidden;
  padding: 40px 32px; margin-bottom: 16px; text-align: center;
  background: linear-gradient(135deg, #0a1628 0%, #1a2340 50%, #0d1830 100%);
  border: 1px solid var(--accent)30;
}
.annual-hero-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent)15 0%, transparent 60%);
  pointer-events: none;
}
.annual-hero-content { position: relative; z-index: 1; }
.annual-hero-label { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.annual-hero-amount { font-size: 48px; font-weight: 800; color: white; font-family: var(--font-mono); letter-spacing: -.02em; }
.annual-hero-sub { font-size: 14px; color: rgba(255,255,255,.7); margin-top: 8px; }
.annual-hero-fun { font-size: 13px; color: rgba(255,255,255,.5); margin-top: 4px; }
.annual-top-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.annual-top-item:last-child { border-bottom: none; }
.annual-bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 0 4px; }
.annual-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.annual-bar-val { font-size: 9px; color: var(--text-3); font-family: var(--font-mono); }
.annual-bar-fill { width: 100%; border-radius: 3px 3px 0 0; min-height: 2px; transition: height .4s ease; }
.annual-bar-label { font-size: 10px; color: var(--text-3); }
.annual-fact {
  background: var(--surface-2); border-radius: 10px; padding: 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.annual-fact-icon { font-size: 24px; flex-shrink: 0; }
.annual-fact-text { font-size: 13px; color: var(--text-2); line-height: 1.5; }

@media print {
  body { background:white !important;color:#0f172a !important; }
  .sidebar, .bulk-bar, .toolbar, .page-header .btn, .actions-row, #sidebar-open, .toast-container { display:none !important; }
  .app-shell { display:block !important; }
  .main-content { margin:0 !important;padding:0 !important; }
  .section-card { box-shadow:none !important;border:1px solid #e2e8f0 !important; }
  .stat-card { background:white !important;border:1px solid #e2e8f0 !important;box-shadow:none !important; }
  .chart-card { break-inside:avoid; }
  table { width:100% !important; }
  .page { padding:16px !important; }
}

/* ─────────────────────────────────────────────
   PREMIUM SYSTEM
───────────────────────────────────────────── */

/* Nav premium lock icon */
.nav-item .nav-premium-lock {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.6;
  line-height: 1;
}

/* Plan badges */
.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.plan-badge-free    { background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border); }
.plan-badge-premium { background: linear-gradient(135deg,#f59e0b22,#eab30822); color: #f59e0b; border: 1px solid #f59e0b44; }
.plan-badge-family  { background: linear-gradient(135deg,#8b5cf622,#7c3aed22); color: #8b5cf6; border: 1px solid #8b5cf644; }

/* Premium gate full page */
.premium-gate-page { display: flex; align-items: center; justify-content: center; min-height: 60vh; }
.premium-gate-wrap {
  text-align: center;
  max-width: 520px;
  padding: 40px 32px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.premium-gate-icon  { font-size: 48px; margin-bottom: 16px; }
.premium-gate-title { font-size: 22px; font-weight: 700; margin: 0 0 10px; }
.premium-gate-desc  { color: var(--text-2); font-size: 14px; margin: 0 0 20px; line-height: 1.6; }
.premium-gate-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  text-align: left;
  margin: 0 0 24px;
  padding: 16px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.premium-gate-feature { display: flex; align-items: center; gap: 6px; }
.premium-gate-price   { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.plan-price-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  min-width: 160px;
  text-align: center;
  transition: border-color .2s, box-shadow .2s;
}
.plan-price-card:first-child { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent)20; }
.plan-name   { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.plan-amount { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.plan-amount span { font-size: 13px; font-weight: 400; color: var(--text-3); }
.plan-or     { font-size: 11px; color: var(--text-3); margin-bottom: 14px; }
.btn-upgrade { width: 100%; }
.premium-gate-admin-hint { font-size: 12px; color: var(--text-3); margin-top: 16px; }

/* Inline lock badge */
.premium-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  background: #f59e0b22;
  color: #f59e0b;
  border: 1px solid #f59e0b44;
  vertical-align: middle;
  margin-left: 6px;
}

/* Plan usage bars in settings */
.plan-usage-bar  { height: 4px; background: var(--border); border-radius: 99px; margin-top: 4px; width: 80px; overflow: hidden; }
.plan-usage-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }

/* ─── Heatmap page ─── */
.heatmap-stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 4px; }
@media (max-width: 768px) { .heatmap-stats-row { grid-template-columns: 1fr 1fr; } }

.heatmap-months-row {
  display: flex;
  padding-left: 32px;
  margin-bottom: 4px;
  overflow-x: auto;
}
.heatmap-month-label { font-size: 10px; color: var(--text-3); width: 15px; min-width: 15px; }

.heatmap-grid { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.heatmap-weekdays {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 0;
  min-width: 24px;
}
.heatmap-wd { font-size: 10px; color: var(--text-3); line-height: 1; padding: 2px 0; }
.heatmap-weeks { display: flex; gap: 3px; }
.heatmap-week  { display: flex; flex-direction: column; gap: 3px; }
.heatmap-cell  {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  cursor: default;
  transition: outline .1s;
  flex-shrink: 0;
}
.heatmap-cell-empty { background: transparent !important; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-3);
}

.heatmap-bars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 100px;
}
.heatmap-bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.heatmap-bar-track { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; background: var(--surface-2); border-radius: 4px; overflow: hidden; min-height: 60px; }
.heatmap-bar-fill  { width: 100%; transition: height .6s ease; min-height: 2px; }
.heatmap-bar-label { font-size: 10px; color: var(--text-3); }
.heatmap-bar-val   { font-size: 9px; color: var(--text-3); white-space: nowrap; }

/* ─── Focus semaine ─── */
.focus-empty {
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
}
.focus-empty-icon  { font-size: 52px; margin-bottom: 14px; }
.focus-empty-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.focus-empty-sub   { color: var(--text-3); font-size: 14px; }

.focus-day-group { margin-bottom: 12px; }
.focus-day-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  margin-bottom: 6px;
}
.focus-day-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.focus-day-label.today    { color: var(--danger); }
.focus-day-label.tomorrow { color: var(--warning); }
.focus-day-date  { font-size: 12px; color: var(--text-3); flex: 1; }
.focus-day-total { font-size: 13px; font-weight: 600; color: var(--text); }

.focus-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  gap: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.focus-card:hover { border-color: var(--accent); box-shadow: 0 2px 12px rgba(79,142,247,.1); }
.focus-card-left  { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.focus-card-logo  { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; flex-shrink: 0; }
.focus-card-dot   { width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0; }
.focus-card-info  { min-width: 0; }
.focus-card-name  { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.focus-card-meta  { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.focus-card-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.focus-card-amount { font-size: 17px; font-weight: 700; }
.focus-card-eur    { font-size: 11px; color: var(--text-3); }

/* ── Assistant IA ────────────────────────────────────────────── */
.assistant-page { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h, 0px)); }
.assistant-wrap { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 0; }

.assistant-no-key {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 60px 24px; text-align: center; flex: 1;
}
.assistant-no-key-icon  { font-size: 48px; }
.assistant-no-key-title { font-size: 20px; font-weight: 700; }
.assistant-no-key-desc  { font-size: 14px; color: var(--text-2); max-width: 440px; line-height: 1.6; }

/* AI active chip */
.ai-active-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500;
  color: var(--accent); background: var(--accent-bg);
  border: 1px solid var(--accent); border-radius: 20px;
  padding: 2px 10px; margin-top: 4px;
}
.ai-active-chip--warn {
  color: var(--warning, #f59e0b); background: color-mix(in srgb, var(--warning, #f59e0b) 10%, transparent);
  border-color: var(--warning, #f59e0b);
}

/* AI config panel */
.ai-config-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 16px;
}
.ai-config-inner {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ai-config-title {
  font-size: 14px; font-weight: 600; color: var(--text); margin: 0;
}
.ai-config-providers {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.ai-config-instructions {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* Chat area */
.chat-area {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 24px 20px 8px;
  display: flex; flex-direction: column; gap: 4px;
}

/* Welcome */
.chat-welcome {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 40px 20px 32px; text-align: center;
}
.chat-welcome-icon  { font-size: 40px; color: var(--accent); }
.chat-welcome-title { font-size: 22px; font-weight: 700; }
.chat-welcome-sub   { font-size: 14px; color: var(--text-3); }

.chat-prompts {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 16px; max-width: 640px;
}
.prompt-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 20px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; transition: all .15s;
  text-align: left;
}
.prompt-chip:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }

/* Messages */
.chat-messages { display: flex; flex-direction: column; gap: 16px; }

.chat-message { display: flex; align-items: flex-start; gap: 10px; }
.chat-message-user { flex-direction: row-reverse; }
.chat-message-error { }

.chat-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-bg); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0; color: var(--accent);
}

.chat-bubble {
  max-width: 72%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text);
}
.chat-bubble-user {
  background: var(--accent); border-color: var(--accent);
  color: #fff; border-radius: 16px 16px 4px 16px;
}
.chat-message-error .chat-bubble { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.chat-bubble h2,.chat-bubble h3,.chat-bubble h4 { margin: 8px 0 4px; font-size: 14px; font-weight: 700; }
.chat-bubble ul { margin: 4px 0 4px 16px; padding: 0; }
.chat-bubble li { margin: 2px 0; }
.chat-bubble code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: var(--font-mono); }
.chat-bubble p { margin: 4px 0; }

/* Thinking animation */
.chat-thinking { display: flex; gap: 5px; align-items: center; padding: 12px 16px; }
.thinking-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); opacity: 0.4;
  animation: thinking-bounce 1.2s infinite ease-in-out;
}
.thinking-dot:nth-child(1) { animation-delay: 0s; }
.thinking-dot:nth-child(2) { animation-delay: .2s; }
.thinking-dot:nth-child(3) { animation-delay: .4s; }
@keyframes thinking-bounce {
  0%,80%,100% { transform: scale(.6); opacity: .4; }
  40%         { transform: scale(1);  opacity: 1; }
}

/* Action cards */
.chat-actions { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 4px 40px; }
.chat-action-card {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; color: var(--text-2);
}
.chat-action-error { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
.chat-action-icon   { font-size: 14px; flex-shrink: 0; }
.chat-action-label  { font-weight: 600; color: var(--text-3); }
.chat-action-result { margin-left: auto; color: var(--text-2); font-size: 11px; }

/* Input bar */
.chat-input-bar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 20px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input {
  flex: 1; resize: none; min-height: 42px; max-height: 160px;
  padding: 10px 14px; border-radius: 12px; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; line-height: 1.5;
  transition: border-color .15s;
}
.chat-input:focus { outline: none; border-color: var(--accent); }
.chat-send-btn { width: 42px; height: 42px; padding: 0; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.chat-disclaimer { font-size: 11px; color: var(--text-3); text-align: center; padding: 0 20px 10px; margin: 0; }

/* Settings IA */
.ai-provider-btn {
  display: flex; align-items: center; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-2); transition: all .15s;
  background: var(--surface-2); user-select: none;
}
.ai-provider-btn:hover { border-color: var(--accent); color: var(--text); }
.ai-provider-btn.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.ai-steps { margin: 6px 0 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.ai-steps li { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.ai-steps strong { color: var(--text); }
.ai-steps code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: 12px; }

.ai-model-info { display:flex; align-items:baseline; gap:10px; padding:4px 0; border-bottom:1px solid var(--border); }
.ai-model-info:last-child { border-bottom:none; }
.ai-model-name { font-family:var(--font-mono); font-size:12px; color:var(--accent); white-space:nowrap; min-width:130px; }
.ai-model-desc { font-size:12px; color:var(--text-3); }

/* ── Conversation sidebar ────────────────────────────────────────────────── */
.assistant-layout { display:flex; flex:1; min-height:0; }

.conv-sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}

.conv-sidebar-top {
  padding: 10px 10px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.conv-new-btn {
  width: 100%;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.conv-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  gap: 6px;
  min-width: 0;
  position: relative;
  transition: background 0.1s;
}
.conv-item:hover  { background: var(--surface-2); }
.conv-item.active { background: var(--accent-bg); }

.conv-item-body { flex:1; min-width:0; }

.conv-item-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  line-height: 1.3;
}
.conv-item.active .conv-item-title { color: var(--accent); }

.conv-item-meta { font-size:11px; color:var(--text-3); margin-top:2px; }

.conv-item-del {
  display: none;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.1s, color 0.1s;
}
.conv-item:hover .conv-item-del { display: block; }
.conv-item-del:hover { background: var(--danger-bg, rgba(239,68,68,.12)); color: var(--danger, #ef4444); }

.conv-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.6;
}

.conv-rename-input {
  font-size: 13px;
  font-weight: 500;
  background: var(--surface-3);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  padding: 1px 6px;
  width: 100%;
  outline: none;
}

/* mobile toggle btn (hidden on desktop) */
.conv-toggle-btn { display:none; }

/* mobile overlay */
.conv-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.conv-overlay.open { display: block; }

@media (max-width: 680px) {
  .conv-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }
  .conv-sidebar.open { transform: translateX(0); }
  .conv-toggle-btn   { display: flex; }
}
