/* Sentri — solid editorial product UI. Tokens in DESIGN.md. */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e4e6ee;
  --border-strong: #cfd3e0;
  --ink: #181a22;
  --muted: #5b6172;
  --faint: #6d7388;
  --accent: #5b5bd6;
  --accent-ink: #4644b8;
  --accent-bg: #eeeffb;
  --pos: #1d7f4f;
  --pos-bg: #e7f5ec;
  --neg: #c4373d;
  --neg-bg: #fbeaea;
  --warn-ink: #966400;
  --warn-bg: #fdf3df;
  --card-shadow: 0 1px 2px rgb(16 17 22 / 0.05);
  --overlay-shadow: 0 16px 40px rgb(16 17 22 / 0.18);
  --scrim: rgb(14 15 20 / 0.5);
  /* z-scale: dropdown < sticky < scrim < modal < toast */
  --z-dropdown: 30;
  --z-scrim: 40;
  --z-modal: 50;
  --z-toast: 60;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body.dark-mode {
  --bg: #101116;
  --surface: #17181f;
  --surface-2: #14151c;
  --border: #272935;
  --border-strong: #3a3d4d;
  --ink: #eceef4;
  --muted: #a6abbe;
  --faint: #8b92a8;
  --accent: #7d7de8;
  --accent-ink: #a2a2f0;
  --accent-bg: #232447;
  --pos: #4cc38a;
  --pos-bg: #17301f;
  --neg: #f2555a;
  --neg-bg: #3b1d1e;
  --warn-ink: #d8a03d;
  --warn-bg: #33270f;
  --card-shadow: none;
  --overlay-shadow: 0 16px 40px rgb(0 0 0 / 0.5);
  --scrim: rgb(0 0 0 / 0.6);
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

.primary-button,
.ghost-button,
.select-pill,
.link-button,
.row-edit,
.row-delete,
.nav-item,
.footer-icon,
.onb-option,
.theme-button {
  transition: transform 0.1s ease, opacity 0.1s ease;
}

.primary-button:active,
.ghost-button:active,
.select-pill:active,
.link-button:active,
.row-edit:active,
.row-delete:active,
.onb-option:active {
  transform: scale(0.96);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.icons {
  display: none;
}

[data-money],
.amount,
.transaction-row strong,
.category-row strong,
.budget-spend,
.budget-percent,
.mini-metric strong,
.stat-card strong,
.page-value,
.donut-center strong,
.goal-content strong,
.goal-card strong {
  font-variant-numeric: tabular-nums;
}

/* ---------- shell ---------- */

.shell {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  background: var(--bg);
  transition: grid-template-columns 0.2s ease;
}

.shell.sidebar-collapsed {
  grid-template-columns: 68px 1fr;
}

/* ---------- sidebar ---------- */

.sidebar {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 20px;
  min-height: 0;
  padding: 20px 16px 16px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.sidebar-head {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 28px;
  align-items: center;
  gap: 8px;
}

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

.brand-mark {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
}

.brand-mark span {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 2.5px solid #fff;
  border-right-color: transparent;
  transform: rotate(45deg);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.2;
}

.brand p {
  margin: 1px 0 0;
  color: var(--faint);
  font-size: 12px;
  white-space: nowrap;
}

.collapse-button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
}

.collapse-button:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.collapse-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.shell.sidebar-collapsed .collapse-button svg {
  transform: rotate(-90deg);
}

.nav-list {
  display: grid;
  gap: 2px;
}

.nav-item {
  width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav-item:hover {
  background: var(--accent-bg);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-weight: 600;
}

.upgrade {
  align-self: end;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.upgrade svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent-ink);
  stroke-linecap: round;
  stroke-width: 1.8;
  margin-bottom: 8px;
}

.upgrade h2 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.upgrade p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.upgrade button {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
}

.upgrade button:hover {
  background: var(--accent-bg);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-icon-button {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.profile-icon-button:hover {
  border-color: var(--accent);
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 650;
}

.footer-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.footer-icon:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.footer-icon.active {
  border-color: transparent;
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.footer-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-toggle {
  display: flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.theme-button {
  width: 30px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
}

.theme-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-button.active {
  background: var(--accent-bg);
  color: var(--accent-ink);
}

/* collapsed sidebar */

.shell.sidebar-collapsed .sidebar {
  padding-inline: 12px;
}

.shell.sidebar-collapsed .sidebar-head {
  grid-template-columns: 1fr;
  justify-items: center;
}

.shell.sidebar-collapsed .brand {
  justify-content: center;
}

.shell.sidebar-collapsed .brand-copy,
.shell.sidebar-collapsed .nav-item span,
.shell.sidebar-collapsed .upgrade,
.shell.sidebar-collapsed .theme-toggle {
  display: none;
}

.shell.sidebar-collapsed .collapse-button {
  margin-top: 6px;
}

.shell.sidebar-collapsed .nav-item {
  width: 40px;
  justify-content: center;
  gap: 0;
  padding: 0;
}

.shell.sidebar-collapsed .nav-list {
  justify-items: center;
}

.shell.sidebar-collapsed .sidebar-footer {
  flex-direction: column;
}

/* ---------- main / topbar ---------- */

.dashboard {
  position: relative;
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 18px 24px 24px;
  overflow: hidden;
}

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

.top-greeting h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
}

.top-greeting p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.account-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-button {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.icon-button:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.has-dot::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--neg);
  box-shadow: 0 0 0 2px var(--surface);
}

/* notifications popover */

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-dropdown);
  width: 320px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--overlay-shadow);
}

.popover-title {
  margin: 0;
  padding: 8px 10px 6px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
}

.notif-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
}

