:root {
  color-scheme: light dark;
  --page: #f4f6fa;
  --card: #fff;
  --ink: #172138;
  --muted: #52617c;
  --line: #dbe2ed;
  --input: #f8fafd;
  --accent: #254fc2;
  --accent-hover: #193c9c;
  --on-accent: #fff;
  --tint: #eaf0ff;
  --positive: #106246;
  --positive-bg: #e2f5ed;
  --negative: #963b28;
  --negative-bg: #fbeddf;
  --shadow: 0 14px 44px #213b7210;
  font-family: Inter, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #101624; --card: #182133; --ink: #edf2fc; --muted: #adb9d1; --line: #36445e;
    --input: #121b2d; --accent: #96b3ff; --accent-hover: #b5caff; --on-accent: #10234f;
    --tint: #26385b; --positive: #a5e6cd; --positive-bg: #19463d; --negative: #ffd1b8;
    --negative-bg: #552e25; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101624; --card: #182133; --ink: #edf2fc; --muted: #adb9d1; --line: #36445e;
  --input: #121b2d; --accent: #96b3ff; --accent-hover: #b5caff; --on-accent: #10234f;
  --tint: #26385b; --positive: #a5e6cd; --positive-bg: #19463d; --negative: #ffd1b8;
  --negative-bg: #552e25; --shadow: none;
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); }
.shell { width: min(100%, 980px); margin: 0 auto; padding: 42px 24px max(32px, env(safe-area-inset-bottom)); }
.page-head { position: relative; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 750; color: var(--accent); }
.brand-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; background: var(--accent); color: var(--on-accent); }
.preview { display: inline-block; position: absolute; right: 0; top: 7px; font-size: 13px; color: var(--muted); }
h1 { font-size: clamp(30px, 6vw, 48px); line-height: 1.05; letter-spacing: -.05em; margin: 19px 0 8px; }
h2 { font-size: 19px; letter-spacing: -.02em; margin: 0; }
p { margin: 0; line-height: 1.5; }
.page-head p, .result-head p, .empty, .send-status { color: var(--muted); }
.layout { display: grid; grid-template-columns: 1.08fr 1fr; align-items: start; gap: 18px; }
.card { min-width: 0; border: 1px solid var(--line); border-radius: 19px; background: var(--card); padding: 23px; box-shadow: var(--shadow); }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 12px; margin-top: 17px; }
.wide { grid-column: 1 / -1; }
label { min-width: 0; display: flex; flex-direction: column; justify-content: end; gap: 6px; font-size: 13px; line-height: 1.35; font-weight: 620; }
input, select { font: inherit; font-size: 16px; width: 100%; min-width: 0; min-height: 46px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--input); }
input::placeholder { color: var(--muted); opacity: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[aria-invalid="true"] { border-color: var(--negative); }
details { border-top: 1px solid var(--line); margin-top: 17px; }
summary { padding: 13px 0 0; cursor: pointer; font-size: 14px; font-weight: 680; }
details > .fields { margin-top: 13px; }
button { min-height: 46px; width: 100%; border: 1px solid transparent; border-radius: 10px; font: inherit; font-weight: 690; cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
.primary { margin-top: 20px; background: var(--accent); color: var(--on-accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { margin-top: 16px; background: var(--tint); color: var(--accent); }
.error { margin-top: 15px; color: var(--negative); font-size: 14px; }
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.result-head p { font-size: 13px; }
.empty { border: 1px dashed var(--line); border-radius: 12px; padding: 19px 14px; font-size: 14px; }
.total { padding: 14px 15px; border-radius: 12px; background: var(--tint); color: var(--accent); }
.total p { font-size: 13px; font-weight: 660; }
.total output { display: block; font-weight: 780; font-size: clamp(22px, 4vw, 34px); line-height: 1.2; letter-spacing: -.045em; overflow-wrap: anywhere; }
.difference { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; padding: 11px 13px; border-radius: 9px; font-size: 13px; color: var(--positive); background: var(--positive-bg); }
.difference[data-tone="negative"] { color: var(--negative); background: var(--negative-bg); }
fieldset { min-width: 0; border: 0; margin: 17px 0 0; padding: 0; }
legend { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
#choices { display: grid; gap: 6px; }
.choice { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; justify-content: initial; gap: 8px; border: 1px solid var(--line); padding: 9px; border-radius: 9px; cursor: pointer; }
.choice:has(:checked) { border-color: var(--accent); background: var(--tint); }
.choice input { width: 16px; min-height: 16px; accent-color: var(--accent); margin: 0; }
.choice strong { font-size: 12px; font-variant-numeric: tabular-nums; }
dl { margin: 10px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; font-size: 13px; }
dt { color: var(--muted); }
dd { text-align: right; margin: 0; font-variant-numeric: tabular-nums; }
.send-status { font-size: 13px; margin-top: 8px; }
@media (max-width: 720px) {
  .shell { padding: 22px 14px max(24px, env(safe-area-inset-bottom)); }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .card { padding: 17px; }
  .page-head { margin-bottom: 18px; }
}
@media (max-width: 350px) {
  .shell { padding-inline: 9px; }
  .card { padding: 13px; }
  .choice { grid-template-columns: auto minmax(0, 1fr); }
  .choice strong { grid-column: 2; }
}
