/* KharchaBook - Mobile-first PWA Stylesheet v2.0 */

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== Theme Variables ===== */
:root {
  /* Brand */
  --brand:        #1a6fd4;
  --brand-2:      #f59e0b;
  --brand-light:  #3b8ef0;
  --brand-glow:   rgba(26, 111, 212, 0.35);

  /* Income / Expense */
  --income:       #2563eb;
  --income-bg:    rgba(37, 99, 235, 0.12);
  --expense:      #ef4444;
  --expense-bg:   rgba(239, 68, 68, 0.12);
  --positive:     #22c55e;
  --negative:     #ef4444;
  --warning:      #f59e0b;

  /* Radii / Shadows */
  --radius:       14px;
  --radius-sm:    9px;
  --nav-h:        68px;
  --header-h:     60px;
}

/* ===== DARK THEME (default) ===== */
[data-theme="dark"], :root {
  --bg-deep:      #070c18;
  --bg-dark:      #0d1526;
  --bg-card:      #131f35;
  --bg-input:     #1b2a42;
  --bg-hover:     #1e3350;
  --border:       rgba(148, 163, 184, 0.10);
  --border-focus: rgba(26, 111, 212, 0.6);
  --text-primary: #f0f4fc;
  --text-muted:   #8fa3c0;
  --text-dim:     #526070;
  --shadow:       0 4px 28px rgba(0,0,0,0.5);
  --logo-src:     url('../icons/icon-dark-192.png');
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg-deep:      #f0f4fb;
  --bg-dark:      #ffffff;
  --bg-card:      #ffffff;
  --bg-input:     #f1f5fb;
  --bg-hover:     #e8eef8;
  --border:       rgba(26, 111, 212, 0.12);
  --border-focus: rgba(26, 111, 212, 0.5);
  --text-primary: #0d1526;
  --text-muted:   #4a6080;
  --text-dim:     #8fa3c0;
  --shadow:       0 2px 16px rgba(26,111,212,0.10);
  --logo-src:     url('../icons/icon-light-192.png');
}

/* ===== Base ===== */
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  transition: background 0.25s, color 0.25s;
}

input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ===== Desktop bg ===== */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  z-index: -1;
}

/* ===== App shell ===== */
#main-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg-deep);
}

/* ===== Top Bar ===== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: var(--header-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-logo { display: flex; align-items: center; gap: 9px; }

.logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-input);
}

.logo-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; display: block; }

.app-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.app-name span { color: var(--brand); }

/* Top bar right controls */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Theme toggle button */
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:active { background: var(--bg-hover); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #3b8ef0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  cursor: pointer;
}

/* ===== Scroll area ===== */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + 16px);
  -webkit-overflow-scrolling: touch;
}

/* ===== Pages ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 6px;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dim);
  transition: color 0.2s, background 0.2s;
  flex: 1;
  min-width: 0;
  -webkit-tap-highlight-color: transparent;
}

.nav-item .nav-icon { font-size: 20px; line-height: 1; }
.nav-item .nav-label { font-size: 10px; font-weight: 500; white-space: nowrap; }
.nav-item.active { color: var(--brand); }
.nav-item.active .nav-icon { transform: scale(1.1); }

.nav-item.nav-add .nav-add-circle {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: white;
  box-shadow: 0 4px 18px var(--brand-glow);
  transition: transform 0.15s;
}
.nav-item.nav-add:active .nav-add-circle { transform: scale(0.93); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 10px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

/* ===== Dashboard hero ===== */
.dashboard-hero {
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-deep) 100%);
  padding: 18px 14px 20px;
  border-bottom: 1px solid var(--border);
}

.hero-greeting { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.hero-name { font-size: 19px; font-weight: 700; margin-bottom: 18px; }

.balance-block { text-align: center; padding: 6px 0 14px; }
.balance-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
}
.balance-amount {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.balance-amount.positive { color: var(--positive); }
.balance-amount.negative { color: var(--negative); }

.summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 14px;
}

.summary-card {
  background: var(--bg-input);
  border-radius: 11px;
  padding: 12px;
  border: 1px solid var(--border);
}

