:root {
    --ink: #12141a;
    --ink-soft: rgba(18, 20, 26, 0.64);
    --ink-faint: rgba(18, 20, 26, 0.42);
    --paper: #ebe8e2;
    --paper-2: #f4f2ed;
    --surface: rgba(255, 252, 247, 0.88);
    --surface-strong: #fffcf7;
    --spruce: #184f45;
    --spruce-mid: #236558;
    --spruce-deep: #0f332c;
    --spruce-wash: rgba(24, 79, 69, 0.1);
    --brass: #a88455;
    --warn: #8a4f12;
    --warn-bg: #f8efe3;
    --danger: #8f2a24;
    --danger-bg: #f8e8e6;
    --line: rgba(18, 20, 26, 0.1);
    --shadow: 0 28px 64px rgba(18, 20, 26, 0.12);
    --shadow-soft: 0 8px 24px rgba(18, 20, 26, 0.06);
    --radius: 18px;
    --radius-sm: 10px;
    --font-display: "Bricolage Grotesque", sans-serif;
    --font-body: "Figtree", sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        radial-gradient(
            900px 520px at 8% -8%,
            #d9e4df 0%,
            transparent 58%
        ),
        radial-gradient(
            760px 480px at 92% 0%,
            #e4ddd2 0%,
            transparent 52%
        ),
        linear-gradient(
            180deg,
            rgba(18, 20, 26, 0.025) 1px,
            transparent 1px
        );
    background-size: auto, auto, 100% 28px;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

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

.shell,
.shell-nav {
    width: min(1180px, calc(100% - 2.5rem));
    margin-left: auto;
    margin-right: auto;
}

.shell {
    padding-bottom: 3.5rem;
}

.shell-wide {
    width: min(1480px, calc(100% - 1.5rem));
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.4rem 0 0.9rem;
    animation: rise 0.45s var(--ease) both;
}

.page-home .nav {
    width: min(1180px, calc(100% - 2.5rem));
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.35rem;
    letter-spacing: -0.05em;
    color: var(--ink);
}

.nav-links {
    display: flex;
    gap: 0.15rem 1.35rem;
    align-items: center;
}

.nav-links a {
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
    transition:
        color 0.2s var(--ease),
        border-color 0.2s var(--ease);
}

.nav-links a:hover {
    color: var(--ink);
}

.nav-links a.active {
    color: var(--ink);
    border-bottom-color: var(--spruce);
}

/* —— Landing —— */
.page-home {
    overflow-x: hidden;
}

.landing {
    display: grid;
    grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1.18fr);
    gap: 0;
    align-items: stretch;
    min-height: calc(100vh - 5.2rem);
    width: min(1400px, 100%);
    margin: 0 auto;
    padding: 0 0 0 clamp(1.25rem, 3vw, 2.5rem);
}

@media (max-width: 980px) {
    .landing {
        grid-template-columns: 1fr;
        min-height: auto;
        padding: 0 1.25rem 2rem;
        gap: 1.5rem;
    }
}

.landing-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.5rem 2.5rem 2.5rem 0;
    animation: rise 0.6s var(--ease) both;
}

@media (max-width: 980px) {
    .landing-copy {
        padding: 1rem 0 0;
    }
}

.kicker {
    margin: 0 0 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brass);
}

.landing-copy .mark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(4.2rem, 9vw, 6.4rem);
    line-height: 0.88;
    letter-spacing: -0.065em;
    margin: 0 0 1.2rem;
    color: var(--ink);
}

.landing-copy .lede {
    margin: 0;
    max-width: 28ch;
    font-size: 1.15rem;
    line-height: 1.55;
    color: var(--ink-soft);
    font-weight: 500;
}

.landing-copy .cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.75rem;
}

.trust-line {
    margin: 1.5rem 0 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink-faint);
    letter-spacing: 0.01em;
}

.landing-visual {
    position: relative;
    min-height: calc(100vh - 5.2rem);
    margin-right: max(-2vw, calc((100% - 100vw) / 2));
    border-radius: 28px 0 0 28px;
    overflow: hidden;
    background:
        linear-gradient(
            155deg,
            #0e2c26 0%,
            #184f45 48%,
            #2a6b5c 100%
        );
    box-shadow: var(--shadow);
    animation: rise 0.7s var(--ease) 0.06s both;
}

@media (max-width: 980px) {
    .landing-visual {
        min-height: 520px;
        margin-right: 0;
        border-radius: 22px;
    }
}

.landing-visual::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            520px 360px at 80% 20%,
            rgba(255, 255, 255, 0.12),
            transparent 60%
        ),
        linear-gradient(
            180deg,
            transparent 0%,
            rgba(0, 0, 0, 0.12) 100%
        );
    pointer-events: none;
}

.sheet {
    position: absolute;
    width: 46%;
    aspect-ratio: 0.72;
    border-radius: 8px;
    background:
        linear-gradient(
            180deg,
            rgba(255, 252, 247, 0.16),
            rgba(255, 252, 247, 0.06)
        );
    border: 1px solid rgba(255, 255, 255, 0.18);
    pointer-events: none;
}

