:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --card: rgba(255,255,255,.92);
  --text: #171717;
  --muted: #6e6e73;
  --line: rgba(0,0,0,.08);
  --green: #2d3e24;
  --lime: #dcfc75;
  --red: #b42318;
  --amber: #a15c00;
  --shadow: 0 14px 40px rgba(0,0,0,.07);
  --radius: 24px;
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { max-width: 1180px; margin: 0 auto; min-height: 100vh; padding: 0 18px calc(98px + var(--safe-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: calc(14px + env(safe-area-inset-top)) 2px 14px; backdrop-filter: saturate(180%) blur(20px); background: rgba(245,245,247,.82); }
.brand { font-size: 15px; font-weight: 800; letter-spacing: .11em; }
.subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 999px; background: #2f9e44; box-shadow: 0 0 0 4px rgba(47,158,68,.12); }
.status-dot.offline { background: #c92a2a; box-shadow: 0 0 0 4px rgba(201,42,42,.1); }
.ghost-button, .secondary-button, .primary-button, .danger-ghost, .danger-button { border: 0; border-radius: 999px; padding: 11px 16px; transition: transform .15s ease, opacity .15s ease, background .15s ease; }
.ghost-button:active, .secondary-button:active, .primary-button:active, .danger-ghost:active, .danger-button:active { transform: scale(.98); }
.ghost-button { background: rgba(255,255,255,.78); color: var(--green); font-weight: 700; }
.secondary-button { background: #fff; color: var(--green); border: 1px solid var(--line); font-weight: 650; }
.primary-button { background: var(--green); color: #fff; font-weight: 700; }
.danger-ghost { background: transparent; color: var(--red); border: 1px solid rgba(180,35,24,.2); }
.danger-button { background: var(--red); color: #fff; font-weight: 700; }
.wide { width: 100%; }
.view { display: none; animation: fadeIn .2s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: .2; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.hero-card { margin-top: 14px; border-radius: 32px; padding: 26px; background: linear-gradient(145deg, #21301b, #35492b); color: white; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.hero-card::after { content: ""; position: absolute; width: 250px; height: 250px; right: -90px; top: -130px; background: var(--lime); opacity: .12; filter: blur(2px); border-radius: 50%; }
.eyebrow { margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 750; }
.hero-card .eyebrow { color: rgba(255,255,255,.68); }
.hero-card h1 { font-size: clamp(38px, 9vw, 64px); margin: 4px 0 10px; letter-spacing: -.04em; line-height: .95; }
.plan-health { display: inline-flex; align-items: center; border-radius: 999px; padding: 7px 11px; font-size: 12px; font-weight: 700; margin-top: 4px; }
.plan-health.good { background: rgba(220,252,117,.16); color: #edffc0; }
.plan-health.bad { background: rgba(255,180,170,.15); color: #ffd1cb; }
.plan-health.neutral { background: rgba(255,255,255,.1); color: white; }
.hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 28px; position: relative; z-index: 2; }
.hero-grid > div { padding: 14px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.07); border-radius: 18px; }
.hero-grid span { display: block; font-size: 11px; color: rgba(255,255,255,.7); margin-bottom: 6px; }
.hero-grid strong { font-size: 18px; }
.section-block { margin-top: 30px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 15px; }
.section-heading.compact { align-items: center; }
.section-heading h1, .section-heading h2 { margin: 0; letter-spacing: -.03em; }
.section-heading h1 { font-size: 32px; }
.section-heading h2 { font-size: 25px; }
.goal-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.goal-card, .allocation-card, .form-card, .settings-card, .history-item, .milestone-item { background: var(--card); border: 1px solid rgba(255,255,255,.7); box-shadow: 0 5px 22px rgba(0,0,0,.035); border-radius: var(--radius); }
.goal-card { padding: 18px; display: flex; gap: 14px; min-height: 280px; }
.goal-icon { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; border-radius: 15px; background: var(--bg); font-size: 23px; }
.goal-copy { min-width: 0; flex: 1; }
.goal-title-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.goal-title-row h3 { margin: 4px 0; font-size: 19px; }
.pill { display: inline-flex; align-items: center; white-space: nowrap; padding: 6px 9px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 10px; font-weight: 700; }
.progress-track { height: 9px; border-radius: 999px; background: #ececef; overflow: hidden; margin: 18px 0; }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--green), #5f7d4d); transition: width .4s ease; }
.metric-row, .highlight-row, .allocation-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.metric-row { padding: 8px 0; color: var(--muted); font-size: 12px; }
.metric-row strong { color: var(--text); font-size: 13px; }
.highlight-row { margin-top: 10px; padding: 13px 0 0; border-top: 1px solid var(--line); font-size: 12px; }
.highlight-row strong { font-size: 18px; color: var(--green); }
.allocation-card { padding: 18px 20px; }
.allocation-row { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.allocation-row:last-child { border-bottom: 0; }
.allocation-row.total { font-size: 16px; font-weight: 700; }
.allocation-row.gap strong.positive { color: #16803c; }
.allocation-row.gap strong.negative { color: var(--red); }
.milestone-list { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; }
.milestone-item { padding: 15px; }
.milestone-item .age { font-size: 12px; color: var(--muted); }
.milestone-item strong { display: block; font-size: 16px; margin: 7px 0 2px; }
.milestone-item small { color: var(--muted); font-size: 10px; line-height: 1.45; }
#planForm { display: grid; gap: 14px; }
.form-card { padding: 20px; }
.form-card h2 { margin: 0 0 16px; font-size: 19px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2,minmax(0,1fr)); }
.form-grid.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; }
input, select { width: 100%; border: 1px solid var(--line); background: #f9f9fb; color: var(--text); border-radius: 14px; padding: 13px 14px; outline: none; min-height: 46px; }
input:focus, select:focus { border-color: rgba(45,62,36,.45); box-shadow: 0 0 0 4px rgba(45,62,36,.08); }
.input-prefix, .input-suffix { position: relative; display: flex; align-items: center; }
.input-prefix > span, .input-suffix > span { color: var(--muted); font-size: 12px; white-space: nowrap; position: absolute; z-index: 1; }
.input-prefix > span { left: 13px; }
.input-prefix input { padding-left: 30px; }
.input-suffix > span { right: 13px; }
.input-suffix input { padding-right: 54px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin: 4px 0 24px; }
.form-actions .wide { width: auto; min-width: 220px; }
.info-banner { background: #eef5ea; color: #40523a; border-radius: 18px; padding: 14px 16px; font-size: 12px; line-height: 1.5; }
.history-list { display: grid; gap: 10px; margin-top: 14px; }
.history-item { padding: 16px; display: grid; grid-template-columns: 1.3fr repeat(4,1fr) auto; gap: 12px; align-items: center; }
.history-item .history-date strong { display: block; }
.history-item small { color: var(--muted); }
.history-metric span { display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px; }
.history-metric strong { font-size: 13px; }
.icon-button { border: 0; background: var(--bg); width: 34px; height: 34px; border-radius: 50%; color: var(--red); }
.utility-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.file-button { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.settings-card { padding: 4px 18px; margin-bottom: 14px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-row strong { display: block; font-size: 14px; }
.settings-row span { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; max-width: 650px; }
.settings-row select { width: auto; min-width: 120px; }
.danger-zone { padding: 18px; }
.danger-zone h2 { margin: 0 0 8px; font-size: 18px; color: var(--red); }
.danger-zone p { color: var(--muted); font-size: 12px; }
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 30; width: min(560px, calc(100% - 24px)); display: grid; grid-template-columns: repeat(4,1fr); gap: 5px; padding: 6px; border: 1px solid rgba(255,255,255,.8); background: rgba(255,255,255,.82); backdrop-filter: blur(24px) saturate(180%); border-radius: 24px; box-shadow: 0 12px 42px rgba(0,0,0,.14); }
.nav-button { border: 0; background: transparent; border-radius: 18px; min-height: 54px; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); }
.nav-button span { font-size: 18px; line-height: 1; }
.nav-button small { font-size: 9px; }
.nav-button.active { background: var(--green); color: white; }
dialog { border: 0; padding: 0; border-radius: 26px; width: min(520px, calc(100% - 32px)); box-shadow: 0 26px 80px rgba(0,0,0,.24); }
dialog::backdrop { background: rgba(0,0,0,.36); backdrop-filter: blur(5px); }
.dialog-card { padding: 24px; position: relative; }
.dialog-card h2 { margin-top: 0; }
.dialog-card ol { padding-left: 22px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.dialog-close { position: absolute; right: 14px; top: 14px; border: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--bg); font-size: 22px; }
.toast { position: fixed; left: 50%; transform: translate(-50%, 20px); bottom: calc(88px + var(--safe-bottom)); z-index: 60; background: #1e1e1f; color: white; border-radius: 999px; padding: 11px 16px; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; white-space: nowrap; max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
@media (max-width: 860px) {
  .goal-grid { grid-template-columns: 1fr; }
  .goal-card { min-height: auto; }
  .milestone-list { grid-template-columns: repeat(2,1fr); }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .history-item { grid-template-columns: 1fr 1fr; }
  .history-item .history-date { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .subtitle { display: none; }
  .hero-card { border-radius: 27px; padding: 22px 18px; }
  .hero-grid { grid-template-columns: 1fr; gap: 8px; }
  .section-heading { align-items: center; }
  .section-heading h1 { font-size: 28px; }
  .section-heading h2 { font-size: 22px; }
  .goal-card { padding: 15px; }
  .goal-icon { width: 40px; height: 40px; flex-basis: 40px; font-size: 20px; }
  .form-grid.two, .form-grid.three { grid-template-columns: 1fr; }
  .form-card { padding: 17px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .wide { width: 100%; }
  .milestone-list { grid-template-columns: 1fr 1fr; }
  .settings-row { align-items: flex-start; }
  .history-item { grid-template-columns: 1fr 1fr; }
  .utility-actions > * { flex: 1; justify-content: center; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
}