.summary-type { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }

.summary-amount { font-size: 17px; font-weight: 700; letter-spacing: -0.4px; }
.summary-amount.income  { color: var(--income); }
.summary-amount.expense { color: var(--expense); }
.summary-amount.positive { color: var(--positive); }
.summary-amount.negative { color: var(--negative); }

/* ===== Section header ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 6px;
}
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.section-link { font-size: 13px; color: var(--brand); cursor: pointer; background: none; border: none; padding: 0; font-weight: 600; }

/* ===== Transaction cards ===== */
.tx-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.tx-card:last-child { border-bottom: none; }

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.tx-icon.income  { background: var(--income-bg);  color: var(--income); }
.tx-icon.expense { background: var(--expense-bg); color: var(--expense); }

.tx-info { flex: 1; min-width: 0; }
.tx-category { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.tx-amount { font-size: 14px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.tx-amount.income  { color: var(--income); }
.tx-amount.expense { color: var(--expense); }

.tx-actions { display: flex; gap: 2px; }
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 5px;
  font-size: 15px;
  border-radius: 7px;
  transition: background 0.2s;
}
.btn-icon:active { background: var(--bg-input); }

/* ===== Charts ===== */
.chart-container { height: 195px; position: relative; }
.chart-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }

/* ===== Page header ===== */
.page-header { padding: 14px 14px 0; }
.page-header h2 { font-size: 21px; font-weight: 800; }

/* ===== Search bar ===== */
.search-filter-bar { display: flex; gap: 8px; padding: 10px 14px; }
.search-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 14px;
}
.filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-primary);
  font-size: 13px;
  min-width: 88px;
  -webkit-appearance: none;
}

/* ===== Add Form ===== */
.type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; }

.type-btn {
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card);
  color: var(--text-muted);
  -webkit-tap-highlight-color: transparent;
}
.type-btn.expense.active { border-color: var(--expense); background: var(--expense-bg); color: var(--expense); }
.type-btn.income.active  { border-color: var(--income);  background: var(--income-bg);  color: var(--income); }

.form-card { margin-top: 0; }

.form-group { margin-bottom: 15px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-primary);
  font-size: 16px;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--border-focus); background: var(--bg-hover); }
.form-group textarea { resize: none; }
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238fa3c0'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 34px;
}

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.2px;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 13px;
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-secondary:active { background: var(--bg-hover); }

.btn-outline {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--brand);
  border: 2px solid var(--brand);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-outline:active { background: var(--income-bg); }

