/* Layout: phone-first single column, navy brand header, answer card first, then inputs and breakdown. */
:root {
  --navy: #000A3B;
  --teal: #00A3A1;
  --teal-on-navy: #2DD4C8;
  --bg: #F3F6F8;
  --surface: #FFFFFF;
  --ink: #0B1533;
  --muted: #5A6681;
  --line: #DCE3EA;
  --soft: #E3F4F3;
  --c-down: #000A3B;
  --c-duty: #00A3A1;
  --c-legal: #6FCFC9;
  --c-disb: #E8A200;
  --c-other: #9AA6BC;
  --c-state: #F2545B;
  --bad: #B3261E;
  --bad-soft: #FCE8E6;
  --display: "Sora", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #050C24; --surface: #0D1736; --ink: #E8EDF7; --muted: #9AA6C2; --line: #1F2B4F;
    --soft: #0F2B3A; --teal: #2DD4C8; --c-down: #8C9BC9; --c-duty: #2DD4C8; --c-legal: #1E8F89;
    --c-disb: #FFCB00; --c-other: #4A5677; --c-state: #FF7B80; --bad: #FF8A80; --bad-soft: #3A1418; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2 { font-family: var(--display); margin: 0; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 18px; font-weight: 600; }
p { margin: 0; }
small { color: var(--muted); font-size: 13px; line-height: 1.45; display: block; }
a { color: var(--teal); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.top { background: var(--navy); color: #fff; }
.top-in, .wrap {
  max-width: 640px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top-in { padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: 64px; display: grid; gap: 10px; }
.wordmark { height: 26px; width: auto; }
.top h1 { font-size: clamp(26px, 7vw, 34px); font-weight: 700; letter-spacing: -0.01em; }
.top .sub { color: #C3CBE0; max-width: 46ch; }

.wrap { display: grid; gap: 16px; margin-top: -44px; padding-bottom: 32px; }

.hero, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
.hero { display: grid; gap: 8px; box-shadow: 0 10px 30px rgba(0, 10, 59, 0.10); }
.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.big { font-family: var(--display); font-weight: 700; font-size: clamp(36px, 11vw, 48px); line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.split { color: var(--muted); }
.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line); margin-top: 6px; }
.stack i { display: block; height: 100%; }
.keys { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px 14px; font-size: 13.5px; }
.keys li { display: flex; align-items: center; gap: 7px; min-width: 0; }
.keys .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.keys .v { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.monthly { margin-top: 6px; padding: 10px 12px; background: var(--soft); border-radius: 10px; font-size: 15px; }
.monthly b { font-variant-numeric: tabular-nums; }
.saved { color: var(--teal); font-weight: 600; font-size: 14px; }

.panel { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span:first-child, legend { font-weight: 600; font-size: 14.5px; padding: 0; }
.money { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.money:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 25%, transparent); }
.money input, dialog input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: 600 18px/1.2 var(--body); padding: 12px; font-variant-numeric: tabular-nums;
}
.money input:focus { outline: none; }
.rm { color: var(--muted); font-size: 14px; padding: 0 0 0 12px; white-space: nowrap; }
.money input + .rm { padding: 0 12px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.seg-4 { grid-template-columns: repeat(4, 1fr); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 11px 6px; font-weight: 600; font-size: 14.5px; color: var(--muted); border-left: 1px solid var(--line); }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--navy); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: -2px; }
@media (prefers-color-scheme: dark) { .seg input:checked + span { background: var(--teal); color: var(--navy); } }

.switch { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; }
.track { width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; transition: background .15s; margin-top: 1px; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--teal); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .45; }
.switch .txt { display: grid; gap: 2px; font-size: 15px; }
.switch.off .txt b { color: var(--muted); }

select {
  width: 100%; font: 600 16px/1.2 var(--body); color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 10px; min-width: 0;
}
[hidden] { display: none !important; }
.foreign { display: grid; gap: 10px; padding: 14px; border-radius: 10px; background: var(--soft); }
.foreign-status { font-weight: 600; font-size: 15px; }
.foreign-status.bad { color: var(--bad); }
.warn { color: var(--bad); font-weight: 600; }
.alert { padding: 10px 12px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: 14px; }
.reno-line { font-size: 15px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; }
.reno-line b { font-variant-numeric: tabular-nums; }
.loan-fields { display: grid; gap: 16px; }
.loan-fields[hidden] { display: none; }

.more { border-top: 1px solid var(--line); padding-top: 14px; }
.more summary { cursor: pointer; font-weight: 600; color: var(--teal); }
.more-in { display: grid; gap: 16px; padding-top: 16px; }
input[type=range] { width: 100%; accent-color: var(--teal); }
.note { margin-top: -8px; }

.bd { display: grid; gap: 2px; }
.bd + .bd { margin-top: 14px; }
.bd h3 { font: 600 13px/1.3 var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }
.line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.line .v { font-variant-numeric: tabular-nums; white-space: nowrap; }
.line .k small { display: inline; margin-left: 4px; }
.line.total { border-bottom: 0; font-weight: 700; }
.line s { color: var(--muted); font-weight: 400; margin-right: 6px; }
.grand { display: flex; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 2px solid var(--ink); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }

.agent { gap: 6px; }
.agent-name { font-family: var(--display); font-weight: 700; font-size: 20px; }
.agent-meta { color: var(--muted); font-size: 14px; }
.actions { margin-top: 8px; }

.share { display: grid; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; text-align: center; gap: 8px;
  min-height: 48px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: 600 15.5px/1.2 var(--body); text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.ghost { background: transparent; color: var(--teal); border-color: transparent; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--teal); color: var(--navy); border-color: var(--teal); } }
.toast { min-height: 1.5em; text-align: center; color: var(--teal); font-weight: 600; font-size: 14px; }

.foot { display: grid; gap: 8px; font-size: 13px; color: var(--muted); padding: 4px 2px 0; }
.foot b { color: var(--ink); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(0, 10, 59, .55); }
dialog form { display: grid; gap: 14px; padding: 22px; }
dialog .hint { color: var(--muted); font-size: 14px; }
dialog input { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px; font-weight: 500; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.dialog-actions .btn { min-height: 44px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
