:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-raised: rgba(255, 255, 255, 0.9);
  --surface-muted: #e6ebf2;
  --text: #0d1117;
  --muted: #6b7280;
  --line: #e6ebf2;
  --line-strong: #cfd6e0;
  --accent: #2563ff;
  --accent-strong: #1649d8;
  --accent-soft: #eef4ff;
  --control-active: #0d1117;
  --control-active-text: #ffffff;
  --teal-ink: #0d1117;
  --ocean: #2563ff;
  --coral: #10d5c2;
  --amber: #a16207;
  --rose-soft: #fff1f2;
  --shadow: 0 24px 52px rgba(15, 23, 42, 0.09);
  --shadow-soft: 0 14px 30px rgba(15, 23, 42, 0.055);
  --radius: 8px;
  --tap: 46px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #101720;
  --surface-raised: rgba(16, 23, 32, 0.92);
  --surface-muted: #141d28;
  --text: #f8fafc;
  --muted: #9aa4b2;
  --line: #263240;
  --line-strong: #3a4655;
  --accent: #2563ff;
  --accent-strong: #a7baff;
  --accent-soft: #16264d;
  --control-active: #f8fafc;
  --control-active-text: #0d1117;
  --teal-ink: #f8fafc;
  --ocean: #2563ff;
  --coral: #10d5c2;
  --amber: #facc15;
  --rose-soft: #35151c;
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 14px 32px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0%, #f8f9fc 50%, #f1f4f9 100%),
    var(--bg);
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.splash-active {
  overflow: hidden;
}

