:root {
    color-scheme: dark;
    --bg: #f4efe5;
    --bg-deep: #e6ddd1;
    --surface: rgba(255, 251, 245, 0.82);
    --surface-strong: rgba(255, 250, 244, 0.98);
    --surface-soft: rgba(20, 49, 38, 0.07);
    --text: #1d261e;
    --muted: #5b665d;
    --line: rgba(29, 38, 30, 0.12);
    --accent: #143126;
    --accent-strong: #245540;
    --accent-soft: #d7eadc;
    --accent-warm: #d98f41;
    --danger: #b13f34;
    --shadow: 0 20px 60px rgba(58, 44, 26, 0.12);
    --shadow-soft: 0 12px 28px rgba(58, 44, 26, 0.1);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --font-ui: "Aptos Display", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
    --font-body: "Aptos", "Segoe UI Variable Text", "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111715;
    --bg-deep: #1b2320;
    --surface: rgba(24, 31, 28, 0.86);
    --surface-strong: rgba(20, 27, 24, 0.98);
    --surface-soft: rgba(215, 234, 220, 0.08);
    --text: #eef4ef;
    --muted: #aab7af;
    --line: rgba(238, 244, 239, 0.1);
    --accent: #8ec7a1;
    --accent-strong: #cfe3b5;
    --accent-soft: rgba(142, 199, 161, 0.12);
    --accent-warm: #f0b06c;
    --danger: #ff9c90;
    --shadow: 0 22px 70px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(217, 143, 65, 0.2), transparent 22rem),
        radial-gradient(circle at top right, rgba(20, 49, 38, 0.2), transparent 18rem),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
    overflow-x: clip;
    -webkit-tap-highlight-color: transparent;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 85%);
}

.page-shell {
    width: min(1320px, calc(100% - 20px));
    margin: 0 auto;
    padding: max(12px, env(safe-area-inset-top)) 0 max(26px, env(safe-area-inset-bottom));
}

img,
svg,
canvas {
    max-width: 100%;
}

.hero,
.calculator-card,
.summary-card,
.insight-card,
.surface-card,
.empty-state,
.app-topbar,
.legal-card {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.app-topbar {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 18px 20px;
    border-radius: var(--radius-xl);
    margin-bottom: 16px;
}

.app-topbar::after {
    content: "";
    position: absolute;
    inset: auto -3rem -3rem auto;
    width: 10rem;
    height: 10rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(217, 143, 65, 0.22), transparent 70%);
}

.app-topbar-copy {
    min-width: 0;
}

.app-topbar-main {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.app-topbar-copy h1 {
    margin-top: 10px;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    max-width: none;
}

.app-topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    justify-content: flex-start;
}

.app-topbar-badge {
    display: grid;
    gap: 4px;
    min-width: 120px;
    padding: 14px 16px;
    border-radius: 22px;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    color: #fff;
    box-shadow: var(--shadow-soft);
    text-align: right;
}

.app-topbar-badge span {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.82;
}

.app-topbar-badge strong {
    font-family: var(--font-ui);
    font-size: 1.05rem;
    line-height: 1;
}

#appConnection {
    opacity: 0.9;
}

.hero {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 20px;
    padding: 22px;
    border-radius: var(--radius-xl);
    margin-bottom: 16px;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -5rem -5rem auto;
    width: 14rem;
    height: 14rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(217, 143, 65, 0.24), transparent 70%);
}

.hero-copy,
.results-stack,
.field-stack,
.summary-metrics,
.insight-grid,
.saved-list {
    display: grid;
    gap: 14px;
}

.hero-brand {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.hero-logo-wrap {
    width: 64px;
    height: 64px;
    border-radius: 22px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
}

.hero-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    font-family: var(--font-ui);
    letter-spacing: -0.04em;
}

h1 {
    margin-top: 10px;
    font-size: clamp(2rem, 6vw, 3.7rem);
    line-height: 0.96;
    max-width: 12ch;
}

h2 {
    font-size: clamp(1.35rem, 3vw, 2rem);
    line-height: 1;
}

h3 {
    font-size: 1.15rem;
    line-height: 1.05;
}

.hero-text,
.section-copy,
.subtle,
.mini-note {
    color: var(--muted);
}

