:root {
    color-scheme: light;
    --bg: #e8edf1;
    --paper: rgba(252, 253, 254, 0.97);
    --paper-strong: #ffffff;
    --ink: #1a2027;
    --muted: #697583;
    --line: rgba(26, 32, 39, 0.1);
    --line-strong: rgba(26, 32, 39, 0.16);
    --accent: #305f8d;
    --accent-strong: #214769;
    --accent-soft: rgba(48, 95, 141, 0.12);
    --ok: #3f6b57;
    --warn: #8a6b33;
    --danger: #9b5454;
    --danger-soft: rgba(155, 84, 84, 0.12);
    --shadow-xl: 0 28px 56px rgba(38, 50, 61, 0.12);
    --shadow-lg: 0 18px 34px rgba(38, 50, 61, 0.09);
    --shadow-sm: 0 10px 18px rgba(38, 50, 61, 0.07);
    --radius-2xl: 34px;
    --radius-xl: 26px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --ease-soft: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
    margin: 0;
    font-family: "Manrope", "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.82), transparent 24%),
        radial-gradient(circle at 82% 18%, rgba(48, 95, 141, 0.08), transparent 18%),
        linear-gradient(180deg, #f5f8fb 0%, #e3eaf0 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 26%),
        repeating-linear-gradient(0deg, rgba(26, 32, 39, 0.03) 0, rgba(26, 32, 39, 0.03) 1px, transparent 1px, transparent 94px);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.34), transparent 80%);
}

.shell {
    width: min(1500px, calc(100% - 40px));
    margin: 28px auto 44px;
    position: relative;
    z-index: 1;
}

.ledger-banner,
.meta-card,
.prep-card,
.builder-card,
.summary-card,
.preview-card,
.sidebar-card,
.notice {
    border: 1px solid var(--line);
    background: var(--paper);
    box-shadow: var(--shadow-xl);
}

.eyebrow,
.meta-label,
.card-kicker {
    margin: 0;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(105, 117, 131, 0.88);
}

.ledger-banner {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) 330px;
    gap: 24px;
    padding: 38px 40px;
    border-radius: var(--radius-2xl);
    margin-bottom: 24px;
    background:
        linear-gradient(180deg, rgba(254, 255, 255, 0.98), rgba(244, 248, 252, 0.95));
    position: relative;
    overflow: hidden;
}

.ledger-banner::after {
    content: "";
    position: absolute;
    top: 24px;
    right: 24px;
    width: 160px;
    height: 160px;
    border-radius: 28px;
    border: 1px solid rgba(48, 95, 141, 0.12);
    background:
        linear-gradient(rgba(48, 95, 141, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(48, 95, 141, 0.04) 1px, transparent 1px);
    background-size: 16px 16px;
    transform: rotate(10deg);
}

.ledger-banner h1,
.section-head h2,
.block-head h3,
.meta-card strong,
.prep-card h2,
.summary-card strong,
.preview-head h2,
.sidebar-card strong {
    margin: 0;
    letter-spacing: -0.05em;
}

.ledger-banner h1 {
    font-size: 30px;
    line-height: 0.92;
}

.lead,
.section-head p,
.meta-card p,
.prep-card p,
.form-note,
.summary-card p,
.notice,
.field-note,
.inline-output,
.preview-box,
table,
.sidebar-card p {
    color: var(--muted);
}

.lead {
    margin: 16px 0 0;
    font-size: 1.04rem;
    line-height: 1.75;
}

.ledger-meta {
    display: grid;
    gap: 16px;
    align-content: start;
}

.meta-card,
.prep-card,
.builder-card,
.summary-card,
.preview-card,
.sidebar-card {
    padding: 24px;
    border-radius: var(--radius-xl);
}

.meta-card {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
}

.meta-card strong {
    display: block;
    margin: 8px 0 6px;
    font-size: 1.16rem;
    line-height: 1.14;
}

.ledger-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 400px;
    gap: 24px;
    align-items: start;
}

.prep-column,
.editor-column,
.preview-column {
    display: grid;
    gap: 18px;
}

.preview-column {
    position: sticky;
    top: 24px;
}