.launch-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  min-height: 100svh;
  min-height: 100dvh;
  display: block;
  padding: max(48px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(78px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  color: #ffffff;
  background:
    radial-gradient(ellipse at 4% 50%, rgba(37, 99, 255, 0.48), transparent 34%),
    radial-gradient(ellipse at 96% 54%, rgba(16, 213, 194, 0.42), transparent 32%),
    linear-gradient(180deg, #06101f 0%, #030a16 48%, #020814 100%);
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 460ms ease,
    transform 460ms ease,
    visibility 460ms ease;
}

.launch-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

.launch-brand {
  position: absolute;
  top: clamp(350px, 47svh, 430px);
  left: 50%;
  width: min(560px, calc(100% - 56px));
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
}

.launch-brand img {
  display: block;
  width: min(440px, calc(100vw - 72px));
  max-width: 440px;
  height: auto;
  object-fit: contain;
  filter:
    drop-shadow(0 22px 40px rgba(16, 213, 194, 0.18))
    drop-shadow(0 18px 42px rgba(37, 99, 255, 0.18));
}

.launch-credit {
  position: absolute;
  left: 50%;
  bottom: max(42px, calc(6svh + env(safe-area-inset-bottom)));
  width: min(430px, calc(100% - 48px));
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
}

.launch-progress {
  position: absolute;
  left: 50%;
  bottom: max(92px, calc(13.9svh + env(safe-area-inset-bottom)));
  width: min(600px, 70vw);
  height: 11px;
  overflow: hidden;
  transform: translateX(-50%);
  background: rgba(137, 158, 195, 0.26);
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 0 28px rgba(16, 213, 194, 0.12);
}

.launch-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2563ff 0%, #1b88ff 48%, #10d5c2 100%);
  border-radius: inherit;
  box-shadow: 0 0 22px rgba(16, 213, 194, 0.62);
  transform: translateX(-100%);
  animation: launch-progress 1650ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes launch-progress {
  0% {
    transform: translateX(-100%);
  }

  72% {
    transform: translateX(-18%);
  }

  100% {
    transform: translateX(0);
  }
}

body,
button,
input,
select {
  font: inherit;
  touch-action: manipulation;
}

button {
  border: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

button:focus {
  outline: 0;
}

button:focus-visible {
  outline: 2px solid rgba(37, 99, 255, 0.38);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.1;
}

@media (prefers-reduced-motion: reduce) {
  .launch-screen,
  .launch-progress span {
    transition: none;
    animation: none;
  }

  .launch-progress span {
    transform: translateX(0);
  }
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(104px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0 14px;
  background: linear-gradient(180deg, rgba(246, 247, 251, 0.98), rgba(246, 247, 251, 0.78));
  backdrop-filter: blur(22px);
}

.topbar-actions {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

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

.brand-logo {
  display: block;
  width: min(224px, calc(100vw - 132px));
  height: auto;
  object-fit: contain;
}

.brand-logo-dark {
  display: none;
  width: min(188px, calc(100vw - 132px));
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: var(--radius);
  box-shadow: 0 14px 26px rgba(11, 92, 255, 0.18);
}

.brand-copy {
  min-width: 0;
}

h1 {
  overflow-wrap: anywhere;
  font-size: 1.82rem;
  font-weight: 950;
  line-height: 1.02;
  letter-spacing: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.brand-copy p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.app-badge {
  min-width: 64px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 950;
}

.theme-toggle {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-toggle .icon {
  width: 16px;
  height: 16px;
}

.app-main {
  display: grid;
  gap: 14px;
}

.app-screen {
  scroll-margin-top: 92px;
}

.app-card {
  background: var(--surface-raised);
  border: 1px solid rgba(232, 236, 243, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(20px);
}

.dashboard,
.expense-form-panel,
.expense-list-panel,
.data-panel {
  padding: 14px;
}

.section-header {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header.compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: 1.16rem;
  font-weight: 920;
  line-height: 1.15;
  letter-spacing: 0;
}

.month-controls {
  display: grid;
  grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap);
  align-items: center;
  gap: 8px;
}

.profile-switcher {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-switcher > p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.profile-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  background: var(--surface-muted);
  border: 1px solid rgba(232, 236, 243, 0.86);
  border-radius: var(--radius);
}

.profile-button {
  min-width: 0;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
  font-weight: 920;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.profile-button:active {
  transform: translateY(1px);
}

.profile-button span {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-strong);
  background: #fff;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 950;
}

.profile-button.active {
  color: var(--control-active-text);
  background: var(--control-active);
  box-shadow: 0 10px 20px rgba(5, 7, 17, 0.12);
}

.profile-button.active span {
  color: var(--control-active);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.icon-button,
.primary-button,
.secondary-button,
.danger-button,
.fab,
.tabbar-button {
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  font-weight: 880;
  letter-spacing: 0;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.icon-button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active,
.fab:active,
.tabbar-button:active {
  transform: translateY(1px);
}

.icon-button {
  width: var(--tap);
  color: var(--text);
  background: var(--surface-muted);
}

select,
input {
  width: 100%;
  min-height: var(--tap);
  color: var(--text);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

@supports (-webkit-touch-callout: none) {
  select,
  input {
    font-size: 16px;
  }
}

select {
  padding: 0 36px 0 12px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input {
  padding: 0 12px;
}

select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(11, 92, 255, 0.13);
}

.balance-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 255, 0.98)),
    #ffffff;
  border: 1px solid rgba(232, 236, 243, 0.98);
  border-radius: var(--radius);
  box-shadow: 0 22px 48px rgba(15, 23, 42, 0.08);
}

.balance-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--ocean), var(--coral));
}

.balance-card::after {
  content: none;
}

.balance-card-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.balance-label {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.balance-amount {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  max-width: 780px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 3.7rem;
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: 0;
}

.balance-result {
  max-width: 780px;
  margin-top: 9px;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 890;
  line-height: 1.28;
  letter-spacing: 0;
}

.balance-meta {
  position: relative;
  z-index: 1;
  min-height: 20px;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 760;
}

.balance-note {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  padding: 11px 12px;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid rgba(232, 236, 243, 0.82);
  border-radius: var(--radius);
  font-size: 0.92rem;
  font-weight: 850;
}

.avatar-stack {
  display: flex;
  flex: 0 0 auto;
}

.avatar-stack span {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: var(--text);
  border: 2px solid #ffffff;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 950;
}

.avatar-stack span + span {
  margin-left: -11px;
  color: #06101f;
  background: #dff8ff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.stat-cell {
  min-width: 0;
  padding: 13px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(232, 236, 243, 0.96);
  border-radius: var(--radius);
}

dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

dd {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 1.14rem;
  font-weight: 950;
}

.split-meter {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(232, 236, 243, 0.96);
  border-radius: var(--radius);
}

.meter-track {
  display: flex;
  height: 10px;
  overflow: hidden;
  background: #e9eef7;
  border-radius: 999px;
}

.meter-fill.alex {
  width: 50%;
  background: var(--accent);
}

.meter-fill.wendee {
  width: 50%;
  background: var(--coral);
}

.meter-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.meter-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 999px;
}

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

.dot.wendee {
  background: var(--coral);
}

.settle-button {
  width: 100%;
  margin-top: 12px;
  min-height: 52px;
}

.home-credit {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
}

.primary-button {
  min-width: 0;
  padding: 0 16px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 26px rgba(11, 92, 255, 0.22);
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.danger-button {
  min-width: 0;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
}

.secondary-button {
  color: var(--text);
}

.secondary-button:hover {
  background: var(--accent-soft);
  border-color: rgba(11, 92, 255, 0.22);
}

.danger-button {
  color: #9f392b;
}

.danger-button:hover {
  background: var(--rose-soft);
  border-color: #f0c7be;
}

.workspace-grid {
  display: grid;
  gap: 14px;
}

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

.expense-form label,
.segmented-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

.amount-field {
  position: relative;
}

.amount-field input {
  padding-right: 44px;
}

.amount-field span {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  font-weight: 950;
  transform: translateY(-50%);
}

.split-hint {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 9px 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(37, 99, 255, 0.14);
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.25;
}

.segmented-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented-field legend {
  padding: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid rgba(232, 236, 243, 0.86);
  border-radius: var(--radius);
}

.segmented-control label {
  display: block;
  min-width: 0;
  color: var(--text);
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 900;
}

.segmented-control input:checked + span {
  color: var(--control-active-text);
  background: var(--control-active);
  box-shadow: 0 8px 16px rgba(5, 7, 17, 0.12);
}

.form-actions,
.data-action-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.count-pill {
  min-width: 36px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 950;
}

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

.empty-state {
  display: grid;
  min-height: 170px;
  place-items: center;
  padding: 22px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  font-weight: 800;
}

.expense-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(232, 236, 243, 0.98);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.035);
}

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

.expense-title {
  min-width: 0;
}

.expense-title h3 {
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 920;
  line-height: 1.23;
  letter-spacing: 0;
}

.expense-date {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.expense-amount {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 950;
  white-space: nowrap;
}

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

.meta-item {
  min-width: 0;
  padding: 10px;
  background: #f7f9fc;
  border: 1px solid #edf1f7;
  border-radius: var(--radius);
}

.meta-label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.meta-value {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 0.9rem;
  font-weight: 880;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  padding: 0 10px;
  color: var(--amber);
  background: #fff6dc;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 920;
}

.status-badge.settled {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

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

.fab {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 18;
  width: 58px;
  height: 58px;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 18px 34px rgba(11, 92, 255, 0.28);
}

.fab .icon {
  width: 24px;
  height: 24px;
}

.tabbar {
  position: fixed;
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 17;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: min(520px, calc(100% - 20px));
  margin: 0 auto;
  padding: 6px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(232, 236, 243, 0.92);
  border-radius: var(--radius);
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px);
}

.tabbar-button {
  min-width: 0;
  min-height: 50px;
  flex-direction: column;
  gap: 3px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 880;
}

.tabbar-button .icon {
  width: 19px;
  height: 19px;
}

.tabbar-button.active {
  color: var(--control-active-text);
  background: var(--control-active);
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: min(360px, calc(100vw - 28px));
  padding: 12px 14px;
  color: #fff;
  background: var(--text);
  border-radius: var(--radius);
  box-shadow: 0 18px 36px rgba(29, 39, 43, 0.24);
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (display-mode: standalone) {
  .app-shell {
    min-height: 100dvh;
    padding-top: max(18px, env(safe-area-inset-top));
  }

  .app-topbar {
    top: env(safe-area-inset-top);
  }

  .tabbar {
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .fab {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
}

html.is-standalone .app-shell {
  min-height: 100dvh;
  padding-top: max(18px, env(safe-area-inset-top));
}

html.is-standalone .app-topbar {
  top: env(safe-area-inset-top);
}

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 10px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .theme-toggle {
    width: 36px;
    padding: 0;
  }

  #themeToggleText {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .app-badge {
    min-width: 56px;
    padding-inline: 10px;
  }

  .dashboard,
  .expense-form-panel,
  .expense-list-panel,
  .data-panel {
    padding: 12px;
  }

  .balance-card {
    padding: 14px;
  }

  .balance-amount {
    font-size: 2.85rem;
  }

  .expense-topline {
    display: grid;
  }

  .expense-amount {
    white-space: normal;
  }
}

@media (min-width: 720px) {
  .app-shell {
    padding: 24px 22px 36px;
  }

  .app-topbar {
    position: static;
    min-height: 76px;
    padding-bottom: 18px;
    background: transparent;
    backdrop-filter: none;
  }

  .app-main {
    gap: 16px;
  }

  .dashboard,
  .expense-form-panel,
  .expense-list-panel,
  .data-panel {
    padding: 18px;
  }

  .section-header {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    align-items: start;
  }

  .section-header.compact {
    display: flex;
  }

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

  .balance-card {
    padding: 22px;
  }

  .balance-amount {
    font-size: 4.45rem;
  }

  .workspace-grid {
    grid-template-columns: minmax(308px, 0.75fr) minmax(0, 1.25fr);
    align-items: start;
  }

  .expense-list-panel {
    grid-row: span 2;
  }

  .data-panel {
    grid-column: 1;
  }

  .expense-meta-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .expense-actions {
    grid-template-columns: repeat(2, 132px);
    justify-content: end;
  }

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

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

  .fab,
  .tabbar {
    display: none;
  }

  .toast {
    bottom: 22px;
  }
}

@media (min-width: 1040px) {
  .app-main {
    grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
    align-items: start;
  }

  .dashboard {
    position: sticky;
    top: 22px;
  }

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

  .expense-list-panel {
    grid-row: auto;
  }

  .data-panel {
    grid-column: auto;
  }
}

html[data-theme="dark"] {
  background: var(--bg);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(180deg, #0d1117 0%, #101720 48%, #0d1117 100%),
    var(--bg);
}

:root[data-theme="dark"] .app-topbar {
  background: linear-gradient(180deg, rgba(13, 17, 23, 0.98), rgba(13, 17, 23, 0.76));
}

:root[data-theme="dark"] .app-card {
  background: var(--surface-raised);
  border-color: rgba(35, 48, 71, 0.96);
}

:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .secondary-button,
:root[data-theme="dark"] .danger-button {
  background: #111827;
  border-color: var(--line);
  color: var(--text);
}

:root[data-theme="dark"] .theme-toggle:hover,
:root[data-theme="dark"] .secondary-button:hover {
  background: #151e31;
  border-color: rgba(109, 141, 255, 0.36);
}

:root[data-theme="dark"] .brand-logo-light {
  display: none;
}

:root[data-theme="dark"] .brand-logo-dark {
  display: block;
}

:root[data-theme="dark"] .app-badge,
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .count-pill,
:root[data-theme="dark"] .status-badge.settled {
  color: var(--text);
  background: #111827;
  border-color: var(--line);
}

:root[data-theme="dark"] select,
:root[data-theme="dark"] input {
  color: var(--text);
  background: rgba(15, 23, 42, 0.96);
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

:root[data-theme="dark"] input::placeholder {
  color: #64748b;
}

:root[data-theme="dark"] .profile-toggle,
:root[data-theme="dark"] .segmented-control {
  background: #090d16;
  border-color: var(--line);
}

:root[data-theme="dark"] .profile-button,
:root[data-theme="dark"] .segmented-control label {
  color: var(--muted);
}

:root[data-theme="dark"] .profile-button span {
  color: var(--text);
  background: #151e31;
}

:root[data-theme="dark"] .profile-button.active,
:root[data-theme="dark"] .segmented-control input:checked + span {
  color: var(--control-active-text);
  background: var(--control-active);
  box-shadow: 0 10px 22px rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .profile-button.active span {
  color: #0d1117;
  background: #ffffff;
}

:root[data-theme="dark"] .split-hint {
  color: #a7baff;
  background: rgba(37, 99, 255, 0.16);
  border-color: rgba(109, 141, 255, 0.28);
}

:root[data-theme="dark"] .balance-card {
  background:
    linear-gradient(180deg, rgba(13, 17, 27, 0.98), rgba(7, 10, 17, 0.98)),
    #070a11;
  border-color: rgba(35, 43, 58, 0.98);
  box-shadow: 0 24px 58px rgba(0, 0, 0, 0.38);
}

:root[data-theme="dark"] .avatar-stack span {
  color: #0d1117;
  background: rgba(255, 255, 255, 0.94);
  border-color: #070a11;
}

:root[data-theme="dark"] .avatar-stack span + span {
  background: #b9f5ff;
}

:root[data-theme="dark"] .stat-cell,
:root[data-theme="dark"] .split-meter,
:root[data-theme="dark"] .expense-card {
  background: rgba(13, 18, 28, 0.82);
  border-color: rgba(35, 48, 71, 0.94);
}

:root[data-theme="dark"] .meter-track {
  background: #1e293b;
}

:root[data-theme="dark"] .meta-item {
  background: #090d16;
  border-color: #1b2434;
}

:root[data-theme="dark"] .status-badge {
  color: #fde68a;
  background: rgba(120, 83, 18, 0.34);
}

:root[data-theme="dark"] .empty-state {
  color: var(--muted);
  background: rgba(15, 23, 42, 0.54);
  border-color: var(--line-strong);
}

:root[data-theme="dark"] .danger-button {
  color: #fda4af;
}

:root[data-theme="dark"] .danger-button:hover {
  background: var(--rose-soft);
  border-color: #7f1d1d;
}

:root[data-theme="dark"] .fab,
:root[data-theme="dark"] .primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 16px 34px rgba(109, 141, 255, 0.28);
}

:root[data-theme="dark"] .primary-button:hover {
  background: #5578ff;
}

:root[data-theme="dark"] .tabbar {
  background: rgba(8, 13, 26, 0.9);
  border-color: rgba(35, 48, 71, 0.9);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.36);
}

/* Native-app dashboard, inspired by the Duolio mobile mockup. */
body {
  background:
    radial-gradient(circle at 50% -8%, rgba(37, 99, 255, 0.06), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #fbfcff 48%, #f7f9fc 100%),
    var(--bg);
}

.app-shell {
  width: min(900px, 100%);
  padding: max(22px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(118px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.app-topbar {
  position: static;
  min-height: 92px;
  padding: 0 0 18px;
  background: transparent;
  backdrop-filter: none;
}

.brand-lockup {
  gap: 14px;
}

.brand-logo {
  width: min(244px, calc(100vw - 132px));
}

.brand-logo-dark {
  width: min(202px, calc(100vw - 132px));
}

.brand-mark {
  width: 70px;
  height: 88px;
  flex-basis: 70px;
  border-radius: 0;
  object-fit: contain;
  box-shadow: none;
}

h1 {
  font-size: 2.32rem;
  line-height: 0.95;
}

.brand-copy p {
  margin-top: 7px;
  color: #5f6785;
  font-size: 1.02rem;
  font-weight: 820;
}

.app-badge {
  display: none;
}

.theme-toggle {
  width: 58px;
  height: 58px;
  min-height: 58px;
  display: inline-grid;
  place-items: center;
  gap: 0;
  padding: 0;
  position: relative;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  border-color: #dce3ee;
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(13, 17, 23, 0.08);
}

.theme-toggle .icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
}

.theme-toggle .theme-icon {
  color: #2563ff;
}

:root[data-theme="dark"] .theme-toggle .theme-icon {
  color: #10d5c2;
}

#themeToggleText {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.dashboard {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.dashboard > .section-header {
  display: block;
  margin-bottom: 16px;
}

.dashboard > .section-header > div:first-child {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.month-controls {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  gap: 8px;
  min-height: 68px;
  padding: 0;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid #dce3ee;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(13, 17, 23, 0.055);
}

.month-controls .icon-button {
  width: 52px;
  min-height: 66px;
  color: var(--text);
  background: transparent;
}

.month-controls select {
  min-height: 66px;
  padding: 0 34px;
  text-align: center;
  color: var(--text);
  background-color: transparent;
  border: 0;
  box-shadow: none;
  font-size: 1.28rem;
  font-weight: 950;
}

.profile-switcher {
  margin: 0 0 18px;
}

.profile-switcher > p {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.profile-toggle {
  min-height: 74px;
  gap: 10px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.8);
  border-color: #dce3ee;
  box-shadow: 0 16px 36px rgba(13, 17, 23, 0.055);
}

.profile-button {
  min-height: 64px;
  border-radius: 8px;
  font-size: 1.08rem;
  font-weight: 920;
}

.profile-button span {
  width: 34px;
  height: 34px;
  color: var(--accent);
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 99, 255, 0.12);
}

.profile-button.active {
  color: #ffffff;
  background: linear-gradient(135deg, #2563ff, #1475ff);
  box-shadow: 0 18px 34px rgba(37, 99, 255, 0.28);
}

.balance-card {
  padding: 22px;
  color: var(--text);
  background:
    radial-gradient(circle at 78% 50%, rgba(37, 99, 255, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86)),
    #ffffff;
  border: 1px solid #dce3ee;
  box-shadow: 0 18px 44px rgba(13, 17, 23, 0.07);
}

.balance-card::before {
  content: none;
}

.balance-card-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(108px, 34%);
  align-items: center;
  gap: 12px;
}

.balance-copy {
  min-width: 0;
}

.balance-label {
  min-height: 34px;
  padding: 0 14px;
  color: var(--accent);
  background: rgba(37, 99, 255, 0.08);
  border: 1px solid rgba(37, 99, 255, 0.12);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.balance-amount {
  margin-top: 26px;
  color: var(--text);
  font-size: 4.25rem;
  line-height: 0.92;
}

.balance-result {
  max-width: 300px;
  color: #5f6785;
  font-size: 1.38rem;
  font-weight: 920;
  line-height: 1.28;
}

.balance-visual {
  position: relative;
  min-height: 172px;
  display: grid;
  place-items: center;
}

.balance-visual img {
  width: min(128px, 100%);
  height: auto;
  filter: drop-shadow(0 22px 24px rgba(16, 213, 194, 0.16));
}

.balance-visual::after {
  content: "";
  position: absolute;
  right: 8%;
  bottom: 15px;
  width: 128px;
  height: 22px;
  background: radial-gradient(ellipse, rgba(13, 17, 23, 0.14), transparent 68%);
}

.balance-visual .avatar-stack {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.avatar-stack span {
  color: #ffffff;
  background: var(--accent);
  border-color: #ffffff;
}

.avatar-stack span + span {
  color: #0d1117;
  background: #bdf7ef;
}

.balance-card .split-meter {
  margin-top: 18px;
  padding: 0;
  background: transparent;
  border: 0;
}

.balance-card .meter-track {
  height: 10px;
  gap: 6px;
  background: transparent;
  border-radius: 999px;
}

.balance-card .meter-fill {
  border-radius: 999px;
}

.balance-card .meter-legend {
  margin-top: 10px;
  color: #5f6785;
  font-size: 1rem;
  font-weight: 860;
}

.meter-legend strong {
  color: var(--text);
  font-weight: 950;
}

.balance-note,
.balance-meta {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.stats-grid {
  gap: 12px;
  margin-top: 20px;
}

.stat-cell {
  min-height: 88px;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-color: #dce3ee;
  box-shadow: 0 14px 30px rgba(13, 17, 23, 0.055);
}

.stat-icon {
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: #eaf1ff;
  border-radius: 999px;
  font-size: 1.35rem;
  font-weight: 950;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.wendee,
.stat-icon.split {
  color: #0fbfac;
  background: #dffbf7;
}

dt {
  font-size: 0.98rem;
  line-height: 1.15;
}

dd {
  margin-top: 6px;
  font-size: 1.35rem;
}

.share-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 0.98rem;
  line-height: 1.2;
}

.share-breakdown span {
  white-space: nowrap;
}

.recent-panel {
  margin-top: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.92);
  border-color: #dce3ee;
  box-shadow: 0 18px 44px rgba(13, 17, 23, 0.07);
}

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

.recent-header h2 {
  font-size: 1.25rem;
  font-weight: 950;
}

.text-button {
  min-height: 34px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 900;
}

.recent-expense-list {
  display: grid;
}

.recent-expense {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto 30px 24px;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.recent-expense:last-child {
  border-bottom: 0;
}

.recent-icon,
.recent-person {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 950;
}

.recent-icon {
  width: 52px;
  height: 52px;
  color: var(--accent);
  background: #eaf1ff;
}

.recent-icon.wendee {
  color: #0fbfac;
  background: #dffbf7;
}

.recent-icon svg {
  width: 27px;
  height: 27px;
}

.recent-copy {
  min-width: 0;
}

.recent-copy h3 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 950;
}

.recent-copy p {
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #5f6785;
  font-size: 0.88rem;
  font-weight: 780;
}

.recent-copy .dot {
  margin-inline: 6px;
  vertical-align: middle;
}

.recent-amount {
  color: var(--text);
  font-size: 1rem;
  font-weight: 950;
  white-space: nowrap;
}

.recent-person {
  width: 30px;
  height: 30px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.86rem;
}

.recent-person.wendee {
  color: #0d1117;
  background: #bdf7ef;
}

.recent-open {
  width: 24px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  color: #74809d;
  background: transparent;
}

.recent-open .icon {
  width: 22px;
  height: 22px;
}

.empty-state.compact {
  min-height: 88px;
  background: transparent;
  border: 0;
}

.settle-button {
  margin-top: 16px;
}

.fab {
  right: max(22px, env(safe-area-inset-right));
  bottom: calc(96px + env(safe-area-inset-bottom));
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #2563ff, #10d5c2);
  box-shadow: 0 22px 34px rgba(37, 99, 255, 0.28);
}

.fab .icon {
  width: 31px;
  height: 31px;
}

.tabbar {
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(760px, calc(100% - 28px));
  min-height: 86px;
  gap: 0;
  padding: 8px;
  background: rgba(255, 255, 255, 0.92);
  border-color: #dce3ee;
  box-shadow: 0 22px 50px rgba(13, 17, 23, 0.14);
}

.tabbar-button {
  min-height: 70px;
  color: #74809d;
  font-size: 0.82rem;
  font-weight: 860;
}

.tabbar-button .icon {
  width: 26px;
  height: 26px;
}

.tabbar-button.active {
  color: var(--accent);
  background: transparent;
}

.workspace-grid {
  margin-top: 18px;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 50% 0%, rgba(37, 99, 255, 0.16), transparent 34%),
    linear-gradient(180deg, #0d1117 0%, #101720 54%, #0d1117 100%),
    var(--bg);
}

:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .month-controls,
:root[data-theme="dark"] .profile-toggle,
:root[data-theme="dark"] .balance-card,
:root[data-theme="dark"] .stat-cell,
:root[data-theme="dark"] .recent-panel {
  background: rgba(16, 23, 32, 0.86);
  border-color: #263240;
}

:root[data-theme="dark"] .month-controls select,
:root[data-theme="dark"] .month-controls .icon-button {
  color: var(--text);
  background-color: transparent;
}

:root[data-theme="dark"] .balance-card {
  background:
    radial-gradient(circle at 78% 50%, rgba(16, 213, 194, 0.1), transparent 34%),
    linear-gradient(180deg, rgba(16, 23, 32, 0.94), rgba(13, 17, 23, 0.94)),
    #0d1117;
}

:root[data-theme="dark"] .balance-result,
:root[data-theme="dark"] .brand-copy p,
:root[data-theme="dark"] .recent-copy p,
:root[data-theme="dark"] .balance-card .meter-legend {
  color: #9aa4b2;
}

:root[data-theme="dark"] .stat-icon,
:root[data-theme="dark"] .recent-icon {
  background: #16264d;
}

:root[data-theme="dark"] .stat-icon.wendee,
:root[data-theme="dark"] .stat-icon.split,
:root[data-theme="dark"] .recent-icon.wendee {
  background: rgba(16, 213, 194, 0.16);
}

:root[data-theme="dark"] .tabbar {
  background: rgba(16, 23, 32, 0.9);
  border-color: #263240;
}

@media (max-width: 520px) {
  .app-shell {
    padding: max(22px, env(safe-area-inset-top)) 26px calc(118px + env(safe-area-inset-bottom));
  }

  .app-topbar {
    min-height: 82px;
    padding-bottom: 12px;
  }

  .brand-logo {
    width: min(206px, calc(100vw - 128px));
  }

  .brand-logo-dark {
    width: min(178px, calc(100vw - 128px));
  }

  .brand-mark {
    width: 58px;
    height: 72px;
    flex-basis: 58px;
  }

  h1 {
    font-size: 1.96rem;
  }

  .brand-copy p {
    margin-top: 4px;
    font-size: 0.88rem;
  }

  .theme-toggle {
    width: 52px;
    height: 52px;
    min-height: 52px;
  }

  .dashboard > .section-header {
    margin-bottom: 14px;
  }

  .month-controls {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    min-height: 60px;
  }

  .month-controls select,
  .month-controls .icon-button {
    min-height: 58px;
  }

  .month-controls .icon-button {
    width: 48px;
  }

  .month-controls select {
    padding-inline: 24px;
    font-size: 1.16rem;
  }

  .profile-switcher {
    margin-bottom: 14px;
  }

  .profile-toggle {
    min-height: 64px;
    padding: 4px;
  }

  .profile-button {
    min-height: 54px;
    gap: 7px;
    font-size: 0.98rem;
  }

  .profile-button span {
    width: 30px;
    height: 30px;
  }

  .balance-card {
    padding: 16px;
  }

  .balance-card-top {
    grid-template-columns: minmax(0, 1fr) 102px;
  }

  .balance-label {
    min-height: 30px;
    padding-inline: 12px;
    font-size: 0.74rem;
  }

  .balance-amount {
    margin-top: 13px;
    font-size: 3rem;
  }

  .balance-result {
    font-size: 1rem;
  }

  .balance-visual {
    min-height: 106px;
  }

  .balance-visual img {
    width: 82px;
  }

  .balance-visual::after {
    width: 86px;
    bottom: 8px;
  }

  .balance-card .split-meter {
    margin-top: 12px;
  }

  .balance-card .meter-track {
    height: 8px;
  }

  .balance-card .meter-legend {
    margin-top: 7px;
    font-size: 0.82rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
  }

  .stat-cell {
    grid-template-columns: 40px minmax(0, 1fr);
    min-height: 66px;
    gap: 9px;
    padding: 9px;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 1.12rem;
  }

  .stat-icon svg {
    width: 21px;
    height: 21px;
  }

  dt {
    font-size: 0.74rem;
  }

  dd {
    margin-top: 4px;
    font-size: 1.06rem;
  }

  .recent-panel {
    margin-top: 14px;
    padding: 12px;
  }

  .recent-header {
    margin-bottom: 4px;
  }

  .recent-header h2 {
    font-size: 1.12rem;
  }

  .recent-expense {
    grid-template-columns: 38px minmax(0, 1fr) auto 24px 16px;
    gap: 5px;
    padding: 9px 0;
  }

  .recent-icon {
    width: 38px;
    height: 38px;
  }

  .recent-icon svg {
    width: 23px;
    height: 23px;
  }

  .recent-copy h3,
  .recent-amount {
    font-size: 0.84rem;
  }

  .recent-copy p {
    margin-top: 4px;
    font-size: 0.68rem;
  }

  .recent-person {
    width: 24px;
    height: 24px;
    font-size: 0.78rem;
  }

  .fab {
    right: max(32px, env(safe-area-inset-right));
    bottom: calc(88px + env(safe-area-inset-bottom));
    width: 66px;
    height: 66px;
  }

  .tabbar {
    left: max(26px, env(safe-area-inset-left));
    right: max(26px, env(safe-area-inset-right));
    width: min(760px, calc(100% - 52px));
    min-height: 78px;
    padding: 7px;
  }

  .tabbar-button {
    min-height: 62px;
    font-size: 0.76rem;
  }

  .tabbar-button .icon {
    width: 24px;
    height: 24px;
  }

  .settle-button {
    margin-top: 76px;
  }
}

@media (max-width: 365px) {
  .app-shell {
    padding-inline: 16px;
  }

  .balance-card-top {
    grid-template-columns: 1fr;
  }

  .balance-visual {
    display: none;
  }

  .recent-expense {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }

  .recent-person,
  .recent-open {
    display: none;
  }

  .tabbar {
    left: max(14px, env(safe-area-inset-left));
    right: max(14px, env(safe-area-inset-right));
    width: min(760px, calc(100% - 28px));
  }
}

/* Keep the app background continuous through the bottom mobile safe area. */
html {
  background: #f7f9fc;
}

body {
  background-color: #f7f9fc;
  background-attachment: fixed;
}

:root[data-theme="dark"] html {
  background: #0d1117;
}

:root[data-theme="dark"] body {
  background-color: #0d1117;
  background:
    linear-gradient(180deg, #0d1117 0, #0d1117 132px, #101720 54%, #0d1117 100%);
  background-attachment: fixed;
}

.tabbar {
  bottom: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
}

@media (max-width: 760px) {
  .app-shell {
    padding-bottom: calc(116px + env(safe-area-inset-bottom));
  }

  .tabbar {
    left: 0;
    right: 0;
    width: 100%;
    min-height: calc(78px + env(safe-area-inset-bottom));
  }

  .fab {
    bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

.month-controls select {
  text-align-last: center;
}

.secondary-button:disabled {
  opacity: 0.62;
}

@media (max-width: 760px) {
  .dashboard > .section-header {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .dashboard > .section-header .month-controls {
    width: 100%;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
  }

  .month-controls select {
    min-width: 0;
    width: 100%;
    justify-self: stretch;
    text-align: center;
    text-align-last: center;
  }

  .balance-card-top {
    grid-template-columns: minmax(0, 1fr) minmax(92px, 31%);
  }

  .balance-result {
    max-width: min(100%, 360px);
    overflow-wrap: normal;
    text-wrap: balance;
  }
}

@media (max-width: 385px) {
  .dashboard > .section-header .month-controls {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
  }

  .month-controls select {
    padding-inline: 12px;
    font-size: 1.04rem;
  }

  .balance-card-top {
    grid-template-columns: 1fr;
  }

  .balance-result {
    max-width: 100%;
  }
}
