:root {
  --bg-canvas: #F3F5F8;
  --bg-surface: #FFFFFF;
  --bg-subtle: #EAEFF5;
  --bg-glass: rgba(255, 255, 255, 0.78);
  --border-hairline: #DCE3EC;
  --border-strong: #94A3B8;

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #526071;

  --brand-primary: #005A9C;
  --brand-primary-hover: #004477;
  --brand-soft: #E6F2FA;
  --brand-on: #FFFFFF;

  --safe-fg: #005A9C;
  --safe-bg: #E6F2FA;
  --safe-border: #7CC0E8;

  --warn-fg: #92400E;
  --warn-bg: #FEF3C7;
  --warn-border: #E69F00;

  --danger-fg: #9F1239;
  --danger-bg: #FFE4E6;
  --danger-border: #E11D48;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 20px rgba(15, 23, 42, 0.03);
  --shadow-fab: 0 8px 24px rgba(0, 90, 156, 0.28);
  --shadow-sheet: 0 -8px 32px rgba(15, 23, 42, 0.16);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --ease-ui: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-sheet: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;

  --nav-height: 68px;
  --header-height: 58px;
  --sidebar-width: 248px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-canvas: #0D1117;
    --bg-surface: #161B22;
    --bg-subtle: #21262D;
    --bg-glass: rgba(22, 27, 34, 0.82);
    --border-hairline: #30363D;
    --border-strong: #6E7681;

    --text-primary: #F0F6FC;
    --text-secondary: #B1BAC4;
    --text-muted: #9BA5B1;

    --brand-primary: #3898EC;
    --brand-primary-hover: #5CB0F8;
    --brand-soft: rgba(56, 152, 236, 0.16);
    --brand-on: #06131F;

    --safe-fg: #79C0FF;
    --safe-bg: rgba(56, 152, 236, 0.16);
    --safe-border: #3898EC;

    --warn-fg: #FCD34D;
    --warn-bg: rgba(230, 159, 0, 0.18);
    --warn-border: #E69F00;

    --danger-fg: #FDA4AF;
    --danger-bg: rgba(225, 29, 72, 0.22);
    --danger-border: #FB7185;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-fab: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-sheet: 0 -8px 32px rgba(0, 0, 0, 0.52);
  }
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--brand-primary);
  outline-offset: 2px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.desktop-sidebar {
  display: none;
}

.top-glass-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-height);
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bg-glass);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (prefers-reduced-transparency: reduce) {
  .top-glass-bar,
  .bottom-glass-nav {
    background: var(--bg-surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

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

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--brand-primary);
  color: var(--brand-on);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-chip {
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-fast) var(--ease-ui), background-color var(--dur-fast) var(--ease-ui);
}

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

.demo-strip {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-border);
  color: var(--warn-fg);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
}

.demo-strip-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.demo-strip-btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--text-primary);
  color: var(--bg-surface);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.main-content {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 14px calc(var(--nav-height) + 88px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: panelReveal var(--dur-base) var(--ease-ui);
}

@keyframes panelReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.card-hero {
  padding: 18px;
  border-radius: var(--radius-lg);
}

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

.card-header > button {
  white-space: nowrap;
  flex-shrink: 0;
}

.card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  border: 1.5px solid transparent;
  white-space: nowrap;
  line-height: 1.2;
}

.status-badge.safe {
  background: var(--safe-bg);
  color: var(--safe-fg);
  border-color: var(--safe-border);
}

.status-badge.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border-color: var(--warn-border);
}

.status-badge.danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: var(--danger-border);
}

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

.hero-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.hero-amount {
  margin: 8px 0 6px;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
}

.hero-amount.danger {
  color: var(--danger-fg);
}

.hero-submetrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0 14px;
}

