:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #64717f;
  --soft: #eef2f6;
  --panel: #ffffff;
  --line: #d8e0e8;
  --line-strong: #bec9d4;
  --nav: #111827;
  --nav-soft: #1f2937;
  --teal: #0f766e;
  --teal-soft: #d9f3ee;
  --blue: #2563eb;
  --blue-soft: #e0ebff;
  --amber: #b45309;
  --amber-soft: #fff2d8;
  --rose: #be123c;
  --rose-soft: #ffe4eb;
  --violet: #6d28d9;
  --violet-soft: #eee7ff;
  --green: #15803d;
  --green-soft: #dff8e7;
  --shadow: 0 16px 40px rgba(22, 33, 44, 0.1);
  --radius: 8px;
  --sidebar-width: 286px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #f7f9fb;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f7f9fb;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 88px minmax(0, 1fr);
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: #f7f9fb;
}

.auth-panel {
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.installer-panel {
  width: min(760px, 100%);
}

.auth-brand {
  margin-bottom: 24px;
}

.auth-copy {
  margin-bottom: 20px;
}

.auth-copy h2 {
  margin: 4px 0 8px;
  font-size: 30px;
  line-height: 1.1;
}

.auth-copy p,
.auth-panel > p {
  color: var(--muted);
  line-height: 1.5;
}

.auth-form,
.installer-form {
  display: grid;
  gap: 16px;
}

.link-button {
  text-decoration: none;
}

.error-box,
.success-box,
.form-error {
  color: var(--rose);
  font-size: 14px;
  font-weight: 700;
}

.error-box,
.success-box {
  margin-bottom: 18px;
  padding: 12px;
  border-radius: var(--radius);
}

.error-box {
  border: 1px solid var(--rose-soft);
  background: var(--rose-soft);
}

.success-box {
  color: var(--green);
  border: 1px solid var(--green-soft);
  background: var(--green-soft);
}

.error-box p,
.success-box p,
.form-error {
  margin: 0;
}

.installer-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--muted);
  font-weight: 700;
}

.check-field input {
  width: 18px;
  height: 18px;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  color: #f8fafc;
  background: var(--nav);
}

.sidebar-collapsed .sidebar {
  padding-inline: 14px;
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 58px;
}

.sidebar-collapsed .brand {
  grid-template-columns: 48px;
  justify-content: center;
}

.sidebar-collapsed .brand > div:not(.brand-mark),
.sidebar-collapsed .nav-label,
.sidebar-collapsed .sidebar-footer p {
  display: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  color: #071118;
  background: #ffffff;
  font-weight: 800;
}

.brand h1,
.topbar h2,
.section-heading h3,
.panel h3,
.drawer h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
}

.eyebrow,
.small-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow,
.sidebar .small-label {
  color: #aeb9c6;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: #cbd5e1;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.nav-item.nav-hidden {
  display: none;
}

