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

:root {
  --app-bg: radial-gradient(circle at top, #fff7f7 0%, #ffe4e6 45%, #fff1f2 100%);
  --app-accent: #ff573c;
  --app-accent-hover: #ff3532;
  --app-accent-soft: rgba(255, 87, 60, 0.12);
  --app-accent-soft-strong: rgba(255, 87, 60, 0.18);
  --app-accent-border: rgba(255, 87, 60, 0.35);
  --app-accent-shadow: rgba(255, 87, 60, 0.22);
  --app-text: #333333;
  --app-heading: #1a1a2e;
  --app-subtitle: #666666;
  --app-muted: #4b5563;
  --app-greeting: #374151;
  --app-surface: #ffffff;
  --app-surface-soft: #f8fafc;
  --app-surface-muted: #f8f9fa;
  --app-border: rgba(0, 0, 0, 0.12);
  --app-card-text: #1a1a2e;
  --app-income: #22c55e;
  --app-income-hover: #16a34a;
  --app-expense: #ef4444;
  --app-expense-hover: #dc2626;
}

html {
  scrollbar-gutter: stable;
}

body {
  font-family: 'Montserrat', sans-serif;
  background: var(--app-bg);
  color: var(--app-text);
  min-height: 100vh;
  padding: 24px 8px;
  overflow-y: scroll;
}

body.motion-fast *,
body.motion-fast *::before,
body.motion-fast *::after {
  transition-duration: 100ms !important;
  animation-duration: 120ms !important;
}

body.motion-slow *,
body.motion-slow *::before,
body.motion-slow *::after {
  transition-duration: 320ms !important;
  animation-duration: 360ms !important;
}

body.motion-off *,
body.motion-off *::before,
body.motion-off *::after {
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

.dashboard-page {
  padding-top: 18px;
}

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-page .container {
  gap: 14px;
}

/* ── Header ── */
header {
  text-align: center;
}

header h1 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--app-heading);
  font-family: 'Margarine';
}

.header-actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.header-logo {
  height: 70px; /* adjust as needed */
  width: auto;
  display: block;
}

#user-email {
  font-size: 0.9rem;
  color: #4b5563;
  font-weight: 600;
}

.page-message {
  min-height: 20px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--app-muted);
}

.dashboard-page .page-message:empty {
  display: none;
}

.page-message.error {
  color: #dc2626;
}

.page-message.success {
  color: #16a34a;
}

.dashboard-page .history-header .page-message {
  min-height: 0;
  text-align: right;
  font-size: 0.85rem;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  margin-left: auto;
  margin-right: 10px;
  flex: 0 1 320px;
}

/* ── Tabs ── */
.tab-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.dashboard-page .tab-row {
  margin-top: 4px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
}

.header-title {
  flex: 1;
  text-align: left;
}

.header-title h1 {
  margin: 0;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.header-greeting {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--app-greeting);
  white-space: nowrap;
}

.btn-settings-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 999px;
  background: var(--app-accent);
  border: 1px solid var(--app-accent);
  color: #ffffff;
  font-size: 1.35rem;
  line-height: 1;
  text-align: center;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 10px 24px var(--app-accent-shadow);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.settings-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.settings-avatar-fallback {
  font-size: 1.2rem;
  line-height: 1;
}

.btn-settings-trigger:hover {
  background: var(--app-accent-hover);
  box-shadow: 0 12px 28px var(--app-accent-shadow);
}

.btn-settings-trigger:active {
  transform: scale(0.98);
}

.settings-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(360px, 90vw);
  padding: 18px;
  border-radius: 18px;
  background: var(--app-surface);
  border: 1px solid var(--app-accent-soft);
  box-shadow: 0 22px 44px rgba(15, 23, 42, 0.16);
  z-index: 40;
  backdrop-filter: blur(12px);
}

.settings-popover::before {
  content: '';
  position: absolute;
  top: -7px;
  right: 15px;
  width: 14px;
  height: 14px;
  background: var(--app-surface);
  border-top: 1px solid var(--app-accent-soft);
  border-left: 1px solid var(--app-accent-soft);
  transform: rotate(45deg);
}

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

.settings-popover-copy {
  margin-top: 4px;
  color: #6b7280;
  font-size: 0.9rem;
}

.settings-popover-close {
  background: transparent;
  border: none;
  color: var(--app-muted);
  font-size: 1rem;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 999px;
}

.settings-popover-close:hover {
  background: var(--app-surface-soft);
}

