/* -------------------------------------------------------------------------
   Design tokens
   Dark is the default visual system. Light is an explicit opt-in.
   Muted green is the accent — use it for actions, selection,
   and key highlights. Keep the rest of the UI neutral.
   ------------------------------------------------------------------------- */

:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Surfaces */
  --bg: #111512;
  --sidebar-bg: #111512;
  --surface: #191f1b;
  --surface-elevated: #202823;
  --surface-hover: #27322b;
  --surface-muted: rgba(255, 255, 255, 0.04);
  --bg-elevated: var(--surface-elevated);

  /* Borders & elevation */
  --border: #29332d;
  --border-subtle: #242d27;
  --checking-card-border: var(--border);
  --shadow: none;
  --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.28);

  /* Text */
  --text: #f1f4f1;
  --text-primary: var(--text);
  --text-muted: #9aa69e;
  --text-subtle: #89978e;

  /* Accent and readable action foreground */
  --accent: #87c79f;
  --accent-hover: #a0d6b3;
  --accent-subtle: color-mix(in srgb, var(--accent) 14%, transparent);
  --purple: var(--accent); /* Compatibility alias for existing renderers. */

  /* Semantic — muted, not neon */
  --positive: #87c79f;
  --negative: #d07a7a;
  --warning: #c9a35a;
  --green: var(--positive);
  --green-bright: #a0d6b3;
  --red: var(--negative);
  --danger: var(--negative);
  --orange: #d4a056;
  --blue: #6a9aa3;
  --ink: #171717;

  /* Overlay */
  --overlay: rgba(0, 0, 0, 0.55);
  --focus-ring: var(--accent);
  --accent-foreground: #111512;

  /* Charts — green leads, then matte hues spaced far apart on the wheel so
     neighbouring slices stay tellable apart without going neon. */
  --chart-1: var(--accent);
  --chart-2: #4fa8a5;
  --chart-3: #d9a24e;
  --chart-4: #6f8fd6;
  --chart-5: #d1758f;
  --chart-6: #7fb069;
  --chart-7: #d97f52;
  --chart-8: #9d92b8;
  --chart-grid: var(--border-subtle);
  --chart-axis: var(--text-subtle);

  /* Radius */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Type */
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.75rem;
  --text-hero: clamp(2.25rem, 5.5vw, 3.25rem);
  --leading-tight: 1.15;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --tracking-tight: -0.02em;
  --tracking-label: 0.04em;

  /* Motion */
  --duration-fast: 0.12s;
  --duration: 0.15s;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Layout */
  --sidebar-width: 216px;
  --app-max-width: 1200px;
  --dashboard-gap: var(--space-6);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f6f7f5;
  --sidebar-bg: #f6f7f5;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --surface-hover: #eef1ed;
  --surface-muted: rgba(0, 0, 0, 0.04);
  --bg-elevated: var(--surface-elevated);

  --border: #e6eae6;
  --border-subtle: #e6eae6;
  --checking-card-border: var(--border);
  --shadow: none;
  --shadow-elevated: 0 8px 24px rgba(0, 0, 0, 0.08);

  --text: #18201c;
  --text-primary: var(--text);
  --text-muted: #646f68;
  --text-subtle: #646f68;

  --accent: #246b4b;
  --accent-hover: #19583d;
  --accent-subtle: color-mix(in srgb, var(--accent) 10%, transparent);
  --purple: var(--accent); /* Compatibility alias for existing renderers. */

  --positive: #246b4b;
  --negative: #c44c4c;
  --warning: #b8860b;
  --green: var(--positive);
  --green-bright: #357f59;
  --red: var(--negative);
  --danger: var(--negative);
  --orange: #c2410c;
  --blue: #2a6f76;
  --ink: #171717;

  --overlay: rgba(0, 0, 0, 0.4);
  --focus-ring: var(--accent);
  --accent-foreground: #ffffff;

  /* Same hues, deepened so they hold up against a white background. */
  --chart-1: var(--accent);
  --chart-2: #2f8f8c;
  --chart-3: #b8802a;
  --chart-4: #4a6fb8;
  --chart-5: #b5546f;
  --chart-6: #5a8f47;
  --chart-7: #b85f34;
  --chart-8: #7a6f99;
  --chart-grid: var(--border-subtle);
  --chart-axis: var(--text-subtle);
}

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

html {
  height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.layout {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  padding: var(--space-8) var(--space-4);
  border-right: 1px solid var(--border-subtle);
  background: var(--sidebar-bg);
  z-index: 30;
  overflow: visible;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-height: 0;
  overflow: visible;
}

.sidebar-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-settings-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  text-align: left;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.sidebar-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.sidebar-link:active {
  background: var(--surface-hover);
}

.sidebar-link--active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.sidebar-link--active:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.sidebar-nav-group {
  position: relative;
}

.sidebar-submenu {
  list-style: none;
  margin: 0;
  display: none;
  position: absolute;
  top: 0;
  left: calc(100% + 0.75rem);
  z-index: 40;
  width: max-content;
  min-width: 11.5rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-elevated);
  flex-direction: column;
  gap: 0.125rem;
}

.sidebar-submenu::before {
  content: "";
  position: absolute;
  top: 0;
  right: 100%;
  width: 0.85rem;
  height: 100%;
}

.sidebar-nav-group:hover .sidebar-submenu,
.sidebar-nav-group:focus-within .sidebar-submenu {
  display: flex;
}

.sidebar-icon {
  flex-shrink: 0;
  width: 1.0625rem;
  height: 1.0625rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.sidebar-link-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-sublink {
  padding: 0.4rem 0.75rem;
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
}

.sidebar-nav-group--child-active .sidebar-link--parent:not(.sidebar-link--active) {
  color: var(--text);
}

.app {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: var(--app-max-width);
  margin-inline: auto;
  padding: 2.5rem 2.75rem;
}

.dashboard-page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--dashboard-gap);
}

