/* Dzen Money Theme — iOS 17 feel */
:root {
  --bg: #1C1C1E;
  --bg-card: #2C2C2E;
  --bg-input: #3A3A3C;
  --border: #48484A;
  --text: #FFFFFF;
  --text-dim: #8E8E93;
  --primary: #FF9F0A;
  --green: #30D158;
  --red: #FF453A;
  --yellow: #FFD60A;
  --blue: #0A84FF;
  --purple: #BF5AF2;
  --orange: #FF9F0A;
  --teal: #64D2FF;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
  --shadow-lift: 0 10px 30px -12px rgba(0,0,0,0.55);
  --nav-height: 58px;
  --glass: rgba(28, 28, 30, 0.72);
  --glass-border: rgba(255, 255, 255, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  animation: pageIn 0.28s ease both;
}
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }

a { color: var(--primary); text-decoration: none; }

/* Top Header — frosted */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: var(--glass);
  /* 10px blur, no saturate — 22px+saturate re-blurred every scrolled frame and
     made long lists feel laggy; cost scales ~quadratically with radius. */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
@media (min-width: 768px) {
  .top-bar { padding: 16px 28px; }
}
@media (min-width: 1280px) {
  .top-bar { padding: 18px 40px; }
}
.top-bar h1 { font-size: 20px; font-weight: 700; }
.top-bar .actions { display: flex; gap: 10px; align-items: center; }

/* Bottom Navigation — frosted, scrollable */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--glass-border);
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 6px 8px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 100;
  gap: 2px;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-dim);
  font-size: 9px;
  gap: 2px;
  padding: 5px 8px;
  min-width: 52px;
  flex-shrink: 0;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s, background 0.18s, transform 0.12s;
}
.bottom-nav a:active { transform: scale(0.92); }
.bottom-nav a .nav-icon { font-size: 20px; line-height: 1; transition: transform 0.18s cubic-bezier(.34,1.56,.64,1); }
.bottom-nav a.active { color: var(--primary); background: rgba(255,159,10,0.12); }
.bottom-nav a.active .nav-icon { transform: translateY(-1px) scale(1.08); }

/* Page Container */
.page { padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (min-width: 768px) {
  .page { padding: 18px 28px; }
}
@media (min-width: 1280px) {
  .page { padding: 24px 40px; max-width: 1500px; }
}
@media (min-width: 1600px) {
  .page { max-width: 1560px; }
}
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; }

