:root {
  color-scheme: dark;
  --bg-canvas: #020816;
  --bg-card: #030D1E;
  --bg-card-elevated: #061630;
  --bg-input: #071935;
  --bg-header: rgba(2, 8, 22, 0.92);
  --bg-nav: rgba(3, 13, 30, 0.96);
  --bg-subtle: rgba(255, 255, 255, 0.03);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --border-hairline: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-primary: #FFFFFF;
  --text-muted: #AEAEB8;
  --accent-gradient: linear-gradient(180deg, #025BCF 0%, #0091BD 100%);
  --accent-blue: #0091BD;
  --mint: #73D0B9;
  --coral: #F87171;
  --coral-bg: rgba(248, 113, 113, 0.14);
  --mint-bg: rgba(115, 208, 185, 0.14);
  --blue-bg: rgba(2, 91, 207, 0.18);
  --radius-card: 16px;
  --radius-control: 12px;
  --tap-min: 48px;
  --nav-height: 68px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-canvas: #F4F7FB;
  --bg-card: #FFFFFF;
  --bg-card-elevated: #EEF3FA;
  --bg-input: #F8FAFC;
  --bg-header: rgba(255, 255, 255, 0.94);
  --bg-nav: rgba(255, 255, 255, 0.97);
  --bg-subtle: rgba(15, 23, 42, 0.03);
  --bg-hover: rgba(15, 23, 42, 0.06);
  --border-hairline: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.20);
  --text-primary: #0B1528;
  --text-muted: #52607A;
  --mint: #0F9D7E;
  --coral: #DC2626;
  --coral-bg: rgba(220, 38, 38, 0.10);
  --mint-bg: rgba(15, 157, 126, 0.12);
  --blue-bg: rgba(2, 91, 207, 0.10);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: clip;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-hairline);
}

.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.settings-label {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-switcher {
  min-height: var(--tap-min);
  padding: 4px 8px 4px 4px;
  border-radius: 12px;
  text-align: left;
  transition: background 0.15s ease;
}

.brand-switcher:hover {
  background: var(--bg-hover);
}

.brand-logo-img {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
}

.brand-account {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-caret {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-gradient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--text-primary);
}

.icon-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-hairline);
  background: var(--bg-card);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-elevated);
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 4px;
}

.month-nav-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.month-nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.month-label {
  font-size: 0.98rem;
  font-weight: 600;
  text-align: center;
  flex: 1;
  min-width: 0;
}

/* Error Banner */
.error-banner {
  max-width: 1040px;
  margin: 12px auto 0;
  padding: 0 16px;
}

.error-banner[hidden] {
  display: none;
}

.error-banner-inner {
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #FECACA;
}

.error-banner-text {
  font-size: 0.9rem;
  font-weight: 500;
}

.error-dismiss-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 10px;
  color: #FECACA;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Main Content */
.app-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--nav-height) + 24px);
}

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

.screen[hidden] {
  display: none;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-card);
  padding: 18px;
  min-width: 0;
}