.settings-user-card {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--app-surface-soft);
  border: 1px solid var(--app-border);
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 12px;
}

.settings-user-avatar-wrap {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--app-accent-soft);
  border: 1px solid var(--app-accent-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-avatar-fallback {
  font-size: 1.3rem;
  line-height: 1;
}

.settings-user-card-link {
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.settings-user-card-link:hover {
  background: rgba(79, 70, 229, 0.07);
  border-color: rgba(79, 70, 229, 0.25);
}

.sidebar-user-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-heading);
}

.sidebar-user-email {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--app-muted);
}

.settings-menu-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-menu-item {
  width: 100%;
  background: var(--app-surface-soft);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.settings-menu-item:hover {
  background: var(--app-accent-soft);
  border-color: var(--app-accent-border);
}

.settings-menu-item-danger {
  color: #b91c1c;
}

.settings-menu-item-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.tab[hidden] {
  display: none;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-quick-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn-quick-transaction {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.2s;
}

.btn-quick-transaction:active {
  transform: scale(0.98);
}

.btn-quick-income {
  background: var(--app-income);
}

.btn-quick-income:hover {
  background: var(--app-income-hover);
}

.btn-quick-expense {
  background: var(--app-expense);
}

.btn-quick-expense:hover {
  background: var(--app-expense-hover);
}

.tab {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--app-border);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  transition: background 0.2s, border-color 0.2s;
}

.tab:hover {
  background: rgba(255, 255, 255, 1);
}

.tab.active {
  background: var(--app-accent);
  border-color: var(--app-accent);
  color: #fff;
}

.tab-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1;
  vertical-align: middle;
  opacity: 0.65;
  transition: background 0.15s, opacity 0.15s;
}

.tab.active .tab-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  opacity: 1;
}

.tab:not(.active) .tab-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.subpage-iframe {
  width: 100%;
  min-height: calc(100vh - 240px);
  border: none;
  display: block;
  border-radius: 12px;
  overflow: hidden;
}

body.embedded {
  padding: 0 8px 24px;
  background: transparent;
  overflow-y: visible;
}

body.embedded header {
  display: none;
}

.tab-panel {
  display: block;
  width: 100%;
  min-width: 0;
}

.tab-panel.panel-fade-out {
  opacity: 0.965;
  transition: opacity 110ms ease;
}

.tab-panel.panel-fade-in {
  animation: tabPanelFadeIn 110ms ease;
}

@keyframes tabPanelFadeIn {
  from {
    opacity: 0.965;
  }

  to {
    opacity: 1;
  }
}

.tab-panel[hidden] {
  display: none;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  width: min(400px, 95vw);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  padding: 22px 22px 18px;
  z-index: 1;
}

#add-modal .modal-content,
#add-goal-modal .modal-content {
  position: fixed;
  width: min(420px, calc(100vw - 24px));
  max-height: min(76vh, 620px);
  overflow-y: auto;
}

#add-modal.modal,
#add-goal-modal.modal {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0;
}

#add-modal .modal-backdrop,
#add-goal-modal .modal-backdrop {
  display: none;
}

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

.modal-header h2 {
  font-size: 1.2rem;
  margin: 0;
  color: var(--app-heading);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--app-muted);
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--app-surface-soft);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.transaction-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 16px;
}

.transaction-tab {
  flex: 1;
  padding: 10px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--app-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.transaction-tab.active {
  color: var(--app-accent);
  border-bottom-color: var(--app-accent);
}

.transaction-tab:hover {
  color: var(--app-accent);
}

.btn-secondary {
  padding: 10px 18px;
  background: var(--app-surface-soft);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

.btn-secondary:hover {
  background: var(--app-surface-muted);
}

.modal[hidden] {
  display: none;
}

.subtitle {
  color: var(--app-subtitle);
  margin-top: 4px;
  font-size: 0.95rem;
}

/* ── Summary Cards ── */
.summary {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 24px; /* space before the add-transaction form */
}

.summary-left {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.breakdown-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.breakdown-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}

.breakdown-list li:last-child {
  border-bottom: none;
}

.breakdown-section-header {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--app-muted);
  padding-top: 4px;
}

.breakdown-section-total {
  font-size: 0.75rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--app-greeting);
}

.breakdown-item-row {
  padding-left: 14px;
}

.breakdown-label {
  font-weight: 600;
  color: var(--app-text);
}

.breakdown-amount {
  color: var(--app-muted);
}

