/* Shared visual tokens. Native UI fonts keep every language local and fast. */
:root {
  --ink: #152c48;
  --muted: #576980;
  --accent: #1563d7;
  --accent-hover: #0d4eaf;
  --soft: #edf4ff;
  --paper: #fff;
  --surface: #fff;
  --subtle: #f8faff;
  --border: #dce4ef;
  --control-border: #8192aa;
  --node: #3f8cae;
  --peer: #6f76ba;
  --referral: #687b98;
  --error: #ae3227;
  --radius: 12px;
  --control: 8px;
  --page-width: 1440px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body { margin: 0; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; font-weight: 600; user-select: none; }
a { color: var(--accent); text-underline-offset: 4px; }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
button:disabled { opacity: .5; cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, strong, b { font-weight: 600; }
h1 { font-size: 36px; line-height: 1.3; letter-spacing: -.9px; text-wrap: balance; }
h2 { font-size: 19px; line-height: 1.5; }
h3 { font-size: 16px; }
p { font-size: 16px; text-wrap: pretty; }
small, .helper, .muted, .save-hint { color: var(--muted); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 16px; top: -80px; padding: 12px; background: var(--surface); z-index: 100; }
.skip:focus { top: 8px; }

/* Compact white masthead; preserve the official logo's original colours. */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: var(--page-width); margin: auto; padding: 8px 40px; min-height: 88px; display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 24px; }
.brand { display: block; width: 174px; height: 68px; flex-shrink: 0; }
.brand img { width: 100%; height: 100%; display: block; object-fit: contain; }
.topbar-title { min-width: 0; border-left: 1px solid var(--border); padding-left: 24px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.topbar-link { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px; font-size: 14px; text-decoration: none; color: var(--ink); border-radius: var(--control); }
.topbar-link:hover { color: var(--accent); background: var(--subtle); }
.language-picker { display: grid; grid-template-columns: 40px minmax(0,1fr); align-items: center; width: 188px; color: var(--muted); }
.language-picker svg { grid-column: 1; grid-row: 1; justify-self: center; pointer-events: none; z-index: 1; }
.language-picker select { grid-column: 1/-1; grid-row: 1; appearance: none; width: 100%; height: 48px; padding: 8px 30px 8px 39px; background-color: var(--surface); border: 1px solid var(--border); border-radius: var(--control); color: var(--ink); font-size: 14px; cursor: pointer; }
.language-picker select, .field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23576980' stroke-width='1.5'/%3E%3C/svg%3E"); background-position: right 12px center; background-repeat: no-repeat; }
.language-picker select:hover { border-color: var(--control-border); }
.language-picker option { background: var(--surface); color: var(--ink); }

/* The page and each main section share the same alignment edges. */
.page { max-width: var(--page-width); margin: 0 auto; padding: 40px 40px 24px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 36px; }
.intro { color: var(--muted); margin-top: 12px; max-width: 68ch; }
.unit-label { color: var(--muted); font-size: 13px; white-space: nowrap; padding-bottom: 2px; }
.workspace { display: grid; grid-template-columns: 304px minmax(0,1fr); gap: 36px; align-items: start; }
.settings { padding: 24px; background: var(--subtle); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.settings h2 { margin-bottom: 20px; }
.results-column { min-width: 0; padding: 0; }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-title h2, .section-title .muted { min-width: 0; overflow-wrap: anywhere; }
.section-title .muted { font-size: 12px; text-align: right; max-width: 48%; }

/* Settings and input states. */
.mode-switch { border: 0; padding: 4px; display: flex; gap: 4px; margin: 0 0 12px; background: #e8eef7; border-radius: 10px; }
.mode-switch label { flex: 1; min-width: 0; position: relative; text-align: center; cursor: pointer; }
.mode-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.mode-switch span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 9px 5px; border-radius: 7px; color: var(--muted); font-size: 14px; line-height: 1.45; font-weight: 600; }
.mode-switch input:checked+span { background: var(--surface); color: var(--accent); box-shadow: 0 1px 3px #152c4812; }
.mode-switch input:focus-visible+span { outline: 2px solid var(--accent); outline-offset: 1px; }
.helper { font-size: 13px; line-height: 1.7; }
.field { margin-top: 24px; }
.field>label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.field input, .field select { width: 100%; max-width: 100%; height: 48px; padding: 10px 12px; background-color: var(--surface); border: 1px solid var(--control-border); border-radius: var(--control); color: var(--ink); font-size: 16px; }
.field select { appearance: none; padding-right: 34px; }
.field .helper { margin-top: 8px; }
.field .minimum-hint { color: var(--ink); font-size: 14px; font-weight: 600; }
.amount-input { position: relative; }
.amount-input input { padding-right: 40px; font-variant-numeric: tabular-nums; }
.amount-input label { position: absolute; right: 14px; top: 11px; color: var(--muted); cursor: text; }
.field-error { font-size: 13px; color: var(--error); margin-top: 6px; }
.field-error:empty { display: none; }
.field input[aria-invalid=true] { border-color: var(--error); background: #fff8f6; }
.text-button { min-height: 44px; border: 0; background: none; color: var(--accent); font-size: 13px; padding: 8px 0; text-align: left; }
.text-button:hover { text-decoration: underline; }
.text-button.muted { color: var(--muted); }
.options { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 20px 0; padding: 12px 0; }
summary { cursor: pointer; min-height: 44px; align-content: center; }
summary::marker { color: var(--muted); }
.options summary { font-weight: 600; font-size: 14px; }
.options summary span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); padding-left: 16px; }
.radio-stack { border: 0; padding: 0; margin: 24px 0 8px; }
.radio-stack legend { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.radio-stack label { display: flex; align-items: flex-start; gap: 10px; margin: 8px 0; padding: 6px 0; min-height: 48px; font-size: 14px; cursor: pointer; }
.radio-stack label>span { min-width: 0; }
.radio-stack input { width: 18px; height: 18px; accent-color: var(--accent); margin: 3px 0 0; flex-shrink: 0; }
.radio-stack small { display: block; font-size: 12px; line-height: 1.6; }
.primary, .secondary { min-height: 48px; padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--control); font-size: 14px; line-height: 1.5; white-space: normal; }
.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { background: var(--surface); color: var(--ink); }
.secondary:hover { background: var(--soft); border-color: var(--control-border); }
.save-hint { font-size: 12px; text-align: center; margin: 10px 0 4px; }

/* Results: one dominant amount, then its components, qualification and periods. */
.income-overview { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); align-items: center; gap: 24px; }
.daily-head { padding: 8px 0; }
.daily-head>span:first-child { font-size: 14px; color: var(--muted); }
.daily-total { font-size: 44px; font-weight: 600; line-height: 1.25; letter-spacing: -1.5px; margin: 12px 0; color: #123d78; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.daily-total small { font-size: 14px; font-weight: 400; letter-spacing: 0; white-space: nowrap; display: inline-block; margin-left: 8px; }
.daily-head>span:last-child { font-size: 12px; color: var(--muted); }
.income-components { border-left: 1px solid var(--border); padding-left: 24px; min-width: 0; }
.income-components>div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.income-components>div>span { flex: 1; min-width: 0; }
.income-components span { font-size: 13px; color: var(--muted); white-space: normal; }
.income-components strong { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.income-components>div>div { max-width: 55%; }
.income-components span small, .subscription-values small { display: block; font-size: 12px; font-weight: 400; line-height: 1.6; }
.subscription-values { text-align: right; min-width: 0; }
.subscription-values strong { white-space: normal; overflow-wrap: anywhere; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; vertical-align: 2px; }
.subscription-dot { background: var(--accent); }
.node-dot { background: var(--node); }
.referral-dot { background: var(--referral); }
.peer-dot { background: var(--peer); }
.reward-explanation { margin-top: 20px; border-top: 1px solid var(--border); }
.reward-explanation summary { min-height: 48px; padding-block: 12px; font-size: 14px; font-weight: 400; color: var(--muted); }
.reward-explanation-body { padding: 14px 16px; background: var(--subtle); border-left: 2px solid #bad2f5; color: var(--muted); }
.reward-explanation-body p { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.reward-explanation-body p+p { margin-top: 12px; }
.rate-schedule { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 8px; }
.rate-schedule summary { font-size: 14px; font-weight: 600; }
.rate-schedule summary span { display: inline-block; margin-left: 12px; color: var(--muted); font-size: 12px; font-weight: 400; }
.rate-schedule .helper { margin: 8px 0 12px; }
.qualification, .period-section { margin-top: 28px; padding-top: 28px; border-top: 1px solid var(--border); }
.status { font-size: 12px; padding: 4px 9px; background: var(--soft); color: var(--accent-hover); border-radius: 5px; white-space: normal; max-width: 48%; text-align: center; }
.status.warning { background: #fff4e5; color: #87541b; }
.qualification-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 20px; margin: 0; }
.qualification-grid dt { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.qualification-grid dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.qualification-grid small { font-size: 12px; font-weight: 400; }
.progress-label { display: flex; justify-content: space-between; gap: 4px 16px; flex-wrap: wrap; margin-top: 20px; font-size: 13px; color: var(--muted); }
.progress-track { height: 5px; background: #e7eef9; border-radius: 8px; margin: 8px 0 12px; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.period-container { container-type: inline-size; }
.periods { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.period { min-width: 0; padding: 14px 12px; border: 1px solid var(--border); border-radius: var(--control); background: var(--surface); text-align: left; color: var(--ink); }
.period:hover { border-color: var(--control-border); background: var(--subtle); }
.period[aria-pressed=true] { border-color: var(--accent); background: var(--soft); box-shadow: inset 0 0 0 1px var(--accent); }
.period .period-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 400; color: var(--muted); }
.period .period-label em { font-style: normal; font-size: 12px; color: var(--accent); }
.period strong { display: block; font-size: 20px; letter-spacing: -.5px; margin-top: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.period small { font-size: 12px; font-weight: 400; }
.period.wide { grid-column: 1/-1; }
@container (max-width: 620px) { .periods { grid-template-columns: repeat(2,minmax(0,1fr)); } }
.chart-section { padding-top: 24px; }
.chart-caption { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart line { stroke: var(--border); stroke-width: 1; }
.period-breakdown { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-top: 16px; font-size: 13px; color: var(--muted); }
.period-breakdown>span { min-width: 0; }
.period-breakdown strong { margin-left: 8px; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Full-width detail module. Sticky header and day column stay inside its scroller. */
.results-detail-panel { min-width: 0; margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border); }
.daily-section .helper { margin-top: 6px; }
.daily-section .section-title { flex-wrap: wrap; }
.table-scroll { width: 100%; max-height: 460px; overflow: auto; position: relative; scrollbar-gutter: stable; border: 1px solid var(--border); border-radius: var(--control); overscroll-behavior-x: contain; isolation: isolate; }
table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
th, td { padding: 13px 16px; border-bottom: 1px solid #e9eef6; background: var(--surface); }
thead th { position: sticky; top: 0; z-index: 3; background: #f1f5fc; font-size: 13px; font-weight: 600; text-align: right; white-space: normal; min-width: 108px; max-width: 190px; box-shadow: 0 1px 0 var(--border); }
th:first-child, td:first-child { position: sticky; left: 0; z-index: 2; text-align: left; background: var(--subtle); box-shadow: 1px 0 0 var(--border); }
thead th:first-child { z-index: 4; min-width: 84px; background: #e9f1fd; }
tbody tr:hover td, tbody tr:hover th { background: var(--soft); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.total-cell { font-weight: 600; color: var(--accent); }
.table-note { margin-top: 12px; }
.rate-scroll { max-height: 320px; }
.rate-scroll th, .rate-scroll td { padding: 11px 12px; }
.layer-details { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.layer-details summary { font-size: 16px; font-weight: 600; }
.layer-details .helper { margin: 8px 0 12px; }
#detail-results > .layer-details:first-child { margin: 0 0 24px; padding: 0 0 20px; border-top: 0; border-bottom: 1px solid var(--border); }
.layer-scroll { max-height: 350px; }
.share-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.rules { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--border); scroll-margin-top: 24px; }
.rules>.section-title { margin-bottom: 12px; }
.rules>p { color: var(--muted); max-width: 1000px; }
.rules details { border-bottom: 1px solid var(--border); padding: 14px 0; }
.rules summary { font-size: 16px; line-height: 1.6; font-weight: 600; }
.rules details p { font-size: 16px; color: var(--muted); margin: 12px 0; max-width: 1000px; }
.rules .table-scroll { margin-top: 16px; max-width: 900px; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-top: 16px; }
.rules .rate-rules-scroll { max-width: 580px; max-height: none; }
.rate-rules-scroll table { table-layout: fixed; }
.rate-rules-scroll th, .rate-rules-scroll td { padding: 10px 12px; white-space: normal; min-width: 0; max-width: none; }
footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px 0 0; color: var(--muted); font-size: 12px; }
.invalid { padding: 24px; background: #fff8f6; border: 1px solid #e6bbb4; border-radius: var(--radius); }
.invalid p { margin-top: 12px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); width: max-content; background: var(--ink); color: #fff; border-radius: var(--control); padding: 12px 20px; z-index: 99; font-size: 14px; box-shadow: 0 4px 24px #152c4826; }
.warning-text { color: var(--error); }

/* Personal subscriptions have their own page and form, separate from team scenarios. */
.calculator-nav { display: flex; flex-wrap: wrap; gap: 8px 24px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.calculator-nav a { display: flex; align-items: center; min-height: 48px; padding: 10px 0; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; font-size: 14px; }
.calculator-nav a[aria-current=page] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.calculator-nav a:hover { color: var(--accent-hover); }
.personal-rate-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.personal-page .settings .field { margin-top: 0; }
.personal-page .primary { margin-top: 12px; }
.personal-page .period-section { margin-top: 0; padding-top: 0; border: 0; }
.personal-page .period-return { display: block; margin-top: 8px; font-size: 13px; font-weight: 600; line-height: 1.6; color: var(--accent-hover); overflow-wrap: anywhere; }
.personal-return-formula { margin-top: 12px; }
.personal-overview { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.personal-metrics { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px; margin: 24px 0 20px; padding-top: 24px; border-top: 1px solid var(--border); }
.personal-metrics dt { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.personal-metrics dd { margin: 0; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.personal-earning-note { margin-top: 8px; }
.fee-note { margin-top: 24px; padding: 16px 18px; border-left: 3px solid var(--accent); background: var(--subtle); color: var(--ink); font-size: 14px; }

/* Reverse plans distinguish the monthly target from conditional funding and one-off rewards. */
.reverse-page .settings .field:first-child { margin-top: 0; }
.reverse-page #results { scroll-margin-top: 20px; }
.reverse-page .primary { margin-top: 12px; }
.reverse-breakdown { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 12px; }
.reverse-breakdown>div, .reverse-referral>div { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px; padding-block: 8px; font-size: 14px; }
.reverse-breakdown strong, .reverse-referral strong { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.reverse-breakdown span, .reverse-referral span { color: var(--muted); }
.reverse-referral { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); }
.reverse-referral .helper { margin-top: 4px; font-size: 13px; }
.reverse-callout { padding: 12px 16px; margin: 18px 0 0; border-left: 3px solid var(--accent); background: var(--subtle); font-size: 14px; line-height: 1.7; }
.reverse-callout.warning { border-color: #b87929; background: #fff8ee; color: #784914; }
#no-match-note { margin: 0 0 24px; }
.reverse-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 20px 24px; margin: 0; }
.reverse-metrics dt { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.reverse-metrics dd { font-size: 21px; font-weight: 600; margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.reverse-funding { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--border); }
.reverse-funding summary { font-size: 16px; font-weight: 600; min-height: 48px; padding-block: 10px; }
.reverse-funding .reverse-metrics { padding-top: 16px; }
.reverse-funding .helper, .reverse-page #large-team-note { margin-top: 16px; }
.funding-breakdown { display: block; margin-top: 6px; font-size: 13px; line-height: 1.6; font-weight: 400; color: var(--muted); }
.comparison-wrap { margin-top: 24px; }
.comparison-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.comparison-table caption { text-align: left; font-size: 14px; font-weight: 600; padding-bottom: 12px; }
.comparison-table th, .comparison-table td { min-width: 0; max-width: none; width: 30%; padding: 12px 8px; white-space: normal; overflow-wrap: anywhere; font-size: 13px; text-align: right; }
.comparison-table th:first-child { width: 40%; text-align: left; position: static; }
.comparison-table thead th { position: static; font-weight: 500; color: var(--muted); }
.comparison-table tbody th { font-weight: 400; }
.comparison-table .comparison-total > * { background: var(--soft); color: var(--accent-hover); font-weight: 600; }
.comparison-table .comparison-referral > * { border-top: 2px solid var(--border); color: var(--muted); }
.allocation-section { margin-bottom: 32px; padding-bottom: 28px; border-bottom: 1px solid var(--border); }
.allocation-section .helper { margin: 12px 0; }
.branch-scroll { margin-top: 16px; max-height: 440px; }
.branch-scroll th, .branch-scroll td { padding: 12px; }
.detail-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.detail-controls label { font-size: 14px; color: var(--muted); }
.detail-controls select { width: auto; min-width: 112px; }
.detail-total { margin-top: 12px; color: var(--accent-hover); }
@media (max-width:1100px) { .reverse-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width:760px) {
  .reverse-metrics { gap: 20px 16px; }
  .reverse-metrics dd { font-size: 20px; }
  .reverse-metrics dt { font-size: 14px; }
  .reverse-page #daily-table thead th:not(:first-child) { min-width: 80px; width: 80px; max-width: 112px; }
}

/* Native script fallbacks; Latin digits remain aligned in all numeric tables. */
html[lang^="zh"] body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
html[lang^="th"] body { font-family: Tahoma, "Noto Sans Thai", system-ui, sans-serif; line-height: 1.8; }
html[lang^="hi"] body { font-family: "Nirmala UI", "Noto Sans Devanagari", system-ui, sans-serif; line-height: 1.8; }
html[lang^="ja"] body { font-family: -apple-system, BlinkMacSystemFont, "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif; }
html[lang^="ko"] body { font-family: -apple-system, BlinkMacSystemFont, "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; word-break: keep-all; overflow-wrap: break-word; }

@media (max-width: 1100px) {
  .topbar-inner { padding-inline: 24px; gap: 16px; }
  .topbar-title { padding-left: 16px; }
  .page { padding: 32px 24px 24px; }
  .workspace { grid-template-columns: 280px minmax(0,1fr); gap: 28px; }
  .settings { padding: 24px 20px; }
  .income-overview { grid-template-columns: 1fr; gap: 12px; }
  .income-components { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 8px; }
  .qualification-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .unit-label { display: none; }
}
@media (max-width: 760px) {
  .topbar-inner { grid-template-columns: minmax(0,1fr) auto; gap: 4px 12px; padding: 8px 20px 12px; }
  .brand { width: 144px; height: 57px; margin-left: -12px; }
  .language-picker { width: 190px; grid-column: 2; grid-row: 1; }
  .language-picker select { font-size: 16px; }
  .topbar-title { grid-column: 1; grid-row: 2; border: 0; padding: 0; font-size: 13px; }
  .topbar-link { grid-column: 2; grid-row: 2; justify-self: end; min-height: 44px; font-size: 13px; padding: 8px 0; max-width: 174px; text-align: right; }
  .page { padding: 28px 20px 24px; }
  .page-heading { display: block; margin-bottom: 28px; }
  h1 { font-size: 28px; letter-spacing: -.6px; }
  h2 { font-size: 19px; }
  .intro { margin-top: 12px; }
  .workspace { grid-template-columns: 1fr; gap: 32px; }
  .settings { padding: 24px 20px; }
  .settings h2 { margin-bottom: 16px; }
  .field { margin-top: 20px; }
  .field>label, .mode-switch span, .options summary { font-size: 16px; }
  .helper { font-size: 14px; }
  .text-button { font-size: 14px; }
  .options summary span, .radio-stack small, .save-hint { font-size: 13px; }
  .radio-stack label, .radio-stack legend { font-size: 16px; }
  .radio-stack input { width: 20px; height: 20px; }
  .primary, .secondary { font-size: 15px; }
  .income-components span { font-size: 14px; }
  .income-components>div>div { max-width: 52%; }
  .daily-total { font-size: 42px; }
  .calculator-nav { gap: 4px 16px; }
  .calculator-nav a { flex: 1 1 120px; font-size: 14px; }
  .personal-metrics { gap: 20px 16px; }
  .personal-metrics dd { font-size: 20px; }
  .qualification-grid { gap: 20px 16px; }
  .qualification-grid dd { font-size: 22px; }
  .rate-schedule summary { font-size: 16px; }
  .rate-schedule summary span { display: block; margin: 4px 0 0 16px; }
  .period-section>.section-title { display: block; }
  .period-section>.section-title .muted { display: block; max-width: none; margin-top: 6px; text-align: left; font-size: 13px; }
  .period .period-label { font-size: 14px; }
  .period strong { font-size: 20px; }
  .period-breakdown { flex-direction: column; font-size: 14px; }
  .period-breakdown>span { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; }
  .period-breakdown strong { margin-left: 0; }
  .chart-caption { align-items: flex-start; flex-direction: column; }
  .chart text { font-size: 13px; }
  .results-detail-panel { margin-top: 32px; padding-top: 24px; }
  .table-scroll { max-height: 420px; }
  th, td { padding: 13px 14px; }
  /* Compact daily data, with full numeric precision and room for long values. */
  #daily-scroll { width: calc(100% + 16px); margin-inline: -8px; }
  #daily-table { width: max-content; min-width: 100%; }
  #daily-table th, #daily-table td { padding: 9px 8px; line-height: 1.5; }
  #daily-table thead th { min-width: 80px; width: 80px; max-width: 112px; padding-block: 10px; line-height: 1.45; }
  #daily-table thead th:first-child { min-width: 64px; width: 64px; }
  #daily-table thead th:nth-child(2) { min-width: 64px; width: 64px; }
  #daily-table thead th:nth-child(4) { min-width: 88px; width: 88px; }
  #daily-table thead th:nth-child(7) { min-width: 96px; width: 96px; }
  #daily-table thead th:nth-child(8) { min-width: 104px; width: 104px; }
  #daily-table thead th:nth-child(9) { min-width: 112px; width: 112px; }
  .personal-page #daily-table thead th:not(:first-child) { min-width: 88px; width: 88px; max-width: 112px; }
  .share-row { align-items: stretch; flex-direction: column; }
  .share-row .secondary { width: 100%; }
  .rules { margin-top: 32px; padding-top: 24px; }
  .rules-grid { grid-template-columns: 1fr; gap: 12px; }
  .rate-rules-scroll th, .rate-rules-scroll td { padding: 10px 8px; font-size: 13px; }
  footer { flex-direction: column; gap: 8px; }
}
@media (max-width: 359px) {
  .topbar-inner { padding-inline: 16px; gap: 4px 8px; }
  .brand { width: 118px; height: 50px; }
  .language-picker { width: 156px; grid-template-columns: 30px minmax(0,1fr); }
  .language-picker select { font-size: 14px; padding-left: 10px; padding-right: 24px; }
  .language-picker svg { display: none; }
  .page { padding-inline: 16px; }
  .settings { padding-inline: 16px; }
  .periods { grid-template-columns: 1fr; }
  .daily-total { font-size: 38px; }
  .personal-metrics { grid-template-columns: 1fr; gap: 16px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  .topbar, .settings, .share-row, .rules, .secondary, .toast { display: none; }
  .page { padding: 0; }
  .workspace { display: block; }
  .results-column { padding: 0; }
  .table-scroll { max-height: none; overflow: visible; }
  .daily-section { break-before: page; }
  thead th, th:first-child, td:first-child { position: static; }
  .periods { grid-template-columns: repeat(4,1fr); }
}