/* Cards */
.card {
  background: linear-gradient(155deg, var(--bg-card) 0%, color-mix(in srgb, var(--bg-card) 92%, #fff 8%) 200%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
/* Hover lift (and its transition) only where hover exists — an always-on
   transition made cards repaint as the cursor swept past during scroll. */
@media (hover: hover) and (min-width: 1024px) {
  .card { transition: box-shadow 0.18s ease; }
  .card:hover { box-shadow: var(--shadow-lift); }
}
.card-title { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; font-weight: 600; }
.card-value { font-size: 26px; font-weight: 700; }
.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }

/* Summary Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.summary-grid .card { margin-bottom: 0; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--bg-input);
  transition: opacity 0.15s, transform 0.1s;
  min-height: 44px;
}
.btn:active { opacity: 0.7; transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #000; }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #000; }
.btn-sm { padding: 6px 14px; font-size: 13px; min-height: 36px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; min-width: 44px; min-height: 44px; font-size: 18px; }
.btn-outline { background: transparent; border: 1px solid var(--border); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px; /* ≥16px prevents iOS focus zoom */
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,159,10,0.18);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { -webkit-appearance: none; appearance: none; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Modal — iOS bottom sheet */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.active { display: flex; animation: overlayIn 0.2s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: 24px 24px 0 0;
  padding: 26px 20px max(20px, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp 0.34s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 -18px 50px -12px rgba(0,0,0,0.6);
}
.modal::before {
  content: "";
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: 40px; height: 5px;
  border-radius: 3px;
  background: var(--border);
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 24px; border-bottom: 1px solid var(--glass-border); max-height: 82vh; padding-bottom: 22px; }
  .modal::before { display: none; }
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 24px; cursor: pointer; padding: 8px; min-width: 44px; min-height: 44px; }

/* Lists — content-visibility lets the browser skip layout/paint for
   off-screen rows, which keeps long transaction lists smooth. */
.list-item {
  content-visibility: auto;
  contain-intrinsic-size: auto 64px;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.list-item:active { background: rgba(255,255,255,0.03); }
.list-item:last-child { border-bottom: none; }
.list-item .icon { font-size: 24px; width: 36px; text-align: center; flex-shrink: 0; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .info .meta { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.list-item .amount { font-size: 15px; font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-item .amount.income { color: var(--green); }
.list-item .amount.expense { color: var(--red); }
.list-item .amount.transfer { color: var(--blue); }

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.progress-bar .fill.green { background: var(--green); }
.progress-bar .fill.yellow { background: var(--yellow); }
.progress-bar .fill.red { background: var(--red); }
.progress-bar .fill.blue { background: var(--blue); }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar select, .filter-bar input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 13px;
  min-height: 40px;
  min-width: 100px;
  flex-shrink: 0;
}
.filter-bar select:focus, .filter-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Type pills */
.type-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.type-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}
.type-pill.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

/* Chart Container */
.chart-container { position: relative; height: 220px; margin: 12px 0; }
.chart-container canvas { width: 100% !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  animation: fadeInUp 0.2s ease;
  white-space: nowrap;
}
.toast.success { background: var(--green); color: #000; }
.toast.error { background: var(--red); color: #fff; }
@keyframes fadeInUp { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Login */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-box h1 { font-size: 24px; margin-bottom: 8px; }
.login-box p { color: var(--text-dim); margin-bottom: 20px; font-size: 14px; }
.login-box .error { color: var(--red); font-size: 13px; margin-top: 12px; display: none; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* Tags / Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.income { background: rgba(48,209,88,0.15); color: var(--green); }
.badge.expense { background: rgba(255,69,58,0.15); color: var(--red); }
.badge.transfer { background: rgba(10,132,255,0.15); color: var(--blue); }
.badge.recurring { background: rgba(191,90,242,0.15); color: var(--purple); }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 16px;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(255,159,10,0.05);
}
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-zone .upload-text { font-size: 14px; color: var(--text-dim); }
.upload-zone .upload-text strong { color: var(--primary); }

/* Import stats */
.import-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  padding: 12px;
  background: rgba(48,209,88,0.08);
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 14px;
}
.import-stats .stat { text-align: center; }
.import-stats .stat-value { font-size: 20px; font-weight: 700; }
.import-stats .stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; }

/* Category toggle chips */
.category-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-input);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-chip.active {
  background: rgba(255,159,10,0.15);
  border-color: var(--primary);
  color: var(--primary);
}
.cat-chip.excluded {
  opacity: 0.4;
  text-decoration: line-through;
}

/* Insight Cards */
.insight-section { margin-bottom: 24px; }
.insight-section h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.insight-card .label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.insight-card .value { font-size: 20px; font-weight: 700; }
.insight-card .desc { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* Gauge (for Ramit buckets) */
.gauge { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gauge .label-wrap { width: 100px; flex-shrink: 0; }
.gauge .label-wrap .name { font-size: 13px; font-weight: 500; }
.gauge .label-wrap .target { font-size: 11px; color: var(--text-dim); }
.gauge .bar-wrap { flex: 1; }
.gauge .pct { font-size: 14px; font-weight: 600; width: 50px; text-align: right; flex-shrink: 0; }

/* Baby Steps */
.baby-steps { display: flex; flex-direction: column; gap: 8px; }
.baby-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--bg-input);
  font-size: 14px;
}
.baby-step.active { background: rgba(10,132,255,0.15); border: 1px solid var(--blue); }
.baby-step.done { opacity: 0.5; }
.baby-step .step-num {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--border); flex-shrink: 0;
}
.baby-step.active .step-num { background: var(--blue); color: #fff; }
.baby-step.done .step-num { background: var(--green); color: #000; }

/* Account Cards */
.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.account-card:active { background: rgba(255,255,255,0.03); }
.account-card .acct-icon { font-size: 28px; width: 40px; text-align: center; }
.account-card .acct-info { flex: 1; }
.account-card .acct-info .name { font-size: 15px; font-weight: 600; }
.account-card .acct-info .meta { font-size: 12px; color: var(--text-dim); }
.account-card .acct-balance { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.account-card .acct-limit { font-size: 11px; color: var(--text-dim); }

/* Color dot */
.color-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  flex: 1; padding: 10px; border: none; background: none;
  color: var(--text-dim); font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  transition: color 0.15s;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* File list for insurance */
.file-list { margin-top: 8px; }
.file-item {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  background: var(--bg-input); border-radius: var(--radius); margin-bottom: 6px;
  font-size: 13px;
}
.file-item .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .file-actions { display: flex; gap: 4px; flex-shrink: 0; }
.file-item .file-actions button { padding: 4px 8px; font-size: 12px; min-height: auto; }

/* Quote indicator */
.quote-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600;
}
.quote-badge.up { background: rgba(48,209,88,0.15); color: var(--green); }
.quote-badge.down { background: rgba(255,69,58,0.15); color: var(--red); }

/* Savings goal card */
.goal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px; cursor: pointer;
}
.goal-card .goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.goal-card .goal-name { font-size: 15px; font-weight: 600; }
.goal-card .goal-amounts { font-size: 13px; color: var(--text-dim); margin-bottom: 4px; }
.goal-card .goal-pct { font-size: 14px; font-weight: 600; }

/* Report card */
.report-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px; cursor: pointer;
}
.report-card .report-date { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.report-card .report-summary { font-size: 13px; color: var(--text-dim); display: flex; gap: 12px; flex-wrap: wrap; }

/* Theme swatches */
.theme-swatch {
  width: 48px; height: 48px; border-radius: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent; transition: border-color 0.2s;
}
.theme-swatch.active { border-color: var(--primary); }
.theme-swatch-grid { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* Supplier badge */
.supplier-tag {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  background: rgba(191,90,242,0.12); color: var(--purple);
  font-size: 11px; margin-left: 4px;
}

/* Date group header */
.date-group-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 10px 12px 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ==================== THEMES ==================== */

/* Light (app default) — Google-Finance-adjacent: white cards, soft borders */
.theme-light {
  --bg: #F6F7F9;
  --bg-card: #FFFFFF;
  --bg-input: #EEF0F3;
  --border: #DDE0E4;
  --text: #1C1C1E;
  --text-dim: #70757A;
  --primary: #FF9500;
  --green: #188038;
  --red: #D93025;
  --blue: #1A73E8;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(0, 0, 0, 0.07);
  --shadow: 0 1px 6px rgba(60, 64, 67, 0.10);
  --shadow-lift: 0 10px 26px -10px rgba(60, 64, 67, 0.28);
}

/* Midnight */
.theme-midnight {
  --bg: #05051e;
  --bg-card: #0d0d2b;
  --bg-input: #16163a;
  --border: #222255;
  --text: #eeeef5;
  --text-dim: #7878a8;
  --primary: #5865f2;
  --blue: #5865f2;
  --green: #2ed573;
  --red: #ff4757;
  --purple: #a29bfe;
}

/* Ocean */
.theme-ocean {
  --bg: #0a0e17;
  --bg-card: #111827;
  --bg-input: #1f2937;
  --border: #374151;
  --text: #f3f4f6;
  --text-dim: #9ca3af;
  --primary: #06b6d4;
  --blue: #06b6d4;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --purple: #a78bfa;
}

/* Investment Dashboard */
.inv-dashboard { margin-bottom: 12px; }
.inv-dash-row1 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.inv-bar-card { min-height: 320px; }
.inv-right-col { display: flex; flex-direction: column; gap: 10px; }
.inv-movers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.inv-mover-card { margin-bottom: 0; }
.mover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.mover-row:last-child { border-bottom: none; }
.mover-ticker { font-weight: 700; min-width: 55px; }
.mover-name { flex: 1; color: var(--text-dim); margin: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover-pct { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 70px; text-align: right; }
.comp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
}
.comp-row .comp-label { color: var(--text-dim); }
.comp-row .comp-val { font-weight: 600; }
.comp-row.comp-total { font-size: 20px; font-weight: 800; padding: 8px 0; }
.comp-divider { border-top: 1px solid var(--border); margin: 4px 0; }
.news-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.news-item:last-child { border-bottom: none; }
.news-item a { color: var(--text); font-weight: 500; }
.news-item a:hover { color: var(--primary); }
.news-item .news-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

@media (min-width: 640px) {
  .inv-dash-row1 { grid-template-columns: 3fr 2fr; }
}
@media (min-width: 1024px) {
  .inv-dash-row1 { grid-template-columns: 2.2fr 1fr; gap: 14px; }
  .inv-right-col { gap: 14px; }
  .inv-bar-card { min-height: 380px; }
  .inv-bar-card .chart-container,
  .inv-bar-card div[style*="height:280px"] { height: 340px !important; }
}
@media (min-width: 1280px) {
  .inv-dashboard .inv-movers { gap: 14px; }
}

/* Responsive */
@media (min-width: 640px) {
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Accounts summary (Net Worth / Available / Savings). Phones: Net Worth takes the
   whole first row and the other two share the second — three 1fr columns could not
   shrink below a balance's width and pushed the page sideways. min-width:0 lets a
   column shrink; a figure that still doesn't fit wraps instead of overflowing. */
.summary-grid.acct-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.acct-summary > .card { min-width: 0; }
.acct-summary > .card:first-child { grid-column: 1 / -1; }
.acct-summary .card-value { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .acct-summary > .card:not(:first-child) .card-value { font-size: 22px; }
}
@media (min-width: 640px) {
  .summary-grid.acct-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .acct-summary > .card:first-child { grid-column: auto; }
}

/* Desktop: wider card padding + bigger charts */
@media (min-width: 1024px) {
  .card { padding: 18px; }
  .chart-container { height: 260px; }
}
@media (min-width: 1280px) {
  .card { padding: 20px 22px; }
  .chart-container { height: 280px; }
}

/* Dashboard: 2-column card layout on desktop */
.dash-2col { display: contents; }
@media (min-width: 1024px) {
  .dash-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 12px;
    align-items: start;
  }
  .dash-2col > .card { margin-bottom: 0; }
}

/* ===== Investments — Advanced Analytics ===== */
.signal-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.4;
}
.signal-buy  { background: rgba(34,197,94,0.15);  color: var(--green); }
.signal-sell { background: rgba(239,68,68,0.15);  color: var(--red); }
.signal-hold { background: rgba(148,163,184,0.15); color: var(--text-dim); }

.stat-tile {
  text-align: center;
  padding: 8px 4px;
  background: var(--bg);
  border-radius: 8px;
}
.stat-tile .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat-tile .value {
  font-size: 16px;
  font-weight: 700;
  margin-top: 3px;
}

canvas.spark {
  display: block;
  flex-shrink: 0;
}

.signal-row:last-child {
  border-bottom: none !important;
}

/* ===== US Market Clock ===== */
.market-clock {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(148, 163, 184, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}
.market-clock .mc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.55);
  flex-shrink: 0;
}
.market-clock.open .mc-dot {
  background: var(--green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  animation: mcPulse 2s infinite;
}
.market-clock .mc-label {
  font-weight: 700;
  letter-spacing: 0.3px;
}
.market-clock .mc-status {
  color: var(--text-dim);
  font-size: 12px;
}
.market-clock .mc-time {
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, "Roboto Mono", monospace;
  margin-left: auto;
  letter-spacing: 0.5px;
}
.market-clock .mc-et {
  color: var(--text-dim);
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, "Roboto Mono", monospace;
}
@keyframes mcPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(1.25); }
}

@media (max-width: 640px) {
  #risk-stats { grid-template-columns: repeat(3, 1fr) !important; }
  #signals-grid { grid-template-columns: 1fr !important; }
  canvas.spark { display: none; }
  .market-clock { padding: 8px 12px; font-size: 12px; gap: 8px; }
  .market-clock .mc-et { display: none; }
}

/* ===== Quick Buy/Sell on holding rows ===== */
.row-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
}
.btn-quick {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}
.btn-quick .icon {
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-quick-buy {
  color: var(--green);
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
}
.btn-quick-buy .icon {
  background: rgba(34, 197, 94, 0.2);
}
.btn-quick-buy:hover {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.18), 0 4px 12px -4px rgba(34, 197, 94, 0.35);
}
.btn-quick-buy:active { transform: translateY(1px); }
.btn-quick-sell {
  color: var(--red);
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.22);
}
.btn-quick-sell .icon {
  background: rgba(239, 68, 68, 0.18);
}
.btn-quick-sell:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.16), 0 4px 12px -4px rgba(239, 68, 68, 0.35);
}
.btn-quick-sell:active { transform: translateY(1px); }

