:root {
    --bg: #eef6d7;
    --paper: rgba(251, 255, 242, 0.88);
    --paper-strong: rgba(248, 255, 236, 0.96);
    --line: rgba(48, 74, 21, 0.14);
    --text: #1e2c11;
    --muted: #5b7042;
    --accent: #8cc63f;
    --accent-strong: #5b8f12;
    --accent-soft: #d9f3ac;
    --success: #3d8c28;
    --success-soft: rgba(61, 140, 40, 0.14);
    --danger: #a84d25;
    --shadow: 0 22px 70px rgba(77, 115, 28, 0.16);
    --shadow-soft: 0 12px 30px rgba(77, 115, 28, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 0 0, rgba(216, 255, 145, 0.78), transparent 28%),
        radial-gradient(circle at 100% 0, rgba(140, 198, 63, 0.22), transparent 24%),
        linear-gradient(155deg, #f6ffe9 0%, #d7efaa 50%, #edf8d6 100%);
}

body.modal-open {
    overflow: hidden;
}

.app-shell {
    padding: 28px;
}

.hero {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    padding: 32px;
    border: 1px solid var(--line);
    border-radius: 30px;
    background:
        linear-gradient(135deg, rgba(248, 255, 236, 0.98), rgba(220, 244, 181, 0.92)),
        linear-gradient(125deg, transparent 0%, rgba(140, 198, 63, 0.12) 100%);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.hero::after {
    content: "";
    position: absolute;
    inset: auto -60px -70px auto;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(140, 198, 63, 0.28), transparent 68%);
}

.hero-copy {
    position: relative;
    z-index: 1;
}

.hero h1,
.denied-panel h1 {
    margin: 0;
    font-size: clamp(44px, 7vw, 84px);
    line-height: 0.92;
    letter-spacing: -0.05em;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.28em;
    color: var(--accent-strong);
}

.lead {
    margin: 12px 0 0;
    max-width: 720px;
    font-size: 18px;
    color: var(--muted);
}

.hero-badge,
.card,
.metric-card,
.entity-card,
.denied-panel,
.notice-card {
    border: 1px solid var(--line);
    background: var(--paper);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-soft);
}

.hero-badge {
    min-width: 240px;
    padding: 18px 20px;
    border-radius: 22px;
    display: grid;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.hero-badge span,
.hero-badge small,
.muted {
    color: var(--muted);
}

.workspace {
    margin-top: 24px;
}

.flash {
    margin-bottom: 16px;
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(140, 198, 63, 0.12);
    border: 1px solid rgba(140, 198, 63, 0.26);
}

.flash-error {
    background: rgba(159, 47, 37, 0.12);
    border-color: rgba(159, 47, 37, 0.24);
    color: var(--danger);
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.tab-button,
button,
input,
select {
    font: inherit;
}

.tab-button,
button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.18s ease, background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.tab-button.active,
button[type="submit"],
.button-accent,
button:hover {
    background: var(--accent);
    color: #162108;
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(140, 198, 63, 0.28);
}

.ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text);
    box-shadow: none;
}

.ghost:hover {
    background: rgba(140, 198, 63, 0.12);
    color: var(--accent-strong);
}

.ghost.danger:hover {
    background: var(--danger);
    color: #fff;
}

.binding-conflict {
    display: grid;
    gap: 8px;
    min-width: 320px;
    padding: 14px;
    border: 1px solid var(--danger);
    border-radius: 14px;
    background: rgba(214, 76, 76, 0.08);
}

button[type="submit"].danger-confirm {
    background: var(--danger);
    color: #fff;
    box-shadow: none;
}

.icon-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    font-size: 28px;
    line-height: 1;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.grid {
    display: grid;
    gap: 18px;
}

.two-up {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    margin-bottom: 18px;
}

.stats-grid,
.card-grid {
    display: grid;
    gap: 18px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.metric-card,
.card,
.entity-card {
    border-radius: 26px;
    padding: 22px;
}

.spotlight {
    background: linear-gradient(145deg, rgba(247, 255, 231, 0.98), rgba(225, 247, 182, 0.92));
}

.metric-label {
    display: block;
    font-size: 12px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.metric-value {
    display: block;
    margin-top: 10px;
    font-size: clamp(28px, 3.3vw, 42px);
    line-height: 1;
}

.metric-meta {
    margin: 12px 0 0;
    color: var(--muted);
}

.section-head,
.entity-head,
.subsection-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
}

.section-head {
    margin-bottom: 18px;
}

.section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
}

