:root {
  --fg: #1d2330; --muted: #667085; --line: #e4e7ec; --bg: #f6f7f9; --card: #fff;
  --accent: #2357d8; --accent-bg: #eef3ff; --danger: #c62828;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--fg); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; line-height: 1.6; }
a { color: var(--accent); }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.top nav a { margin-left: 1rem; text-decoration: none; }
main { max-width: 720px; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.6rem; margin: .75rem 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
.lead { color: var(--muted); margin-top: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.25rem; margin: 1rem 0; }
.crumb { font-size: .9rem; color: var(--muted); }

form#calc { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
form#calc .mode { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; display: flex; gap: 1.25rem; font-weight: 600; }
form#calc label { display: flex; flex-direction: column; font-size: .9rem; color: var(--muted); }
form#calc .mode label { flex-direction: row; gap: .35rem; color: var(--fg); font-size: 1rem; }
input[type=number], select { font: inherit; font-size: 1.05rem; padding: .5rem .6rem; margin-top: .25rem;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--fg); width: 100%; }
@media (max-width: 520px) { form#calc { grid-template-columns: 1fr; } }

.net { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1rem; padding: .75rem 1rem;
  background: var(--accent-bg); border-radius: 10px; margin-bottom: .75rem; }
.net span { color: var(--muted); }
.net strong { font-size: 1.8rem; color: var(--accent); }
.net small { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .45rem .25rem; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
th[scope=row], thead th:first-child { text-align: left; font-weight: 500; }
tr.sub th, tr.sub td { color: var(--muted); font-size: .9rem; }
tfoot th, tfoot td { font-weight: 700; border-bottom: 0; }
thead th { color: var(--muted); font-weight: 500; font-size: .9rem; }
.note, .hint { color: var(--muted); font-size: .85rem; }
.button { display: inline-block; padding: .55rem .9rem; background: var(--accent); color: #fff; border-radius: 8px; text-decoration: none; }
.near { list-style: none; padding: 0; margin: 0; }
.near li { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.near span { color: var(--muted); font-variant-numeric: tabular-nums; }
.help ul { padding-left: 1.2rem; }

dialog.error { border: 2px solid var(--danger); border-radius: 12px; max-width: 420px; }
dialog.error h2 { color: var(--danger); }
dialog.error button { font: inherit; padding: .4rem 1.2rem; }
footer { max-width: 720px; margin: 1rem auto 2rem; padding: 0 1rem; color: var(--muted); font-size: .8rem; }

.updating { background: #fff4d6; border-bottom: 1px solid #f0d58c; color: #6b4e00; padding: .55rem 1rem; text-align: center; font-weight: 600; }
.switch { margin: .25rem 0; }
.card.wide { padding: .5rem; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.detail { min-width: 860px; font-size: .9rem; }
table.detail caption { text-align: left; color: var(--muted); font-size: .85rem; padding: .25rem; }
table.detail th[scope=row] { position: sticky; left: 0; background: var(--card); white-space: nowrap; }
table.detail thead th { white-space: nowrap; }
table.detail .net-cell { font-weight: 700; color: var(--accent); }
table.detail tbody tr:hover td, table.detail tbody tr:hover th { background: var(--accent-bg); }
@media (min-width: 900px) { main:has(.card.wide) { max-width: 1100px; } }
.top .brand, .top nav a { white-space: nowrap; }
table.detail thead th:first-child { position: sticky; left: 0; background: var(--card); }
@media (max-width: 520px) {
  .top { flex-wrap: wrap; gap: .25rem; }
  .top nav a { margin: 0 .9rem 0 0; }
}
.asof { margin: .1rem 0 .6rem; color: var(--muted); font-size: .88rem; }
.asof .badge { display: inline-block; background: var(--accent); color: #fff; font-weight: 700; border-radius: 6px; padding: .05rem .5rem; margin-right: .25rem; }
.h1-year { font-size: .6em; color: var(--accent); vertical-align: middle; white-space: nowrap; }
.top .brand small { color: var(--accent); font-weight: 600; }
.ad { margin: 1rem 0; min-height: 100px; }