.btn-danger {
  width: 100%;
  padding: 13px;
  background: rgba(239,68,68,0.08);
  color: var(--expense);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

/* Export row buttons */
.export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.btn-export {
  padding: 11px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-export:active { background: var(--bg-hover); border-color: var(--brand); }
.btn-export-email {
  grid-column: 1 / -1;
  background: rgba(26,111,212,0.08);
  border-color: rgba(26,111,212,0.25);
  color: var(--brand);
}

/* ===== Insights ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 10px 14px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.stat-value { font-size: 19px; font-weight: 800; color: var(--text-primary); }
.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }
.stat-value.warning  { color: var(--warning); }

.cat-bar-item { margin-bottom: 11px; }
.cat-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.progress-bar { height: 5px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--expense), #f97316); border-radius: 3px; transition: width 0.5s ease; }

/* ===== AI Card ===== */
.ai-card { border: 1px solid rgba(26,111,212,0.2); }
.ai-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.ai-icon { font-size: 19px; }
.ai-header h3 { margin-bottom: 0; text-transform: none; color: var(--brand-light); font-size: 14px; }
.ai-intro { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.ai-suggestions { margin-bottom: 10px; }
.ai-item { font-size: 13px; color: var(--text-primary); padding: 8px 0; border-bottom: 1px solid var(--border); line-height: 1.6; }
.ai-item:last-child { border-bottom: none; }
.ai-loading { color: var(--text-muted); font-size: 13px; text-align: center; padding: 14px; }
.ai-error { color: var(--expense); font-size: 12px; }
.disclaimer {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 10px;
  line-height: 1.5;
  background: rgba(239,68,68,0.04);
  border-radius: 6px;
  padding: 8px 10px;
  border-left: 3px solid rgba(239,68,68,0.25);
}

/* ===== Settings ===== */
.field-hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; line-height: 1.5; }
.currency-preview { font-size: 12px; color: var(--brand-light); margin-top: 4px; }
.about-text { font-size: 13px; color: var(--text-muted); margin-top: 5px; }

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 20px 16px 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.footer-copy { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.footer-powered { font-size: 11px; color: var(--text-dim); }
.footer-powered a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.footer-powered a:hover { text-decoration: underline; }
.footer-links { display: flex; justify-content: center; gap: 16px; margin-top: 8px; }
.footer-links a { font-size: 11px; color: var(--text-dim); text-decoration: none; }
.footer-links a:hover { color: var(--brand); }

/* ===== Onboarding / Auth ===== */
#onboarding {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg-deep);
  padding: 0;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.onboarding-header {
  background: linear-gradient(160deg, var(--bg-card) 0%, var(--bg-deep) 100%);
  padding: clamp(28px, 7vw, 52px) 24px clamp(20px, 4vw, 34px);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.onboard-logo {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  overflow: hidden;
  margin: 0 auto 14px;
  box-shadow: 0 8px 32px var(--brand-glow);
  background: var(--bg-input);
}
.onboard-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: 20px; display: block; }

.onboard-title { font-size: clamp(20px, 5.5vw, 26px); font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.onboard-title span { color: var(--brand); }
.onboard-sub { font-size: 13px; color: var(--text-muted); }

/* Auth tabs */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin: 0;
}
.auth-tab {
  flex: 1;
  padding: 14px 10px;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: 0.1px;
  -webkit-tap-highlight-color: transparent;
}
.auth-tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.auth-panel { display: none; }
.auth-panel.active { display: block; }

.auth-form-wrap { padding: 18px 14px 32px; }

/* Social login row */
.social-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-social:active { background: var(--bg-hover); }
.btn-social .social-icon { font-size: 18px; }
.btn-social.google { border-color: rgba(66,133,244,0.3); }
.btn-social.google:active { background: rgba(66,133,244,0.06); }
.btn-social-label { color: var(--text-dim); font-size: 12px; }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--text-dim);
  font-size: 12px;
}
.divider::before,
.divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
}
.auth-switch a { color: var(--brand); font-weight: 700; cursor: pointer; text-decoration: none; }

.section-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(26,111,212,0.12);
  color: var(--brand-light);
  margin-bottom: 12px;
}
.required-badge { background: rgba(239,68,68,0.10); color: var(--expense); }

/* Auth footer inside onboarding */
.onboard-footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.onboard-footer p { font-size: 11px; color: var(--text-dim); }
.onboard-footer a { color: var(--brand); text-decoration: none; font-weight: 600; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 1000;
  opacity: 0;
  transition: all 0.28s ease;
  white-space: nowrap;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error   { border-color: rgba(239,68,68,0.4); background: var(--bg-deep); }
.toast-success { border-color: rgba(34,197,94,0.3); }

/* ===== Install banner ===== */
#install-banner {
  display: none;
  align-items: center;
  gap: 9px;
  background: var(--bg-card);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 150;
}
.install-text { flex: 1; font-size: 12px; color: var(--text-muted); }
.install-text strong { display: block; font-size: 13px; color: var(--text-primary); margin-bottom: 1px; }
.btn-install { background: var(--brand); color: white; border: none; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-dismiss { background: transparent; border: none; color: var(--text-dim); font-size: 19px; cursor: pointer; padding: 0 3px; }

/* ===== Currency detect badge ===== */
.currency-detect-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--positive);
  background: rgba(34,197,94,0.08);
  border: 1px solid rgba(34,197,94,0.2);
  border-radius: 20px;
  padding: 3px 9px;
  margin-top: 5px;
}