.sidebar-collapsed .nav-item {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 8px;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.is-active {
  color: #ffffff;
  background: var(--nav-soft);
  outline: none;
}

.nav-symbol {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: currentColor;
}

.nav-symbol svg,
.sidebar-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-symbol svg path:first-child:last-child {
  fill: none;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-tools {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.sidebar-icon-button {
  width: 36px;
  height: 36px;
  min-height: 36px;
  min-width: 0;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-icon-button:hover,
.sidebar-icon-button:focus-visible {
  outline-color: rgba(255, 255, 255, 0.18);
}

.sidebar-collapsed #logoutButton {
  display: none;
}

.sidebar-footer p {
  margin: 0;
  color: #d8dee8;
  font-size: 13px;
  line-height: 1.45;
}

.sidebar-footer .small-label {
  margin-bottom: 6px;
}

.main-content {
  min-width: 0;
  padding: 24px;
}

.topbar,
.section-heading,
.panel-header,
.drawer-header,
.drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 76px;
  margin-bottom: 20px;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 32px;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.sort-select {
  min-width: 150px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
}

.currency-select {
  min-width: 92px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.icon-button,
.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.primary-button {
  min-width: 112px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--teal);
  font-weight: 700;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #115e59;
  outline: 3px solid var(--teal-soft);
}

.secondary-button {
  min-width: 112px;
  padding: 0 16px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #ffffff;
  font-weight: 700;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--line-strong);
  outline: 3px solid var(--soft);
}

.icon-button {
  width: 40px;
  height: 40px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #ffffff;
  font-weight: 800;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--line-strong);
  outline: 3px solid var(--soft);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h3 {
  font-size: 24px;
  line-height: 1.2;
}

.section-heading p {
  max-width: 760px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.muted-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.month-switcher {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.switcher-stack {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.chart-toolbar {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  width: max-content;
  min-height: 40px;
  margin: -6px 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.segment {
  min-width: 98px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.segment.is-active {
  color: #ffffff;
  background: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel,
.table-card,
.account-card,
.category-card,
.debt-card,
.member-card,
.insight-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(22, 33, 44, 0.03);
}

.metric-card {
  min-height: 72px;
  max-height: 98px;
  padding: 10px;
  overflow: auto;
}

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

.metric-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 800;
}

.metric-value {
  margin: 8px 0 3px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.money-stack {
  display: inline-grid;
  gap: 3px;
}

.money-stack small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-caption {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-layout,
.investment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 18px;
  margin-bottom: 18px;
}

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

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  margin-bottom: 16px;
}

.panel h3 {
  margin-top: 3px;
  font-size: 18px;
}

.status-pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  color: #065f46;
  background: var(--green-soft);
}

.status-pill.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-pill.danger {
  color: var(--rose);
  background: var(--rose-soft);
}

.cashflow-panel canvas {
  display: block;
  width: 100%;
  height: 110px;
  min-height: 0;
  max-height: 110px;
}

.investment-layout canvas {
  display: block;
  width: 100%;
  height: 220px;
  min-height: 0;
  max-height: 220px;
}

.insight-list,
.category-list,
.debt-list,
.transaction-list,
.household-switcher {
  display: grid;
  gap: 12px;
}

.household-switcher {
  grid-template-columns: repeat(auto-fit, minmax(160px, max-content));
  margin-bottom: 16px;
}

.insight-list.compact {
  gap: 10px;
}

.insight-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.config-strip {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.config-strip div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.config-strip p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.config-strip .warning-text {
  color: var(--amber);
  font-weight: 800;
}

.transaction-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.transaction-row h4 {
  margin: 0;
  font-size: 14px;
}

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

.transaction-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--rose);
}

.insight-symbol {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #082f2b;
  background: var(--teal-soft);
  font-size: 12px;
  font-weight: 900;
}

.insight-item h4,
.category-row h4,
.debt-row h4,
.account-card h4,
.category-card h4,
.debt-card h4,
.member-card h4,
.insight-card h4 {
  margin: 0;
  font-size: 15px;
}

.insight-item p,
.category-row p,
.debt-row p,
.account-card p,
.category-card p,
.debt-card p,
.member-card p,
.insight-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.category-row,
.debt-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.progress-bar {
  width: 100%;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecf2;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--teal);
}

.progress-fill.warning {
  background: var(--amber);
}

.progress-fill.danger {
  background: var(--rose);
}

.amount {
  font-weight: 800;
  white-space: nowrap;
}

.summary-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
}

.summary-item {
  min-width: 0;
  min-height: 64px;
  max-height: 92px;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-item strong {
  display: block;
  margin-top: 4px;
  font-size: 19px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.table-card {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.data-table-inner {
  --table-cols: minmax(180px, 1.2fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) minmax(110px, 0.8fr) minmax(130px, 0.9fr) minmax(132px, auto);
  min-width: 720px;
}

.income-table {
  --table-cols: minmax(180px, 1.35fr) minmax(100px, 0.7fr) minmax(110px, 0.75fr) minmax(110px, 0.75fr) minmax(120px, 0.8fr) minmax(132px, auto);
}

.investment-table {
  --table-cols: minmax(180px, 1.2fr) minmax(130px, 0.9fr) minmax(95px, 0.65fr) minmax(140px, 0.9fr) minmax(190px, 1.15fr) minmax(132px, auto);
  min-width: 860px;
}

.data-row,
.data-head {
  display: grid;
  grid-template-columns: var(--table-cols);
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

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

.data-head {
  min-height: 44px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.data-cell {
  min-width: 0;
}

.data-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-cell span {
  color: var(--muted);
  font-size: 13px;
}

.data-table-inner > .empty-state {
  grid-column: 1 / -1;
}

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

.category-board,
.account-grid,
.debt-detail-grid,
.household-grid,
.insight-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.category-card,
.account-card,
.debt-card,
.member-card,
.insight-card {
  min-height: 132px;
  max-height: 280px;
  padding: 12px;
  overflow: auto;
}

.account-card,
.debt-card,
.member-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.purpose-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.purpose-option {
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.purpose-option.is-active {
  color: #ffffff;
  border-color: transparent;
  background: var(--teal);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 44px;
  border-radius: 999px;
  background: var(--teal);
}

.card-value {
  margin-top: auto;
  font-size: 26px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recommendation-box {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--green-soft);
  border-radius: var(--radius);
  background: #f4fbf6;
}

.recommendation-box strong {
  font-size: 20px;
}

.recommendation-box p {
  margin: 0;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.admin-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.admin-row .card-actions {
  margin-top: 0;
}

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

.admin-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.admin-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.admin-option span {
  min-width: 0;
}

.admin-option strong,
.admin-option small {
  display: block;
}

.admin-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.savings-admin-option {
  align-items: flex-start;
  flex-direction: column;
}

.debt-model {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.debt-row .debt-model {
  grid-column: 1 / -1;
}

.debt-model label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.debt-model input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 9px;
  color: var(--ink);
  font-weight: 800;
}

.debt-model p {
  margin: 0;
  max-height: 58px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.compact-actions {
  margin-top: 10px;
}

.text-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.text-button {
  color: var(--ink);
  background: var(--soft);
}

.danger-button {
  color: var(--rose);
  background: var(--rose-soft);
}

.chip {
  color: var(--ink);
  background: var(--soft);
}

.chip.teal {
  color: #0f4f49;
  background: var(--teal-soft);
}

.chip.blue {
  color: #1d4ed8;
  background: var(--blue-soft);
}

.chip.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.chip.rose {
  color: var(--rose);
  background: var(--rose-soft);
}

.chip.violet {
  color: var(--violet);
  background: var(--violet-soft);
}

.debt-card .repayment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.repayment-stat {
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.repayment-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.repayment-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
}

.drawer {
  width: min(620px, calc(100vw - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

.drawer::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.drawer-content {
  padding: 20px;
}

.drawer-header {
  margin-bottom: 18px;
}

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

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

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-field input,
.form-field select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--teal);
  outline: 3px solid var(--teal-soft);
}

.drawer-actions {
  margin-top: 20px;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .metric-grid,
  .category-board,
  .account-grid,
  .debt-detail-grid,
  .household-grid,
  .insight-grid,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-layout,
  .investment-layout,
  .wide-grid {
    grid-template-columns: 1fr;
  }

  .cashflow-panel canvas {
    height: 110px;
    max-height: 110px;
  }

  .investment-layout canvas {
    height: 200px;
    max-height: 200px;
  }
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 74px;
    text-align: center;
    font-size: 13px;
  }

  .sidebar-footer {
    display: none;
  }

  .main-content {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .month-switcher,
  .section-actions,
  .sort-select {
    width: 100%;
  }

  .section-actions {
    justify-content: stretch;
  }

  .primary-button,
  .secondary-button {
    flex: 1 1 auto;
  }

  .metric-grid,
  .category-board,
  .account-grid,
  .debt-detail-grid,
  .household-grid,
  .insight-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .month-switcher {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .segment {
    min-width: 0;
    white-space: normal;
  }
}

@media (max-width: 560px) {
  .brand {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar h2 {
    font-size: 28px;
  }

  .topbar-actions {
    display: flex;
    justify-content: flex-start;
  }

  .section-heading h3 {
    font-size: 22px;
  }

  .category-row,
  .debt-row,
  .card-top {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .debt-card .repayment-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
