/* css/style.css */

/* ── Custom Properties ─────────────────────────────────── */
:root {
  --bg-base:    #080d1a;
  --bg-panel:   #111827;
  --bg-raised:  #1e293b;
  --bg-hover:   #0f2744;
  --border:     #2a4a7a;
  --border-mid: #334155;
  --text:       #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim:   #96a8bc;   /* WCAG AA: ≥4.5:1 on bg-raised (#1e293b) */
  --text-faint: #768ba6;   /* WCAG AA: ≥4.5:1 on bg-panel (#111827) and bg-raised */
  --accent:     #38bdf8;
  --accent-btn: #0ea5e9;
  --amber:      #f59e0b;
  --green:      #4ade80;
  --red:        #f87171;
  --violet:     #818cf8;

  --radius-sm:  6px;
  --radius:     8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --sidebar-w:  200px;
  --bottom-nav-h: 60px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Light mode overrides ───────────────────────────────── */
html[data-theme="light"] {
  --bg-base:    #f0f4f8;
  --bg-panel:   #ffffff;
  --bg-raised:  #e8edf4;
  --bg-hover:   #d8e4f0;
  --border:     #b0c4d8;
  --border-mid: #c8d8e8;
  --text:       #1a2332;
  --text-muted: #3d5166;
  --text-dim:   #4a6278;
  --text-faint: #556d88;   /* darkened from #5a7490: 4.54:1 on bg-raised, 4.84 on bg-base, 5.34 on bg-panel */
  --accent:     #026aa1;   /* darkened from #0284c7: 4.55:1 on bg-hover, 4.99 on bg-raised, 5.31 on bg-base, 5.87 on bg-panel */
  --accent-btn: #0369a1;
  --amber:      #b45309;
  --green:      #16a34a;
  --red:        #dc2626;
  --violet:     #4f46e5;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }
a { color: var(--accent); }

/* WCAG 2.2 AA — focus indicators for all interactive elements */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* WCAG 2.2 AA — radio buttons visible on dark backgrounds */
input[type="radio"] {
  accent-color: var(--accent);
}

/* ── Layout ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-logo {
  color: var(--accent);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 20px 20px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-tagline {
  display: block;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 1px;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
  min-height: 44px;   /* WCAG fix: minimum touch target */
}
.nav-item:hover  { color: var(--text); background: var(--bg-raised); }
.nav-item.active { color: var(--accent); background: var(--bg-hover); border-left-color: var(--accent); }
.nav-icon { width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.6;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
}

.view { display: none; padding: 28px 32px; min-height: 100vh; }
.view.active { display: block; }

/* ── View header ────────────────────────────────────────── */
.view-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

/* ── Add button ─────────────────────────────────────────── */
.add-btn {
  background: var(--accent-btn);
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  min-height: 44px;   /* WCAG fix: minimum touch target */
}
.add-btn:hover { opacity: 0.85; }

/* ── Content grid (two-column layout) ───────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

/* Cards stacked inside dashboard columns get uniform spacing */
#charts-col,
#right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Stats row ──────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Bottom nav (mobile) ────────────────────────────────── */
.bottom-nav { display: none; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* ── Stat cards ─────────────────────────────────────────── */
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.stat-label { color: var(--text-dim); font-size: 12px; font-weight: 600; letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-value.accent { color: var(--accent); }
.stat-sub { color: var(--text-faint); font-size: 12px; margin-top: 6px; }

/* ── Badges ─────────────────────────────────────────────── */
.badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; display: inline-block; }
.badge-active    { background: #052e16; color: var(--green); }
.badge-paused    { background: #1c1a07; color: #fcd34d; }
.badge-cancelled { background: #1c0707; color: var(--red); }
.badge-renewal   { background: var(--bg-raised); color: var(--accent); }
.badge-renewal.urgent { background: #3d1a07; color: var(--amber); }
.badge-category  { background: var(--bg-raised); color: var(--text-muted); font-size: 11px; padding: 3px 8px; border-radius: 20px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent-btn); color: #fff; border-radius: var(--radius); padding: 10px 20px;
  font-size: 13px; font-weight: 600; transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--bg-raised); color: var(--text-muted); border-radius: var(--radius); padding: 10px 20px;
  font-size: 13px;
}
.btn-secondary:hover { color: var(--text); }

.btn-danger { background: #3d0707; color: var(--red); border-radius: var(--radius); padding: 10px 20px; font-size: 13px; font-weight: 600; }

.btn-icon {
  background: var(--bg-raised); border-radius: var(--radius-sm); padding: 6px 10px;
  color: var(--text-muted); font-size: 12px;
  min-height: 44px;   /* WCAG fix: minimum touch target */
}
.btn-icon:hover { color: var(--text); }

/* Modal button aliases */
.btn-cancel { background: var(--bg-raised); color: var(--text-muted); border-radius: var(--radius); padding: 10px 20px; font-size: 13px; }
.btn-cancel:hover { color: var(--text); }
.btn-save   { background: var(--accent-btn); color: #fff; border-radius: var(--radius); padding: 10px 20px; font-size: 13px; font-weight: 600; transition: opacity 0.15s; }
.btn-save:hover { opacity: 0.85; }

/* ── Form elements ──────────────────────────────────────── */
.form-input, .form-select {
  background: var(--bg-raised); border: 1px solid var(--border-mid); border-radius: var(--radius);
  padding: 10px 12px; color: var(--text); font-size: 13px; width: 100%;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--accent); }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; display: block; margin-bottom: 6px; }
.form-group { display: flex; flex-direction: column; }

/* Form error */
.form-error { color: var(--red); font-size: 12px; margin-top: 8px; }

/* ── Toolbar ─────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title  { font-size: 24px; font-weight: 700; color: var(--text); }   /* WCAG fix: was 22px */
.page-sub    { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.toolbar     { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar-search { width: 220px; }
.toolbar-filter { width: auto; }

/* Toolbar search/filter inputs */
.search {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  width: 220px;
}
.search:focus { outline: none; border-color: var(--accent); }

.filter-select {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  width: auto;
}
.filter-select:focus { outline: none; border-color: var(--accent); }

/* ── Table ──────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-faint);
  letter-spacing: 1px; text-transform: uppercase; padding: 10px 12px;
  border-bottom: 1px solid var(--bg-raised);
}
.data-table td { padding: 13px 12px; border-bottom: 1px solid var(--bg-raised); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-panel); }
.sub-name { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.star-btn  { color: var(--text-faint); font-size: 16px; background: none; border: none; cursor: pointer; padding: 0; }
.star-btn.starred { color: var(--amber); }
.cost-cell .amount { font-weight: 700; color: var(--accent); }
.cost-cell .cycle  { color: var(--text-dim); font-size: 12px; }
.renewal-date { color: var(--text-dim); font-size: 13px; }
.renewal-date.urgent { color: var(--amber); }

/* sub-table alias for data-table */
.sub-table { width: 100%; border-collapse: collapse; }
.sub-table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-faint);
  letter-spacing: 1px; text-transform: uppercase; padding: 10px 12px;
  border-bottom: 1px solid var(--bg-raised);
}
.sub-table td { padding: 13px 12px; border-bottom: 1px solid var(--bg-raised); vertical-align: middle; }
.sub-table tr:hover td { background: var(--bg-panel); }

/* Subscription table cell classes */
.star       { color: var(--amber); }
.star.empty { color: var(--bg-raised); }
.cost       { font-weight: 700; color: var(--accent); }
.cycle      { color: var(--text-dim); font-size: 12px; }

/* category-badge alias for badge-category */
.category-badge { background: var(--bg-raised); color: var(--text-muted); font-size: 11px; padding: 3px 8px; border-radius: 20px; }

/* status-badge */
.status-badge           { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap; display: inline-block; }
.status-badge.active    { background: #052e16; color: #4ade80; }
.status-badge.paused    { background: #1c1a07; color: #fcd34d; }
.status-badge.cancelled { background: #1c0707; color: #f87171; }

/* action-btn alias for btn-icon */
.action-btn {
  background: var(--bg-raised); border-radius: var(--radius-sm); padding: 6px 10px;
  color: var(--text-muted); font-size: 12px; cursor: pointer; border: none;
  min-height: 44px;   /* WCAG fix: minimum touch target */
}
.action-btn:hover { color: var(--text); }

/* overflow menu */
.overflow-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 50;
  min-width: 140px;
  display: flex;
  flex-direction: column;
}
.overflow-menu button {
  background: none;
  border: none;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 100%;
}
.overflow-menu button:hover { background: var(--bg-raised); color: var(--text); }

/* ── Trust banner ───────────────────────────────────────── */
.trust-banner {
  background: var(--bg-hover); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.trust-banner-text { font-size: 13px; color: var(--text-dim); }
.trust-banner-text strong { color: var(--accent); }
.trust-banner-close { color: var(--text-faint); font-size: 20px; background: none; border: none; cursor: pointer; padding: 0 4px; line-height: 1; }

/* ── Possible savings card ──────────────────────────────── */
.savings-body { font-size: 12px; color: var(--text-muted); line-height: 1.6; }
.savings-amount { color: var(--text); }

/* trust-dismiss alias for trust-banner-close */
.trust-dismiss { color: var(--text-faint); font-size: 20px; background: none; border: none; cursor: pointer; padding: 0 4px; line-height: 1; }

/* ── Waste alert ────────────────────────────────────────── */
.waste-alert {
  background: #1c1007; border: 1px solid #92400e; border-left: 3px solid var(--amber);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 24px;
  font-size: 13px; color: #fcd34d;
}
.waste-alert strong { color: var(--amber); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-xl);
  width: 100%; max-width: 520px; padding: 28px; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.modal-sub { font-size: 13px; color: var(--text-faint); margin-bottom: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* ── Autocomplete dropdown ──────────────────────────────── */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autocomplete-item:hover,
.autocomplete-item--active {
  background: var(--bg-hover);
  color: var(--accent);
}

/* ── Alerts / empty states ──────────────────────────────── */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-dim); }
.empty-state h3 { font-size: 18px; color: var(--text-muted); margin-bottom: 8px; }
.empty-state p  { font-size: 13px; margin-bottom: 24px; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #052e16;
  color: #4ade80;
  border: 1px solid #166534;
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  pointer-events: none;
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2.2s forwards;
}
.toast.toast-error {
  background: #1c0707;
  color: #f87171;
  border-color: #991b1b;
}
@keyframes toastIn  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ── Persistent footer ──────────────────────────────────── */
.privacy-footer {
  display: none; /* sidebar already shows this text on desktop */
}

/* ── Charts ─────────────────────────────────────────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 110px; font-size: 12px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.bar-track { flex: 1; background: var(--bg-raised); border-radius: 4px; height: 8px; }
.bar-fill  { height: 8px; border-radius: 4px; transition: width 0.3s ease; }
.bar-amount { width: 80px; font-size: 12px; color: var(--text-dim); flex-shrink: 0; }

/* Sparkline */
.sparkline { display: flex; align-items: flex-end; gap: 8px; height: 56px; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.spark-bar { width: 100%; background: var(--border); border-radius: 3px 3px 0 0; }
.spark-col.current .spark-bar { background: var(--accent); }
.spark-bar.current { background: var(--accent); }    /* JS adds .current directly to bar */
.spark-label { font-size: 11px; color: var(--text-faint); margin-top: 4px; text-align: center; }
.spark-col.current .spark-label { color: var(--accent); }

/* spark-month aliases for spark-label */
.spark-month         { font-size: 11px; color: var(--text-faint); margin-top: 4px; text-align: center; }
.spark-month.current { color: var(--accent); }

/* ── Dashboard extras ───────────────────────────────────── */
.renewal-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--bg-raised); }
.renewal-item:last-child { border-bottom: none; }
.renewal-name { font-size: 13px; color: var(--text); font-weight: 500; }
.renewal-date-text { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* renewal-badge */
.renewal-badge {
  background: var(--bg-raised);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.renewal-badge.soon { background: #3d1a07; color: var(--amber); }

/* ── Affiliate cards ─────────────────────────────────────── */
.affiliate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.affiliate-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.affiliate-tier-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 16px;
  margin-top: 4px;
}

.affiliate-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.affiliate-card-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.affiliate-saving {
  background: #052e16;
  color: #4ade80;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 12px;
}

.affiliate-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.affiliate-btn {
  background: var(--accent-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}
.affiliate-btn:hover { opacity: 0.85; }

.affiliate-link-note {
  font-size: 11px;
  color: var(--text-faint);
}

/* Alternatives disclosure box */
.disclosure {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ── Export / Import view ────────────────────────────────── */
.export-section {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.export-section.danger-zone {
  border-color: #991b1b;
}

.export-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.export-section-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.export-btn-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.export-btn {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 20px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.export-btn:hover { border-color: var(--accent); color: var(--accent); }

.export-privacy {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 12px;
  font-style: italic;
}

.import-mode-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.import-mode-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.import-result {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
}
.import-result.success { background: #052e16; color: #4ade80; border: 1px solid #166534; }
.import-result.error   { background: #1c0707; color: #f87171; border: 1px solid #991b1b; }

/* ── Settings view ──────────────────────────────────────── */
.settings-field { margin-bottom: 16px; }

.settings-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: block;
}

.settings-select,
.settings-input {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  width: 200px;
}
.settings-select:focus,
.settings-input:focus { outline: none; border-color: var(--accent); }

.settings-save-btn {
  background: var(--accent-btn);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.15s;
}
.settings-save-btn:hover { opacity: 0.85; }

.settings-saved {
  color: #4ade80;
  font-size: 13px;
  margin-left: 12px;
  display: none;
}

/* Danger zone button */
.danger-btn {
  background: #991b1b;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.danger-btn:hover { background: #dc2626; }

/* ── Help blocks ─────────────────────────────────────────── */
.help-block {
  margin-bottom: 24px;
}
.help-block summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  list-style: none;
  user-select: none;
  padding: 8px 0;
}
.help-block summary::-webkit-details-marker { display: none; }
.help-block summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.15s;
  color: var(--accent);
  flex-shrink: 0;
}
.help-block[open] summary::before { transform: rotate(90deg); }
.help-block summary:hover { color: var(--text-muted); }

.help-body {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}
.help-body h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin: 14px 0 6px;
}
.help-body h4:first-child { margin-top: 0; }
.help-body p { margin-bottom: 8px; }
.help-body p:last-child { margin-bottom: 0; }
.help-body ul { padding-left: 20px; margin-bottom: 8px; }
.help-body li { margin-bottom: 4px; }
.help-body strong { color: var(--text); font-weight: 600; }
.help-body .help-tip {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 12px;
}
.help-body .help-tip strong { color: var(--amber); }

/* ── Dark mode toggle switch ─────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  user-select: none;
}

.theme-toggle-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
}

/* The toggle track */
.toggle-track {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}

/* The toggle thumb */
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.25s, background 0.25s;
}

/* When dark mode is active (default), thumb left; when light mode, thumb right */
html[data-theme="light"] .toggle-track {
  background: var(--accent);
  border-color: var(--accent-btn);
}

html[data-theme="light"] .toggle-thumb {
  transform: translateX(20px);
  background: #ffffff;
}

/* Icon inside toggle — sun/moon */
.toggle-icon {
  font-size: 13px;
  min-width: 16px;
  text-align: center;
}

/* ── Light mode specific tweaks ─────────────────────────── */
html[data-theme="light"] .stat-card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

html[data-theme="light"] .bar-fill {
  opacity: 0.85;
}

html[data-theme="light"] .help-block {
  border-color: var(--border);
  background: var(--bg-raised);
}

html[data-theme="light"] .modal-box {
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

html[data-theme="light"] .trust-banner {
  background: #fef9c3;
  border-color: #ca8a04;
  color: #713f12;
}
html[data-theme="light"] .trust-banner-text { color: #5c4a1e; }
html[data-theme="light"] .trust-banner-text strong { color: #713f12; }

html[data-theme="light"] .waste-alert {
  background: #fef2f2;
  border-color: #dc2626;
  color: #7f1d1d;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  body { flex-direction: column; }

  .sidebar { display: none; }

  .main {
    margin-left: 0;
    margin-bottom: var(--bottom-nav-h);
    min-height: calc(100vh - var(--bottom-nav-h));
  }

  .view { padding: 20px 16px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 10;
  }

  .bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; color: var(--text-dim); font-size: 18px;
    min-height: 44px;   /* WCAG fix: minimum touch target */
  }
  .bottom-nav-item span { font-size: 9px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
  .bottom-nav-item.active { color: var(--accent); }

  .privacy-footer {
    display: block;
    text-align: center; padding: 16px; font-size: 12px; color: var(--text-faint);
    border-top: 1px solid var(--border); margin-top: 32px;
  }

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

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

  .data-table th:nth-child(2),
  .data-table td:nth-child(2) { display: none; } /* hide category on mobile */
}

/* Mobile: show toggle in bottom bar footer area */
@media (max-width: 640px) {
  .theme-toggle {
    justify-content: center;
    padding: 8px 16px;
  }
}

/* ── Sidebar logo enhancements ──────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 24px;
}
.sidebar-logo-mark {
  color: var(--accent);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.sidebar-logo-text {
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 2px;
  line-height: 1.1;
}
.sidebar-tagline {
  display: block;
  font-size: 9px;
  color: var(--text-faint);
  letter-spacing: 1.5px;
  font-weight: 500;
  margin-top: 2px;
}

/* ── Hero feature panels ─────────────────────────────────── */
.hero-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.hero-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, transform 0.2s;
}
.hero-panel:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.hero-icon {
  color: var(--accent);
  opacity: 0.9;
  line-height: 0;
}
.hero-panel-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--text);
}
.hero-panel-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Brand card (right column) ───────────────────────────── */
.brand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 16px;
  gap: 8px;
  background: linear-gradient(135deg, var(--bg-panel) 0%, var(--bg-raised) 100%);
  border-color: var(--accent);
}
.brand-card-logo {
  color: var(--accent);
  line-height: 0;
}
.brand-card-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-card-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent);
}
.brand-card-sub {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.brand-card-tagline {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 1px;
}

/* ── Nav icon alignment ──────────────────────────────────── */
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  flex-shrink: 0;
}
.nav-icon svg {
  display: block;
}

/* Light mode brand card */
html[data-theme="light"] .brand-card {
  background: linear-gradient(135deg, #f0f6ff 0%, #e0eaf5 100%);
  border-color: var(--accent);
}

/* Responsive hero panels */
@media (max-width: 640px) {
  .hero-features {
    grid-template-columns: 1fr;
  }
  .hero-icon svg {
    width: 48px;
    height: 48px;
  }
}

/* Hero panels as interactive buttons */
.hero-panel-btn {
  cursor: pointer;
}
.hero-panel-btn:active {
  transform: translateY(0px) scale(0.98);
}

/* ── Page empty state ────────────────────────────────────── */
.page-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}
.empty-state-icon {
  color: var(--text-faint);
  opacity: 0.6;
}
.empty-state-text {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 280px;
  line-height: 1.5;
}

/* ── Export / Settings section title icons ───────────────── */
.export-section-title,
.settings-section-title,
.card-title {
  display: flex;
  align-items: center;
  gap: 0;
}

/* ── Export page enhancements ────────────────────────────── */
.export-loss-list {
  margin: 8px 0 8px 20px;
  padding: 0;
  font-size: inherit;
  color: inherit;
  line-height: 1.7;
}
.export-loss-list li {
  list-style: disc;
}

.export-format-label {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
  margin-bottom: 12px;
  letter-spacing: 0.3px;
}

.export-tip {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.export-tip strong {
  color: var(--text);
  font-size: 13px;
}
html[data-theme="light"] .export-tip {
  background: #eef4ff;
  border-left-color: var(--accent);
}

.import-mode-label {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  gap: 4px;
  transition: border-color 0.15s;
}
.import-mode-label:has(input:checked) {
  border-color: var(--accent);
  background: var(--bg-raised);
}
.import-mode-label input {
  margin-bottom: 2px;
}
.import-mode-helper {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 20px;
  line-height: 1.4;
}
.import-mode-helper-warn {
  color: var(--amber);
}

.import-replace-warning {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #f87171;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #b91c1c;
  font-weight: 500;
}
html[data-theme="light"] .import-replace-warning {
  background: #fef2f2;
  border-color: #dc2626;
  color: #7f1d1d;
}
