:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --ink: #122033;
    --muted: #5f6f82;
    --line: #dce5ef;
    --brand: #0f766e;
    --brand-dark: #0b5e57;
    --brand-soft: #e6f5f2;
    --accent: #f59e0b;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --ok: #15803d;
    --ok-soft: #ecfdf3;
    --shadow: 0 20px 55px rgba(15, 42, 68, 0.08);
    --radius: 20px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 85% -10%, rgba(15, 118, 110, 0.12), transparent 34rem),
        radial-gradient(circle at 5% 8%, rgba(245, 158, 11, 0.08), transparent 28rem),
        var(--bg);
    color: var(--ink);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(220, 229, 239, 0.9);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), #14b8a6);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.28);
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 17px;
    letter-spacing: -0.02em;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 11px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.pill.muted {
    background: #eef2f7;
    color: var(--muted);
    font-weight: 600;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 28px;
    align-items: center;
    padding: 46px 0 30px;
}

.eyebrow {
    display: inline-block;
    color: var(--brand);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.hero h1 {
    margin: 0 0 12px;
    font-size: clamp(30px, 4.2vw, 52px);
    line-height: 1.04;
    letter-spacing: -0.045em;
    max-width: 720px;
}

.hero p {
    margin: 0;
    color: var(--muted);
    font-size: 16px;
    max-width: 700px;
}

.hero-card {
    background: #102a43;
    color: #fff;
    border-radius: 22px;
    padding: 20px 22px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.hero-card::after {
    content: "";
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.18);
    right: -60px;
    top: -70px;
}

.hero-card span {
    display: block;
    color: #a9bfd4;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-card strong {
    display: block;
    font-size: 42px;
    letter-spacing: -0.04em;
    line-height: 1.1;
    margin: 8px 0 4px;
}

.hero-card strong small {
    font-size: 16px;
    color: #fbbf24;
    letter-spacing: 0;
}

.hero-card p {
    margin: 0;
    font-size: 12px;
    color: #c7d7e6;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(360px, 0.88fr);
    gap: 22px;
    align-items: start;
    padding-bottom: 34px;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(220, 229, 239, 0.95);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-card {
    padding: 24px;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.card-head h2,
.card-head h3 {
    margin: 0;
    letter-spacing: -0.03em;
}

.card-head h2 {
    font-size: 24px;
}

.card-head h3 {
    font-size: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge.soft {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.badge.ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.badge.bad {
    background: var(--danger-soft);
    color: var(--danger);
}

.badge.warn {
    background: #fffbeb;
    color: #b45309;
}

.alert {
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-size: 13px;
}

.alert ul {
    margin: 6px 0 0;
    padding-left: 18px;
}

fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 26px;
}

legend {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

legend span {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 11px;
    letter-spacing: 0;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

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

.field label {
    font-size: 12px;
    font-weight: 800;
    color: #334155;
}

.field small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--ink);
    padding: 9px 11px;
    font: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.input:focus {
    border-color: var(--brand);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

select.input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 13px) calc(50% - 2px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 34px;
}

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

.market-option {
    cursor: pointer;
    display: block;
}

.market-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.market-box {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 74px;
    padding: 12px 13px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.market-box strong {
    font-size: 13px;
    line-height: 1.25;
}

.market-box small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
}

.market-option input:checked + .market-box {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.1);
}

.filament-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.filament-head label {
    display: block;
}

.filament-head small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

.filament-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filament-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) 105px 150px 34px;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
}

.filament-name {
    min-width: 0;
}

.filament-unit {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.filament-unit span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.filament-unit .input {
    min-height: 36px;
    padding: 7px 8px;
}

.icon-button {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    font: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.icon-button:hover {
    border-color: #fecaca;
    background: var(--danger-soft);
    color: var(--danger);
}

.filament-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 9px 11px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 12px;
}

.filament-summary strong {
    font-weight: 800;
}

.filament-result {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.filament-result-row {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 74px;
    gap: 9px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 12px;
}

.filament-result-info {
    min-width: 0;
}

.filament-result-info strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filament-result-info small {
    display: block;
    color: var(--muted);
    font-size: 10px;
}

.filament-result-row > strong {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.filament-result-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    color: var(--muted);
    font-size: 11px;
}

.filament-result-total strong {
    color: var(--ink);
}

.inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.link-button {
    border: 0;
    background: transparent;
    padding: 4px 2px;
    color: var(--brand);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

.advanced {
    margin-top: 2px;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 12px 14px;
    background: #fbfdff;
}

.advanced summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    color: #334155;
}

.advanced summary span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

.advanced[open] summary {
    margin-bottom: 14px;
}

.checkbox-field {
    justify-content: flex-start;
}

.switch-label {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
}

.switch-label input {
    width: 17px;
    height: 17px;
    margin: 1px 0 0;
    accent-color: var(--brand);
}

.submit-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 20px;
    border-radius: 12px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.button:hover {
    text-decoration: none;
    transform: translateY(-1px);
}

.button.primary {
    background: linear-gradient(135deg, var(--brand), #0d9488);
    color: #fff;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.24);
}

.button.primary:hover {
    background: linear-gradient(135deg, var(--brand-dark), #0f766e);
}

.button.ghost {
    background: #fff;
    border-color: var(--line);
    color: #334155;
}

.button.mini {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
}

.results-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 92px;
}

.result-card,
.sale-card,
.comparison-card,
.empty-card,
.tax-card {
    padding: 22px;
}

.result-head h2 {
    margin: 2px 0 4px;
    font-size: 44px;
    line-height: 1;
    letter-spacing: -0.055em;
}

.result-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 18px 0 20px;
}

.kpi {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
}

.kpi span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
}

.kpi strong {
    font-size: 14px;
    letter-spacing: -0.02em;
}

.section-title {
    margin: 0 0 10px;
    font-size: 13px;
    color: #334155;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cost-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cost-row {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr) 74px;
    gap: 9px;
    align-items: center;
    font-size: 12px;
}

.cost-row span {
    color: #475569;
}

.cost-row strong {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bar {
    height: 7px;
    background: #eef2f7;
    border-radius: 999px;
    overflow: hidden;
}

.bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), #2dd4bf);
}

.cost-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--line);
    margin-top: 14px;
    padding-top: 14px;
}