.hero-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.6;
    max-width: 62ch;
    overflow-wrap: anywhere;
}

.hero-points,
.hero-actions,
.primary-actions,
.support-actions,
.actions-row,
.legend,
.saved-head,
.saved-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.hero-points span {
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.36);
    border: 1px solid var(--line);
    font-size: 0.9rem;
    font-weight: 700;
}

.main-grid {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.calculator-card,
.summary-card,
.surface-card {
    border-radius: var(--radius-xl);
    padding: 20px;
    min-width: 0;
}

.calculator-card {
    display: grid;
    gap: 18px;
}

.section-top,
.card-head,
.field-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.field-stack {
    grid-template-columns: 1fr;
}

.input-card {
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.full-width {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 10px;
}

.field label,
.metric-card span,
.hero-metric span {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--muted);
}

.field-value {
    color: var(--accent);
    font-size: 0.94rem;
    font-weight: 800;
    white-space: normal;
    text-align: right;
    overflow-wrap: anywhere;
}

input,
select,
button {
    font: inherit;
}

input {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

select:focus,
input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(36, 85, 64, 0.12);
    transform: translateY(-1px);
}

input.input-invalid,
input.input-invalid:focus {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px rgba(177, 63, 52, 0.14);
}

.native-select {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
}

.custom-select {
    position: relative;
}

.custom-select-trigger {
    width: 100%;
    min-height: 56px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08)),
        var(--surface-strong);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.custom-select-trigger:focus-visible,
.custom-select.open .custom-select-trigger {
    border-color: var(--accent);
    box-shadow:
        0 0 0 4px rgba(36, 85, 64, 0.12),
        0 16px 34px rgba(20, 49, 38, 0.14);
    transform: translateY(-1px);
}

.custom-select-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
    text-align: left;
}

.custom-select-copy strong {
    font-family: var(--font-ui);
    font-size: 1rem;
    letter-spacing: -0.03em;
}

.custom-select-copy span {
    font-size: 0.86rem;
    color: var(--muted);
}

.custom-select-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    color: var(--muted);
    transition: transform 0.2s ease, color 0.2s ease;
}

.custom-select.open .custom-select-icon {
    transform: rotate(225deg) translateY(-1px);
    color: var(--accent);
}

.custom-select-panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 6px;
    max-height: min(320px, 44vh);
    padding: 10px;
    overflow: auto;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 250, 244, 0.96);
    box-shadow: 0 24px 50px rgba(20, 49, 38, 0.16);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.98);
    transform-origin: top center;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

:root[data-theme="dark"] .custom-select-panel {
    background: rgba(20, 27, 24, 0.96);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.36);
}

.custom-select.open .custom-select-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.custom-select-option {
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    display: grid;
    gap: 2px;
    text-align: left;
    border-radius: 16px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
}

.custom-select-option strong {
    font-family: var(--font-ui);
    font-size: 0.98rem;
    letter-spacing: -0.03em;
}

.custom-select-option span {
    color: var(--muted);
    font-size: 0.84rem;
}

.custom-select-option:hover,
.custom-select-option:focus-visible {
    background: var(--accent-soft);
    border-color: rgba(36, 85, 64, 0.16);
    transform: none;
}

.custom-select-option.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

.custom-select-option.active span {
    color: rgba(255, 255, 255, 0.78);
}

.segmented {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--surface-strong);
}

.segmented button,
.chip-btn,
.primary-btn,
.secondary-btn,
.ghost-btn {
    min-height: 50px;
    border-radius: 15px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
    min-width: 0;
}

.segmented button {
    background: transparent;
    color: var(--muted);
}

.segmented button.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #fff;
}

.chip-btn,
.primary-btn,
.secondary-btn,
.ghost-btn {
    padding: 13px 16px;
}

.action-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.action-btn-strong {
    min-height: 58px;
    font-size: 1rem;
    box-shadow: 0 14px 28px rgba(20, 49, 38, 0.18);
}

.btn-icon {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    font-weight: 900;
    line-height: 1;
}

.btn-icon svg,
.icon-glyph svg {
    width: 16px;
    height: 16px;
}

.full-width-btn {
    width: 100%;
}

