:root {
    --bg: #f4f7f3;
    --bg-elevated: #eef5ee;
    --surface: #ffffff;
    --surface-muted: #f8faf8;
    --text: #101410;
    --text-muted: #667065;
    --line: #dce5dc;
    --line-strong: #c8d4c8;
    --accent: #8cc63f;
    --accent-deep: #6fa32d;
    --accent-soft: #edf7df;
    --danger-soft: #fbe9e7;
    --warning-soft: #fff6db;
    --success-soft: #ebf7e8;
    --shadow-sm: 0 1px 2px rgba(16, 20, 16, 0.04);
    --shadow-md: 0 10px 30px rgba(16, 20, 16, 0.06);
    --radius: 8px;
    --radius-lg: 12px;
    --max-width: 1160px;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(140, 198, 63, 0.08), transparent 180px),
        var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: #1c3d1b;
}

img {
    display: block;
    max-width: 100%;
}

.layout {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 28px 20px 48px;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(244, 247, 243, 0.96);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(220, 229, 220, 0.9);
}

.site-header__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-logo {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-form {
    margin: 0;
}

.nav-form button {
    padding: 8px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.nav-form button:hover {
    background: var(--surface);
    color: var(--text);
}

.nav a:hover {
    background: var(--surface);
    color: var(--text);
}

.hero,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.hero {
    padding: 32px;
}

.panel {
    margin-bottom: 20px;
    padding: 28px;
}

.panel.narrow {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

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

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-deep);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    color: var(--text);
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(28px, 5vw, 40px);
    line-height: 1.08;
    font-weight: 700;
}

h2 {
    font-size: 18px;
    line-height: 1.25;
    font-weight: 700;
}

h3 {
    font-size: 15px;
    line-height: 1.3;
    font-weight: 700;
}

.intro,
.section-intro,
.muted,
.data-table td,
pre {
    color: var(--text-muted);
}

.intro {
    margin: 12px 0 0;
    max-width: 64ch;
    font-size: 15px;
}

.section-intro {
    margin: 10px 0 0;
    max-width: 70ch;
}

.flash-stack {
    margin-bottom: 16px;
    display: grid;
    gap: 10px;
}

.flash {
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.flash-success {
    border-color: #c7e7c1;
    background: var(--success-soft);
}

.flash-error {
    border-color: #f0c8c1;
    background: var(--danger-soft);
}

.flash-warning,
.flash-info {
    background: var(--warning-soft);
}

.cta-grid,
.status-grid,
.workspace-grid,
.field-grid,
.detail-grid,
.debug-grid {
    display: grid;
    gap: 16px;
}

.cta-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.status-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-top: 24px;
}

.workspace-grid,
.detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.field-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.debug-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.cta-card,
.metric-card,
.section-card,
.selection-card,
.detail-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}

.cta-card {
    text-decoration: none;
    color: inherit;
    transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.cta-card:hover {
    transform: translateY(-1px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
}

.cta-card h2,
.metric-card__value {
    margin-top: 2px;
}

.cta-card p:last-child {
    margin-bottom: 0;
}

.metric-card {
    background: var(--surface-muted);
}

.metric-card__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.metric-card__value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-subsection {
    margin-top: 20px;
}

.hero-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-card {
    background: var(--surface-muted);
}

.section-card--accent {
    background: linear-gradient(180deg, var(--accent-soft), var(--surface));
    border-color: #d8e8c2;
}

.table-shell {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.stack-form {
    display: grid;
    gap: 16px;
}

.stack-form p {
    margin: 0;
}

.stack-form label {
    display: inline-block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.stack-form input,
.stack-form select,
.stack-form textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}

.stack-form input.vat-highlight-input {
    background: #fff7cc;
    border-color: #d7c46c;
    font-weight: 700;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
    outline: none;
    border-color: #a8c48f;
    box-shadow: 0 0 0 3px rgba(140, 198, 63, 0.16);
}

.stack-form ul.errorlist {
    margin: 6px 0 0;
    padding-left: 18px;
    color: #a54332;
}

.button-row,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inline-actions form {
    margin: 0;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--accent);
    color: #0d130c;
    text-decoration: none;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease;
}

.button:hover {
    filter: brightness(0.98);
}

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

.button.button-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line-strong);
}

.button.button-vat-highlight {
    background: #fff1a8;
    color: #302700;
    border-color: #d8c45c;
    font-weight: 700;
}

.button.button-success {
    background: #9ad872;
    color: #0d130c;
}

.button.button-small {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.cell-copy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.copy-button {
    min-width: 34px;
    padding: 0 10px;
    line-height: 1;
}

.copy-button[data-copied="true"] {
    background: var(--success-soft);
    border-color: #c7e7c1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--surface-muted);
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

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

.compact-table th,
.compact-table td {
    padding: 10px 12px;
}

.selection-card,
.detail-card {
    box-shadow: var(--shadow-sm);
}

.selection-card p:last-child,
.detail-card p:last-child {
    margin-bottom: 0;
}

.empty-state {
    text-align: left;
    background: var(--surface-muted);
}

.final-action-block {
    border-top: 1px solid var(--line);
    padding-top: 20px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid transparent;
}

.status-ok {
    background: var(--success-soft);
    color: #245d1f;
    border-color: #c7e7c1;
}

.status-warning {
    background: var(--warning-soft);
    color: #7b6400;
    border-color: #f1dc9b;
}

.status-error,
.run-banner-error {
    background: var(--danger-soft);
    color: #8d3a2e;
}

.simple-list,
.record-list {
    margin: 0;
    padding-left: 18px;
}

.run-banner {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.run-banner-ok {
    background: var(--success-soft);
    border-color: #c7e7c1;
}

.run-banner-warning {
    background: var(--warning-soft);
    border-color: #f1dc9b;
}

.details,
details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 14px;
}

summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
}

pre {
    margin: 12px 0 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12.5px;
    line-height: 1.55;
}

.status-inline {
    min-height: 20px;
}

@media (max-width: 760px) {
    .site-header__inner,
    .panel-heading,
    .hero-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .layout {
        padding: 20px 14px 36px;
    }

    .hero,
    .panel {
        padding: 20px;
    }

    .nav {
        width: 100%;
    }
}
