:root {
    --bg: #f4efe7;
    --surface: rgba(255, 251, 245, 0.84);
    --surface-strong: #fffdf8;
    --surface-ink: #fff7ee;
    --ink: #1f2b2d;
    --muted: #66757a;
    --line: rgba(31, 43, 45, 0.11);
    --accent: #0f766e;
    --accent-strong: #0c5f59;
    --accent-soft: rgba(15, 118, 110, 0.12);
    --warm: #b45309;
    --warm-soft: rgba(180, 83, 9, 0.12);
    --danger: #a83d49;
    --danger-soft: rgba(168, 61, 73, 0.1);
    --success: #256d1b;
    --success-soft: rgba(37, 109, 27, 0.1);
    --shadow: 0 26px 70px rgba(58, 46, 32, 0.12);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 0% 0%, rgba(180, 83, 9, 0.14), transparent 25%),
        radial-gradient(circle at 100% 10%, rgba(15, 118, 110, 0.16), transparent 30%),
        linear-gradient(180deg, #f8f3ea 0%, #f1e9dd 100%);
}

pre,
code {
    font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

.page-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 72px;
}

.hero-panel,
.panel,
.result-card,
.metric-card,
.alert {
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
    gap: 24px;
    padding: 32px;
    margin-bottom: 24px;
}

.eyebrow,
.side-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent-strong);
}

.hero-main h1,
.panel-heading h2,
.results-header h2,
.result-card h3 {
    margin: 0;
    font-family: "Iowan Old Style", "Palatino Linotype", serif;
}

.hero-main h1 {
    margin-top: 14px;
    font-size: clamp(2.5rem, 5vw, 4.3rem);
    line-height: 0.92;
    max-width: 10ch;
}

.hero-copy,
.panel-heading p,
.subtle,
.hint,
.feature-list li,
.mini-card span,
.fact-card span,
.total-card span,
.metric-card span,
.empty-state,
.error-copy {
    color: var(--muted);
}

.hero-copy {
    margin: 18px 0 26px;
    max-width: 62ch;
    font-size: 1.03rem;
    line-height: 1.65;
}

.hero-stat-row,
.metric-grid,
.facts-grid,
.totals-grid,
.mini-grid {
    display: grid;
    gap: 14px;
}

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

.hero-stat,
.mini-card,
.fact-card,
.total-card {
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(15, 118, 110, 0.1);
    background: rgba(255, 255, 255, 0.62);
}

.hero-stat strong,
.mini-card strong,
.fact-card strong,
.total-card strong,
.metric-card strong {
    display: block;
    font-size: 1rem;
}

.hero-stat span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.93rem;
}

.hero-side {
    display: flex;
}

.side-card {
    width: 100%;
    padding: 26px;
    border-radius: calc(var(--radius-xl) - 4px);
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.1), rgba(255, 255, 255, 0.72)),
        var(--surface-strong);
    border: 1px solid rgba(15, 118, 110, 0.16);
}

.feature-list {
    margin: 18px 0 0;
    padding-left: 20px;
    display: grid;
    gap: 12px;
}

.dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
    gap: 24px;
    align-items: start;
}

.panel {
    padding: 28px;
}

.compact-panel {
    padding-bottom: 24px;
}

.side-stack {
    display: grid;
    gap: 24px;
}

.panel-heading {
    margin-bottom: 18px;
}

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

.dropzone {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 260px;
    padding: 28px;
    border-radius: calc(var(--radius-xl) - 6px);
    border: 2px dashed rgba(15, 118, 110, 0.34);
    background:
        radial-gradient(circle at top, rgba(15, 118, 110, 0.14), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(246, 235, 221, 0.88));
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.dropzone:hover,
.dropzone.is-dragover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.dropzone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-title {
    display: block;
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.dropzone-subtitle {
    display: block;
    color: var(--muted);
    margin-bottom: 14px;
}

.dropzone-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 0.88rem;
    color: var(--accent-strong);
    background: rgba(15, 118, 110, 0.08);
}

.file-list {
    display: grid;
    gap: 10px;
}

.file-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(15, 118, 110, 0.12);
    animation: rise 0.25s ease;
}

.file-chip strong {
    word-break: break-word;
}

.action-row,
.result-actions,
.result-card-head,
.result-title-row,
.code-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.button {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 12px 18px;
    text-decoration: none;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #14928a);
}

.button-secondary {
    color: var(--accent-strong);
    background: rgba(15, 118, 110, 0.12);
    border-color: rgba(15, 118, 110, 0.18);
}