.dashboard-page-header h1 {
  margin: 0;
  font-size: 1.625rem;
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-snug);
}

.page[hidden] {
  display: none;
}

/* Checking */
.checking-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--dashboard-gap);
  align-items: start;
}

.checking-balance-card {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  min-height: 0;
  padding: 0 0 var(--dashboard-gap);
  display: grid;
  grid-template-columns: 1fr;
  justify-items: start;
  align-content: center;
  row-gap: 0.35rem;
}

.overview-cashflow-actions {
  margin-top: 0.75rem;
}

.overview-account-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}

.overview-account-row:last-child {
  border-bottom: none;
}

.overview-account-main {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.overview-account-detail {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.overview-account-goals {
  margin-top: 0.35rem;
  padding-left: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.overview-account-goal-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.goal-editor-help {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.goal-editor-plan-preview {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.checking-left-stack {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: var(--dashboard-gap);
  min-width: 0;
}

.checking-bills-card {
  width: 100%;
  padding: var(--space-6);
}

.checking-bills-hint {
  margin: -0.35rem 0 0.75rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.checking-bills-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checking-bills-card.checking-widget.card {
  border-color: var(--border-subtle);
}

.checking-chart-card {
  width: 100%;
  padding: var(--space-6);
}

.checking-txn-card {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  width: 100%;
  padding: var(--space-6);
}

.checking-chart-label {
  margin: 0 0 0.75rem;
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  color: var(--text);
}

.checking-chart-wrap {
  width: 100%;
}

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

.checking-chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.checking-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.checking-chart-point {
  fill: var(--chart-1);
  stroke: var(--surface);
  stroke-width: 2;
}

.checking-chart-point-group {
  pointer-events: none;
}

.checking-chart-hit {
  fill: transparent;
  stroke: none;
  pointer-events: all;
  cursor: pointer;
}

.checking-chart-point--hover {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.checking-chart-point-group:hover .checking-chart-point--hover,
.checking-chart-point-group:focus-within .checking-chart-point--hover {
  opacity: 1;
}

.checking-chart-callout {
  fill: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
}

.checking-chart-y-label,
.checking-chart-x-label {
  fill: var(--chart-axis);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
}

.checking-chart-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.checking-txn-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.checking-txn-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) auto;
  gap: 0.5rem 0.75rem;
  align-items: baseline;
  padding: 0.45rem 0;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.checking-txn-row + .checking-txn-row {
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
}

.checking-txn-date {
  color: var(--text-muted);
  white-space: nowrap;
}

.checking-txn-desc {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.checking-txn-pending {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--border) 70%, transparent);
  vertical-align: middle;
}

.checking-txn-row--pending .checking-txn-amount {
  opacity: 0.85;
}

.checking-txn-amount {
  font-weight: 500;
  white-space: nowrap;
  text-align: right;
}

.checking-txn-amount.amount--pos {
  color: var(--green);
}

.checking-txn-amount.amount--neg {
  color: var(--red);
}

.checking-txn-footer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  margin-top: 0.35rem;
  padding-top: 0.25rem;
}

.checking-txn-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition:
    color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.checking-txn-arrow[hidden] {
  display: none !important;
}

.checking-txn-arrow--left,
.checking-txn-arrow--right {
  display: none !important;
}

.checking-txn-footer--expanded .checking-txn-arrow--left:not([hidden]),
.checking-txn-footer--expanded .checking-txn-arrow--right:not([hidden]) {
  display: inline-flex !important;
}

.checking-txn-arrow:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.checking-txn-arrow--left {
  position: absolute;
  left: 0;
}

.checking-txn-arrow--right {
  position: absolute;
  right: 0;
}

.checking-txn-arrow-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
}

.checking-txn-card.checking-widget.card {
  border-color: var(--border-subtle);
}

.checking-txn-card.checking-widget.card .checking-txn-arrow--toggle[aria-expanded="true"] .checking-txn-arrow-icon--down {
  display: none;
}

.checking-txn-card.checking-widget.card .checking-txn-arrow--toggle[aria-expanded="true"] .checking-txn-arrow-icon--up {
  display: block;
}

.checking-txn-card.checking-widget.card .checking-txn-arrow--toggle[aria-expanded="false"] .checking-txn-arrow-icon--up {
  display: none;
}

.checking-balance-label {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-muted);
}

.spending-period-label {
  display: inline-block;
  margin: 0;
}

.month-filter-host {
  position: relative;
  display: inline-flex;
  width: 10.5rem;
  max-width: 100%;
  min-width: 9.25rem;
  vertical-align: middle;
}

.month-filter-native {
  display: none !important;
}

.month-filter-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-width: 0;
  min-height: 2.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.month-filter-trigger:hover,
.month-filter-trigger[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--accent) 52%, var(--border));
  background: var(--surface-elevated);
}

.month-filter-trigger:focus-visible,
.month-filter-option:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.month-filter-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.month-filter-caret {
  flex: 0 0 0.45rem;
  width: 0.45rem;
  height: 0.45rem;
  margin-top: -0.2rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

.month-filter-options {
  position: absolute;
  z-index: 100;
  top: calc(100% + var(--space-2));
  left: 0;
  display: grid;
  gap: 0.15rem;
  width: max(100%, 11rem);
  max-height: 18rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.35rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
}

.month-filter-options[hidden] {
  display: none;
}

.month-filter-option {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.month-filter-option:hover,
.month-filter-option[aria-selected="true"] {
  background: var(--accent-subtle);
  color: var(--accent);
}

.month-filter-option[aria-selected="true"] {
  font-weight: 600;
}

.checking-balance-value {
  margin: 0;
  font-size: clamp(2rem, 3.5vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: var(--leading-tight);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: left;
}

.checking-balance-hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: left;
}

.savings-stat-value {
  margin: 0 0 0.75rem;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--green);
}

/* Overview */
.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
  gap: var(--dashboard-gap);
  align-items: start;
}

.overview-layout > section {
  min-width: 0;
}