.prep-card {
    background:
        linear-gradient(180deg, rgba(252, 253, 254, 0.98), rgba(244, 248, 251, 0.94));
}

.prep-card-accent {
    background:
        linear-gradient(180deg, rgba(48, 95, 141, 0.12), rgba(245, 249, 252, 0.94));
    border-color: rgba(48, 95, 141, 0.18);
}

.prep-card h2 {
    margin-top: 8px;
    font-size: 1.84rem;
    line-height: 1.02;
}

.prep-list {
    margin: 14px 0 0;
    padding-left: 18px;
    line-height: 1.75;
}

.builder-card {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(246, 249, 252, 0.96));
}

.section-head {
    display: grid;
    gap: 10px;
    margin-bottom: 22px;
}

.section-head h2 {
    font-size: clamp(2rem, 3vw, 2.8rem);
    line-height: 0.98;
}

.section-head p,
.meta-card p,
.prep-card p,
.summary-card p,
.sidebar-card p {
    margin: 0;
    line-height: 1.72;
}

.tool-form {
    display: grid;
    gap: 18px;
}

.builder-block {
    display: grid;
    gap: 16px;
    padding: 20px;
    border-radius: 22px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
}

.block-head {
    display: grid;
    gap: 6px;
}

.block-head h3 {
    font-size: 1.34rem;
    line-height: 1.02;
}

.grid-two,
.grid-three {
    display: grid;
    gap: 16px;
}

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

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

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

.field > span {
    font-size: 0.94rem;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    padding: 15px 17px;
    font: inherit;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
    transition: border-color 180ms var(--ease-soft), box-shadow 180ms var(--ease-soft), background 180ms var(--ease-soft), transform 180ms var(--ease-soft);
}

textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.65;
}

input::placeholder,
textarea::placeholder {
    color: rgba(105, 117, 131, 0.72);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: rgba(48, 95, 141, 0.4);
    background: rgba(255, 255, 255, 0.95);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        0 0 0 4px rgba(48, 95, 141, 0.1);
    transform: translateY(-1px);
}

.field-note {
    margin-top: 2px;
    font-size: 0.88rem;
    line-height: 1.6;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: transform 180ms var(--ease-soft), box-shadow 180ms var(--ease-soft), background 180ms var(--ease-soft), opacity 180ms var(--ease-soft);
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.52; cursor: not-allowed; }

button[type="submit"] {
    color: #fffdfa;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    box-shadow: 0 14px 28px rgba(33, 71, 105, 0.22);
}

.ghost-button {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.action-row,
.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.builder-actions {
    display: grid;
    gap: 14px;
}

.form-note,
.field-note {
    margin: 0;
}

.notice {
    padding: 16px 18px;
    border-radius: 18px;
    line-height: 1.7;
}

.notice.success {
    color: var(--ok);
    background: rgba(68, 100, 83, 0.1);
}

.notice.error {
    color: var(--danger);
    background: var(--danger-soft);
}

.hidden { display: none !important; }

.summary-card,
.preview-card,
.sidebar-card {
    background:
        linear-gradient(180deg, rgba(252, 253, 254, 0.98), rgba(243, 247, 251, 0.95));
}

.summary-card strong,
.sidebar-card strong {
    display: block;
    margin: 8px 0 10px;
    font-size: 1.52rem;
    line-height: 1.04;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(48, 95, 141, 0.14);
    background: rgba(255, 255, 255, 0.74);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.summary-box,
.preview-box {
    border-radius: 20px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.84);
    padding: 16px;
}

.summary-box-compact {
    margin-top: 6px;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
}

.summary-line.total {
    border-top: 1px solid var(--line);
    margin-top: 8px;
    padding-top: 12px;
    font-weight: 800;
    color: var(--ink);
}

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

.preview-head h2 {
    font-size: clamp(1.8rem, 2.6vw, 2.4rem);
    line-height: 1;
}

.invoice-preview {
    border-radius: 24px;
    border: 1px solid var(--line);
    background: var(--paper-strong);
    padding: 24px;
    box-shadow: inset 0 0 0 1px rgba(26, 32, 39, 0.04);
}

.invoice-title-row,
.invoice-header,
.invoice-summary {
    display: grid;
    gap: 18px;
}

.invoice-title-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-bottom: 24px;
}