.stacked-actions {
    position: sticky;
    bottom: max(10px, env(safe-area-inset-bottom));
    z-index: 8;
    padding: 10px;
    border-radius: 22px;
    background: rgba(255, 250, 244, 0.92);
    border: 1px solid var(--line);
    box-shadow: 0 18px 38px rgba(20, 49, 38, 0.12);
    grid-template-columns: 1fr;
}

:root[data-theme="dark"] .stacked-actions {
    background: rgba(20, 27, 24, 0.92);
}

.icon-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.icon-only-btn {
    min-height: 52px;
    display: inline-grid;
    place-items: center;
    padding: 10px;
}

.icon-glyph {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    font-size: 0.98rem;
    font-weight: 800;
    background: var(--accent-soft);
    color: var(--accent);
}

.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;
}

.print-report {
    display: none;
}

.chip-btn {
    background: rgba(255, 255, 255, 0.3);
    border-color: var(--line);
    color: var(--text);
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    color: #fff;
}

.secondary-btn {
    background: var(--surface-strong);
    border-color: var(--line);
    color: var(--text);
}

.ghost-btn {
    background: transparent;
    border-color: var(--line);
    color: var(--text);
}

.compact-btn {
    min-height: 44px;
    padding-inline: 14px;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    transform: none;
    box-shadow: none;
}

.primary-actions,
.support-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.support-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actions-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status {
    min-height: 1.25rem;
    color: var(--muted);
    font-size: 0.92rem;
    padding-inline: 2px;
}

.summary-card {
    display: grid;
    gap: 18px;
    min-width: 0;
}

.hero-metric {
    padding: 18px;
    border-radius: 26px;
}

.accent-metric {
    background: linear-gradient(135deg, var(--accent), var(--accent-warm));
    color: #fff;
}

.accent-metric span {
    color: rgba(255, 255, 255, 0.84);
}

.hero-metric strong {
    display: block;
    margin-top: 10px;
    font-family: var(--font-ui);
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
}

.summary-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card,
.insight-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-family: var(--font-ui);
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-wrap {
    position: relative;
    min-height: 240px;
    margin-top: 14px;
}

.chart-wrap svg {
    width: 100%;
    height: 100%;
    display: block;
}

.donut-wrap {
    max-width: 320px;
    margin-inline: auto;
}

.line-wrap {
    min-height: 280px;
}

.chart-center {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    pointer-events: none;
}

.chart-center strong {
    font-family: var(--font-ui);
    font-size: 1.7rem;
    letter-spacing: -0.04em;
}

.tiny {
    font-size: 0.82rem;
}

.legend {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.9rem;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legend i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.principal-dot {
    background: #8ec7a1;
}

.interest-dot {
    background: #d98f41;
}

.balance-dot {
    background: #cfe3b5;
}

.table-wrap {
    overflow: auto;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.04);
    overscroll-behavior-x: contain;
}

.schedule-wrap {
    max-height: min(56vh, 460px);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}

.compare-table {
    min-width: 0;
}

th,
td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-strong);
    color: var(--muted);
    font-weight: 800;
}

tbody tr:hover {
    background: rgba(36, 85, 64, 0.08);
}

.saved-list {
    gap: 12px;
    max-height: min(420px, 52vh);
    overflow-y: auto;
    padding-right: 4px;
    align-content: start;
    overscroll-behavior: contain;
}

.saved-item {
    display: grid;
    gap: 10px;
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.05);
}

.saved-name {
    font-weight: 800;
    font-size: 1rem;
}

.saved-meta,
.mini-note,
.subtle,
.section-copy {
    font-size: 0.92rem;
    line-height: 1.5;
}

.empty-state {
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    color: var(--muted);
}

.no-margin {
    margin: 0;
}

input[type="range"] {
    width: 100%;
    height: 38px;
    margin: 0;
    appearance: none;
    background: transparent;
    border-radius: 999px;
    padding: 0;
    border: 0;
    box-shadow: none;
    transform: none;
    cursor: pointer;
    --range-progress: 50%;
    --range-track: linear-gradient(90deg, var(--accent) 0%, var(--accent-warm) var(--range-progress), rgba(128, 140, 131, 0.18) var(--range-progress), rgba(128, 140, 131, 0.18) 100%);
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 12px;
    border-radius: 999px;
    background: var(--range-track);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.14),
        inset 0 -1px 2px rgba(0, 0, 0, 0.08);
}