/* ===== iOS component kit (2026 redesign) ===== */

/* Floating Action Button */
.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(var(--nav-height) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(140deg, #FFB340, var(--primary));
  color: #1a1204;
  font-size: 28px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 150;
  box-shadow: 0 10px 26px -6px rgba(255,159,10,0.5), 0 4px 12px rgba(0,0,0,0.35);
  transition: transform 0.15s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(0.9) rotate(90deg); }
@media (hover: hover) { .fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px -6px rgba(255,159,10,0.6), 0 6px 16px rgba(0,0,0,0.4); } }

/* Segmented control */
.segmented {
  display: flex;
  background: var(--bg-input);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--glass-border);
}
.segmented button {
  flex: 1;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(.2,.8,.2,1);
  -webkit-tap-highlight-color: transparent;
}
.segmented button.active { background: var(--bg-card); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.segmented button.active.seg-buy { background: rgba(48,209,88,0.18); color: var(--green); }
.segmented button.active.seg-sell { background: rgba(255,69,58,0.16); color: var(--red); }

/* iOS-style range slider */
input[type="range"].ios-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  background: transparent;
}
input[type="range"].ios-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) var(--fill, 50%), var(--bg-input) var(--fill, 50%));
}
input[type="range"].ios-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  margin-top: -10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.45);
  cursor: grab;
  transition: transform 0.1s;
}
input[type="range"].ios-slider:active::-webkit-slider-thumb { transform: scale(1.15); cursor: grabbing; }