.notif-row:hover {
  background: var(--surface-2);
}

.notif-row .notif-dot {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font-size: 12px;
}

.notif-row.warn .notif-dot { background: var(--warn-bg); color: var(--warn-ink); }
.notif-row.neg .notif-dot { background: var(--neg-bg); color: var(--neg); }
.notif-row.info .notif-dot { background: var(--accent-bg); color: var(--accent-ink); }

.notif-row .notif-dot svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.notif-row strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.notif-row p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.popover .empty-note {
  padding: 16px 10px;
}

.dashboard-view {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

/* ---------- overview strip ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, minmax(0, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.stat-card {
  position: relative;
  min-height: 104px;
  padding: 14px 18px;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.stat-card:last-child {
  border-right: 0;
}

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

.stat-card h3,
.stat-top span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.stat-card p {
  margin: 6px 0 0;
  font-size: 12px;
}

.stat-card p span {
  color: var(--faint);
}

.up {
  color: var(--pos);
  font-weight: 550;
}

.down {
  color: var(--neg);
  font-weight: 550;
}

.ghost-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
}

.ghost-icon:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.ghost-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sparkline {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 34px;
  opacity: 0.9;
}

/* ---------- panels ---------- */

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  grid-template-rows: minmax(230px, 0.8fr) minmax(150px, 0.5fr);
  gap: 14px;
  min-height: 0;
}

