:root {
  color-scheme: dark;
  --bg: #0b0b0b;
  --surface: #171717;
  --navigation: #111;
  --line: #3e3e3e;
  --selected: #333;
  --text: #f5f5f5;
  --muted: #b5b5b5;
  --accent: #f1f1f1;
  font-family: Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { overscroll-behavior: none; }
h1, h2, p, dl, dd { margin: 0; }
button, input, select { font: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  background: var(--bg);
}
.app-header {
  display: flex;
  flex: none;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 39px; border-radius: 12px; background: white; color: var(--bg); font-weight: 800; }
.brand-name { font-size: 1.1875rem; font-weight: 700; }
.icon { width: 24px; height: 24px; display: block; }
.button.top-link { border: 0; color: var(--muted); font-size: .8125rem; }
.top-link .icon { width: 20px; height: 20px; opacity: .75; }
#main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left));
  scrollbar-width: thin;
}
#main:focus { outline: none; }
.app-nav {
  flex: none;
  display: flex;
  background: var(--navigation);
  padding: 0 8px env(safe-area-inset-bottom);
}
.app-nav .nav-tab {
  flex: 1;
  min-height: 80px;
  border: 0;
  border-radius: 16px;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  letter-spacing: .04em;
}
.nav-tab[aria-current] { color: var(--text); }
.nav-indicator { display: grid; place-items: center; width: 56px; height: 32px; border-radius: 16px; }
.nav-tab[aria-current] .nav-indicator { background: #353535; }
.nav-tab:not([aria-current]) .icon { opacity: .8; }

.page-title { font-size: 2rem; letter-spacing: -.025em; font-weight: 700; line-height: 1.15; margin-bottom: 14px; }
.section-title { font-size: 1.375rem; line-height: 1.22; font-weight: 700; }
.muted { color: var(--muted); font-size: .8125rem; line-height: 1.4; }
.card { background: var(--surface); border-radius: 24px; padding: 16px; }
.card.outlined { border: 1px solid var(--line); border-radius: 18px; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: grid; gap: 14px; }
.block { width: 100%; }
.button {
  border: 1px solid var(--line);
  border-radius: 24px;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  font-size: .9375rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.button:active { background: var(--selected); }
.button.primary:active { background: #d5d5d5; }
.button:disabled { opacity: .45; cursor: default; }
@media (hover: hover) {
  .button:not(:disabled):hover { background: #ffffff0b; }
  .button.primary:not(:disabled):hover { background: #ddd; }
}

label.field { display: block; position: relative; min-width: 0; --field-bg: var(--bg); }
.card label.field { --field-bg: var(--surface); }
.field-caption {
  position: absolute;
  z-index: 1;
  top: 0;
  left: 11px;
  max-width: calc(100% - 22px);
 -transform: translateY(-50%);
  color: var(--muted);
  background: var(--field-bg);
  padding-inline: 4px;
  font-size: .8125rem;
  white-space: nowrap;
}
.field input, input.field {
  width: 100%;
  min-width: 0;
  min-height: 56px;
  border: 1px solid #727272;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 1.0625rem;
  padding: 12px;
}
input::placeholder { color: var(--muted); opacity: .85; }
.field input:focus, input.field:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.select-field { display: grid; gap: 6px; }
.field-label { font-size: .875rem; font-weight: 700; }
.select-control { display: flex; position: relative; }
.select-control select { display: block; width: 100%; appearance: none; text-align: start; padding-inline-end: 42px; }
.select-control option { background: #272727; color: var(--text); }
.select-control .icon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; pointer-events: none; }
.factor-field .field-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.factor-field .icon { right: auto; left: 13px; }
.factor-field select { padding-inline-start: 37px; padding-inline-end: 12px; }
.profile-form { margin-top: 22px; gap: 18px; }
.profile-form .card .button, .profile-form .card .muted { margin-top: 8px; }
.profile-form .date-button { justify-content: center; }
.date-button .icon { width: 20px; height: 20px; }
.profile-form .form-error { margin-top: -4px; }
.subtitle { margin-top: -6px; }
.home-date { margin-top: -5px; margin-bottom: 20px; font-size: 1rem; }
#main[data-screen='home'] > .card { margin-bottom: 16px; }
#main[data-screen='home'] .card > .button { margin-top: 12px; }
.home-hero .hero-amount { display: flex; align-items: baseline; gap: 8px; margin: 12px 0 6px; }
.hero-amount strong { font-size: clamp(2rem, 8vw, 2.875rem); line-height: 1.05; overflow-wrap: anywhere; }
.hero-amount span { flex-shrink: 0; }
.card > .section-title + p:not(.hero-amount) { margin-top: 8px; }
.compact { gap: 7px; margin-top: 23px; }
.plan-projection { margin-top: 5px; }
.compact .button { margin-top: 7px; }
.form-error { font-size: .875rem; line-height: 1.4; color: var(--accent); }
.app-dialog { width: min(calc(100% - 42px), 420px); padding: 22px; margin: auto; background: #272727; color: var(--text); border: 1px solid var(--line); border-radius: 24px; }
.app-dialog::backdrop { background: rgb(0 0 0 / .68); }
.app-dialog .field { --field-bg: #272727; margin-top: 9px; }
.dialog-actions { justify-content: flex-end; flex-wrap: wrap; }
#toast { position: fixed; bottom: calc(92px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--accent); color: var(--surface); padding: 12px 18px; border-radius: 24px; font-size: .875rem; max-width: calc(100% - 28px); width: max-content; opacity: 0; pointer-events: none; z-index: 4; }
#toast.visible { opacity: 1; }

@media (min-width: 680px) {
  .app-shell { border-inline: 1px solid #222; }
}