.breakdown-bar {
  width: 100%;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.breakdown-fill {
  height: 100%;
  background: var(--app-accent);
  transition: width 0.3s;
}

.card {
  background: var(--app-surface);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  border-top: 4px solid transparent;
}

.inline-save-message {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.82rem;
  font-style: italic;
  align-self: center;
}

.inline-save-message:empty {
  display: none;
}

.inline-save-message.success {
  color: #16a34a;
}

.inline-save-message.error {
  color: #dc2626;
}

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

.goals-header-message {
  flex: 1;
  text-align: right;
  font-size: 0.78rem;
  font-style: italic;
  padding-right: 6px;
  transition: opacity 0.3s;
}

.goals-header-message:empty {
  display: none;
}

.goals-header-message.success {
  color: #16a34a;
}

.goals-header-message.error {
  color: #dc2626;
}

.btn-add-goal {
  background: #8b5cf6;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-add-goal:hover {
  background: #7c3aed;
}

.btn-add-transaction {
  background: var(--app-accent);
}

.btn-add-transaction:hover {
  background: var(--app-accent-hover);
}

.btn-breakdown-action {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--app-accent-border);
  background: var(--app-accent-soft);
  color: var(--app-accent-hover);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-breakdown-action:hover {
  background: var(--app-accent-soft-strong);
  border-color: var(--app-accent-border);
}

.card.balance  { border-top-color: var(--app-accent); }
.card.income   { border-top-color: #22c55e; }
.card.expense  { border-top-color: #ef4444; }
.card.savings-goals { border-top-color: #8b5cf6; }

.goals-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}

.goals-list li {
  margin-bottom: 6px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.goals-list li:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.goals-list strong {
  color: var(--app-accent);
}

.goals-list .goal-amount {
  color: var(--app-card-text);
}

/* Progress Bar Container */
.progress-bar {
  width: 100%;
  height: 10px;
  background: #e5e7eb;
  border-radius: 20px;
  overflow: hidden;
  margin-top: 8px;
  position: relative;
}

/* Progress Fill */
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 20px;
  background: linear-gradient(90deg, #4caf50, #22c55e);
  transition: width 0.6s ease;
}

/* Completed goal */
.progress-fill.complete {
  background: linear-gradient(90deg, #FFD700, #facc15);
}

/* Percentage text */
.progress-text {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
  display: block;
}


.goal-actions {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}

.btn-add-save,
.btn-edit,
.btn-delete {
  background: var(--app-surface-soft);
  border: 1px solid var(--app-border);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s, border-color 0.2s;
}

.btn-add-save {
  color: #22c55e;
}

.btn-add-save:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
}

.btn-edit {
  color: var(--app-accent);
}

.btn-edit:hover {
  background: var(--app-accent-soft);
  border-color: var(--app-accent-border);
}

.btn-delete {
  color: #ef4444;
}

.btn-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

.card-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
  font-weight: 600;
}

.card-amount {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--app-card-text);
}

.card-amount.positive { color: #22c55e; }
.card-amount.negative { color: #ef4444; }

/* ── Form Section ── */
.form-section,
.history-section {
  background: var(--app-surface);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  width: 100%;
}

.form-section h2,
.history-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--app-heading);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--app-muted);
}

.form-group input,
.form-group select {
  padding: 9px 12px;
  border: 1.5px solid var(--app-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--app-text);
  background: var(--app-surface-soft);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--app-accent);
  background: var(--app-surface);
}

.form-group input[type="number"]::-webkit-inner-spin-button,
.form-group input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.form-group input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--app-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--app-text);
  background: var(--app-surface-soft);
  transition: border-color 0.2s;
  resize: vertical;
  min-height: 60px;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--app-accent);
  background: var(--app-surface);
}

.form-group select option {
  color: var(--app-text);
  background: var(--app-surface);
}