.card-hero {
  background:
    radial-gradient(120% 120% at 100% 0%, rgba(0, 145, 189, 0.20) 0%, rgba(2, 91, 207, 0.06) 45%, transparent 75%),
    var(--bg-card);
  border-color: rgba(0, 145, 189, 0.30);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

/* Hero Balance */
.hero-amount {
  margin: 8px 0 4px;
  font-size: 2.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.amount-positive {
  color: var(--mint);
}

.amount-negative {
  color: var(--coral);
}

.hero-note {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.02rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.unassigned-line {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

/* Buttons */
.btn {
  min-height: var(--tap-min);
  padding: 0 16px;
  border-radius: var(--radius-control);
  font-weight: 600;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.btn:active {
  transform: scale(0.99);
}

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

.btn[hidden] {
  display: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #FFFFFF;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-hairline);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: var(--coral-bg);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #FCA5A5;
}

/* Payday Strip & Cards */
.payday-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.payday-mini-card {
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 14px;
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.payday-mini-card:hover {
  border-color: rgba(0, 145, 189, 0.45);
  background: rgba(2, 91, 207, 0.08);
}

.payday-mini-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.payday-mini-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.payday-mini-left {
  text-align: right;
  flex-shrink: 0;
}

.payday-mini-left-val {
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.payday-mini-left-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.payday-mini-proj {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Category Breakdown */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.category-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 10px;
  min-width: 0;
}

.category-pill-name {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.category-pill-val {
  margin-top: 4px;
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Lists */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.entry-item {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.entry-main {
  min-width: 0;
  flex: 1;
}

.entry-name {
  font-weight: 600;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-need { background: rgba(2, 91, 207, 0.24); color: #93C5FD; }
.tag-want { background: rgba(248, 113, 113, 0.18); color: #FCA5A5; }
.tag-invest { background: rgba(115, 208, 185, 0.18); color: var(--mint); }
.tag-bill { background: rgba(0, 145, 189, 0.22); color: #7DD3FC; }
.tag-sub { background: rgba(167, 139, 250, 0.20); color: #DDD6FE; }
.tag-overdue { background: var(--coral-bg); color: #FCA5A5; }
.tag-paid { background: var(--mint-bg); color: var(--mint); }

.entry-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.entry-amount {
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.delete-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 10px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.delete-btn:hover {
  color: var(--coral);
  background: var(--coral-bg);
}

.edit-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 10px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.edit-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.payday-top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

/* Payday Detail Card */
.payday-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.payday-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.payday-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.empty-state {
  text-align: center;
  padding: 22px 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Bills & Calendar */
.bills-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.view-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-hairline);
}

.view-toggle-btn {
  min-height: var(--tap-min);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.view-toggle-btn[aria-selected="true"] {
  background: var(--accent-gradient);
  color: #FFFFFF;
}

.bill-item {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-hairline);
  border-radius: 14px;
  padding: 10px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bill-item.is-paid {
  border-color: rgba(115, 208, 185, 0.28);
  background: rgba(115, 208, 185, 0.04);
}

.bill-item.is-overdue {
  border-color: rgba(248, 113, 113, 0.35);
}

.bill-check-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bill-check-btn:hover {
  border-color: var(--accent-blue);
}

.bill-check-btn[aria-pressed="true"] {
  background: var(--mint-bg);
  border-color: rgba(115, 208, 185, 0.65);
  color: var(--mint);
}

.bill-menu-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 10px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.bill-menu-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-blank {
  min-height: var(--tap-min);
}

.calendar-day {
  min-height: var(--tap-min);
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 2px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
}

.calendar-day:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
}

.calendar-day.is-today {
  border-color: rgba(0, 145, 189, 0.65);
}

.calendar-day.is-selected {
  background: rgba(2, 91, 207, 0.25);
  border-color: var(--accent-blue);
}

.cal-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 6px;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
}

.cal-dot-paid { background: var(--mint); }
.cal-dot-unpaid { background: var(--accent-blue); }
.cal-dot-overdue { background: var(--coral); }
.cal-dot-schedule { background: #C084FC; }

.dash-cal-toggle {
  min-width: 196px;
}

.field textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.94rem;
  resize: vertical;
}

.calendar-day-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-hairline);
}

.calendar-day-heading {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.payday-proj-note {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Savings */
.savings-goal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-gradient);
  transition: width 0.25s ease;
}

.savings-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.savings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

/* Credit Cards */
.card-helper-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-variant-numeric: tabular-nums;
}

.card-stmt-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.card-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tag-partial {
  background: var(--blue-bg);
  color: #93C5FD;
}

/* Dashboard Analytics (read-only cards, SVG chart, Money Health) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero-projected {
  margin: 0 0 14px;
  font-size: 0.86rem;
  font-weight: 600;
  color: #93C5FD;
  font-variant-numeric: tabular-nums;
}

.card-link {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.card-link:hover {
  border-color: rgba(0, 145, 189, 0.45);
}

.card-chevron {
  font-size: 1.25rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.dash-savings-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--mint);
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
}

.dash-lower-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
}

.dash-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.dash-goals-list {
  display: grid;
  gap: 10px;
}

.dash-goal-row {
  display: grid;
  gap: 4px;
}

.dash-goal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
}

.dash-goal-name {
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-goal-nums {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.progress-track-sm {
  height: 6px;
  margin-bottom: 0;
}

.compact-select {
  min-height: var(--tap-min);
  padding: 6px 10px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.84rem;
  max-width: 170px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-income { background: var(--mint); }
.legend-expense { background: #38BDF8; }

.chart-wrap {
  width: 100%;
  overflow: hidden;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.health-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.health-row {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.health-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.health-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.health-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.health-pct {
  font-weight: 700;
  font-size: 0.94rem;
  font-variant-numeric: tabular-nums;
}

.settings-divider {
  border: 0;
  border-top: 1px solid var(--border-hairline);
  margin: 6px 0;
}

/* Notifications Bell & Panel */
.notif-bell-btn {
  position: relative;
  padding: 0;
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--coral);
  color: #020816;
  font-size: 0.7rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notif-badge[hidden] {
  display: none;
}

.notif-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(1, 5, 14, 0.76);
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.notif-backdrop[hidden] {
  display: none;
}

.notif-panel {
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.notif-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notif-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.notif-popup-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-hairline);
  background: rgba(2, 91, 207, 0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.notif-popup-bar[hidden] {
  display: none;
}

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 24px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.notif-group-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.notif-row {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-hairline);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.notif-row.is-unread {
  border-color: rgba(0, 145, 189, 0.40);
  background: rgba(2, 91, 207, 0.08);
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent-blue);
  flex-shrink: 0;
}

.notif-row:not(.is-unread) .notif-dot {
  background: transparent;
  border: 1px solid var(--border-strong);
}

.notif-open-btn {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  text-align: left;
  padding: 4px 0;
}

.notif-toggle-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.notif-toggle-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.toggle-check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap-min);
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-hairline);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.9rem;
  cursor: pointer;
}

.toggle-check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: #0091BD;
  flex-shrink: 0;
}

/* Placeholder Tabs */
.placeholder-card {
  text-align: center;
  padding: 36px 20px;
}

.placeholder-pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--blue-bg);
  color: #7DD3FC;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Header + Add Button */
.fab {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent-gradient);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(2, 91, 207, 0.35);
}

.fab:hover {
  filter: brightness(1.06);
}

/* Primary Navigation (bottom bar on phones/tablets, left sidebar >= 1024px) */
.primary-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  min-height: var(--nav-height);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-nav);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-hairline);
}

.nav-brand,
.nav-btn.nav-settings {
  display: none;
}

.nav-items {
  max-width: 1040px;
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.nav-btn {
  min-height: var(--tap-min);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 2px;
  transition: color 0.15s ease, background 0.15s ease;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-btn[aria-current="page"] {
  color: var(--text-primary);
}

.nav-btn[aria-current="page"] .nav-dot {
  background: var(--accent-gradient);
  opacity: 1;
}

.nav-dot {
  width: 24px;
  height: 3px;
  border-radius: 999px;
  opacity: 0;
  margin-bottom: 1px;
}

/* Modal / Bottom Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(1, 5, 14, 0.76);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.sheet-backdrop[hidden] {
  display: none;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom, 0px));
}

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

.sheet-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field input, .field select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.96rem;
}

.form-error {
  background: var(--coral-bg);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #FECACA;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
}

.form-error[hidden] {
  display: none;
}

.picker-list {
  display: grid;
  gap: 10px;
}

.picker-item {
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border-hairline);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.picker-item:hover {
  border-color: rgba(0, 145, 189, 0.5);
  background: rgba(2, 91, 207, 0.12);
}

.picker-item-title {
  font-weight: 600;
  font-size: 0.96rem;
}

.picker-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Desktop Layout (>= 768px) */
@media (min-width: 768px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
  }

  .month-bar {
    min-width: 280px;
  }

  .settings-label {
    display: inline;
  }

  .app-main {
    padding: 24px 24px calc(var(--nav-height) + 24px);
  }

  .bills-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .screen-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .dash-lower-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .span-2 {
    grid-column: 1 / -1;
  }

  .sheet-backdrop {
    align-items: center;
    padding: 24px;
  }

  .sheet {
    border-radius: 20px;
  }
}

/* Desktop Sidebar Layout (>= 1024px) */
@media (min-width: 1024px) {
  :root {
    --sidebar-w: 240px;
  }

  .primary-nav {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: var(--sidebar-w);
    height: 100vh;
    border-top: 0;
    border-right: 1px solid var(--border-hairline);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
  }

  .nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 20px;
  }

  .nav-items {
    max-width: none;
    height: auto;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .nav-btn {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: var(--tap-min);
    padding: 0 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    width: 100%;
  }

  .nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
  }

  .nav-btn[aria-current="page"] {
    background: var(--blue-bg);
    color: var(--text-primary);
  }

  .nav-icon {
    width: 20px;
    height: 20px;
  }

  .nav-dot {
    display: none;
  }

  .nav-btn.nav-settings {
    display: flex;
    margin-top: auto;
  }

  .app-header,
  .readonly-banner,
  .error-banner,
  .app-main {
    margin-left: var(--sidebar-w);
  }

  .app-main {
    padding-bottom: 24px;
  }

  .header-top {
    order: 2;
  }

  .month-bar {
    order: 1;
  }

  .app-header .brand,
  .header-actions #btn-open-settings {
    display: none;
  }

  .notif-backdrop {
    background: transparent;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 76px 24px 24px;
  }

  .notif-panel {
    width: 400px;
    max-width: calc(100vw - 280px);
    height: auto;
    max-height: 72vh;
    border-radius: 16px;
    border: 1px solid var(--border-strong);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.55);
  }
}

/* Narrow Phone Header Fit (<= 380px) */
@media (max-width: 380px) {
  .header-inner {
    padding: 10px 12px;
  }

  .header-top {
    gap: 6px;
  }

  .header-actions {
    gap: 6px;
  }

  .brand {
    gap: 6px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .brand-title {
    font-size: 0.9rem;
  }

  .fab {
    padding: 0 11px;
    font-size: 0.86rem;
    gap: 4px;
  }

  .brand-logo-img {
    width: 28px;
    height: 28px;
  }

  .brand-switcher {
    padding: 4px;
  }
}

/* Read-Only Banner & Workspace Lock */
.readonly-banner {
  max-width: 1040px;
  margin: 12px auto 0;
  padding: 0 16px;
}

.readonly-banner[hidden] {
  display: none;
}

.readonly-banner-inner {
  background: var(--blue-bg);
  border: 1px solid rgba(0, 145, 189, 0.45);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.readonly-banner-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

[data-readonly="true"] [data-write-action],
[data-readonly="true"] .delete-btn,
[data-readonly="true"] .bill-check-btn,
[data-readonly="true"] .bill-menu-btn,
[data-readonly="true"] #btn-fab-add {
  display: none !important;
}

.settings-footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

:root[data-theme="light"] .hero-projected {
  color: #025BCF;
}

:root[data-theme="light"] .tag-need {
  background: rgba(2, 91, 207, 0.12);
  color: #025BCF;
}

:root[data-theme="light"] .tag-want,
:root[data-theme="light"] .tag-overdue {
  background: rgba(220, 38, 38, 0.10);
  color: #B91C1C;
}

:root[data-theme="light"] .tag-bill {
  background: rgba(0, 145, 189, 0.12);
  color: #0369A1;
}

:root[data-theme="light"] .tag-sub {
  background: rgba(124, 58, 237, 0.12);
  color: #6D28D9;
}

:root[data-theme="light"] .tag-partial {
  background: rgba(2, 91, 207, 0.12);
  color: #1D4ED8;
}

:root[data-theme="light"] .btn-danger {
  color: #B91C1C;
}

:root[data-theme="light"] .error-banner-inner {
  color: #991B1B;
}

:root[data-theme="light"] .error-dismiss-btn {
  color: #991B1B;
}

:root[data-theme="light"] .form-error {
  color: #991B1B;
}

/* Payment Method Chips & Toast */
.method-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.method-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: var(--tap-min);
  max-width: 100%;
  padding: 0 0 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
  font-size: 0.84rem;
  font-weight: 600;
}

.method-chip-del {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  flex-shrink: 0;
  border-radius: 999px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.method-chip-del:hover:not(:disabled) {
  color: var(--coral);
  background: var(--coral-bg);
}

.method-add-row {
  display: flex;
  gap: 8px;
}

.method-add-row input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-min);
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.94rem;
}

.confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 70;
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.40);
  max-width: calc(100vw - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast[hidden] {
  display: none;
}

@media (min-width: 1024px) {
  .toast {
    left: auto;
    right: 24px;
    bottom: 24px;
    transform: none;
  }
}

/* Interactive Feature Tutorial Overlay */
.tour-layer {
  position: fixed;
  inset: 0;
  z-index: 65;
  pointer-events: none;
}

.tour-layer[hidden] {
  display: none;
}

.tour-highlight {
  position: fixed;
  border: 2px solid #0091BD;
  border-radius: 16px;
  box-shadow: 0 0 0 4px rgba(0, 145, 189, 0.28);
  pointer-events: none;
  transition: top 160ms ease, left 160ms ease, width 160ms ease, height 160ms ease;
}

.tour-highlight[hidden] {
  display: none;
}

.tour-card {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100vw - 24px);
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tour-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tour-step-badge {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.tour-skip-btn {
  min-width: 64px;
  min-height: var(--tap-min);
  padding: 0 14px;
}

.tour-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.tour-body {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.tour-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: width 160ms ease, background 160ms ease;
}

.tour-dot.is-active {
  width: 20px;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
}

.tour-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.tour-actions .btn {
  min-height: var(--tap-min);
}

@media (min-width: 768px) {
  .tour-card {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 400px;
    max-width: calc(100vw - 48px);
  }
}

/* Auth & Pending Approval Screens */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg-canvas);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-card);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-logo-img {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.auth-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.auth-tagline {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-status-msg {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--mint-bg);
  color: var(--mint);
  font-size: 0.88rem;
  font-weight: 600;
}

.auth-status-msg[hidden] {
  display: none;
}

.admin-user-row,
.share-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
}

.admin-user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.admin-user-actions .btn {
  min-height: var(--tap-min);
  padding: 0 12px;
  font-size: 0.84rem;
}

.primary-nav[hidden],
.app-header[hidden],
.app-main[hidden],
.field[hidden] {
  display: none !important;
}
