:root {
    --ink: #1a2332;
    --muted: #5d6b7c;
    --line: #d5deea;
    --paper: #ffffff;
    --sand: #e7eef6;
    --bg: #e6edf5;
    --pine: #163a46;
    --pine-2: #1f5162;
    --copper: #c26a3a;
    --danger: #8c2f2f;
    --danger-bg: #fdeeee;
    --shadow: 0 16px 40px rgba(22, 40, 64, 0.1);
    --serif: "Fraunces", "Iowan Old Style", Palatino, serif;
    --sans: "Outfit", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, #f7fafc 0, #f7fafc 4.5rem, var(--bg) 4.5rem);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.45;
}

h1, h2, h3, legend, .brand-name, .net strong {
    font-family: var(--serif);
    font-weight: 560;
    letter-spacing: -0.02em;
}

a { color: var(--pine); }

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
    align-items: center;
    padding: 0.85rem 1.4rem;
    background: var(--pine);
    color: #f4f7f8;
}

.brand { display: flex; gap: 0.8rem; align-items: center; }

.mark {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 0.55rem;
    background:
        linear-gradient(#f4f7f8, #f4f7f8) 0.42rem 0.58rem / 1.3rem 2px no-repeat,
        linear-gradient(#f4f7f8, #f4f7f8) 0.42rem 1rem / 0.9rem 2px no-repeat,
        linear-gradient(var(--copper), var(--copper)) 0.42rem 1.42rem / 1.15rem 2px no-repeat,
        #0f2a33;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.kicker {
    margin: 0;
    color: var(--copper);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.brand-name { margin: 0; font-size: 1.35rem; color: #f4f7f8; }

.brand-note {
    max-width: 28rem;
    margin: 0;
    color: #d5e4ea;
    font-size: 0.92rem;
}

.layout {
    display: grid;
    grid-template-columns: minmax(22rem, 38rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1.25rem 0 2.8rem;
}

.panel, .empty, .banner {
    background: var(--paper);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 1.15rem;
    box-shadow: var(--shadow);
}

.panel { padding: 1.2rem 1.25rem 1.5rem; }

.panel-intro h1 { margin: 0.15rem 0 0.35rem; font-size: 2rem; }

.panel-intro p, .empty p, .banner p { color: var(--muted); }

form { counter-reset: section; }

fieldset {
    margin: 1.15rem 0 0;
    padding: 0.15rem 0 0.15rem;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
}

legend {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem 0 0.35rem;
    color: var(--pine);
    font-size: 1.2rem;
}

legend::before {
    counter-increment: section;
    content: counter(section);
    display: grid;
    place-items: center;
    width: 1.55rem;
    height: 1.55rem;
    border-radius: 999px;
    background: var(--sand);
    color: var(--pine);
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 650;
}

.fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 0.8rem;
}

.field { display: flex; flex-direction: column; gap: 0.28rem; min-width: 0; }

.field:has(textarea) { grid-column: 1 / -1; }

.field label, .field-check label { font-size: 0.86rem; font-weight: 600; }

.field input, .field select, .field textarea {
    width: 100%;
    padding: 0.68rem 0.75rem;
    border: 1px solid #c9d5e2;
    border-radius: 0.7rem;
    background: #f8fafc;
    color: var(--ink);
    font: inherit;
}

.field input::placeholder, .field textarea::placeholder {
    color: #8b98a8;
    opacity: 1;
}

.field textarea { resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus {
    outline: 2px solid rgba(20, 52, 43, 0.28);
    border-color: var(--pine);
}

.field-check {
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    padding-top: 1.45rem;
}

.field-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--pine); }

.hint { margin: 0; color: var(--muted); font-size: 0.78rem; }

.field.is-invalid input, .field.is-invalid select, .field.is-invalid textarea { border-color: var(--danger); }

.errors { margin: 0; padding-left: 1rem; color: var(--danger); font-size: 0.82rem; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    margin-top: 1rem;
}

.actions p { margin: 0; color: var(--muted); font-size: 0.85rem; }

button {
    font: inherit;
    cursor: pointer;
}

.primary, .ghost {
    border-radius: 999px;
    padding: 0.72rem 1.15rem;
    font-weight: 600;
}

.primary {
    border: 0;
    background: var(--copper);
    color: #fffaf6;
}

.primary:hover { background: #a8562c; }

.primary:disabled { opacity: 0.7; cursor: progress; }

.ghost {
    border: 1px solid var(--line);
    background: white;
    color: var(--pine);
}

.result { min-width: 0; position: sticky; top: 1rem; }

.result-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.7rem;
}

.result-toolbar p { margin: 0; color: var(--muted); }

.banner { padding: 1rem 1.1rem; margin-bottom: 0.8rem; }

.banner h2 { margin: 0 0 0.3rem; font-size: 1.35rem; }

.banner.error { background: var(--danger-bg); border-color: #efd2c8; }

.empty {
    padding: 1.5rem 1.35rem 1.6rem;
    background:
        linear-gradient(180deg, rgba(194, 106, 58, 0.08), transparent 5.5rem),
        var(--paper);
}

.empty h2 { margin: 0.2rem 0 0.6rem; font-size: 2.1rem; }

.empty ol { margin: 0; padding-left: 1.15rem; color: var(--ink); }

.empty li + li { margin-top: 0.45rem; }

.sheet {
    background: var(--paper);
    border-radius: 0.4rem;
    box-shadow: var(--shadow);
    padding: 1.35rem 1.3rem 1.1rem;
    color: #221e18;
}

.sheet-head, .identity, .totals, .sheet-foot {
    display: flex;
    justify-content: space-between;
    gap: 1.2rem;
}

.sheet-head { border-bottom: 3px solid var(--pine); padding-bottom: 0.8rem; }

.sheet-head h2 { margin: 0.1rem 0; font-size: 2rem; }

.period, .sheet-meta { margin: 0; color: var(--muted); }

.sheet-meta { text-align: right; }

.identity { padding: 0.9rem 0; }

.identity section { flex: 1; }

.identity h3, .section-title {
    margin: 0 0 0.35rem;
    color: var(--pine);
    font-size: 1rem;
}

.section-title { margin-top: 0.4rem; }

.name { margin: 0; font-weight: 650; }

.multiline { white-space: pre-line; margin: 0.15rem 0 0.45rem; }

dl { margin: 0; }

.identity dl div, .sheet-foot dl div, .totals dl div {
    display: grid;
    grid-template-columns: 8.5rem 1fr;
    gap: 0.4rem;
    margin-top: 0.15rem;
}

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

dd { margin: 0; }

.table-scroll { overflow-x: auto; }

.grid {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    font-size: 0.86rem;
}

.grid th, .grid td {
    padding: 0.38rem 0.4rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

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

.grid thead th {
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.grid tfoot th, .grid tfoot td { font-weight: 650; border-bottom: 0; }

.category th {
    padding-top: 0.7rem;
    color: var(--pine);
    font-family: var(--serif);
    font-size: 0.95rem;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
}

.fine { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.78rem; }

.totals { align-items: stretch; margin-top: 1rem; gap: 1rem; }

.totals dl { flex: 1; }

.totals dl div { grid-template-columns: 1fr auto; padding: 0.28rem 0; border-bottom: 1px solid var(--line); }

.net {
    min-width: 14rem;
    padding: 0.9rem 1rem;
    background: var(--pine);
    color: #f4f7f8;
    border-radius: 0.9rem;
}

.net p, .net span { margin: 0; }

.net strong {
    display: block;
    margin: 0.15rem 0 0.35rem;
    font-size: 2rem;
}

.net span { color: #e7d3b0; font-size: 0.85rem; }

.sheet-foot {
    flex-direction: column;
    margin-top: 1rem;
    padding-top: 0.7rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.78rem;
}

.sheet-foot dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem 1rem; }

.sheet-foot dl div { display: block; }

.sheet-foot dd { font-weight: 650; color: var(--ink); }

@media (max-width: 1040px) {
    .layout { display: block; width: min(100% - 1.5rem, 1180px); }
    .topbar { align-items: flex-start; }
    .brand-note { margin-top: 0.35rem; }
    .panel { margin-bottom: 1rem; }
    .result { position: static; }
}

@media (max-width: 720px) {
    .topbar { display: block; }
    .brand-note { display: block; margin-top: 0.35rem; }
    .fields, .sheet-foot dl, .identity, .sheet-head, .totals { display: block; }
    .field-check { padding-top: 0; }
    .sheet-meta { text-align: left; margin-top: 0.4rem; }
    .net { margin-top: 0.8rem; }
    .grid thead { display: none; }
    .grid, .grid tbody, .grid tr, .grid td { display: block; width: 100%; }
    .grid tr { padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
    .grid td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: 0;
        padding: 0.12rem 0;
        text-align: right;
        white-space: normal;
    }
    .grid td::before { content: attr(data-label); color: var(--muted); font-size: 0.75rem; }
    .earnings td:first-child::before { content: none; }
    .grid td:first-child { font-weight: 650; text-align: left; }
    .grid tfoot { display: block; }
    .grid tfoot tr { display: flex; justify-content: space-between; }
    .grid tfoot th { text-align: left; }
    .category { display: block; padding-top: 0.6rem; }
}

@media print {
    body { background: white; }
    .topbar, .panel, .result-toolbar, .banner, .empty { display: none !important; }
    .layout { display: block; padding: 0; }
    .sheet { box-shadow: none; border-radius: 0; padding: 0; }
    a { color: inherit; text-decoration: none; }
}