.sheet-a {
    top: 11%;
    right: 10%;
    transform: rotate(8deg);
    animation: float-a 7s ease-in-out infinite alternate;
}

.sheet-b {
    top: 22%;
    right: 28%;
    transform: rotate(-6deg);
    opacity: 0.75;
    animation: float-b 8.5s ease-in-out infinite alternate;
}

.drop-stage {
    position: relative;
    z-index: 1;
    height: 100%;
    min-height: inherit;
    display: flex;
    flex-direction: column;
    padding: 1.6rem 1.6rem 1.5rem;
}

.dropzone {
    flex: 1;
    border: 1px dashed rgba(255, 255, 255, 0.38);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    text-align: center;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition:
        background 0.25s var(--ease),
        border-color 0.25s var(--ease),
        transform 0.25s var(--ease);
    background: rgba(255, 255, 255, 0.06);
}

.dropzone:hover,
.dropzone.dragover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
}

.dropzone .glyph {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.14);
    margin-bottom: 0.35rem;
    animation: pulse 3s var(--ease) infinite;
}

.dropzone .glyph svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dropzone strong {
    display: block;
    font-family: var(--font-display);
    font-size: 1.55rem;
    letter-spacing: -0.035em;
    font-weight: 700;
}

.dropzone span {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.95rem;
    max-width: 26ch;
    line-height: 1.45;
}

.stage-footer {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stage-footer .file-list,
.stage-footer .doc-list {
    margin: 0;
    color: #fff;
}

.stage-footer .file-list li,
.stage-footer .doc-list li {
    border-bottom-color: rgba(255, 255, 255, 0.16);
}

.stage-footer .file-list li span:last-child,
.stage-footer .meta {
    color: rgba(255, 255, 255, 0.7);
}

.stage-footer a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.stage-footer .badge {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.stage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.progress {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 100%;
    width: 0%;
    background: #fff;
    transition: width 0.35s var(--ease);
}

.meta {
    margin: 0;
    font-size: 0.88rem;
}

button,
.btn {
    appearance: none;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.82rem 1.25rem;
    font: inherit;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    background: var(--spruce);
    color: #fff;
    transition:
        transform 0.2s var(--ease),
        background 0.2s var(--ease);
}

button:hover,
.btn:hover {
    background: var(--spruce-mid);
    transform: translateY(-1px);
}

button.secondary,
.btn.secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

button.secondary:hover,
.btn.secondary:hover {
    background: rgba(255, 252, 247, 0.7);
}

button.on-dark,
.btn.on-dark {
    background: #fffcf7;
    color: var(--spruce-deep);
}

button.on-dark:hover,
.btn.on-dark:hover {
    background: #fff;
}

button.on-dark.secondary,
.btn.on-dark.secondary {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.32);
}

button.on-dark.secondary:hover,
.btn.on-dark.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.file-list,
.doc-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    max-height: 150px;
    overflow: auto;
}

.file-list li,
.doc-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.7rem 0.15rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
}

.panel {
    margin: 1.25rem 0 2rem;
    padding: 1.35rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    animation: rise 0.65s var(--ease) 0.06s both;
}

.hero {
    padding: 1.2rem 0 0.75rem;
    animation: rise 0.5s var(--ease) both;
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 3.5vw, 2.85rem);
    line-height: 0.96;
    letter-spacing: -0.045em;
    margin: 0 0 0.5rem;
}

.hero p {
    margin: 0;
    max-width: 46ch;
    color: var(--ink-soft);
    font-size: 1.02rem;
    line-height: 1.55;
    font-weight: 500;
}

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

/* —— Validate —— */
.validate-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    margin: 0.2rem 0 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(10px);
    animation: rise 0.5s var(--ease) 0.04s both;
}

.counter {
    font-size: 0.88rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.counter strong {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 1.15rem;
    letter-spacing: -0.03em;
}

.toolbar-actions {
    margin-top: 0;
}

.workspace {
    display: grid;
    grid-template-columns: 260px minmax(0, 1.1fr) minmax(300px, 0.95fr);
    gap: 0.9rem;
    min-height: 74vh;
    animation: rise 0.65s var(--ease) 0.08s both;
}

@media (max-width: 1180px) {
    .workspace {
        grid-template-columns: 230px 1fr;
    }

    .fields-pane {
        grid-column: 1 / -1;
        min-height: 360px;
    }
}

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

.queue-pane,
.preview-pane,
.fields-pane {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 440px;
}

.pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1.05rem;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 252, 247, 0.65);
}

.pane-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.02rem;
    letter-spacing: -0.03em;
    font-weight: 700;
}

.queue-search {
    margin: 0.85rem 0.85rem 0.35rem;
}

.queue-search input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
    font: inherit;
    background: #fff;
    outline: none;
}

.queue-search input:focus {
    border-color: rgba(24, 79, 69, 0.45);
    box-shadow: 0 0 0 3px var(--spruce-wash);
}