.invoice-title-row h3 {
    margin: 6px 0 0;
    font-size: 2rem;
    letter-spacing: -0.04em;
}

.invoice-status-badge {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(48, 95, 141, 0.12);
    color: var(--accent-strong);
    font-weight: 800;
    font-size: 0.88rem;
}

.invoice-header {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 20px;
}

.inline-output {
    line-height: 1.75;
    white-space: pre-line;
}

.invoice-summary {
    grid-template-columns: 1fr;
    margin-bottom: 20px;
}

.preview-box strong {
    display: block;
    margin-bottom: 8px;
    color: var(--ink);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.96rem;
}

th,
td {
    text-align: left;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

th:last-child,
td:last-child {
    text-align: right;
}

.ad-slot,
.ad-placeholder {
    border: 1px solid var(--line);
    border-radius: 22px;
    min-height: 340px;
    background: rgba(255, 255, 255, 0.86);
    overflow: hidden;
}

.ad-placeholder {
    padding: 16px;
}

.ad-mockup {
    position: relative;
    min-height: 306px;
    height: 100%;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(243, 247, 251, 0.96));
    box-shadow: inset 0 0 0 1px rgba(26, 32, 39, 0.06);
}

.ad-mockup::before {
    content: "";
    position: absolute;
    inset: 16px;
    border-radius: 18px;
    border: 1px solid rgba(48, 95, 141, 0.1);
}

.ad-mockup-top,
.ad-mockup-media,
.ad-mockup-badge,
.ad-mockup-lines {
    position: absolute;
}

.ad-mockup-top {
    top: 28px;
    left: 28px;
    width: 112px;
    height: 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
}

.ad-mockup-media {
    inset: 84px 28px 112px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(48, 95, 141, 0.12), rgba(121, 146, 170, 0.12));
}

.ad-mockup-lines {
    left: 28px;
    right: 28px;
    bottom: 32px;
    display: grid;
    gap: 12px;
}

.ad-mockup-lines span {
    display: block;
    height: 14px;
    border-radius: 999px;
    background: rgba(48, 95, 141, 0.14);
}

.ad-mockup-lines span:last-child {
    width: 58%;
}

.ad-mockup-badge {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 156px;
    height: 156px;
    border-radius: 50%;
    display: grid;
    place-content: center;
    gap: 2px;
    background: linear-gradient(135deg, var(--accent), #4f7da8);
    color: #fff;
    box-shadow: 0 16px 30px rgba(33, 71, 105, 0.18);
}

.ad-mockup-badge span {
    display: block;
    font-size: 1.52rem;
    font-weight: 800;
    line-height: 1;
    text-align: center;
    letter-spacing: 0.04em;
}

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

    .preview-column {
        position: static;
    }

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

@media (max-width: 860px) {
    .shell {
        width: min(100% - 24px, 100%);
        margin: 14px auto 28px;
    }

    .ledger-banner,
    .meta-card,
    .prep-card,
    .builder-card,
    .summary-card,
    .preview-card,
    .sidebar-card {
        padding: 22px;
        border-radius: 24px;
    }

    .ledger-banner,
    .prep-column,
    .grid-two,
    .grid-three,
    .invoice-header,
    .invoice-summary {
        grid-template-columns: 1fr;
    }

    .ledger-banner h1 {
        font-size: 30px;
    }

    .invoice-title-row,
    .preview-head {
        grid-template-columns: 1fr;
        display: grid;
    }
}

@media print {
    body {
        background: #fff;
    }

    body::before,
    .ledger-banner,
    .prep-column,
    .editor-column,
    .summary-card,
    .sidebar-card,
    #invoice-print {
        display: none !important;
    }

    .shell {
        width: 100%;
        margin: 0;
    }

    .ledger-grid,
    .preview-column,
    .preview-card,
    .invoice-preview {
        display: block;
        box-shadow: none;
        border: 0;
        background: transparent;
        padding: 0;
    }
}
h1 {
    font-size: 30px;
}
