:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --text: #14213d;
  --muted: #6b7280;
  --brand: #2952cc;
  --brand-dark: #17203a;
  --positive: #1a9e63;
  --negative: #d34848;
  --border: #e7eaf1;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(20, 33, 61, 0.06);
}

* { box-sizing: border-box; }
svg { display: block; flex-shrink: 0; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- sidebar (desktop) ---------- */
.sidebar {
  width: 220px;
  background: var(--brand-dark);
  color: #fff;
  padding: 24px 16px;
  display: none;
  flex-direction: column;
  gap: 4px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-flex; }
.sidebar .brand {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  padding: 0 12px;
}
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
}
.sidebar .nav-link svg { flex-shrink: 0; }
.sidebar .nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; }
.sidebar .nav-link-muted { margin-top: auto; color: rgba(255,255,255,0.4); }

.content {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 96px;
  width: 100%;
}

.page-title { font-size: 22px; margin: 4px 0 20px; }

.mobile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.mobile-topbar .brand { font-size: 18px; font-weight: 700; }
.mobile-topbar-actions { display: flex; gap: 8px; }
.settings-gear {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
}

/* ---------- hero net worth card ---------- */
.hero-card {
  display: block;
  background: linear-gradient(135deg, var(--brand), #4671e8);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.hero-header-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; padding-right: 40px; }
.hero-label { font-size: 14px; opacity: 0.85; }
.hero-amount { font-size: 28px; font-weight: 700; }
.hero-amount-row { display: flex; align-items: center; gap: 12px; }
.hero-sparkline { flex-shrink: 0; opacity: 0.9; }
.hero-sub { font-size: 12px; opacity: 0.75; margin-top: 6px; }
.hero-sub-row { display: flex; justify-content: space-between; font-size: 12px; opacity: 0.75; margin-top: 4px; }
.hero-spark-caption { font-size: 12px; font-style: italic; color: #cbd3ea; text-align: right; margin-top: 2px; }
.hero-warning { margin-top: 10px; font-size: 12px; background: rgba(0,0,0,0.15); padding: 6px 10px; border-radius: 8px; }
.hero-hint { margin-top: 10px; font-size: 12px; opacity: 0.85; }
.hero-card-relative { position: relative; }
.hero-logo {
  width: 28px; height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}
.hero-logo img { width: 100%; height: 100%; object-fit: cover; }
.hero-edit-btn {
  position: absolute;
  top: 16px; right: 16px;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px 18px;
}
.net-worth-line {
  display: block;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 4px 18px;
}
.net-worth-line strong { color: var(--text); }
.net-worth-line strong.positive { color: var(--positive); }
.net-worth-line strong.negative { color: var(--negative); }

/* ---------- quick actions ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 6px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.quick-action:hover { transform: translateY(-1px); }
.quick-icon {
  display: flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 50%;
}
.quick-icon-blue { background: rgba(70,113,232,0.14); color: #4671e8; }
.quick-icon-pink { background: rgba(194,72,141,0.14); color: #c2478d; }
.quick-icon-teal { background: rgba(43,167,176,0.14); color: #2ba7b0; }

/* ---------- income/expense flow card ---------- */
.flow-card {
  display: block;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 24px;
}
.flow-label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin-bottom: 12px; }
.flow-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.flow-row:last-child { margin-bottom: 0; }
.flow-row-label { width: 62px; flex-shrink: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.flow-bar-track { flex: 1; height: 9px; border-radius: 5px; background: var(--bg); overflow: hidden; }
.flow-bar-fill { height: 100%; border-radius: 5px; transition: width 0.3s ease; }
.flow-bar-fill.income { background: var(--positive); }
.flow-bar-fill.expense { background: var(--negative); }
.flow-bar-fill.bills { background: #e08a3c; }
.flow-row-amount { width: 64px; flex-shrink: 0; text-align: right; font-size: 13px; font-weight: 700; }
.flow-row-amount.bills { color: #e08a3c; }

/* ---------- sections & stat cards ---------- */
.section { margin-bottom: 26px; }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-header h2 { font-size: 16px; margin: 0; }

.accordion summary.section-header {
  cursor: pointer;
  list-style: none;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 0;
}
.accordion summary.section-header::-webkit-details-marker { display: none; }
.accordion summary.section-header::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.accordion[open] summary.section-header {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
.accordion[open] summary.section-header::after { transform: rotate(-135deg); }
.accordion .form-card, .accordion .list-card {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: -1px;
}
.see-all { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--brand); font-weight: 600; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; color: var(--muted); font-size: 14px; }

.main-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand);
  background: rgba(41,82,204,0.12);
  padding: 2px 7px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.stat-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: block;
}
.stat-name { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat-amount { font-size: 18px; font-weight: 700; }

/* generic "this is clickable" affordance */
.clickable { cursor: pointer; transition: transform 0.08s ease, box-shadow 0.08s ease; }
.clickable:hover { box-shadow: 0 4px 16px rgba(20,33,61,0.12); }
.clickable:active { transform: scale(0.98); }

/* ---------- list rows (bills / transactions) ---------- */
.list-card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
a.list-row { display: flex; }
.list-row.row-deposit { background: rgba(26,158,99,0.07); }
.list-row.row-withdrawal { background: rgba(211,72,72,0.05); }
.list-row.row-transfer { background: rgba(43,167,176,0.06); }
.list-row-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.list-row-main { flex: 1; min-width: 0; }
.list-row-title { font-weight: 600; font-size: 14px; }
.list-row-sub { font-size: 12px; color: var(--muted); }
.list-row-sub .negative { color: var(--negative); font-weight: 600; }
.list-row-sub .positive { color: var(--positive); font-weight: 600; }
.list-row-amount { font-weight: 700; font-size: 14px; color: var(--negative); white-space: nowrap; }
.list-row-amount.positive { color: var(--positive); }
.list-empty { padding: 20px 16px; color: var(--muted); font-size: 13px; }

/* denser rows for long account lists */
.list-card-compact .list-row { padding: 9px 14px; gap: 10px; }
.list-card-compact .avatar { width: 32px; height: 32px; }
.list-card-compact .list-row-title { font-size: 13.5px; }

/* collapsed account group (e.g. "Retirement funds") on Home */
.account-group { margin-top: 8px; }
.account-group-summary {
  cursor: pointer;
  list-style: none;
}
.account-group-summary::-webkit-details-marker { display: none; }
.account-group-summary::after {
  content: "";
  width: 7px; height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  margin-left: 4px;
}
.account-group[open] .account-group-summary::after { transform: rotate(-135deg); }
.avatar-cluster { display: flex; flex-shrink: 0; }
.avatar-cluster-item {
  width: 32px; height: 32px;
  margin-left: -10px;
  border: 2px solid var(--card);
}
.avatar-cluster-item:first-child { margin-left: 0; }
.account-group-members { border-top: 1px solid var(--border); }
.account-group-members .list-row { padding: 9px 14px; gap: 10px; }
.account-group-members .avatar { width: 32px; height: 32px; }
.account-group-members .list-row-title { font-size: 13.5px; }

/* ---------- calendar ---------- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cal-nav-btn {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.cal-nav-next svg { transform: rotate(180deg); }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-day {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.cal-day-bill-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #d6a92a;
}
.cal-day-payday-dot {
  position: absolute;
  top: 5px; left: 5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--positive);
}
.payday-icon { background: rgba(26,158,99,0.12); color: var(--positive); }
.cal-day-empty { background: transparent; box-shadow: none; }
.cal-day.today { border: 1.5px solid var(--brand); }
.cal-day-amount { font-size: 9px; font-weight: 700; }
.cal-day.pos .cal-day-amount { color: var(--positive); }
.cal-day.neg .cal-day-amount { color: var(--negative); }
.cal-day.payday { background: var(--positive); }
.cal-day.payday .cal-day-num, .cal-day.payday .cal-day-amount { color: #fff; }
.cal-day.payday .cal-day-payday-dot { display: none; }

/* ---------- insights / spending chart ---------- */
.spend-card {
  background: linear-gradient(160deg, #2952cc, #5a86f0);
  border-radius: var(--radius);
  padding: 22px 20px 14px;
  color: #fff;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  position: relative;
}
.spend-label { font-size: 13px; opacity: 0.85; }
.spend-amount { font-size: 26px; font-weight: 700; margin-top: 4px; }
.spend-chart { width: 100%; height: 110px; margin-top: 14px; display: block; }
.chart-point { transition: r 0.1s ease; }
.chart-point.active { r: 5; fill: #ffffff; }
.chart-point-hit { cursor: pointer; }
.spend-chart-peak {
  position: absolute;
  top: 64px;
  transform: translateX(-50%);
  background: #fff;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  white-space: nowrap;
}
.spend-months {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  opacity: 0.8;
  padding-bottom: 4px;
}

.insight-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 22px;
}
.insight-bubble-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  color: #fff;
}
.insight-bubble-icon.down { background: var(--positive); }
.insight-bubble-icon.up { background: var(--negative); }

.rank {
  width: 20px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

/* ---------- transaction list (avatar rows, grouped by day) ---------- */
.txn-group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 18px 0 8px; }
.txn-group-label:first-of-type { margin-top: 0; }
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.avatar-logo {
  background: #fff;
  overflow: hidden;
  border: 1px solid var(--border);
}
.avatar-logo img { width: 100%; height: 100%; object-fit: cover; }
.list-card-compact .avatar-logo { width: 32px; height: 32px; }
.avatar-stack { position: relative; flex-shrink: 0; }
.avatar-badge {
  position: absolute; bottom: -3px; right: -3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--card);
  overflow: hidden;
}
.avatar-badge img { width: 100%; height: 100%; object-fit: cover; }
.list-row-right { text-align: right; flex-shrink: 0; }
.list-row-right .list-row-amount { font-size: 14px; }
.list-row-amount.neutral { color: var(--text); }
.list-row-status { font-size: 11px; color: var(--muted); margin-top: 2px; }

.filter-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}
.filter-pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card);
  white-space: nowrap;
}
.pill.active { border-color: var(--brand); color: var(--brand); background: rgba(41,82,204,0.08); }