.queue-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem;
    overflow: auto;
    flex: 1;
    max-height: none;
}

.queue-item {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 0.8rem 0.85rem;
    cursor: pointer;
    color: inherit;
    display: grid;
    gap: 0.4rem;
    transition: background 0.2s var(--ease);
}

.queue-item:hover {
    background: var(--spruce-wash);
    transform: none;
}

.queue-item.active {
    background: rgba(24, 79, 69, 0.12);
    box-shadow: inset 3px 0 0 var(--spruce);
}

.queue-item .name {
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: -0.015em;
    word-break: break-word;
}

.queue-item .row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.preview-body {
    padding: 1rem;
    flex: 1;
    min-height: 380px;
    background:
        linear-gradient(
            90deg,
            rgba(18, 20, 26, 0.03) 1px,
            transparent 1px
        )
        0 0 / 28px 28px,
        var(--surface-strong);
}

.preview-body iframe,
.preview-body img {
    width: 100%;
    min-height: 60vh;
    max-height: 74vh;
    border: 0;
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.preview-empty,
.fields-empty {
    color: var(--ink-soft);
    padding: 2.4rem 1.2rem;
    text-align: center;
    line-height: 1.5;
}

.fields-body {
    padding: 1rem 1.15rem 1.4rem;
    overflow: auto;
    flex: 1;
}

.field {
    margin-bottom: 0.95rem;
}

.field label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.35rem;
    color: var(--ink-soft);
    font-weight: 700;
}

.field .conf {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--spruce-deep);
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.85rem;
    font: inherit;
    background: #fff;
    outline: none;
    transition:
        border-color 0.2s var(--ease),
        box-shadow 0.2s var(--ease);
}

.field input:focus,
.field textarea:focus {
    border-color: rgba(24, 79, 69, 0.5);
    box-shadow: 0 0 0 3px var(--spruce-wash);
}

.field.needs-review input,
.field.needs-review textarea {
    border-color: rgba(138, 79, 18, 0.45);
    background: var(--warn-bg);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.5rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #dce8e4;
    color: var(--ink);
}

.badge.type-invoice {
    background: #d5e8e2;
    color: var(--spruce-deep);
}

.badge.type-contract {
    background: #e2e5ef;
    color: #33415f;
}

.badge.type-delivery_note {
    background: #ece4d7;
    color: #5c4424;
}

.badge.warn {
    background: #f0dfc4;
    color: #6b3d08;
}

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

.badge.ok {
    background: #d5e8e2;
    color: var(--spruce-deep);
}

.toast {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    padding: 0.9rem 1.15rem;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition:
        opacity 0.25s var(--ease),
        transform 0.25s var(--ease);
    z-index: 50;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.85rem;
    animation: rise 0.55s var(--ease) 0.05s both;
}

.stat {
    padding: 1.2rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    transition: transform 0.25s var(--ease);
}

.stat:hover {
    transform: translateY(-2px);
}

.stat .n {
    font-family: var(--font-display);
    font-size: 1.9rem;
    letter-spacing: -0.04em;
    font-weight: 700;
}

.stat .l {
    font-size: 0.84rem;
    color: var(--ink-soft);
    margin-top: 0.25rem;
    font-weight: 500;
}

.issues {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}

.issues li {
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-sm);
    background: var(--warn-bg);
    margin-bottom: 0.45rem;
    font-size: 0.88rem;
    border: 1px solid rgba(138, 79, 18, 0.14);
}

.issues li.error {
    background: var(--danger-bg);
    border-color: rgba(143, 42, 36, 0.14);
}

.dash-layout {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 1rem;
    margin-top: 1rem;
}

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

.dash-side {
    border-radius: var(--radius);
    padding: 1.55rem;
    color: #fff;
    background:
        linear-gradient(
            150deg,
            #0e2c26 0%,
            #184f45 55%,
            #2a6b5c 100%
        );
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    animation: rise 0.65s var(--ease) 0.08s both;
}

.dash-side::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            360px 240px at 90% 10%,
            rgba(255, 255, 255, 0.12),
            transparent 60%
        );
    pointer-events: none;
}

.dash-side > * {
    position: relative;
    z-index: 1;
}

.dash-side h2 {
    margin: 0 0 0.5rem;
    font-family: var(--font-display);
    font-size: 1.45rem;
    letter-spacing: -0.035em;
}

.dash-side p {
    margin: 0 0 1.25rem;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.5;
}

.dash-panel {
    margin: 0;
}

.dash-panel-head {
    border: 0;
    padding: 0 0 0.85rem;
    background: transparent;
}

.dash-recent {
    max-height: 380px;
}

.stat-type .n {
    font-size: 1rem;
    line-height: 1.35;
}

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

@keyframes float-a {
    from {
        transform: rotate(8deg) translateY(0);
    }
    to {
        transform: rotate(10deg) translateY(-10px);
    }
}

@keyframes float-b {
    from {
        transform: rotate(-6deg) translateY(0);
    }
    to {
        transform: rotate(-4deg) translateY(8px);
    }
}

@keyframes pulse {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