.overview-layout .overview-hero {
  grid-column: 1;
  grid-row: 1;
  padding: var(--space-6);
}

.overview-hero-summary {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.overview-hero .checking-balance-label {
  margin: 0;
}

.overview-hero .checking-balance-value {
  font-size: clamp(2.5rem, 4.5vw, 3.5rem);
  letter-spacing: -0.045em;
}

.overview-networth-change {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.overview-trend .checking-bills-hint {
  margin: 0 0 0.75rem;
}

.overview-chart-wrap .checking-chart-line {
  stroke: var(--accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.overview-hero .checking-chart-svg {
  max-height: 240px;
}

.overview-chart-wrap .checking-chart-grid {
  stroke: var(--border-subtle);
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
}

.overview-layout .overview-cashflow-card {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--space-6);
}

.overview-layout .overview-cashflow-card.checking-widget.card {
  border-left-color: var(--accent);
}

.overview-cashflow-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
}

.overview-cashflow-header .checking-chart-label {
  margin: 0;
}

.overview-cashflow-filter {
  width: 10rem;
}

.overview-cashflow-card .overview-cashflow-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.overview-cashflow-card .overview-cashflow-item {
  gap: 0.4rem;
}

.overview-cashflow-card .overview-cashflow-value {
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.overview-cashflow-card .overview-cashflow-value.amount--pos,
.overview-cashflow-card .overview-cashflow-value.amount--neg {
  color: var(--text);
}

.overview-cashflow-card .overview-cashflow-item:first-child .overview-cashflow-value {
  color: var(--accent);
}

.overview-layout .overview-goals-card.checking-widget.card {
  grid-column: 2;
  grid-row: 1;
  align-self: stretch;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border-subtle));
}

.overview-goals-card .overview-goal-progress-track {
  height: 0.5rem;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.overview-goals-card .overview-goal-top {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.overview-goals-card .overview-goal-actions {
  justify-content: flex-start;
  flex-shrink: 1;
}

.overview-goals-card .overview-goal-actions .btn {
  min-height: 2rem;
}

.overview-goals-card [data-goal-action="contribute"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
  background: var(--accent-subtle);
}

.overview-goals-card .overview-goal-meta {
  line-height: 1.55;
  color: var(--text-muted);
}

.overview-accounts-card .overview-account-row {
  padding: 0.8rem 0;
}

.overview-accounts-card .overview-account-main {
  font-variant-numeric: tabular-nums;
}

.overview-accounts-card .overview-account-main > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.overview-accounts-card .overview-account-main > :last-child {
  white-space: nowrap;
}

.overview-layout .overview-activity-card {
  grid-column: 1 / -1;
  grid-row: 4;
}

.overview-layout .overview-accounts-card {
  grid-column: 1;
  grid-row: 3;
}

.overview-layout .overview-allocation-card {
  grid-column: 2;
  grid-row: 3;
}

.overview-activity-card .checking-txn-list {
  max-height: none;
}

.overview-layout .checking-chart-empty {
  padding: 1rem 0;
  line-height: 1.55;
}

@media (max-width: 1000px) {
  .overview-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .overview-layout .overview-hero,
  .overview-layout .overview-cashflow-card,
  .overview-layout .overview-accounts-card,
  .overview-layout .overview-goals-card.checking-widget.card,
  .overview-layout .overview-allocation-card,
  .overview-layout .overview-activity-card {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 640px) {
  .overview-goals-card .overview-goals-header {
    flex-wrap: wrap;
  }

  .overview-layout .overview-hero {
    padding: var(--space-4);
  }

  .overview-cashflow-card .overview-cashflow-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .overview-layout .overview-cashflow-card {
    padding: var(--space-5);
  }

  .overview-layout .overview-txn-list .overview-txn-row {
    grid-template-columns: max-content minmax(0, 1fr) auto;
    gap: 0.25rem 0.5rem;
  }

  .overview-layout .overview-txn-account {
    grid-column: 2;
    grid-row: 2;
    white-space: normal;
  }

  .overview-layout .overview-txn-row > :last-child {
    grid-column: 3;
    grid-row: 1 / 3;
  }
}

.overview-right-stack {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: var(--dashboard-gap);
  min-width: 0;
}

.overview-chart-wrap .checking-chart-svg {
  min-height: 200px;
}

.overview-pie-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
}

.overview-pie-chart {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.overview-pie-svg {
  display: block;
  width: 100%;
  overflow: visible;
}

/* A hairline in the card color separates neighbouring wedges, so even
   similar-value slices stay legible without brightening the fills. */
.overview-pie-slice {
  cursor: pointer;
  stroke: var(--surface);
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition:
    opacity var(--duration) var(--ease),
    filter var(--duration) var(--ease),
    transform var(--duration) var(--ease);
  transform-origin: center;
}

.overview-pie-wrap.is-slice-hover .overview-pie-slice {
  opacity: 0.28;
  filter: saturate(0.45);
}

.overview-pie-wrap.is-slice-hover .overview-pie-slice.is-hovered {
  opacity: 1;
  filter: saturate(1.15) brightness(1.08);
}

.overview-pie-callout {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.overview-pie-wrap.is-slice-hover .overview-pie-callout.is-visible {
  opacity: 1;
}

.overview-pie-callout-line {
  fill: none;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.overview-pie-callout-text {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.overview-pie-legend {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 9rem;
}

.overview-pie-legend-item {
  display: grid;
  grid-template-columns: 0.65rem minmax(0, 1fr) auto;
  gap: 0.45rem 0.55rem;
  align-items: center;
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: 0.35rem;
  padding: 0.15rem 0.25rem;
  margin: -0.15rem -0.25rem;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.overview-pie-legend-item.is-hovered {
  background: var(--surface-hover);
}

.overview-pie-legend-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
}

.overview-pie-legend-label {
  color: var(--text);
}

.overview-pie-legend-value {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Spending: a clear total, readable category rows, then supporting cash flow. */
.spending-layout {
  grid-template-columns: 1fr;
}

.spending-layout .checking-left-stack {
  grid-column: 1;
}

.spending-headline {
  position: relative;
  min-width: 0;
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.spending-headline > * {
  min-width: 0;
  max-width: 100%;
}

.spending-headline-label {
  margin: 0 0 var(--space-3);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
}

.spending-headline .month-filter-trigger {
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
}

.spending-headline .spending-period-label {
  margin-bottom: var(--space-4);
}

.spending-headline .checking-balance-value {
  margin: 0;
  color: var(--text);
  font-size: var(--text-hero);
  font-weight: 500;
  letter-spacing: var(--tracking-tight);
  overflow-wrap: anywhere;
}

.spending-month-comparison {
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
  font-size: var(--text-md);
}

.spending-month-comparison[data-direction="lower"] {
  color: var(--positive);
}

.spending-category-list {
  display: grid;
  gap: var(--space-6);
  margin: var(--space-6) 0 0;
  padding: 0;
  list-style: none;
}

.spending-category-row {
  min-width: 0;
}

.spending-category-row-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-md);
}

.spending-category-name {
  flex: 1 1 12rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.spending-category-amount {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.spending-category-share {
  display: block;
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.spending-category-track {
  height: 0.5rem;
  margin-top: var(--space-2);
  overflow: hidden;
  border-radius: var(--radius-full);
  background: var(--surface-hover);
}

.spending-category-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in srgb, var(--accent) 65%, var(--surface));
}

.spending-category-row:first-child .spending-category-fill {
  background: var(--accent);
}

.spending-cashflow-card.checking-widget.card {
  min-width: 0;
  background: var(--surface);
  border-color: var(--border-subtle);
}

.spending-cashflow-chart {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.spending-sankey-svg {
  display: block;
  width: 100%;
  min-width: 0;
  height: auto;
  overflow: visible;
}

.spending-sankey-flow {
  transition: opacity 0.15s ease;
}

.spending-sankey-source {
  opacity: 0.9;
}

.spending-sankey-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 500;
}

.spending-sankey-value {
  fill: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.overview-txn-list .overview-txn-row {
  grid-template-columns: max-content minmax(0, 1fr) max-content auto;
}

.overview-txn-account {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.overview-cashflow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.overview-cashflow-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.overview-cashflow-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.overview-cashflow-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.overview-cashflow-value.amount--pos {
  color: var(--green);
}

.overview-cashflow-value.amount--neg {
  color: var(--red);
}

#overview-accounts-list .checking-txn-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.overview-goals-card .overview-goals-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.overview-goals-card .overview-goals-header .checking-chart-label {
  margin-bottom: 0.15rem;
}

.overview-goals-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.overview-goal-item {
  padding: 0.75rem 0 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.overview-goal-item:first-child {
  border-top: none;
  padding-top: 0;
}

.overview-goal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.overview-goal-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.overview-goal-type {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.overview-goal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  flex-shrink: 0;
  justify-content: flex-end;
}

.overview-goal-actions .btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
}

.overview-goal-progress-track {
  margin-top: 0.65rem;
  height: 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 70%, transparent);
  overflow: hidden;
}

.overview-goal-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.overview-goal-progress-fill.is-complete {
  background: var(--green-bright);
}

.overview-goal-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.goal-editor-dialog {
  width: min(420px, 100%);
}

.goal-editor-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.goal-editor-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.goal-editor-field input,
.goal-editor-field select {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--text);
  padding: 0.45rem 0.55rem;
  font: inherit;
}

.goal-editor-error {
  margin: 0;
  color: var(--red);
  font-size: 0.85rem;
}

.subscriptions-layout {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.subscriptions-layout .checking-balance-card {
  grid-column: 1 / -1;
  grid-row: 1;
}

.subscriptions-scope-hint {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.subscriptions-layout .checking-left-stack {
  grid-column: 1;
  grid-row: 2;
}

.subscriptions-calendar-card {
  grid-column: 2;
  grid-row: 2;
  align-self: start;
  width: 100%;
}

.subscriptions-calendar-header {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.subscriptions-calendar-title {
  flex: 1;
  margin: 0;
  text-align: center;
}

.subscriptions-calendar-nav {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.25rem;
  height: 2rem;
  line-height: 1;
  min-width: 2rem;
  padding: 0;
}

.subscriptions-calendar-nav:hover {
  background: var(--surface-muted);
}

.subscriptions-changes-hint {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.subscriptions-reset-baseline {
  align-self: flex-start;
}

.subscriptions-hub-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

.subscriptions-hub-link:hover {
  opacity: 0.85;
}

.subscriptions-calendar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subscriptions-calendar-weekdays,
.subscriptions-calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.35rem;
}

.subscriptions-calendar-weekday {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

.subscriptions-calendar-day {
  min-height: 3.25rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.subscriptions-calendar-day--blank {
  border-color: transparent;
  background: transparent;
}

.subscriptions-calendar-day--today {
  border-color: var(--accent);
}

.subscriptions-calendar-day-num {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.subscriptions-calendar-day--today .subscriptions-calendar-day-num {
  color: var(--accent);
}

.subscriptions-calendar-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  margin-top: auto;
}

.subscriptions-calendar-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  flex: 0 0 auto;
}

.subscriptions-calendar-dot--due {
  background: var(--negative);
}

.subscriptions-calendar-dot--paid {
  background: var(--green);
}

.subscriptions-calendar-day--clickable {
  cursor: pointer;
}

.subscriptions-calendar-day--clickable:hover {
  border-color: var(--text-muted);
}

.subscriptions-calendar-day--selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.subscriptions-calendar-day-detail {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.subscriptions-calendar-day-detail-title {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.subscriptions-calendar-day-detail-list .subscriptions-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.subscriptions-calendar-detail-row {
  align-items: center;
}

.subscriptions-calendar-detail-row .subscriptions-row-meta {
  grid-column: 1 / -1;
}

.subscriptions-due-status-btn {
  border: none;
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
}

.subscriptions-due-status-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.subscriptions-layout .checking-left-stack > .checking-bills-card,
.subscriptions-list-card {
  width: 100%;
  max-width: 100%;
}

.subscriptions-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.subscriptions-filter {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.subscriptions-filter:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.subscriptions-filter--active {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.subscriptions-list .subscriptions-row {
  grid-template-columns: minmax(0, 1.4fr) auto;
  grid-template-rows: auto auto auto;
  row-gap: 0.15rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.subscriptions-list .subscriptions-row:last-child {
  border-bottom: none;
}

.subscriptions-row-meta,
.subscriptions-row-dates {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.subscriptions-row-dates {
  grid-column: 1;
}

.subscriptions-row .checking-txn-amount,
.subscriptions-price-change {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
}

.subscriptions-calendar-day-detail-list .subscriptions-calendar-detail-row .checking-txn-desc {
  grid-column: 1;
  grid-row: 1;
}

.subscriptions-calendar-day-detail-list .subscriptions-calendar-detail-row .subscriptions-due-status-btn {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.subscriptions-calendar-day-detail-list .subscriptions-calendar-detail-row .checking-txn-amount {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
}

.subscriptions-price-change {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
}

.subscriptions-price-prev {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: line-through;
  font-variant-numeric: tabular-nums;
}

.subscriptions-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  vertical-align: middle;
}

.subscriptions-badge--cancelled {
  color: var(--negative);
  background: color-mix(in srgb, var(--negative) 14%, transparent);
}

.subscriptions-badge--price {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 14%, transparent);
}


.credit-card-account-row,
.credit-card-activity-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
}

.credit-card-account-row:first-child,
.credit-card-activity-row:first-child {
  border-top: none;
}

.credit-card-account-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.credit-card-account-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-card-account-source,
.credit-card-txn-account {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.credit-card-account-balance,
.credit-card-activity-row > span:last-child {
  flex-shrink: 0;
  font-weight: 500;
  white-space: nowrap;
}

.credit-card-account-balance.amount--neg,
.credit-card-activity-row .amount--neg {
  color: var(--red);
}

.credit-card-activity-row .amount--pos {
  color: var(--green);
}

.credit-card-txn-list .credit-card-txn-row {
  grid-template-columns: max-content minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  row-gap: 0.1rem;
}

.credit-card-txn-row .credit-card-txn-account {
  grid-column: 2;
  grid-row: 2;
}

.credit-card-txn-row .checking-txn-amount {
  grid-column: 3;
  grid-row: 1 / span 2;
}

/* Header */
.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--dashboard-gap);
}

.title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.subtitle {
  margin: 0.2rem 0 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-snug);
}

.investments-layout {
  display: flex;
  flex-direction: column;
  gap: var(--dashboard-gap);
  align-items: start;
}

.investments-layout > #retirement401k-root,
.investments-layout > #brokerage-balance-root {
  width: 100%;
  padding-inline: 0;
  box-sizing: border-box;
}

.investments-layout > #retirement401k-empty,
.investments-layout > #brokerage-balance-empty {
  padding-inline: 1.25rem;
}

.investment-widget.checking-widget.card {
  border-color: var(--border-subtle);
  padding: var(--space-6);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.investment-widget .k401-monthly-strip {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  width: 100%;
}

/* Account pages: balance and trend lead; activity follows the supporting insight. */
.account-layout {
  display: flex;
  flex-direction: column;
  gap: var(--dashboard-gap);
  align-items: stretch;
}

.account-primary {
  min-width: 0;
  padding: var(--space-8);
}

.account-primary .checking-balance-card.checking-widget.card,
.account-primary .checking-chart-card.checking-widget.card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.account-primary .checking-balance-card {
  margin-bottom: var(--space-8);
}

.account-page .checking-balance-value {
  font-size: var(--text-hero);
  overflow-wrap: anywhere;
}

.account-primary .checking-chart-wrap {
  max-width: 100%;
}

.account-primary .checking-chart-svg {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.account-support.checking-left-stack {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.account-support > :only-child {
  grid-column: 1 / -1;
}

.account-page .checking-txn-card {
  min-width: 0;
  padding: var(--space-6);
  border-color: var(--border-subtle);
}

.account-page .checking-txn-list {
  min-width: 0;
}

.account-page .savings-stat-value {
  color: var(--positive);
}

.account-investments-balance.checking-balance-card.checking-widget.card {
  padding: var(--space-8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.account-page .investment-widget {
  min-width: 0;
}

.account-page .investments-layout > .empty-state {
  margin: 0;
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-align: start;
}

@media (max-width: 900px) {
  .account-support.checking-left-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .account-primary,
  .account-investments-balance.checking-balance-card.checking-widget.card {
    padding: var(--space-5);
  }

  .account-primary .checking-balance-card {
    margin-bottom: var(--space-6);
  }

  .account-page .checking-bills-card,
  .account-page .checking-txn-card {
    padding: var(--space-5);
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.25rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease),
    opacity var(--duration) var(--ease);
}

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

.btn:active {
  background: color-mix(in srgb, var(--surface-hover) 80%, var(--text) 6%);
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-foreground);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: transparent;
}

.btn-primary:active {
  background: color-mix(in srgb, var(--accent-hover) 88%, #000);
}

.btn-secondary {
  background: transparent;
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-muted);
  border-color: color-mix(in srgb, var(--border) 70%, var(--text) 12%);
}

.btn-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--negative) 45%, var(--border));
  color: var(--negative);
}

.btn-danger:hover {
  background: color-mix(in srgb, var(--negative) 10%, transparent);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  padding: 0.4rem 0.5rem;
  color: var(--text-muted);
}

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

.btn-icon {
  font-size: 1rem;
  line-height: 1;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.checking-widget.card {
  border: 1px solid var(--border-subtle);
  box-shadow: none;
}

.checking-balance-card.checking-widget.card {
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.checking-chart-card.checking-widget.card {
  border-color: var(--border-subtle);
}

/* Status bar */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-6);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--dashboard-gap);
  background: var(--surface);
  border-color: var(--border-subtle);
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 5rem;
}

.status-item--grow {
  flex: 1;
  min-width: 8rem;
}

.status-item--actions {
  margin-left: auto;
  align-self: center;
  min-width: 0;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.status-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-subtle);
}

.status-value {
  font-size: var(--text-md);
  font-weight: 500;
}

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  width: fit-content;
}

.status-badge--backend {
  background: color-mix(in srgb, var(--positive) 16%, transparent);
  color: var(--positive);
}

.status-badge--client {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning);
}

.status-badge--loading {
  background: var(--accent-subtle);
  color: var(--accent);
}

.status-badge--empty {
  background: var(--surface-hover);
  color: var(--text-muted);
}

/* Bucket grid */
.bucket-summary {
  padding: var(--space-6);
  margin-bottom: var(--dashboard-gap);
}

.bucket-summary-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.bucket-summary-period {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.bucket-summary-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.bucket-summary-toggle .month-filter-host {
  width: 9.25rem;
  min-width: 0;
}

.bucket-summary-toggle .month-filter-trigger {
  min-height: 2rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.bucket-summary-toggle-btn {
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.bucket-summary-toggle-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.bucket-summary-toggle-btn--active {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.bucket-card {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: transparent;
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.bucket-card:hover {
  background: var(--surface-muted);
}

.bucket-card--active {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: var(--accent-subtle);
}

.bucket-card-label {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-subtle);
}

.bucket-card-count {
  margin: 0.25rem 0 0;
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
}

.bucket-card-total {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.bucket-card--income .bucket-card-count { color: var(--green); }
.bucket-card--net .bucket-card-count { color: var(--accent); }
.bucket-card--bills .bucket-card-count { color: var(--blue); }
.bucket-card--savings .bucket-card-count { color: var(--purple); }
.bucket-card--spending .bucket-card-count { color: var(--orange); }
.bucket-card--debt .bucket-card-count { color: var(--red); }

/* Table */
.table-card {
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.table-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category-label {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

.category-select {
  min-width: 11rem;
  max-width: 14rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.source-pill {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  color: var(--text-subtle);
  white-space: nowrap;
}

.source-pill--manual { background: var(--accent-subtle); color: var(--accent); }
.source-pill--learned { background: var(--surface-muted); color: var(--text-muted); }
.source-pill--rule { background: var(--surface-muted); color: var(--text-muted); }

.section-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

.select {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}

.select:hover {
  border-color: color-mix(in srgb, var(--border) 60%, var(--text-muted));
}

.select:focus-visible {
  border-color: var(--accent);
}

.select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
}

.txn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.txn-table th,
.txn-table td {
  padding: 0.55rem var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.txn-table th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--text-subtle);
  background: var(--surface);
  position: sticky;
  top: 0;
}

.txn-table tbody tr {
  transition: background var(--duration) var(--ease);
}

.txn-table tbody tr:hover {
  background: var(--surface-muted);
}

.txn-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.txn-table .amount--pos { color: var(--positive); }
.txn-table .amount--neg { color: var(--negative); }

.bucket-pill {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
  background: var(--surface-muted);
  color: var(--text-muted);
}

.bucket-pill--income { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }
.bucket-pill--savings { background: var(--accent-subtle); color: var(--accent); }
.bucket-pill--debt { background: color-mix(in srgb, var(--negative) 14%, transparent); color: var(--negative); }
.bucket-pill--due { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.bucket-pill--paid { background: color-mix(in srgb, var(--positive) 14%, transparent); color: var(--positive); }

.bucket-select {
  min-width: 9rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.txn-desc {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conf-low {
  color: var(--orange);
}

.empty-state {
  margin: 0;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Settings overlay */
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: flex-end;
}

.settings-overlay[hidden] {
  display: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
}

.settings-panel {
  position: relative;
  width: min(380px, 100%);
  height: 100%;
  container-type: inline-size;
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-elevated);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.settings-header-start {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.settings-back-btn {
  flex-shrink: 0;
}

.settings-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.settings-body {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
  min-height: 0;
}

.settings-view[hidden] {
  display: none;
}

.settings-section--file-upload {
  margin-top: 2.25rem;
}

.settings-section--file-upload .uploaded-files-list {
  margin-top: 0.3rem;
  row-gap: 0.25rem;
  column-gap: 0.5rem;
}

.settings-section--footer {
  margin-top: auto;
  padding-top: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.settings-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.settings-nav-row:hover {
  background: var(--surface-hover);
}

.settings-section--footer #btn-open-settings-account {
  position: relative;
  align-self: stretch;
}

.settings-section--footer #btn-open-settings-account::before {
  content: "";
  position: absolute;
  top: calc(-0.375rem - 0.5px);
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
}

.settings-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.settings-nav-row:hover {
  background: var(--surface-hover);
}

.settings-nav-chevron {
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
}

.settings-upload-history {
  width: 75cqw;
}

.settings-upload-history-toggle {
  width: 100%;
  justify-content: space-between;
  box-sizing: border-box;
  list-style: none;
  background: transparent;
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.settings-upload-history-toggle:hover {
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
}

.settings-upload-history-toggle::-webkit-details-marker {
  display: none;
}

.settings-upload-history-toggle .settings-nav-chevron {
  color: inherit;
}

.settings-upload-history[open] > summary .settings-nav-chevron {
  transform: rotate(90deg);
}

.settings-upload-history-body {
  margin-top: 0.45rem;
  padding: 0.35rem 0.75rem 0.15rem;
}

.settings-upload-history-empty {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.settings-upload-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.settings-upload-history-item {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
}

.settings-upload-history-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
}

.settings-upload-history-account {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.settings-upload-history-balance {
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
}

.settings-upload-history-file {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-upload-history-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.settings-account-username {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
}

.settings-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.settings-section:has(#btn-connect-plaid) h3 {
  font-weight: 700;
}

.settings-section:has(#btn-clear) {
  display: flex;
  justify-content: center;
}

#btn-clear {
  width: 75cqw;
}

.theme-segmented {
  display: flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
}

.theme-segment {
  flex: 1;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}

.theme-segment:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.theme-segment--active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.theme-segment--active:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin-bottom: 0.35rem;
}

#btn-connect-plaid,
#btn-sync-plaid {
  min-width: 4.625rem;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: normal;
  line-height: 1.2;
}

.settings-status {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.settings-status--inline {
  flex: 1;
  min-width: 9rem;
  line-height: 1.35;
}

.plaid-items-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.plaid-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
}

.plaid-item-name {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-elevated, var(--bg));
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.plaid-item-status {
  display: inline-flex;
  align-items: center;
  padding: 0.13rem 0.33rem;
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.42rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  box-shadow: var(--shadow);
  white-space: nowrap;
  cursor: pointer;
}

.plaid-item-status:hover,
.plaid-item-status:focus-visible {
  filter: brightness(0.92);
}

.plaid-item-status:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.plaid-item-status--connected {
  background: var(--positive);
  color: var(--ink);
}

.plaid-item-status--disconnected {
  background: var(--negative);
  color: #fff;
}

.uploaded-files-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: max-content max-content;
  column-gap: 0.5rem;
  row-gap: 0.1rem;
  justify-content: start;
  align-items: baseline;
}

.uploaded-file-item {
  display: contents;
}

.uploaded-file-name {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  white-space: nowrap;
}

.uploaded-file-actions {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-shrink: 0;
}

.uploaded-file-replace,
.uploaded-file-clear {
  box-sizing: border-box;
  flex-shrink: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.25;
}

.uploaded-file-replace:hover {
  background: transparent;
  opacity: 0.8;
}

.uploaded-file-replace {
  color: var(--text);
}

.uploaded-file-status {
  margin-left: 0.15rem;
}

[data-theme="light"] .uploaded-file-replace {
  color: var(--text);
}

[data-theme="light"] .uploaded-file-replace:hover {
  background: transparent;
}

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  padding: 1rem;
}

.confirm-overlay[hidden] {
  display: none;
}

.confirm-dialog {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  width: min(360px, 100%);
  box-shadow: var(--shadow-elevated);
}

.confirm-dialog h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.confirm-text {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.import-preview-dialog {
  width: min(420px, 100%);
}

.import-preview-meta,
.import-preview-destination {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.import-preview-details {
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  font-size: 0.8125rem;
}

.import-preview-details dt {
  margin: 0;
  color: var(--text-muted);
}

.import-preview-details dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  color: var(--text);
}

.column-mapping-dialog {
  width: min(520px, 100%);
  max-height: min(90vh, 720px);
  overflow-y: auto;
}

.column-mapping-meta {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.column-mapping-form {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.column-mapping-field {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.8125rem;
}

.column-mapping-field span {
  color: var(--text-muted);
}

.column-mapping-field select,
.column-mapping-field input {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--bg-elevated, var(--bg));
  color: var(--text);
  font: inherit;
}

.column-mapping-preview h4 {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.column-mapping-preview-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.85rem;
}

.column-mapping-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.column-mapping-preview-table th,
.column-mapping-preview-table td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.45rem;
  text-align: left;
  white-space: nowrap;
}

.column-mapping-preview-table th {
  background: var(--bg-elevated, var(--bg));
  color: var(--text-muted);
}

.column-mapping-error {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  color: var(--danger);
}

.account-assignment-dialog {
  width: min(480px, 100%);
}

.import-destination-dialog {
  width: min(420px, 100%);
}

.import-destination-meta {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.import-destination-options {
  margin: 0 0 1rem;
  padding: 0;
  border: none;
  display: grid;
  gap: 0.5rem;
}

.import-destination-option {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.import-destination-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.import-destination-option-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.import-destination-option input[type="radio"] {
  margin: 0;
}

.import-destination-option strong {
  font-weight: 600;
}

.import-destination-option .import-destination-option-desc {
  margin-left: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.import-destination-error {
  margin: 0 0 0.75rem;
  color: var(--red);
  font-size: 0.8125rem;
}

.account-assignment-meta {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.account-assignment-options {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.85rem;
  padding: 0;
  border: 0;
}

.account-assignment-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.account-assignment-option input[type="radio"] {
  margin: 0;
}

.account-assignment-option--credit {
  flex-wrap: wrap;
}

.account-assignment-option--credit input[type="text"] {
  flex: 1 1 100%;
  margin-left: 1.45rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.account-assignment-option--credit input[type="text"]:disabled {
  opacity: 0.55;
}

.account-assignment-preview h4 {
  margin: 0 0 0.45rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.account-assignment-preview-table-wrap {
  overflow-x: auto;
  margin-bottom: 0.85rem;
}

.account-assignment-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.account-assignment-preview-table th,
.account-assignment-preview-table td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.45rem;
  text-align: left;
}

.account-assignment-preview-table th {
  background: var(--bg-elevated, var(--bg));
  color: var(--text-muted);
}

.account-assignment-error {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  color: var(--danger);
}

.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;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-full);
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-elevated);
  z-index: 300;
}

.toast[hidden] {
  display: none;
}

.toast--error {
  background: color-mix(in srgb, var(--negative) 16%, var(--surface-elevated));
  border-color: color-mix(in srgb, var(--negative) 35%, var(--border));
  color: var(--negative);
}

/* Thin bubble progress bar for file uploads (replaces reading toasts) */
.upload-progress {
  --upload-progress-green: var(--accent);
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(169px, calc(32.5vw - 0.5rem));
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  overflow: hidden;
  z-index: 350;
  pointer-events: none;
  opacity: 1;
  transition: opacity var(--duration) var(--ease);
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress.is-finishing {
  opacity: 0;
}

.upload-progress__fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: var(--upload-progress-green);
  transition: width 0.22s var(--ease);
}

/* Large desktop: let the content column breathe a little wider. */
@media (min-width: 1600px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --app-max-width: 1280px;
    --sidebar-width: 232px;
  }
}

/* Laptop / small desktop */
@media (max-width: 1180px) {
  .app {
    padding: var(--space-5) var(--space-5) var(--space-8);
  }
}

/* Tablet: single content column, narrower sidebar. */
@media (max-width: 900px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"] {
    --sidebar-width: 180px;
  }

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

  .checking-left-stack {
    grid-column: 1;
    grid-row: 2;
  }

  .checking-txn-card,
  .overview-right-stack,
  .subscriptions-calendar-card {
    grid-column: 1;
    grid-row: 3;
  }

  .subscriptions-layout,
  .spending-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  :root {
    --dashboard-gap: var(--space-4);
  }

  .investment-widget .k401-monthly-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .layout {
    flex-direction: column;
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--sidebar-bg);
    padding: 0.65rem 0.75rem;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
    min-height: 0;
    overflow: visible;
  }

  .sidebar-footer {
    margin-top: 0;
    margin-left: auto;
    padding-top: 0;
    border-top: none;
  }

  .sidebar-link {
    width: auto;
  }

  .sidebar-nav-group {
    position: relative;
  }

  .sidebar-submenu {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    z-index: 20;
    min-width: 9.5rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-elevated);
  }

  .sidebar-submenu::before {
    content: none;
  }

  .sidebar-nav-group--child-active .sidebar-submenu {
    display: flex;
  }

  .sidebar-sublink {
    padding: 0.45rem 0.75rem;
  }

  .goal-editor-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .header {
    flex-direction: column;
  }

  .bucket-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .checking-left-stack {
    grid-column: 1;
    grid-row: 2;
  }

  .checking-txn-card {
    grid-column: 1;
    grid-row: 3;
  }

  .subscriptions-calendar-card {
    grid-column: 1;
    grid-row: 3;
  }

  .overview-right-stack {
    grid-column: 1;
    grid-row: 3;
  }

  .app {
    width: 100%;
    padding: var(--space-4) var(--space-4) var(--space-8);
  }

  .checking-bills-card,
  .checking-chart-card,
  .checking-txn-card {
    padding: var(--space-4);
  }

  .investment-widget.checking-widget.card,
  .bucket-summary,
  .status-bar {
    padding: var(--space-4);
  }

  .status-bar {
    gap: var(--space-3) var(--space-4);
  }

  .status-item--actions {
    margin-left: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-gate-shell {
  width: min(480px, 100%);
}

.auth-gate-dialog {
  width: 100%;
  padding: 0;
  overflow: hidden;
}

.auth-view {
  display: flex;
  flex-direction: column;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, var(--bg));
  text-align: center;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.auth-brand-name {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}

.auth-body {
  padding: 2rem;
}

.auth-title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.auth-lead {
  margin: 0 0 1.75rem;
  max-width: 34ch;
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.auth-signin-panel {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  background: color-mix(in srgb, var(--bg) 65%, var(--surface));
}

.auth-signin-label {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.auth-actions {
  display: flex;
  gap: 0.75rem;
}

.auth-actions-single {
  flex-direction: column;
}

.auth-actions-single .btn {
  width: 100%;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.75rem 1rem;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
  border-radius: calc(var(--radius) + 2px);
  font-size: 0.9375rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn-google:hover {
  background: #f8f9fa;
  border-color: #c6c9cc;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.18);
}

.btn-google:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-google-icon {
  flex-shrink: 0;
}

.auth-footer {
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, var(--bg));
}

.auth-footer p {
  margin: 0;
  text-align: center;
  color: var(--text-subtle);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.auth-config-warning {
  margin: 1.25rem 0 0;
  padding: 0.85rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--orange) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--orange) 8%, var(--surface));
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.auth-config-warning code {
  font-size: 0.8125rem;
}

.auth-error {
  margin: 1.25rem 0 0;
  padding: 0.85rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
  color: var(--red);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.auth-view[hidden] {
  display: none !important;
}

#auth-restricted-view .auth-lead {
  max-width: 42ch;
}

#auth-restricted-view .btn-secondary {
  width: 100%;
  min-height: 3rem;
}

body.auth-locked .layout {
  display: none;
}

body.is-dashboard-loading {
  overflow: hidden;
}

body.is-dashboard-loading .settings-backdrop {
  display: none;
}

body.is-dashboard-loading .settings-overlay:not([hidden]) {
  pointer-events: none;
}

body.is-dashboard-loading .settings-panel {
  pointer-events: auto;
}

body.is-dashboard-loading:has(#settings-overlay:not([hidden])) .dashboard-loading {
  padding-right: min(360px, 40vw);
}

/* Fixed to the viewport so the panel stays centered no matter how tall the
   page is or how far it was scrolled; the box still tracks the .app column,
   which is centered in the space beside the sidebar. */
.dashboard-loading {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.dashboard-loading[hidden] {
  display: none !important;
}

.dashboard-loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: min(260px, 82vw);
  min-height: min(220px, 70vw);
  padding: 1.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-xl);
  background: transparent;
  box-shadow: none;
  text-align: center;
}

.dashboard-loading-title[hidden],
.dashboard-loading-hint[hidden] {
  display: none;
}

.dashboard-loading-spinner {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-top-color: var(--accent);
  animation: dashboard-loading-spin 0.7s linear infinite;
}

.dashboard-loading-title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

.dashboard-loading-hint {
  margin: 0;
  max-width: 28ch;
  font-size: var(--text-md);
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

@keyframes dashboard-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-loading-spinner {
    animation: none;
    opacity: 0.85;
  }

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

/* The sidebar becomes a top bar here, so the overlay spans the full width. */
@media (max-width: 640px) {
  .dashboard-loading {
    left: 0;
  }
}