.button-tertiary,
.button-ghost {
    color: var(--ink);
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--line);
}

.button-ghost.is-copied {
    color: var(--success);
    border-color: rgba(37, 109, 27, 0.24);
    background: var(--success-soft);
}

.panel pre,
.code-block {
    margin: 0;
    padding: 16px;
    border-radius: var(--radius-md);
    background: #172224;
    color: #f6f8f9;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
}

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

.mini-card {
    min-height: 92px;
    background: rgba(255, 255, 255, 0.74);
}

.mini-card span {
    display: block;
    margin-top: 6px;
    font-size: 0.92rem;
}

.alert {
    margin-bottom: 18px;
    padding: 16px 20px;
}

.alert-error {
    background: linear-gradient(135deg, var(--danger-soft), rgba(255, 255, 255, 0.9));
    border-color: rgba(168, 61, 73, 0.2);
}

.alert-success {
    background: linear-gradient(135deg, var(--success-soft), rgba(255, 255, 255, 0.9));
    border-color: rgba(37, 109, 27, 0.18);
}

.results-shell {
    margin-top: 30px;
}

.results-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.results-header p {
    margin: 8px 0 0;
    color: var(--muted);
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metric-card {
    padding: 18px 20px;
}

.metric-card strong {
    margin-top: 8px;
    font-size: 1.7rem;
    line-height: 1;
}

.result-grid {
    display: grid;
    gap: 20px;
}

.result-card {
    padding: 24px;
}

.result-card-error {
    border-color: rgba(168, 61, 73, 0.24);
    background: linear-gradient(135deg, rgba(168, 61, 73, 0.08), rgba(255, 251, 245, 0.92));
}

.result-title-row {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.result-title-row h3 {
    font-size: 1.48rem;
}

.subtle {
    margin: 8px 0 0;
}

.type-pill,
.status-pill,
.chip,
.inline-note {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 800;
}

.type-pill {
    padding: 8px 12px;
    background: rgba(180, 83, 9, 0.1);
    color: var(--warm);
}

.status-pill {
    height: 36px;
    padding: 0 14px;
}

.status-success {
    color: var(--success);
    background: var(--success-soft);
}

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

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 16px;
}

.chip {
    padding: 9px 12px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--accent-strong);
}

.chip-strong {
    background: rgba(180, 83, 9, 0.12);
    color: var(--warm);
}

.inline-note {
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--warm-soft);
    color: var(--warm);
}

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 16px;
}

.tab-button {
    appearance: none;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
    color: var(--muted);
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.tab-button.is-active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), #1d8d84);
    border-color: transparent;
}

.tab-panel {
    display: none;
}

.tab-panel.is-active {
    display: block;
    animation: fadeUp 0.2s ease;
}

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

.fact-card strong {
    margin-top: 8px;
    line-height: 1.4;
}

.totals-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
}

.total-card-strong {
    background: rgba(15, 118, 110, 0.1);
    border-color: rgba(15, 118, 110, 0.16);
}

.note-block {
    margin-top: 16px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid var(--line);
}

.note-block strong {
    display: block;
    margin-bottom: 10px;
}

.note-block p,
.note-block pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.table-wrap {
    overflow: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.7);
}

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

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid rgba(31, 43, 45, 0.08);
    font-size: 0.95rem;
}

.data-table thead th {
    position: sticky;
    top: 0;
    background: var(--surface-ink);
    color: var(--accent-strong);
    z-index: 1;
}

.empty-state {
    padding: 18px;
    border-radius: var(--radius-lg);
    border: 1px dashed rgba(31, 43, 45, 0.14);
    background: rgba(255, 255, 255, 0.6);
}

.code-actions {
    justify-content: flex-end;
    margin-bottom: 12px;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1060px) {
    .hero-panel,
    .dashboard {
        grid-template-columns: 1fr;
    }

    .hero-stat-row,
    .metric-grid,
    .facts-grid,
    .totals-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 20px, 1240px);
        padding-top: 18px;
    }

    .hero-panel,
    .panel,
    .result-card {
        padding: 20px;
    }

    .hero-main h1 {
        max-width: none;
        font-size: 2.6rem;
    }

    .hero-stat-row,
    .metric-grid,
    .facts-grid,
    .totals-grid,
    .mini-grid {
        grid-template-columns: 1fr;
    }

    .action-row,
    .result-actions,
    .result-card-head,
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .tab-bar {
        overflow-x: auto;
        padding-bottom: 4px;
        flex-wrap: nowrap;
    }
}