.submetric-box {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.submetric-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.submetric-val {
  font-size: 19px;
  font-weight: 800;
  margin-top: 2px;
  letter-spacing: -0.02em;
}

.cf-bar-svg {
  width: 100%;
  height: 22px;
  display: block;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(15, 23, 42, 0.25);
}

.swatch-fixed {
  background: repeating-radial-gradient(circle at 3px 3px, #CBD5E1 0 1px, #475569 1px 4px);
}

.swatch-debt {
  background: repeating-linear-gradient(45deg, #3730A3 0 3px, #A5B4FC 3px 5px);
}

.swatch-save {
  background: repeating-linear-gradient(0deg, #0072B2 0 3px, #BAE6FD 3px 4.5px);
}

.swatch-spent {
  background: #E69F00;
}

.swatch-remain {
  background: #CBD5E1;
}

.diagnosis-card {
  border-left: 5px solid var(--brand-primary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diagnosis-card.warn {
  border-left-color: var(--warn-border);
}

.diagnosis-card.danger {
  border-left-color: var(--danger-border);
}

.diagnosis-headline {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.4;
}

.diagnosis-detail {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.btn-primary {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
  color: var(--brand-on);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform var(--dur-fast) var(--ease-ui), background-color var(--dur-fast) var(--ease-ui);
}

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

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

.btn-secondary {
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform var(--dur-fast) var(--ease-ui), background-color var(--dur-fast) var(--ease-ui);
}

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

.btn-danger-ghost {
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--danger-fg);
  border: 1px solid var(--danger-border);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.equation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.eq-cell {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: left;
  min-height: 58px;
  border: 1px solid transparent;
  transition: border-color var(--dur-fast) var(--ease-ui);
}

.eq-cell:hover {
  border-color: var(--brand-primary);
}

.eq-k {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.eq-v {
  font-size: 16px;
  font-weight: 800;
  margin-top: 2px;
}

.leak-chart-svg,
.debt-timeline-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-label-main {
  font-size: 12.5px;
  font-weight: 700;
  fill: var(--text-primary);
}

.chart-label-sub {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-secondary);
}

.chart-track {
  fill: var(--bg-subtle);
}

.chart-val-main {
  font-size: 12px;
  font-weight: 800;
  fill: var(--text-primary);
}

.chart-val-sub {
  font-size: 11px;
  font-weight: 700;
  fill: var(--safe-fg);
}

.chart-val-sub.warn {
  fill: var(--warn-fg);
}

.chart-val-sub.danger {
  fill: var(--danger-fg);
}

.chart-grid-line {
  stroke: var(--border-hairline);
  stroke-width: 1;
}

.chart-axis-text {
  font-size: 11px;
  font-weight: 600;
  fill: var(--text-secondary);
}

.chart-callout {
  font-size: 11.5px;
  font-weight: 800;
  fill: var(--brand-primary);
  paint-order: stroke;
  stroke: var(--bg-surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 12px;
  gap: 4px;
}

.seg-btn {
  min-height: 44px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.25;
  padding: 4px 6px;
  transition: background-color var(--dur-fast) var(--ease-ui), color var(--dur-fast) var(--ease-ui);
}

.seg-btn small {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
}

.seg-btn.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.10);
}

.kpi-trio {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kpi-mini {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.kpi-mini-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.kpi-mini-val {
  font-size: 16px;
  font-weight: 800;
  margin-top: 3px;
}

.slider-block {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.range-input {
  width: 100%;
  height: 36px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.pill-btn.active {
  background: var(--brand-primary);
  color: var(--brand-on);
  border-color: var(--brand-primary);
}

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

.debt-row,
.budget-row,
.tx-row,
.goal-row,
.alert-row {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.row-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.rank-tag {
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-primary);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.row-title {
  font-size: 15px;
  font-weight: 700;
}

.row-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.row-amount {
  font-size: 16px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  overflow: hidden;
  border: 1px solid var(--border-hairline);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand-primary);
  transition: width 220ms var(--ease-ui);
}

.progress-fill.warn {
  background: repeating-linear-gradient(45deg, #E69F00 0 6px, #B45309 6px 9px);
}

.progress-fill.danger {
  background: repeating-linear-gradient(-45deg, #E11D48 0 6px, #881337 6px 9px);
}

.stepper-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.step-btn {
  min-width: 44px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
  font-size: 14px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-val {
  min-width: 78px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
}

.inline-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.inline-tag.business {
  background: var(--warn-bg);
  color: var(--warn-fg);
  border: 1px solid var(--warn-border);
}

.inline-tag.reimbursed {
  background: var(--safe-bg);
  color: var(--safe-fg);
  border: 1px solid var(--safe-border);
}

.discipline-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 13px;
}

.bottom-glass-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  height: var(--nav-height);
  padding: 6px;
  border-radius: 22px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.45);
  -webkit-backdrop-filter: blur(24px) saturate(1.45);
  border: 1px solid var(--border-hairline);
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.12);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}

.nav-item {
  min-height: 48px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  position: relative;
  transition: color var(--dur-fast) var(--ease-ui), background-color var(--dur-fast) var(--ease-ui);
}

.nav-item.active {
  color: var(--brand-primary);
  background: var(--brand-soft);
}

.nav-badge-count {
  position: absolute;
  top: 4px;
  right: calc(50% - 18px);
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger-border);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fab-quick-add {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height) + max(20px, env(safe-area-inset-bottom)));
  z-index: 38;
  min-height: 52px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--brand-primary);
  color: var(--brand-on);
  font-size: 15px;
  font-weight: 800;
  box-shadow: var(--shadow-fab);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform var(--dur-fast) var(--ease-ui), background-color var(--dur-fast) var(--ease-ui);
}

.fab-quick-add:hover {
  background: var(--brand-primary-hover);
}

.fab-quick-add:active {
  transform: scale(0.96);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

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

.sheet-panel {
  width: 100%;
  max-width: 540px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 12px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-sheet);
  animation: sheetRise 230ms var(--ease-sheet);
}

@keyframes sheetRise {
  from {
    opacity: 0;
    transform: translateY(28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sheet-grabber {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 0 auto 12px;
}

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

.sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
}

.amount-display {
  background: var(--bg-subtle);
  border: 2px solid var(--brand-primary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.amount-currency {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
}

.amount-input-lg {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 32px;
  font-weight: 800;
  text-align: right;
  outline: none;
}

.cat-chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.cat-chip {
  min-height: 48px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-hairline);
  background: var(--bg-surface);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.cat-chip.selected {
  background: var(--brand-soft);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.key-btn {
  min-height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 90ms var(--ease-ui), background-color 90ms var(--ease-ui);
}

.key-btn:active {
  transform: scale(0.96);
  background: var(--border-hairline);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.text-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-hairline);
  background: var(--bg-surface);
  font-size: 15px;
}

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

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.toggle-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--brand-primary);
}

.toast {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--text-primary);
  color: var(--bg-surface);
  padding: 8px 14px 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  max-width: calc(100vw - 32px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toast-undo-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--brand-primary);
  color: var(--brand-on);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.pace-row {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pace-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.pace-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
  overflow: visible;
}

.pace-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand-primary);
}

.pace-fill.warn {
  background: repeating-linear-gradient(45deg, #E69F00 0 6px, #B45309 6px 9px);
}

.pace-fill.danger {
  background: repeating-linear-gradient(-45deg, #E11D48 0 6px, #881337 6px 9px);
}

.pace-today-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--text-primary);
  border-radius: 2px;
}

.toast[hidden] {
  display: none;
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-secondary);
  font-size: 14px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

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

@media (min-width: 960px) {
  .app-shell {
    flex-direction: row;
  }

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px 14px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-hairline);
    gap: 18px;
  }

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

  .sidebar-btn {
    min-height: 46px;
    padding: 0 14px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-secondary);
    transition: background-color var(--dur-fast) var(--ease-ui), color var(--dur-fast) var(--ease-ui);
  }

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

  .sidebar-btn.active {
    background: var(--brand-soft);
    color: var(--brand-primary);
  }

  .sidebar-btn-left {
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }

  .workspace-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  .top-glass-bar {
    padding: 12px 28px;
  }

  .top-glass-bar .brand-lockup {
    display: flex;
  }

  .top-glass-bar .brand-mark,
  .top-glass-bar .brand-title {
    display: none;
  }

  .top-glass-bar .brand-sub {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
  }

  .main-content {
    padding: 24px 28px 48px;
    gap: 20px;
  }

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

  .equation-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .bottom-glass-nav,
  .fab-quick-add {
    display: none;
  }

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

  .sheet-panel {
    border-radius: 22px;
    padding: 20px 24px 24px;
  }

  .sheet-grabber {
    display: none;
  }
}

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