.cost-total span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.cost-total strong {
    font-size: 20px;
    letter-spacing: -0.03em;
}

.sale-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.sale-head h3 {
    margin: 0;
    font-size: 17px;
    letter-spacing: -0.02em;
}

.sale-head small {
    color: var(--muted);
    font-size: 11px;
}

.sale-price {
    margin: 14px 0 0;
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.055em;
    line-height: 1;
}

.sale-sub {
    margin: 3px 0 14px;
    color: var(--muted);
    font-size: 12px;
}

.sale-lines {
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--line);
}

.sale-lines > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid #f0f4f8;
    font-size: 12px;
}

.sale-lines dt {
    color: #475569;
}

.sale-lines dd {
    margin: 0;
    color: #334155;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sale-lines .strong {
    font-weight: 800;
}

.sale-lines .strong dt {
    color: var(--ink);
}

.sale-total {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.sale-total > div {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
}

.sale-total span {
    display: block;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sale-total strong {
    display: block;
    margin-top: 2px;
    font-size: 17px;
    letter-spacing: -0.03em;
}

.ok-text {
    color: var(--ok) !important;
}

.bad-text {
    color: var(--danger) !important;
}

.sale-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    color: var(--muted);
    font-size: 11px;
}

.sale-foot strong {
    color: var(--ink);
}

.table-wrap {
    overflow-x: auto;
    margin: 0 -4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 540px;
}

th,
td {
    text-align: right;
    padding: 9px 8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th:first-child,
td:first-child {
    text-align: left;
    white-space: normal;
}

th {
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.result-actions .button {
    flex: 1;
    min-width: 150px;
}

.empty-card {
    text-align: left;
}

.empty-icon {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 20px;
    font-weight: 900;
    margin-bottom: 14px;
}

.empty-card h2 {
    margin: 0 0 8px;
    font-size: 24px;
    letter-spacing: -0.03em;
}

.empty-card p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.checklist {
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checklist li {
    position: relative;
    padding-left: 24px;
    color: #334155;
    font-size: 13px;
}

.checklist li::before {
    content: "✓";
    position: absolute;
    left: 0;
    top: 0;
    color: var(--brand);
    font-weight: 900;
}

.tax-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tax-list > div {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.tax-list > div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.tax-list strong,
.tax-list span,
.tax-list small {
    display: block;
}

.tax-list strong {
    font-size: 14px;
}

.tax-list span {
    color: var(--ink);
    font-size: 13px;
    margin-top: 1px;
}

.tax-list small {
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.sources {
    padding: 4px 0 38px;
}

.sources details {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px 18px;
}

.sources summary {
    cursor: pointer;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.sources-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-top: 18px;
}

.sources-grid h4 {
    margin: 0 0 6px;
    font-size: 13px;
}

.sources-grid p {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 12px;
}

.sources-grid a {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    margin: 0 8px 4px 0;
}

.disclaimer {
    margin: 18px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11px;
}

.footer {
    border-top: 1px solid var(--line);
    background: #fff;
    padding: 18px 0;
}

.footer .container {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 11px;
}

.muted {
    color: var(--muted);
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .results-column {
        position: static;
    }

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

    .hero-card {
        max-width: 340px;
    }

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

@media (max-width: 640px) {
    .container {
        width: min(100% - 20px, 1180px);
    }

    .topbar-inner {
        min-height: auto;
        padding: 10px 0;
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-meta {
        justify-content: flex-start;
    }

    .hero {
        padding: 28px 0 20px;
    }

    .hero h1 {
        font-size: 34px;
    }

    .form-card,
    .result-card,
    .sale-card,
    .comparison-card,
    .empty-card,
    .tax-card {
        padding: 17px;
    }

    .form-grid,
    .market-grid {
        grid-template-columns: 1fr;
    }

    .filament-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px;
    }

    .filament-name {
        grid-column: 1 / -1;
    }

    .filament-result-row {
        grid-template-columns: minmax(0, 1fr) 70px;
    }

    .filament-result-row .bar {
        display: none;
    }

    .result-head h2 {
        font-size: 38px;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .cost-row {
        grid-template-columns: 96px minmax(0, 1fr) 70px;
    }

    .sources-grid {
        grid-template-columns: 1fr;
    }

    .sale-price {
        font-size: 32px;
    }
}

@media print {
    body {
        background: #fff;
        font-size: 12px;
    }

    .topbar,
    .hero,
    .form-card,
    .sources,
    .footer,
    .result-actions,
    .inline-actions {
        display: none !important;
    }

    .layout {
        display: block;
        padding: 0;
    }

    .card {
        box-shadow: none;
        border-color: #cbd5e1;
        break-inside: avoid;
        margin-bottom: 12px;
    }

    .results-column {
        position: static;
    }
}