/* ===== Misc ===== */
.no-data { text-align: center; color: var(--text-dim); font-size: 13px; padding: 24px 14px; }
.insights-content {}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== iOS safe area ===== */
@supports (padding: max(0px)) {
  .bottom-nav {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .scroll-area { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
}

/* ===== Desktop ===== */
@media (min-width: 480px) {
  body {
    background: #05090f;
    background-image: radial-gradient(circle at 1px 1px, rgba(26,111,212,0.06) 1px, transparent 0);
    background-size: 26px 26px;
  }
  #main-app, #onboarding {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 80px rgba(0,0,0,0.65), 0 0 0 1px rgba(26,111,212,0.07);
    min-height: 100dvh;
  }
}

[data-theme="light"] body {
  background: #e8eef8;
}
[data-theme="light"] #main-app,
[data-theme="light"] #onboarding {
  box-shadow: 0 0 40px rgba(26,111,212,0.12);
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.page.active > * { animation: fadeIn 0.2s ease; }
.card { animation: fadeIn 0.22s ease; }

/* Privacy page */
.privacy-page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--bg-deep);
  color: var(--text-primary);
  padding: 24px 16px 48px;
  font-size: 14px;
  line-height: 1.7;
}
.privacy-page h1 { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.privacy-page h2 { font-size: 15px; font-weight: 700; color: var(--brand-light); margin: 20px 0 6px; }
.privacy-page p  { color: var(--text-muted); margin-bottom: 8px; }
.privacy-page .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 20px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* ═══════════════════════════════════════════
   AI ASSISTANT — Consent Modal + Cards
═══════════════════════════════════════════ */

/* Consent modal overlay */
.ai-consent-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ai-consent-modal {
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
  max-width: 480px;
  width: 100%;
  padding: 24px 20px 40px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  animation: slideUp 0.28s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.consent-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.consent-title {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.consent-intro {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Data preview table — shows WHAT is sent */
.consent-data-preview {
  background: var(--bg-input);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.consent-data-preview-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.consent-data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.consent-data-row:last-child { border-bottom: none; }

.consent-data-label { color: var(--text-muted); }
.consent-data-value { font-weight: 600; color: var(--text-primary); font-size: 11px; }
.consent-data-value.sent  { color: var(--positive); }
.consent-data-value.not-sent { color: var(--expense); }

/* Consent checkbox row */
.consent-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(26,111,212,0.06);
  border: 1px solid rgba(26,111,212,0.15);
  border-radius: 10px;
}

.consent-check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--brand);
  cursor: pointer;
}

.consent-check-label {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  cursor: pointer;
}
.consent-check-label a {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.consent-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* AI output cards */
.ai-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ai-result-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-result-meta {
  font-size: 10px;
  color: var(--text-dim);
  background: var(--bg-input);
  padding: 3px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.ai-suggestion-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ai-suggestion-item:last-of-type { border-bottom: none; }

.ai-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.6;
  flex: 1;
}

.ai-para {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 0;
  line-height: 1.6;
}

.ai-guidance-tip {
  font-size: 12px;
  color: var(--brand-light);
  background: rgba(26,111,212,0.06);
  border: 1px solid rgba(26,111,212,0.15);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0 4px;
  line-height: 1.6;
}

.ai-disclaimer-inline {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 10px;
  line-height: 1.5;
  background: rgba(239,68,68,0.04);
  border-radius: 6px;
  padding: 8px 10px;
  border-left: 3px solid rgba(239,68,68,0.2);
}

/* Consent revoked state */
.ai-consent-revoked {
  text-align: center;
  padding: 20px 16px;
}
.ai-consent-revoked p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }

/* Data sent summary badge */
.ai-data-sent-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 12px;
}
.ai-data-sent-badge .badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--positive);
  flex-shrink: 0;
}

/* Settings — AI consent toggle */
.consent-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.consent-status-row:last-child { border-bottom: none; }
.consent-status-label { font-size: 13px; color: var(--text-primary); }
.consent-status-sub   { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--brand); border-color: var(--brand); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); background: white; }

