:root {
    --bg: #f5f7f4;
    --panel: #ffffff;
    --ink: #17212b;
    --muted: #66727e;
    --line: #d9e0e5;
    --green: #1f7a5c;
    --green-dark: #145b45;
    --blue: #376fa8;
    --coral: #cf684f;
    --gold: #ba8830;
    --soft-green: #e8f3ee;
    --soft-blue: #e9f0f8;
    --soft-coral: #faece7;
    --shadow: 0 18px 48px rgba(30, 45, 58, 0.12);
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: linear-gradient(180deg, #f8faf7 0%, var(--bg) 48%, #eef3f0 100%);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 28px 20px;
    color: #f7fbf9;
    background: #17212b;
}

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

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 3px;
    color: #b7c5ce;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--green), var(--blue));
    font-weight: 800;
}

.brand-mark.large {
    width: 56px;
    height: 56px;
    margin: 0 auto 8px;
}

.nav-tabs {
    display: grid;
    gap: 8px;
}

.nav-button,
.ghost-button {
    width: 100%;
    border: 0;
    border-radius: var(--radius);
    color: inherit;
    background: transparent;
    text-align: left;
}

.nav-button {
    padding: 12px 14px;
    color: #cfdae1;
}

.nav-button:hover,
.nav-button.is-active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
    color: #b7c5ce;
}

.ghost-button {
    padding: 10px 0;
    color: #ffffff;
}

.main {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 2rem;
}

h2 {
    margin-bottom: 6px;
    font-size: 1.12rem;
}

.top-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.view {
    display: none;
}

.view.is-visible {
    display: grid;
    gap: 18px;
}

.panel,
.metric {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(30, 45, 58, 0.06);
}

.panel {
    padding: 22px;
}

.section-heading {
    margin-bottom: 16px;
}

.section-heading p {
    margin-bottom: 0;
    color: var(--muted);
}

.section-heading.compact {
    margin-bottom: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.wide {
    grid-column: 1 / -1;
}

label,
fieldset {
    display: grid;
    gap: 7px;
    min-width: 0;
    color: #2f3b45;
    font-weight: 700;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    margin-bottom: 8px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 12px;
    color: var(--ink);
    background: #fbfcfd;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(31, 122, 92, 0.18);
    border-color: var(--green);
}

input[type="range"] {
    padding: 0;
    accent-color: var(--green);
}

.range-output {
    color: var(--muted);
    font-weight: 600;
}

.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    position: relative;
}

.chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip span {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    color: #35434e;
    background: #ffffff;
    font-weight: 700;
}

.chip input:checked + span {
    color: #ffffff;
    border-color: var(--green);
    background: var(--green);
}

.size-block {
    overflow-x: auto;
}

.size-table {
    min-width: 720px;
    display: grid;
    grid-template-columns: 82px repeat(8, minmax(72px, 1fr));
    gap: 8px;
    align-items: center;
}

.size-table .cell {
    min-height: 42px;
    display: grid;
    align-items: center;
}

.size-table .head {
    color: var(--muted);
    font-weight: 800;
}

.size-table input[type="number"] {
    padding: 8px;
}

.soldout-cell {
    justify-items: center;
}

.primary-button,
.secondary-button {
    border: 0;
    border-radius: var(--radius);
    min-height: 42px;
    padding: 10px 14px;
    font-weight: 800;
}

.primary-button {
    color: #ffffff;
    background: var(--green);
}

.primary-button:hover {
    background: var(--green-dark);
}

.secondary-button {
    border: 1px solid var(--line);
    color: var(--ink);
    background: #ffffff;
}

.file-label {
    display: inline-flex;
    align-items: center;
}

.file-label input {
    display: none;
}

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

.record-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: #fbfcfd;
}

.record-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
}

.record-actions {
    display: flex;
    gap: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.metric {
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-weight: 700;
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 1.7rem;
}

canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.setting-row {
    display: grid;
    gap: 8px;
}

.setting-row strong {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}

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

th {
    color: var(--muted);
    font-size: 0.86rem;
    text-transform: uppercase;
}

.estimate-result {
    min-height: 220px;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 170px;
    color: var(--muted);
    text-align: center;
}

.result-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 18px;
}

.confidence {
    border-radius: var(--radius);
    padding: 14px;
    background: var(--soft-green);
}

.insight-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.insight-list li {
    border-left: 4px solid var(--blue);
    padding: 8px 10px;
    background: var(--soft-blue);
}

.login-screen {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(23, 33, 43, 0.88);
    z-index: 20;
}

.login-screen.is-visible {
    display: grid;
}

.login-card {
    width: min(440px, 100%);
    border-radius: var(--radius);
    padding: 30px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.login-card h1,
.login-card p {
    text-align: center;
}

.login-card p {
    color: var(--muted);
}

.form-message {
    min-height: 20px;
    color: var(--coral);
    font-weight: 700;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: 360px;
    border-radius: var(--radius);
    padding: 12px 14px;
    color: #ffffff;
    background: #17212b;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(10px);
    transition: 180ms ease;
    pointer-events: none;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 4px 9px;
    background: var(--soft-coral);
    color: #8b3d2d;
    font-weight: 800;
    font-size: 0.84rem;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

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

    .nav-button {
        text-align: center;
    }

    .form-grid,
    .stats-grid,
    .settings-grid,
    .result-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main,
    .sidebar,
    .panel {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    h1 {
        font-size: 1.55rem;
    }

    .nav-tabs {
        grid-template-columns: 1fr;
    }

    .record-row {
        grid-template-columns: 1fr;
    }
}