.amount-input {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.dollar-sign {
  position: absolute;
  left: 12px;
  color: var(--app-muted);
  font-weight: 600;
  z-index: 1;
}

.amount-input input {
  width: 100%;
  padding-left: 24px; /* space for $ */
  padding-right: 40px;
}

.amount-stepper {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1.5px solid var(--app-border);
  border-radius: 6px;
  background: var(--app-surface-soft);
  overflow: hidden;
}

.amount-step-btn {
  width: 20px;
  height: 12px;
  border: none;
  background: transparent;
  color: var(--app-muted);
  font-size: 0.56rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.16s ease, color 0.16s ease;
}

.amount-step-btn + .amount-step-btn {
  border-top: 1px solid var(--app-border);
}

.amount-step-btn:hover {
  background: var(--app-surface-muted);
  color: var(--app-text);
}

.amount-step-btn:active {
  background: var(--app-surface);
}

.amount-step-btn:focus-visible {
  outline: 2px solid var(--app-accent-soft-strong);
  outline-offset: 1px;
}

.amount-input input:disabled + .amount-stepper .amount-step-btn {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-add {
  display: inline-block;
  padding: 10px 24px;
  background: var(--app-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-add:hover  { background: var(--app-accent-hover); }
.btn-add:active { transform: scale(0.98); }

/* ── History Section ── */
.history-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.history-header h2 {
  margin-bottom: 0;
  margin-right: auto;
}

.btn-clear {
  padding: 6px 14px;
  background: transparent;
  border: 1.5px solid #ef4444;
  color: #ef4444;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-clear:hover {
  background: #ef4444;
  color: #fff;
}

#transaction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.empty-state {
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
  padding: 32px 0;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid transparent;
  background: var(--app-surface-muted);
  width: 100%;
}

.transaction-item.income  { border-left-color: #22c55e; }
.transaction-item.expense { border-left-color: #ef4444; }

.transaction-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.transaction-desc {
  font-weight: 600;
  font-size: 0.95rem;
}

.transaction-category {
  font-size: 0.75rem;
  color: var(--app-muted);
}

.transaction-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.transaction-amount {
  font-size: 1rem;
  font-weight: 700;
}

.transaction-item.income  .transaction-amount { color: #22c55e; }
.transaction-item.expense .transaction-amount { color: #ef4444; }

.btn-delete {
  background: none;
  border: none;
  color: #ccc;
  font-size: 0.85rem;
  cursor: pointer;
  transition: color 0.2s;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-delete:hover { color: #ef4444; }

.split-group {
  margin-bottom: 16px;
}

.split-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.split-group-header h3 {
  font-size: 0.95rem;
  color: #1f2937;
}

.split-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.split-row {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr auto;
  gap: 10px;
  align-items: end;
}

.split-row-remove {
  min-width: 40px;
  padding: 9px 10px;
}

.split-actions-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.split-ratio-status {
  margin: 0;
  flex: 1;
}

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

/* ── FAQ Page ── */
.faq-section {
  padding-bottom: 8px;
}

.faq-item {
  border-bottom: 1px solid var(--app-border);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  padding: 14px 0;
  text-align: left;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--app-heading);
  cursor: pointer;
  transition: color 0.2s;
}

.faq-question:hover {
  color: var(--app-accent);
}

.faq-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--app-accent);
  line-height: 1;
  transition: transform 0.2s;
}

.faq-answer {
  padding: 0 0 14px;
  font-size: 0.9rem;
  color: var(--app-text);
  line-height: 1.65;
}

.faq-answer p + p {
  margin-top: 8px;
}

/* ── Terms & Conditions Page ── */
.legal-section {
  max-width: 780px;
}

.legal-effective {
  font-size: 0.82rem;
  color: var(--app-muted);
  margin-bottom: 6px;
}

.legal-intro {
  font-size: 0.92rem;
  color: var(--app-text);
  line-height: 1.65;
  margin-bottom: 24px;
}

.legal-block {
  margin-bottom: 20px;
}

.legal-block h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--app-heading);
  margin-bottom: 8px;
}

.legal-block p {
  font-size: 0.9rem;
  color: var(--app-text);
  line-height: 1.65;
  margin-bottom: 8px;
}

.legal-block p:last-child {
  margin-bottom: 0;
}

.legal-list {
  margin: 8px 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-list li {
  font-size: 0.9rem;
  color: var(--app-text);
  line-height: 1.6;
}

.legal-link {
  color: var(--app-accent);
  text-underline-offset: 3px;
}

.legal-link:hover {
  color: var(--app-accent-hover);
}

/* ── Visual Preferences Page ── */
.visuals-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.visuals-helper-copy {
  font-size: 0.88rem;
  color: #6b7280;
}

.visuals-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.visual-preset-card {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.visual-preset-card:hover {
  border-color: var(--app-accent-border);
}

.visual-preset-card.active {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 2px var(--app-accent-soft);
}

.visual-preset-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #1f2937;
}

.visual-preset-preview {
  display: block;
  width: 100%;
  height: 44px;
  border-radius: 9px;
  background: var(--preview-bg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  position: relative;
}

.visual-preset-preview::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--preview-accent);
}

.visual-preset-meta {
  font-size: 0.76rem;
  color: #6b7280;
}

.visuals-actions {
  display: flex;
  justify-content: flex-end;
}

.visuals-empty {
  font-size: 0.9rem;
  color: #9ca3af;
}

/* ── Account Page ── */
.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.compact-heading-row {
  margin-bottom: 12px;
}

.section-heading-row h2,
.compact-heading-row h3 {
  margin: 0;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--app-surface-soft);
  border: 1px solid var(--app-border);
}

.role-badge-parent {
  color: #7c3aed;
  border-color: rgba(124, 58, 237, 0.22);
  background: rgba(124, 58, 237, 0.08);
}

.role-badge-child {
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.22);
  background: rgba(15, 118, 110, 0.08);
}

.role-badge-solo {
  color: var(--app-muted);
}

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

.profile-top-layout {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.profile-name-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  justify-self: end;
  width: 100%;
}

.profile-photo-trigger {
  border: 1px solid var(--app-accent-border);
  background: var(--app-surface-soft);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-photo-trigger-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.profile-photo-trigger:hover {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 2px var(--app-accent-soft);
}

.profile-photo-trigger-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--app-muted);
}

.profile-photo-device-note {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--app-muted);
  text-align: center;
  max-width: 120px;
}