input[type="range"]::-moz-range-track {
    height: 12px;
    border-radius: 999px;
    background: rgba(128, 140, 131, 0.18);
    box-shadow:
        inset 0 1px 1px rgba(255, 255, 255, 0.14),
        inset 0 -1px 2px rgba(0, 0, 0, 0.08);
}

input[type="range"]::-moz-range-progress {
    height: 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-warm));
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 26px;
    height: 26px;
    margin-top: -7px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.74) 45%, rgba(255, 255, 255, 0.12) 46%),
        linear-gradient(135deg, var(--accent), var(--accent-warm));
    border: 2px solid rgba(255, 255, 255, 0.78);
    box-shadow:
        0 10px 18px rgba(20, 49, 38, 0.22),
        0 0 0 6px rgba(36, 85, 64, 0.08);
}

input[type="range"]::-moz-range-thumb {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.74) 45%, rgba(255, 255, 255, 0.12) 46%),
        linear-gradient(135deg, var(--accent), var(--accent-warm));
    border: 2px solid rgba(255, 255, 255, 0.78);
    box-shadow:
        0 10px 18px rgba(20, 49, 38, 0.22),
        0 0 0 6px rgba(36, 85, 64, 0.08);
}

input[type="range"]:focus-visible::-webkit-slider-thumb,
input[type="range"]:active::-webkit-slider-thumb {
    box-shadow:
        0 12px 24px rgba(20, 49, 38, 0.24),
        0 0 0 8px rgba(36, 85, 64, 0.12);
}

input[type="range"]:focus-visible::-moz-range-thumb,
input[type="range"]:active::-moz-range-thumb {
    box-shadow:
        0 12px 24px rgba(20, 49, 38, 0.24),
        0 0 0 8px rgba(36, 85, 64, 0.12);
}

.app-footer {
    margin-top: 18px;
    padding: 18px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 0.86rem;
}

.footer-brand,
.footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.footer-brand strong {
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 1rem;
}

.footer-links a,
.footer-brand a,
.legal-content a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
}

.footer-links a:hover,
.footer-brand a:hover,
.legal-content a:hover {
    text-decoration: underline;
}

.legal-shell {
    width: min(900px, calc(100% - 20px));
}

.legal-card {
    padding: 24px;
    border-radius: var(--radius-xl);
}

.legal-head,
.legal-content,
.legal-actions {
    display: grid;
    gap: 14px;
}

.legal-content {
    margin-top: 18px;
}

.legal-content h2 {
    font-size: 1.15rem;
}

.legal-content p {
    margin: 0;
    color: var(--text);
    line-height: 1.7;
}

.legal-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 22px;
}