.inline-picker {
    min-width: 260px;
}

.inline-picker span {
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.section-head h2,
.card h2,
.entity-card h3,
.modal-head h3 {
    margin: 0;
}

.entity-card h3 {
    font-size: 24px;
}

.entity-card p {
    margin: 6px 0 0;
    color: var(--muted);
}

.wide {
    min-height: 220px;
}

.entity-meta {
    margin-top: 16px;
    color: var(--muted);
}

.entity-actions,
.row-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.entity-actions {
    margin-top: 18px;
}

.chip,
.tag,
.muted-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
}

.chip {
    background: rgba(140, 198, 63, 0.18);
    color: var(--accent-strong);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.tag {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(37, 27, 20, 0.08);
}

.muted-tag {
    background: rgba(109, 90, 77, 0.08);
    color: var(--muted);
}

.notice-card {
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: 22px;
    display: grid;
    gap: 4px;
}

.stack-form,
.panel-form,
.inline-form {
    display: grid;
    gap: 14px;
}

.toolbar-form {
    display: grid;
    grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.compact-form {
    min-width: 240px;
    gap: 10px;
}

.checkbox-line {
    align-items: center;
    display: flex;
    gap: 10px;
}

.checkbox-line input[type="checkbox"] {
    width: auto;
}

.section-gap {
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

input,
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid rgba(37, 27, 20, 0.14);
    background: rgba(255, 255, 255, 0.86);
    color: var(--text);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(37, 27, 20, 0.08);
    vertical-align: top;
}

th {
    color: var(--accent-strong);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

code {
    font-family: "Cascadia Code", "Consolas", monospace;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(26, 18, 13, 0.52);
    z-index: 999;
}

.modal-backdrop.open {
    display: flex;
}

.modal-shell {
    width: min(100%, 1080px);
    max-height: calc(100vh - 48px);
}

.modal-card {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    max-height: calc(100vh - 48px);
    border-radius: 30px;
    overflow: hidden;
    background: var(--paper-strong);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow);
}

.modal-card-xl {
    width: min(100%, 1180px);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    padding: 22px 24px 20px;
    border-bottom: 1px solid rgba(37, 27, 20, 0.08);
    background: linear-gradient(180deg, rgba(247, 255, 235, 0.96), rgba(237, 249, 214, 0.88));
}

.modal-body {
    overflow: auto;
    padding: 24px;
    display: grid;
    gap: 24px;
}

.modal-subsection {
    display: grid;
    gap: 18px;
}

.mapping-list {
    display: grid;
    gap: 12px;
}

.mapping-row {
    display: flex;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.64);
    border: 1px solid rgba(37, 27, 20, 0.06);
}

.mapping-form {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
}

.add-stage-form {
    padding-top: 8px;
    border-top: 1px solid rgba(37, 27, 20, 0.08);
}

.empty-state {
    padding: 16px;
    border-radius: 16px;
    background: rgba(109, 90, 77, 0.08);
    color: var(--muted);
}

.denied-shell {
    display: grid;
    place-items: center;
}

.denied-panel {
    max-width: 720px;
    padding: 40px;
    border-radius: 28px;
}

@media (max-width: 1040px) {
    .mapping-form {
        grid-template-columns: 1fr;
    }

    .mapping-row {
        flex-direction: column;
    }
}

@media (max-width: 900px) {
    .hero {
        flex-direction: column;
        align-items: start;
    }

    .toolbar-form {
        grid-template-columns: 1fr;
    }

    .app-shell {
        padding: 18px;
    }

    .modal-backdrop {
        padding: 12px;
    }

    .modal-body {
        padding: 18px;
    }
}
.checkbox-label {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    min-width: 18px;
    height: 18px;
    padding: 0;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.vat-on {
    background: rgba(61, 140, 40, 0.14);
    color: var(--success);
}

.vat-off {
    background: rgba(109, 90, 77, 0.08);
    color: var(--muted);
}