.family-inline-message {
  min-height: 20px;
  text-align: left;
  margin-bottom: 10px;
}

.role-switch-row {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}

.role-switch-toggle {
  min-height: 36px;
}

.role-switch-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(340px, 86vw);
  padding: 12px;
  border-radius: 12px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.14);
  z-index: 25;
  display: grid;
  gap: 10px;
}

.role-switch-panel[hidden] {
  display: none;
}

.role-switch-panel select {
  min-width: 100%;
}

.role-switch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.family-section-heading {
  align-items: flex-start;
}

.family-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.family-summary-card {
  padding: 14px;
  border-radius: 14px;
  background: var(--app-surface-soft);
  border: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.family-summary-card-wide {
  margin-top: 8px;
}

.family-management-layout {
  margin-top: 8px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px;
  align-items: start;
}

.family-management-layout .family-members-section {
  min-height: 100%;
}

.family-join-parent-card {
  margin-top: 0;
}

.family-summary-label {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--app-muted);
}

.family-invite-code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  padding: 8px 10px;
}

.family-invite-code-box strong {
  letter-spacing: 0.08em;
  font-size: 1rem;
}

.family-invite-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.family-invite-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
  color: var(--app-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
}

.family-invite-icon-btn svg {
  width: 16px;
  height: 16px;
}

.family-invite-icon-btn:hover {
  border-color: var(--app-accent-border);
  background: var(--app-accent-soft);
}

.family-invite-icon-btn:focus-visible {
  outline: none;
  border-color: var(--app-accent);
  box-shadow: 0 0 0 2px var(--app-accent-soft);
}

.family-invite-icon-btn:active {
  transform: scale(0.96);
}

.family-join-parent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
  min-height: 68px;
  align-items: center;
}

.family-join-parent-row input {
  min-height: 42px;
  padding: 9px 12px;
  border: 1.5px solid var(--app-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--app-text);
  background: var(--app-surface-soft);
  transition: border-color 0.2s;
}

.family-join-parent-row input:focus {
  outline: none;
  border-color: var(--app-accent);
  background: var(--app-surface);
}

.family-join-parent-row .btn-secondary {
  min-height: 42px;
  align-self: center;
}

.family-members-section {
  display: flex;
  flex-direction: column;
}

.family-members-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.family-member-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
}

.family-member-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.parent-child-avatar-wrap {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 34px;
  border: 1px solid var(--app-accent-border);
  background: var(--app-accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.parent-child-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.parent-child-avatar-fallback {
  font-size: 0.95rem;
  line-height: 1;
}

@media (max-width: 1140px) {
  .family-management-layout {
    grid-template-columns: 1fr;
  }
}

.family-member-header p,
.family-detail-copy {
  margin: 4px 0 0;
  color: var(--app-muted);
  font-size: 0.88rem;
}

.family-permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.family-permission-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--app-text);
}

.family-permission-toggle input {
  accent-color: var(--app-accent);
}

.parent-portal-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.parent-portal-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.parent-portal-filter {
  min-width: 220px;
}

.parent-portal-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.parent-portal-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.parent-portal-grid > .card {
  min-height: 0;
}

.parent-portal-grid > .card:last-child {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.parent-portal-grid > .card:last-child::before,
.parent-portal-grid > .card:last-child::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 120ms ease;
}