/* Slider row (label + value + slider) */
.slider-row { margin-bottom: 16px; }
.slider-row .slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.slider-row .slider-head label { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.slider-row .slider-head .slider-val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }

/* Progress ring */
.ring-wrap { position: relative; width: 150px; height: 150px; margin: 0 auto; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-wrap .ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.ring-wrap .ring-pct { font-size: 26px; font-weight: 800; line-height: 1; }
.ring-wrap .ring-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* Verdict banner */
.verdict {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 600; margin-bottom: 12px;
}
.verdict .v-icon { font-size: 24px; }
.verdict.ok { background: rgba(48,209,88,0.12); border: 1px solid rgba(48,209,88,0.3); color: var(--green); }
.verdict.warn { background: rgba(255,214,10,0.1); border: 1px solid rgba(255,214,10,0.28); color: var(--yellow); }
.verdict.bad { background: rgba(255,69,58,0.1); border: 1px solid rgba(255,69,58,0.28); color: var(--red); }

/* Big trade amount preview */
.trade-total {
  text-align: center;
  padding: 14px;
  background: var(--bg);
  border-radius: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--glass-border);
}
.trade-total .tt-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.trade-total .tt-value { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ===== Google-Finance-style portfolio hero ===== */
.gf-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
}
.gf-label { font-size: 12px; color: var(--text-dim); font-weight: 500; }
.gf-value { font-size: 38px; font-weight: 800; letter-spacing: -1px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.gf-sub { font-size: 14px; color: var(--text-dim); margin-top: 2px; font-variant-numeric: tabular-nums; }
.gf-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.gf-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg-input);
  color: var(--text-dim);
  white-space: nowrap;
}
.gf-pill.up { background: rgba(24,128,56,0.10); color: var(--green); }
.gf-pill.down { background: rgba(217,48,37,0.10); color: var(--red); }
.gf-pill.neutral { background: var(--bg-input); color: var(--text); }
.gf-side { text-align: right; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.gf-updated { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
@media (max-width: 640px) {
  .gf-value { font-size: 30px; }
  .gf-side { text-align: left; align-items: flex-start; }
}

/* Recent transactions rows */
.rt-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.rt-row:last-child { border-bottom: none; }
.rt-badge {
  flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}
.rt-badge.buy { background: rgba(24,128,56,0.12); color: var(--green); }
.rt-badge.sell { background: rgba(217,48,37,0.10); color: var(--red); }
.rt-sym { font-weight: 700; min-width: 52px; }
.rt-detail { flex: 1; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rt-total { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rt-date { color: var(--text-dim); font-size: 11px; min-width: 52px; text-align: right; white-space: nowrap; }

/* ===== Read-only viewer mode =====
   The server stamps <html class="viewer-mode"> on pages it serves to a viewer, so
   everything here applies from first paint. UX only — the server enforces it. */
.viewer-mode .owner-only { display: none !important; }

/* Bottom nav keeps only Transactions / Accounts / Investments; no "More" menu,
   no FAB (always a write), no AI assistant. */
.viewer-mode .bottom-nav a:not([data-page="transactions"]):not([data-page="accounts"]):not([data-page="investments"]),
.viewer-mode #more-btn,
.viewer-mode #more-menu,
.viewer-mode .more-btn,
.viewer-mode .more-menu,
.viewer-mode .fab,
.viewer-mode .ait-root { display: none !important; }
.viewer-mode .bottom-nav { justify-content: center; gap: 6px; }
.viewer-mode .bottom-nav a { flex: 1 1 0; max-width: 136px; min-width: 0; font-size: 10px; }

/* Top bar: when the title + actions don't fit (phones), the actions drop to a
   second, right-aligned row instead of truncating the page title. */
.viewer-mode .top-bar { gap: 10px; }
.viewer-mode .top-bar:has(.viewer-chrome) { flex-wrap: wrap; row-gap: 8px; }
.viewer-mode .top-bar:has(.viewer-chrome) > .actions { margin-left: auto; }
.viewer-mode .top-bar:has(.viewer-chrome) > h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.viewer-chrome { display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.viewer-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.2;
  white-space: nowrap;
  color: color-mix(in srgb, var(--blue) 80%, var(--text));
  background: color-mix(in srgb, var(--blue) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--blue) 28%, transparent);
  cursor: default;
  user-select: none;
}
.viewer-pill-icon { font-size: 13px; line-height: 1; }
.viewer-signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: border-color 0.15s, opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) { .viewer-signout:hover { border-color: var(--text-dim); } }
.viewer-signout:active { opacity: 0.75; transform: scale(0.97); }
.viewer-signout:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 380px) {
  .viewer-chrome { gap: 6px; }
  .viewer-pill { padding: 4px 9px; font-size: 11px; }
  .viewer-signout { padding: 4px 10px; font-size: 11px; }
}

/* Settings → Shared access (read-only) */
.share-list { margin-top: 10px; }
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.share-row:last-child { border-bottom: none; }
.share-info { flex: 1; min-width: 0; }
.share-email { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.share-remove { color: var(--red); flex-shrink: 0; }
.share-empty { font-size: 12px; color: var(--text-dim); padding: 6px 0; }
.share-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.share-add .form-group { flex: 1 1 220px; margin: 0; }
.share-add .btn { min-height: 46px; flex-shrink: 0; }
.share-add .btn:disabled, .share-remove:disabled { opacity: 0.55; cursor: default; }
.share-error { font-size: 12px; color: var(--red); margin-top: 8px; }
.share-note { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.share-url { color: var(--text); font-weight: 600; user-select: all; }
.share-owners { font-size: 12px; color: var(--text-dim); margin-top: 6px; overflow-wrap: anywhere; }
.share-warn {
  font-size: 12px;
  line-height: 1.45;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  background: color-mix(in srgb, var(--yellow) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--yellow) 40%, transparent);
}
.share-activity { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.share-activity summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.share-activity summary::-webkit-details-marker { display: none; }
.share-activity summary::before {
  content: "▸";
  display: inline-block;
  width: 14px;
  transition: transform 0.15s;
}
.share-activity[open] summary::before { transform: rotate(90deg); }
.share-log { margin-top: 8px; }
.share-log-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.share-log-row:last-child { border-bottom: none; }
.share-log-time { color: var(--text-dim); flex-shrink: 0; min-width: 96px; font-variant-numeric: tabular-nums; }
.share-log-what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-log-path { color: var(--text-dim); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