.panel {
  min-height: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.panel h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.select-pill,
select.select-pill {
  height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.select-pill:hover {
  background: var(--surface-2);
}

.select-pill svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

select.select-pill {
  appearance: none;
  -webkit-appearance: none;
  min-width: 118px;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a90a4' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 9 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 13px;
}

.link-button {
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
}

.link-button:hover {
  background: var(--accent-bg);
}

/* ---------- spending / donut ---------- */

.spending-body {
  display: grid;
  grid-template-columns: minmax(170px, 0.7fr) minmax(240px, 1fr);
  align-items: center;
  gap: 18px;
}

.donut-wrap {
  display: grid;
  place-items: center;
}

.donut {
  width: min(188px, 17vw);
  height: min(188px, 17vw);
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
}

.donut::before {
  content: "";
  position: absolute;
  inset: 17px;
  border-radius: inherit;
  background: var(--surface);
}

.donut-center {
  position: relative;
  z-index: 1;
  text-align: center;
}

.donut-center span {
  color: var(--muted);
  font-size: 11px;
}

.donut-center strong {
  display: block;
  margin: 4px 0 2px;
  font-size: 18px;
  font-weight: 650;
}

.donut-center p {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
}

.category-list {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

.category-row {
  display: grid;
  grid-template-columns: 10px minmax(90px, 1fr) auto 38px;
  align-items: center;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.category-row:last-child {
  border-bottom: 0;
}

.category-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.category-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.category-row strong {
  font-weight: 600;
}

.category-row small {
  color: var(--faint);
  font-size: 12px;
  text-align: right;
}

.report-button {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  margin-top: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
}

.report-button:hover {
  background: var(--accent-bg);
}

.report-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- transactions ---------- */

.transactions {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

.day-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding: 6px 2px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.day-group-header:first-child {
  margin-top: 0;
}

.transaction-row {
  display: grid;
  grid-template-columns: 30px minmax(100px, 1fr) max-content;
  align-items: center;
  gap: 10px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.transaction-row:last-child {
  border-bottom: 0;
}

.transaction-row.has-delete {
  grid-template-columns: 30px minmax(100px, 1fr) max-content 26px;
}

.merchant-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.merchant-icon.starbucks { color: #fff; background: #0b6b45; border-color: #0b6b45; }
.merchant-icon.salary { color: var(--pos); background: var(--pos-bg); border-color: transparent; }
.merchant-icon.amazon { color: #131921; background: #ffd814; border-color: #ffd814; }
.merchant-icon.uber { color: #fff; background: #111; border-color: #111; font-size: 9px; }
.merchant-icon.netflix { color: #e50914; background: #17181f; border-color: #17181f; }

.transaction-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.transaction-meta {
  margin-top: 1px;
  color: var(--faint);
  font-size: 11.5px;
}

.transaction-row strong {
  font-weight: 600;
}

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

.row-delete {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  font-size: 15px;
  line-height: 1;
}

.row-delete:hover {
  background: var(--neg-bg);
  color: var(--neg);
}

.row-edit {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
}

.row-edit:hover {
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.row-edit svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- budgets ---------- */

.budget-list {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

.budget-row {
  display: grid;
  grid-template-columns: 10px 108px minmax(90px, 1fr) 110px 40px;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.budget-row:last-child {
  border-bottom: 0;
}

.budget-row.has-delete {
  grid-template-columns: 10px 108px minmax(90px, 1fr) 110px 40px 24px 24px;
}

.budget-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.bar span {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar span.over {
  background: var(--neg);
}

.budget-spend {
  color: var(--faint);
  font-size: 12px;
  text-align: right;
}

.budget-spend strong {
  color: var(--ink);
  font-weight: 600;
}

.budget-percent {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.budget-row .over-label {
  color: var(--neg);
}

.budget-pace-note {
  margin: -4px 0 8px;
  padding-left: 20px;
  color: var(--neg);
  font-size: 11.5px;
}

/* ---------- goals ---------- */

.goal-content {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.progress-ring {
  position: relative;
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0 var(--progress, 0%), var(--border) var(--progress, 0%) 100%);
}

.progress-ring span {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.goal-content h4 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
}

.goal-content strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
  font-weight: 600;
}

.goal-content p {
  margin: 0;
  color: var(--faint);
  font-size: 12px;
}

/* ---------- inner pages ---------- */

.hero-row {
  margin: 2px 0 14px;
}

.hero-row h2 {
  margin: 0 0 3px;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.hero-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.app-page {
  min-height: 0;
  display: grid;
  gap: 14px;
  overflow: hidden;
}

.two-column-page {
  grid-template-columns: 1.5fr 0.9fr;
}

.three-card-page {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
}

.page-panel {
  min-height: 0;
  overflow: hidden;
}

.page-panel.wide {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
}

.wide-panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.wide-panel-body .full-list {
  flex: 1;
}

.bills-calendar {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 12px;
  flex: none;
}

.bills-cal-day {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 8px;
  background: var(--surface-2);
}

.bills-cal-day.is-today {
  background: var(--accent-bg);
}

.bills-cal-dow {
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.bills-cal-num {
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.bills-cal-day.is-today .bills-cal-num {
  color: var(--accent-ink);
}

.bills-cal-dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.page-panel.wide .full-list,
.page-panel.wide .budget-expanded {
  overflow: auto;
  align-content: start;
}

.page-panel > h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.page-value {
  display: block;
  margin-bottom: 6px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.page-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.mini-metric {
  display: grid;
  gap: 2px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.mini-metric:last-child {
  border-bottom: 0;
}

.mini-metric small {
  color: var(--muted);
  font-size: 12px;
}

.mini-metric strong {
  font-size: 18px;
  font-weight: 650;
}

.goal-card {
  position: relative;
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 4px;
}

.goal-card .progress-ring {
  margin-bottom: 12px;
}

.goal-card h3 {
  font-size: 14px !important;
}

.goal-card > .row-delete {
  position: absolute;
  top: 10px;
  right: 10px;
}

.goal-card .goal-actions {
  margin-top: 8px;
}

.add-goal-card {
  display: grid;
  place-items: center;
  min-height: 140px;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.empty-note {
  margin: 0;
  padding: 20px 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.sample-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 550;
  vertical-align: 2px;
}

/* ---------- cash flow ---------- */

.cashflow-page {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  align-content: start;
}

.chart-panel {
  grid-column: 1 / -1;
}

.barchart {
  display: block;
  width: 100%;
  height: auto;
}

.barchart rect {
  transition: opacity 0.15s ease;
}

.barchart:hover rect {
  opacity: 0.45;
}

.barchart rect:hover {
  opacity: 1;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
}

.range-note {
  margin-left: 6px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 2px;
  vertical-align: 0;
}

.cf-table {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
}

.cf-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 1fr 0.55fr;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.cf-row:last-child {
  border-bottom: 0;
}

.cf-row span:not(:first-child) {
  text-align: right;
}

.cf-row.cf-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.cf-row .cf-month {
  font-weight: 550;
}

.cf-pos {
  color: var(--pos);
  font-weight: 550;
}

.cf-neg {
  color: var(--neg);
  font-weight: 550;
}

.flow-row {
  display: grid;
  grid-template-columns: 10px minmax(90px, 0.9fr) minmax(60px, 1fr) max-content 36px;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.flow-row:last-child {
  border-bottom: 0;
}

.flow-row strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.flow-row small {
  color: var(--faint);
  font-size: 12px;
  text-align: right;
}

/* ---------- insights ---------- */

.insights-page {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  align-items: start;
  overflow: auto;
}

.insights-page .stats-grid {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.insights-page .wide-panel {
  grid-column: 1 / -1;
}

.insight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.insight-row:last-child {
  border-bottom: 0;
}

.insight-row .insight-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}

.insight-row .insight-sub {
  display: block;
  margin-top: 1px;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 400;
}

.insight-row strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.insight-row .delta {
  min-width: 52px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.health-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.health-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.health-metrics .mini-metric {
  border-bottom: 0;
}

.stat-top-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.range-toggle {
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.range-toggle:hover {
  border-color: var(--border-strong);
  color: var(--ink);
}

@media (max-width: 1180px) {
  .insights-page,
  .health-metrics {
    grid-template-columns: 1fr;
  }
}

/* ---------- accounts ---------- */

.transaction-row.has-controls {
  grid-template-columns: 30px minmax(100px, 1fr) max-content 24px 24px;
}

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

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-ink);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
}

/* ---------- settings ---------- */

.settings-page {
  grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.4fr);
  align-content: start;
  /* cards keep natural height; the page itself scrolls */
  align-items: start;
  overflow: auto;
}

.settings-profile {
  display: grid;
  align-content: start;
  gap: 16px;
}

.settings-person {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 12px;
}

.settings-avatar {
  width: 44px;
  height: 44px;
  font-size: 15px;
}

.settings-person h3 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 650;
}

.settings-person p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-column {
  display: grid;
  align-content: start;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  gap: 14px;
}

.settings-card {
  display: grid;
  align-content: start;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.setting-row p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.setting-input {
  width: 64px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.setting-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.soon-pill {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--faint);
  font-size: 11px;
  font-weight: 550;
}

/* switch */

.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 21px;
  flex: none;
}

.switch input {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgb(16 17 22 / 0.25);
  transition: transform 0.15s ease;
}

.switch input:checked + .track {
  background: var(--accent);
}

.switch input:checked + .track::after {
  transform: translateX(14px);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- assistant dock ---------- */

.assistant-dock {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: var(--z-dropdown);
  width: 156px;
  height: 38px;
  display: grid;
  grid-template-columns: auto 0 0;
  align-items: center;
  gap: 0;
  overflow: hidden;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--overlay-shadow);
  transform: translateX(-50%);
  transition: width 0.2s ease, grid-template-columns 0.2s ease, padding 0.2s ease;
}

.assistant-dock:hover,
.assistant-dock:focus-within,
.assistant-dock.is-open {
  width: min(520px, calc(100% - 64px));
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 0 14px;
}

.assistant-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 600;
}

.assistant-tab svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.assistant-dock input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  opacity: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  transition: opacity 0.15s ease;
}

.assistant-dock:hover input,
.assistant-dock:focus-within input,
.assistant-dock.is-open input {
  opacity: 1;
}

.assistant-dock input::placeholder {
  color: var(--faint);
}

.assistant-dock kbd {
  min-width: 44px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  opacity: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  text-align: center;
  transition: opacity 0.15s ease;
}

.assistant-dock:hover kbd,
.assistant-dock:focus-within kbd,
.assistant-dock.is-open kbd {
  opacity: 1;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-scrim);
  display: grid;
  place-items: center;
  background: var(--scrim);
}

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

.modal {
  z-index: var(--z-modal);
  width: min(440px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--overlay-shadow);
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 650;
}

.modal .modal-note {
  margin: -6px 0 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.field input,
.field select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.field input::placeholder {
  color: var(--faint);
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.field-check {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

.field-check input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.form-error {
  margin: 0 0 2px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--neg) 30%, transparent);
  border-radius: 8px;
  background: var(--neg-bg);
  color: var(--neg);
  font-size: 13px;
}

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

.primary-button {
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.primary-button.danger {
  border-color: var(--neg);
  background: var(--neg);
}

.ghost-button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
}

.ghost-button:hover {
  background: var(--surface-2);
}

/* ---------- onboarding ---------- */

.onboarding {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: var(--bg);
  animation: onboarding-in 0.25s ease-out;
}

@keyframes onboarding-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.onboarding-card {
  width: min(420px, 100%);
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.onboarding-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin-bottom: 10px;
}

.onboarding-mark span {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border-width: 3.5px;
}

.onboarding-card h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.onboarding-sub {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.onboarding-features {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.onboarding-feature {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.onboarding-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-bg);
  color: var(--accent-ink);
}

.onboarding-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.onboarding-feature strong {
  display: block;
  margin-bottom: 2px;
  font-size: 13.5px;
  font-weight: 600;
}

.onboarding-feature p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.onb-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.onb-dots {
  display: flex;
  gap: 6px;
}

.onb-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}

.onb-dot.active {
  background: var(--accent);
}

.onboarding-card .onb-field {
  width: 100%;
  margin-bottom: 10px;
}

.onb-option {
  width: 100%;
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}

.onb-option:hover {
  border-color: var(--accent);
}

.onb-option.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.onb-option strong {
  font-size: 13.5px;
  font-weight: 600;
}

.onb-option p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.onb-actions {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.onboarding-cta {
  flex: 1;
  height: 42px;
}

.onboarding .onb-skip {
  justify-self: center;
  margin-top: 2px;
  color: var(--muted);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-toast);
  max-width: 340px;
  padding: 11px 15px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--overlay-shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.has-undo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.toast.has-undo.show {
  pointer-events: auto;
}

.toast button {
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #a2a2f0;
  font-size: 13px;
  font-weight: 700;
}

.toast button:hover {
  background: rgb(255 255 255 / 0.12);
}

.drillable {
  cursor: pointer;
}

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

.filter-chip {
  gap: 8px;
  color: var(--accent-ink);
  font-weight: 600;
}

.filter-chip .category-swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

.tag.paid-tag {
  background: var(--pos-bg);
  color: var(--pos);
}

.hidden-by-search {
  opacity: 0.25;
}

/* ---------- density ---------- */

.density-compact .panel {
  padding: 11px;
}

.density-compact .stat-card {
  min-height: 84px;
  padding: 10px 14px;
}

.density-compact .transaction-row,
.density-compact .budget-row,
.density-compact .category-row,
.density-compact .flow-row,
.density-compact .cf-row,
.density-compact .insight-row {
  padding: 4px 2px;
}

.density-compact .setting-row {
  padding: 6px 2px;
}

.density-compact .stats-grid,
.density-compact .content-grid,
.density-compact .app-page {
  gap: 10px;
}

.density-compact .settings-column {
  gap: 10px;
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card:nth-child(2) {
    border-right: 0;
  }

  .stat-card:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .content-grid {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  body {
    overflow: auto;
    height: auto;
    min-height: 100dvh;
  }

  .shell {
    height: auto;
    min-height: 100dvh;
  }

  .dashboard {
    height: auto;
    overflow: visible;
  }

  .dashboard-view {
    overflow: visible;
  }

  .two-column-page,
  .three-card-page,
  .settings-page,
  .cashflow-page {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .page-panel.wide {
    grid-template-rows: auto auto;
  }

  .page-panel.wide .full-list,
  .page-panel.wide .budget-expanded {
    overflow-x: auto;
    overflow-y: visible;
  }

  .app-page {
    overflow: visible;
  }
}

@media (max-width: 880px) {
  /* the cf-row breakdown table has 5 real columns of dollar amounts — keep them
     legible and let the row scroll horizontally instead of squeezing them */
  .cf-row {
    min-width: 420px;
  }

  /* 14 day-cells is too cramped on a phone; show the coming week instead */
  .bills-calendar {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .bills-cal-day:nth-child(n + 8) {
    display: none;
  }

  .shell,
  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  /* the sidebar becomes a fixed bottom tab bar */
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 35; /* above content, below the modal scrim (40) */
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    border-right: 0;
  }

  .sidebar-head,
  .upgrade,
  .theme-toggle,
  .nav-item span {
    display: none;
  }

  .nav-list {
    display: flex;
    flex: 1;
    min-width: 0;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: none;
    width: 44px;
    height: 44px;
    justify-content: center;
    gap: 0;
    padding: 0;
  }

  .donut {
    width: min(168px, 42vw);
    height: min(168px, 42vw);
  }

  /* let merchant/account names truncate earlier so amounts and row
     controls never require a horizontal scroll to reach; row buttons get
     taller hit areas (40px) to approach the touch-target minimum */
  .row-delete,
  .row-edit {
    width: 30px;
    height: 40px;
  }

  .transaction-row.has-delete {
    grid-template-columns: 26px minmax(70px, 1fr) max-content 30px;
  }

  .transaction-row.has-controls {
    grid-template-columns: 26px minmax(60px, 1fr) max-content 30px 30px;
  }

  /* drop the decorative bar track in allocation rows; name+value+percent is
     the data that matters and this is the only way it fits without scrolling */
  .flow-row {
    grid-template-columns: 10px minmax(50px, 1fr) max-content 30px;
  }

  .flow-row .bar {
    display: none;
  }

  .sidebar-footer {
    flex: none;
    flex-direction: row;
    gap: 8px;
  }

  .dashboard {
    /* clear the fixed bottom bar */
    padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    margin: -14px -14px 12px;
    padding: 10px 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  /* modals present as bottom sheets on phones */
  .modal-overlay {
    place-items: end center;
  }

  .modal {
    width: 100%;
    max-height: 88dvh;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    animation: sheet-up 0.22s ease-out;
  }

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

  .stat-card {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .stat-card:last-child {
    border-bottom: 0;
  }

  /* on phones the spending donut leads the dashboard, above the balance strip.
     content-grid dissolves (display: contents) so its panels join the same
     flex flow as the stats strip and can be reordered across containers */
  .dashboard-view:has(> .stats-grid) {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: visible;
  }

  .dashboard-view:has(> .stats-grid) .content-grid {
    display: contents;
  }

  .dashboard-view:has(> .stats-grid) .spending-panel {
    order: -1;
  }

  .dashboard-view:has(> .stats-grid) .stats-grid {
    margin-bottom: 0;
  }

  .spending-body {
    grid-template-columns: 1fr;
  }

  .budget-row {
    grid-template-columns: 10px minmax(80px, 1fr) 40px;
  }

  .budget-row.has-delete {
    grid-template-columns: 10px minmax(80px, 1fr) 40px 30px 30px;
  }

  .budget-row .bar,
  .budget-spend {
    grid-column: 2 / -1;
  }

  .budget-spend {
    text-align: left;
  }

  .assistant-dock {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom));
    width: calc(100% - 28px);
    grid-template-columns: auto minmax(0, 1fr);
  }

  .assistant-dock input {
    opacity: 1;
  }

  .assistant-dock kbd {
    display: none;
  }

  .popover {
    width: min(320px, calc(100vw - 28px));
  }

  .toast {
    right: 14px;
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

@keyframes sheet-up {
  from { opacity: 0.6; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}

/* swipe page-change feedback (mobile) */
@keyframes swipe-in-left {
  from { opacity: 0.4; transform: translateX(18px); }
  to { opacity: 1; transform: none; }
}

@keyframes swipe-in-right {
  from { opacity: 0.4; transform: translateX(-18px); }
  to { opacity: 1; transform: none; }
}

.swipe-in-left {
  animation: swipe-in-left 0.2s ease-out;
}

.swipe-in-right {
  animation: swipe-in-right 0.2s ease-out;
}

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