.legal-btn {
    width: 100%;
    justify-content: center;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.pulse {
    animation: fadeUp 0.45s ease both;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (min-width: 1080px) {
    .app-topbar-main {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .main-grid {
        grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
        align-items: start;
    }

    .calculator-card {
        position: sticky;
        top: 14px;
    }

    .stacked-actions {
        position: static;
        padding: 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }
}

@media (max-width: 960px) {
    .summary-metrics,
    .insight-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .main-grid {
        gap: 14px;
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 10px, 1320px);
        padding: max(8px, env(safe-area-inset-top)) 0 max(24px, env(safe-area-inset-bottom));
    }

    .results-stack {
        display: contents;
    }

    .hero,
    .calculator-card,
    .summary-card,
    .surface-card,
    .app-topbar,
    .legal-card {
        padding: 16px;
        border-radius: 24px;
    }

    .app-topbar {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .app-topbar-main {
        gap: 12px;
    }

    .app-topbar-badge {
        text-align: left;
        min-width: 0;
    }

    .calculator-card {
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        gap: 14px;
    }

    .section-top {
        gap: 8px;
    }

    .section-copy {
        margin: 0;
        font-size: 0.86rem;
        line-height: 1.35;
    }

    .hero-brand {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .hero-logo-wrap {
        width: 58px;
        height: 58px;
        border-radius: 20px;
    }

    h1 {
        max-width: none;
        font-size: clamp(1.9rem, 10vw, 2.8rem);
    }

    .summary-metrics,
    .insight-grid,
    .actions-row,
    .legal-actions {
        grid-template-columns: 1fr;
    }

    .field-stack {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .field-stack .full-width {
        grid-column: 1 / -1;
    }

    .scenario-card,
    .interest-method-card,
    .primary-actions,
    .support-actions {
        grid-column: 1 / -1;
    }

    .input-card,
    .metric-card,
    .insight-card,
    .saved-item {
        padding: 12px;
        border-radius: 18px;
    }

    .field {
        gap: 8px;
    }

    .field label,
    .metric-card span,
    .hero-metric span,
    .field-value {
        font-size: 0.84rem;
    }

    input,
    .custom-select-trigger,
    .segmented button,
    .chip-btn,
    .primary-btn,
    .secondary-btn,
    .ghost-btn {
        min-height: 46px;
        padding: 11px 12px;
        border-radius: 14px;
        font-size: 0.94rem;
    }

    .segmented {
        padding: 4px;
        gap: 4px;
        border-radius: 16px;
    }

    .primary-actions {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .stacked-actions {
        margin-inline: -2px;
        margin-bottom: 2px;
        padding: 8px;
        border-radius: 18px;
    }

    .support-actions {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 8px;
    }

    .support-actions .secondary-btn,
    .support-actions .ghost-btn {
        min-height: 42px;
        padding-inline: 8px;
        font-size: 0.82rem;
    }

    .icon-only-btn {
        min-height: 44px;
        padding: 6px;
    }

    .hero-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .hero-actions > * {
        width: 100%;
    }

    .chart-wrap {
        min-height: 220px;
    }

    .line-wrap {
        min-height: 250px;
    }

    .app-footer {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }

    table {
        min-width: 620px;
    }
}

@media (max-width: 480px) {
    .page-shell {
        width: min(100% - 6px, 1320px);
        padding: max(6px, env(safe-area-inset-top)) 0 max(20px, env(safe-area-inset-bottom));
    }

    .calculator-card {
        gap: 12px;
    }

    .section-copy {
        display: none;
    }

    h2 {
        font-size: 1.15rem;
    }

    .app-topbar-copy h1 {
        font-size: clamp(1.55rem, 9vw, 2rem);
    }

    .app-topbar-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .eyebrow {
        padding: 6px 10px;
        font-size: 0.68rem;
    }

    .hero-actions {
        grid-template-columns: 1fr;
    }

    .hero-points {
        display: grid;
        grid-template-columns: 1fr;
    }

    .section-top,
    .card-head,
    .field-head,
    .saved-head,
    .saved-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    .field-value {
        text-align: left;
    }

    .field-stack {
        gap: 8px;
    }

    .scenario-card,
    .interest-method-card {
        grid-column: 1 / -1;
    }

    .input-card,
    .metric-card,
    .insight-card,
    .saved-item {
        padding: 10px;
        border-radius: 16px;
    }

    .field {
        gap: 6px;
    }

    input,
    .custom-select-trigger,
    .segmented button,
    .chip-btn,
    .primary-btn,
    .secondary-btn,
    .ghost-btn {
        min-height: 42px;
        padding: 9px 10px;
        font-size: 0.88rem;
    }

    .compact-btn {
        min-height: 40px;
        padding-inline: 12px;
    }

    .support-actions {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .support-actions .secondary-btn,
    .support-actions .ghost-btn {
        min-height: 40px;
        font-size: 0.8rem;
    }

    .btn-icon {
        width: 24px;
        height: 24px;
    }

    .icon-glyph {
        width: 22px;
        height: 22px;
        font-size: 0.86rem;
    }

    .custom-select-panel {
        padding: 8px;
        border-radius: 18px;
    }

    .custom-select-option {
        min-height: 48px;
        padding: 10px 12px;
        border-radius: 14px;
    }

    .hero-metric strong {
        font-size: 2.25rem;
    }

    .stacked-actions {
        position: sticky;
        bottom: max(6px, env(safe-area-inset-bottom));
    }

    .table-wrap {
        margin-inline: -4px;
        border-radius: 18px;
    }

    table {
        min-width: 560px;
    }
}

@media (max-width: 380px) {
    .hero,
    .calculator-card,
    .summary-card,
    .surface-card,
    .app-topbar,
    .legal-card {
        padding: 14px;
        border-radius: 20px;
    }

    .hero-logo-wrap {
        width: 52px;
        height: 52px;
    }

    h1 {
        font-size: clamp(1.75rem, 11vw, 2.3rem);
    }

    .eyebrow {
        font-size: 0.7rem;
        padding: 7px 10px;
    }

    .hero-text,
    .section-copy,
    .subtle,
    .mini-note,
    th,
    td {
        font-size: 0.86rem;
    }

    .field-stack {
        grid-template-columns: 1fr;
    }

    .field-stack .full-width,
    .scenario-card,
    .interest-method-card,
    .primary-actions,
    .support-actions {
        grid-column: 1 / -1;
    }

    .input-card,
    .metric-card,
    .insight-card,
    .saved-item {
        padding: 10px;
        border-radius: 16px;
    }

    .compact-btn {
        width: 100%;
    }

    .footer-links {
        display: grid;
        width: 100%;
        gap: 8px;
    }

    .chart-wrap {
        min-height: 200px;
    }

    .line-wrap {
        min-height: 220px;
    }
}

@media print {
    @page {
        size: A4;
        margin: 14mm;
    }

    html,
    body {
        background: #fff;
        color: #000;
        font-family: "Aptos", "Segoe UI", sans-serif;
    }

    body::before,
    .page-shell > .container > :not(.print-report) {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .print-report {
        display: block;
    }

    .print-report__inner {
        color: #17241b;
    }

    .print-report__header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 20px;
        padding-bottom: 16px;
        border-bottom: 2px solid #d7dfd9;
        margin-bottom: 18px;
    }

    .print-report__brand h1 {
        margin: 0 0 6px;
        font-size: 26px;
        line-height: 1.05;
        color: #143126;
        max-width: none;
    }

    .print-report__brand p,
    .print-report__meta,
    .print-report__label,
    .print-report__subtext {
        margin: 0;
        color: #536156;
        font-size: 12px;
        line-height: 1.5;
    }

    .print-report__scenario {
        text-align: right;
    }

    .print-report__scenario-name {
        display: block;
        font-family: "Aptos Display", "Segoe UI", sans-serif;
        font-size: 20px;
        font-weight: 700;
        color: #17241b;
        margin-bottom: 6px;
    }

    .print-report__grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 18px;
    }

    .print-report__metric,
    .print-report__card {
        border: 1px solid #d7dfd9;
        border-radius: 12px;
        background: #fbfcfb;
        padding: 12px 14px;
        box-shadow: none;
        break-inside: avoid;
    }

    .print-report__metric strong {
        display: block;
        margin-top: 6px;
        font-size: 18px;
        line-height: 1.2;
        color: #143126;
    }

    .print-report__details {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
        margin-bottom: 18px;
    }

    .print-report__card h2 {
        margin: 0 0 10px;
        font-size: 15px;
        color: #17241b;
    }

    .print-report__detail-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 14px;
    }

    .print-report__detail-item {
        display: grid;
        gap: 4px;
    }

    .print-report__detail-item strong {
        font-size: 14px;
        color: #17241b;
    }

    .print-report__schedule {
        border: 1px solid #d7dfd9;
        border-radius: 12px;
        overflow: hidden;
    }

    .print-report__schedule-head {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 12px;
        padding: 14px 16px;
        background: #eff5f0;
        border-bottom: 1px solid #d7dfd9;
    }

    .print-report__schedule-head h2 {
        margin: 0;
        font-size: 15px;
        color: #17241b;
    }

    .print-report__table {
        width: 100%;
        border-collapse: collapse;
        font-size: 11px;
    }

    .print-report__table thead {
        display: table-header-group;
    }

    .print-report__table th,
    .print-report__table td {
        padding: 8px 10px;
        border-bottom: 1px solid #e3e9e4;
        text-align: left;
        vertical-align: top;
    }

    .print-report__table th {
        background: #f7faf7;
        color: #445247;
        font-weight: 700;
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .print-report__table tbody tr:nth-child(even) {
        background: #fbfcfb;
    }

    .print-report__table tbody tr,
    .print-report__metric,
    .print-report__card,
    .print-report__schedule {
        break-inside: avoid;
    }

    .print-report__footer {
        margin-top: 14px;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        font-size: 11px;
        color: #536156;
    }

    .print-report__footer strong {
        color: #17241b;
    }
}