.parent-portal-grid > .card:last-child::before {
  top: 52px;
  background: linear-gradient(to bottom, var(--app-surface) 0%, rgba(255, 255, 255, 0) 100%);
  backdrop-filter: blur(2px);
}

.parent-portal-grid > .card:last-child::after {
  bottom: 12px;
  background: linear-gradient(to top, var(--app-surface) 0%, rgba(255, 255, 255, 0) 100%);
  backdrop-filter: blur(2px);
}

.parent-portal-grid > .card:last-child.show-top-fade::before {
  opacity: 1;
}

.parent-portal-grid > .card:last-child.show-bottom-fade::after {
  opacity: 1;
}

.compact-family-member-card {
  padding-bottom: 12px;
}

.parent-child-metrics {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--app-muted);
  font-size: 0.88rem;
}

.parent-child-metrics strong {
  color: var(--app-text);
}

.parent-child-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.parent-child-actions .btn-secondary {
  flex: 0 1 auto;
}

.parent-child-color-button {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid hsl(var(--child-color-hue) 58% 34%);
  background: hsl(var(--child-color-hue) 72% 52%);
  box-shadow: inset 0 0 0 2px var(--app-surface);
  cursor: pointer;
  flex: 0 0 26px;
  margin-left: auto;
}

.parent-child-color-button:hover {
  filter: brightness(1.05);
}

.parent-child-color-button:focus-visible {
  outline: 2px solid var(--app-accent);
  outline-offset: 2px;
}

.parent-child-actions .parent-child-color-button:last-child {
  margin-left: auto;
}

#parent-recent-activity {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 6px;
}

.parent-child-color-card {
  box-shadow: inset 4px 0 0 hsl(var(--child-color-hue) 70% 46%);
}

.parent-child-avatar-wrap-colored {
  border-color: hsl(var(--child-color-hue) 70% 46%);
  background: hsl(var(--child-color-hue) 75% 92%);
}

.parent-recent-activity-item {
  border-left: 3px solid hsl(var(--child-color-hue) 70% 46%);
  border-radius: 12px;
  background: var(--app-surface-soft);
  padding: 11px 12px 11px 34px;
  margin-bottom: 8px;
  border-bottom: none;
}

#parent-recent-activity .parent-recent-activity-item:last-child {
  margin-bottom: 0;
}

.parent-recent-activity-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: hsl(var(--child-color-hue) 62% 38%);
}

.parent-recent-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: hsl(var(--child-color-hue) 70% 46%);
}

.account-form-actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
}

.visuals-section,
.profile-section {
  display: flex;
  flex-direction: column;
}

.profile-section,
.family-section {
  padding-top: 16px;
}

.profile-section .section-heading-row,
.family-section .section-heading-row {
  margin-bottom: 8px;
}

.profile-section {
  position: relative;
}

.profile-section #account-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.visuals-section .account-form-actions,
.profile-section .account-form-actions {
  margin-top: auto;
  padding-top: 16px;
}

.account-section-description {
  font-size: 0.88rem;
  color: #6b7280;
  margin-bottom: 14px;
}

.profile-photo-preview {
  width: 100px;
  height: 100px;
  border-radius: 999px;
  border: 1px solid var(--app-accent-border);
  background: var(--app-accent-soft);
  object-fit: cover;
  display: block;
}

.profile-photo-meta {
  font-size: 0.86rem;
  color: var(--app-muted);
}

.profile-photo-local-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--app-accent-hover);
  background: var(--app-accent-soft);
  border: 1px solid var(--app-accent-border);
  line-height: 1;
}

.profile-avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.profile-avatar-option {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--app-border);
  border-radius: 12px;
  background: var(--app-surface-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.profile-avatar-option img {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

.profile-avatar-option:hover {
  border-color: var(--app-accent-border);
  transform: translateY(-1px);
}

.profile-avatar-option.active {
  border-color: var(--app-accent);
  box-shadow: 0 0 0 2px var(--app-accent-soft);
}

.profile-avatar-option:focus-visible {
  outline: none;
  border-color: var(--app-accent);
  box-shadow: 0 0 0 2px var(--app-accent-soft);
}

@media (max-width: 560px) {
  .profile-avatar-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.profile-photo-cropper {
  width: min(320px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--app-border);
  background: var(--app-surface);
}

.profile-photo-cropper canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.profile-photo-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.profile-photo-slider-label {
  font-size: 0.84rem;
  color: var(--app-muted);
  margin-bottom: 4px;
}

.profile-photo-controls input[type="range"] {
  width: 100%;
}

#profile-photo-input {
  width: 100%;
  padding: 8px;
  border: 1.5px solid var(--app-border);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--app-muted);
  background: var(--app-surface-soft);
}

#profile-photo-input:focus {
  outline: none;
  border-color: var(--app-accent);
  background: var(--app-surface);
}