/* ---------- horizontally scrollable icon chips (budgets on account page) ---------- */
.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin-bottom: 6px;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 72px;
}
.chip-icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: #fff;
  font-weight: 700;
}
.chip-label { font-size: 11px; text-align: center; color: var(--muted); font-weight: 600; line-height: 1.2; }
.chip-add .chip-icon { background: var(--card); color: var(--brand); border: 1.5px dashed var(--border); }

/* ---------- bills total ---------- */
.bills-total-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-top: 14px;
}
.bills-total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.bills-total-row + .bills-total-row { margin-top: 6px; }
.bills-total-row strong { font-size: 16px; }

/* ---------- budgets overview ---------- */
.budget-overview {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.budget-ring-wrap { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.budget-ring { width: 120px; height: 120px; }
.budget-ring circle { transition: stroke-dashoffset 0.4s ease; }
.budget-ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.budget-ring-pct { font-size: 22px; font-weight: 800; line-height: 1.1; }
.budget-ring-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.budget-overview-details { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.budget-overview-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; gap: 10px; }
.budget-overview-row strong { font-size: 15px; }
.budget-overview-warning { margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--negative); }
.budget-bar-track { height: 6px; border-radius: 3px; background: var(--bg); overflow: hidden; margin: 5px 0 3px; }
.budget-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.budget-bar-fill.over { background: var(--negative); }
.budget-row .list-row-sub { margin-top: 0; }
.over-badge {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.02em;
  color: #fff; background: var(--negative); border-radius: 5px; padding: 1px 6px; margin-left: 4px;
  vertical-align: middle;
}

/* ---------- forms ---------- */
.form-card, .login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
input, select {
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
/* Custom-styled dropdown that replaces the browser's native <select>
   picker sheet (see base.html's enhancement script) — the real <select>
   stays in the DOM (hidden) so form submission and any onchange handlers
   keep working untouched; this is purely the visual layer. */
.select-wrap { position: relative; }
.select-wrap select { display: none; }
.select-display {
  font-size: 15px;
  padding: 10px 36px 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  position: relative;
  user-select: none;
}
.select-display::after {
  content: "";
  position: absolute;
  right: 14px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.select-panel {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 0 12px 28px rgba(0,0,0,0.28));
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
  padding: 6px;
}
.select-panel[hidden] { display: none; }
.select-wrap-disabled .select-display { opacity: 0.55; cursor: not-allowed; }
input:disabled, .form-card input[disabled] { opacity: 0.55; cursor: not-allowed; }
.select-option {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.select-option:hover { background: var(--bg); }
.select-option.selected { background: var(--brand); color: #fff; font-weight: 600; }

.primary-btn, button[type="submit"] {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.danger-btn {
  background: transparent;
  color: var(--negative);
  border: 1px solid var(--negative);
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  max-width: 420px;
  margin-top: 14px;
}
.checkbox-row { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; color: var(--text); }
.checkbox-row input { width: 18px; height: 18px; flex-shrink: 0; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 11px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--bg); }

.search-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 10px;
}
.search-row-icon { color: var(--muted); display: flex; flex-shrink: 0; }
.search-row-input {
  flex: 1; border: none; background: transparent; color: var(--text);
  font-size: 14px; outline: none; min-width: 0;
}
.search-row-input::placeholder { color: var(--muted); }
.search-row-clear {
  color: var(--muted); font-size: 18px; line-height: 1; flex-shrink: 0;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.segmented { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; gap: 4px; }
.segment { flex: 1; border: none; background: transparent; padding: 8px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; text-align: center; text-decoration: none; display: block; }
.segment.active { background: var(--brand); color: #fff; }
.error { color: var(--negative); font-size: 13px; }
.muted { color: var(--muted); }
.app-version { text-align: center; color: var(--muted); font-size: 12px; margin: 24px 0 8px; }

/* ---------- login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-dark);
}
.login-card { text-align: center; align-items: stretch; }
.login-logo { font-size: 36px; display: flex; justify-content: center; }
.login-card h1 { margin: 4px 0 0; }
.pin-username { text-align: center; }
.pin-boxes { display: flex; gap: 10px; justify-content: center; }
.pin-box {
  width: 52px; height: 58px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  padding: 0;
}
.pin-box:focus { outline: none; border-color: var(--brand); }

/* ---------- bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(20,33,61,0.06);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--muted);
  padding: 6px 0;
  font-weight: 600;
}
.tab.active { color: var(--brand); }
.tab-icon { font-size: 18px; }
.tab-fab { position: relative; top: -14px; }
.tab-fab-circle {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(41,82,204,0.4);
}

/* ---------- responsive switch ---------- */
@media (min-width: 860px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  .mobile-topbar { display: none; }
  .content { padding-bottom: 40px; }
}

/* ---------- dark mode ----------
   Default (no explicit choice) follows the OS setting. The Settings-page
   toggle sets data-theme="dark"/"light" on <html> via localStorage, which
   always wins over the OS setting in both directions. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420;
    --card: #171d2b;
    --text: #f0f2f7;
    --muted: #9aa4b6;
    --border: #262e40;
    --shadow: 0 2px 10px rgba(0,0,0,0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420;
  --card: #171d2b;
  --text: #f0f2f7;
  --muted: #9aa4b6;
  --border: #262e40;
  --shadow: 0 2px 10px rgba(0,0,0,0.35);
}

/* ---------- theme switch (Settings page) ---------- */
.switch-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}
.switch-track::before {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::before { transform: translateX(20px); }