#profile-photo-input::file-selector-button {
  margin-right: 10px;
  padding: 8px 12px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  color: var(--app-text);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

#profile-photo-input::file-selector-button:hover {
  border-color: var(--app-accent-border);
  background: var(--app-accent-soft);
}

#profile-photo-input::-webkit-file-upload-button {
  margin-right: 10px;
  padding: 8px 12px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  background: var(--app-surface);
  color: var(--app-text);
  font-weight: 600;
  cursor: pointer;
}

.profile-photo-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-photo-modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#profile-photo-modal.modal {
  align-items: flex-start;
  justify-content: flex-start;
  padding-top: var(--profile-photo-modal-top, 0px);
  padding-left: var(--profile-photo-modal-left, 0px);
}

#profile-photo-modal .modal-backdrop {
  background: rgba(0, 0, 0, 0.3);
}

#profile-photo-modal .modal-content {
  transform-origin: top left;
  animation: profilePhotoModalExpand 170ms ease;
}

@keyframes profilePhotoModalExpand {
  from {
    opacity: 0.88;
    transform: scale(0.94);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.profile-photo-modal-actions {
  padding-top: 4px;
}

.account-danger-section {
  border: 1px solid rgba(239, 68, 68, 0.25);
  background: var(--app-surface);
}

#delete-account-modal.modal {
  align-items: flex-start;
  justify-content: flex-start;
  padding-top: var(--delete-account-modal-top, 0px);
  padding-left: var(--delete-account-modal-left, 0px);
}

#delete-account-modal .modal-backdrop {
  display: none;
}

#delete-account-modal .modal-content {
  width: min(400px, calc(100vw - 20px));
  max-height: min(72vh, 520px);
  overflow-y: auto;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.22);
}

.btn-danger {
  padding: 10px 18px;
  background: #ef4444;
  border: 1px solid #ef4444;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s, transform 0.1s;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-danger:active {
  transform: scale(0.98);
}

/* ── System dark mode (no saved theme in localStorage) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --app-bg: radial-gradient(circle at top, #121826 0%, #0f172a 48%, #111827 100%);
    --app-accent: #8b5cf6;
    --app-accent-hover: #8b5cf6;
    --app-accent-soft: rgba(139, 92, 246, 0.12);
    --app-accent-soft-strong: rgba(139, 92, 246, 0.18);
    --app-accent-border: rgba(139, 92, 246, 0.35);
    --app-accent-shadow: rgba(139, 92, 246, 0.22);
    --app-text: #e5e7eb;
    --app-heading: #f8fafc;
    --app-subtitle: #cbd5e1;
    --app-muted: #cbd5e1;
    --app-greeting: #e2e8f0;
    --app-surface: #172033;
    --app-surface-soft: #1e293b;
    --app-surface-muted: #1f2937;
    --app-border: rgba(148, 163, 184, 0.35);
    --app-card-text: #f8fafc;
  }
}

/* ── Auth / Login Page ── */
.auth-page {
  padding: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  gap: 24px;
}

.auth-brand {
  text-align: center;
}

.auth-brand .header-logo {
  margin: 0 auto;
}

.auth-brand h1 {
  font-family: 'Margarine', cursive;
  font-size: 2.6rem;
  font-weight: 400;
  color: var(--app-heading);
  margin: 0;
}

.auth-brand p {
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: var(--app-subtitle);
}

.auth-card {
  width: min(480px, 100%);
  background: var(--app-surface);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.10), 0 1.5px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--app-border);
  overflow: hidden;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--app-border);
}

.auth-tab {
  flex: 1;
  padding: 14px 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--app-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -1px;
}

.auth-tab:hover {
  color: var(--app-accent);
}

.auth-tab.active {
  color: var(--app-accent);
  border-bottom-color: var(--app-accent);
}

.auth-panel {
  padding: 28px 28px 24px;
}

.auth-panel[hidden],
.auth-panel:not(.active) {
  display: none;
}

.auth-panel h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--app-heading);
  margin: 0 0 4px;
}

.auth-copy {
  font-size: 0.88rem;
  color: var(--app-muted);
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field-copy {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--app-muted);
  line-height: 1.45;
}

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

.auth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--app-text);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--app-accent);
  cursor: pointer;
}

.text-link {
  font-size: 0.88rem;
  color: var(--app-accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.text-link:hover {
  color: var(--app-accent-hover);
  text-decoration: underline;
}

.auth-message {
  min-height: 18px;
  font-size: 0.88rem;
  text-align: center;
}

.auth-message:empty {
  display: none;
}

.auth-message-text {
  margin: 0;
}

.auth-message.error {
  color: #dc2626;
}

.auth-message.success {
  color: #16a34a;
}

.auth-message.password-requirements {
  text-align: left;
  color: var(--app-text);
  background: var(--app-surface-soft);
  border: 1px solid var(--app-accent-border);
  border-radius: 12px;
  padding: 10px 12px;
}

.password-requirements-list {
  margin: 8px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

.password-requirements-list li {
  color: var(--app-text);
  line-height: 1.4;
}

.auth-divider {
  position: relative;
  text-align: center;
  margin: 2px 0;
}

.auth-divider::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 1px solid var(--app-border);
}

.auth-divider span {
  position: relative;
  display: inline-block;
  padding: 0 10px;
  background: var(--app-surface);
  color: var(--app-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-social-button {
  width: 100%;
  border: 1px solid var(--app-border);
  background: var(--app-surface-soft);
  color: var(--app-text);
  border-radius: 12px;
  padding: 12px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.auth-social-button:hover {
  background: var(--app-accent-soft);
  border-color: var(--app-accent-border);
}

.auth-social-button:active {
  transform: scale(0.99);
}

.auth-social-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #ea4335;
  font-weight: 800;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gis-button-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
}

#google-gis-login-button:empty {
  display: none;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  display: block;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  body {
    padding: 16px 8px;
  }

  .form-section,
  .history-section {
    padding: 16px;
  }

  .container {
    gap: 16px;
  }

  header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 4px;
  }

  .header-title {
    flex: 0 1 auto;
  }

  .header-title .header-logo {
    height: 56px;
  }

  .header-tools {
    width: 100%;
    justify-content: space-between;
    min-width: 0;
  }

  .dashboard-page .history-header .page-message {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .header-greeting {
    font-size: 0.85rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .btn-settings-trigger {
    width: 40px;
    height: 40px;
  }

  .settings-popover {
    right: -2px;
    width: min(320px, calc(100vw - 24px));
  }

  .summary {
    grid-template-columns: 1fr;
  }

  .summary-left {
    gap: 16px;
  }

  .card {
    padding: 16px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1 1 calc(50% - 6px);
    text-align: center;
    padding: 10px 12px;
  }

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

  .history-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  .dashboard-page .history-header .page-message {
    max-width: 100%;
    flex: 1 1 100%;
    margin-left: auto;
    margin-right: 0;
  }

  .transaction-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .transaction-right {
    width: 100%;
    justify-content: space-between;
  }

  .section-heading-row {
    flex-wrap: wrap;
  }

  .role-switch-row {
    width: 100%;
    justify-content: flex-start;
  }

  .role-switch-panel {
    left: 0;
    right: auto;
    width: min(340px, calc(100vw - 32px));
  }

  .family-invite-code-box {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .family-invite-code-box strong {
    word-break: break-word;
  }

  .family-join-parent-row {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .modal-content {
    width: min(400px, calc(100vw - 16px));
    padding: 18px 14px 14px;
  }

  #add-modal .modal-content,
  #add-goal-modal .modal-content {
    width: min(340px, 88vw);
    max-height: 74vh;
  }

  #delete-account-modal .modal-content {
    width: min(340px, 88vw);
    max-height: 72vh;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn-secondary,
  .modal-actions .btn-add {
    flex: 1 1 140px;
  }

  .split-row {
    grid-template-columns: 1fr;
  }

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

  .profile-top-layout {
    grid-template-columns: 1fr;
  }

  .profile-name-fields {
    justify-self: stretch;
  }

  .profile-photo-trigger {
    width: fit-content;
  }

  .profile-photo-trigger-group {
    align-items: flex-start;
  }

  .profile-photo-device-note {
    max-width: none;
    text-align: left;
  }

  .parent-portal-grid {
    grid-template-columns: 1fr;
  }

  .split-row-remove {
    width: fit-content;
  }

  .split-actions-bottom {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 420px) {
  .tab {
    flex-basis: 100%;
  }

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

  .auth-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 22px 18px 20px;
  }

  .auth-brand h1 {
    font-size: 2rem;
  }
}
