:root {
    color-scheme: light dark;
    --bg: #0f172a;
    --surface: rgba(15, 23, 42, 0.65);
    --surface-light: #f8fafc;
    --surface-alt: rgba(255, 255, 255, 0.04);
    --primary: #2563eb;
    --primary-light: #3b82f6;
    --accent: #f97316;
    --text: #0f172a;
    --text-muted: rgba(15, 23, 42, 0.64);
    --border: rgba(15, 23, 42, 0.1);
    --card-shadow: 0 20px 45px -25px rgba(15, 23, 42, 0.35);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    margin: 0;
    background: linear-gradient(160deg, #0f172a 0%, #1d2951 48%, #1e1b4b 100%);
    color: var(--text);
    font-family: inherit;
    min-height: 100vh;
}

body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top, #1e293b, #0f172a 60%);
}

* {
    box-sizing: border-box;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 999;
    backdrop-filter: blur(14px);
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #e2e8f0;
}

.brand-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.brand-text {
    display: inline-block;
}

.brand-accent {
    color: var(--accent);
}

.topbar .logout {
    margin-left: 20px;
}

.topbar .btn.ghost {
    color: rgba(226, 232, 240, 0.95);
    border-color: rgba(226, 232, 240, 0.45);
    background: rgba(148, 163, 184, 0.12);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.topbar .btn.ghost:hover,
.topbar .btn.ghost:focus {
    color: #fff;
    border-color: rgba(226, 232, 240, 0.75);
    background: rgba(148, 163, 184, 0.22);
}

.nav a {
    margin-left: 20px;
    color: rgba(226, 232, 240, 0.9);
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
}

.nav a:hover {
    color: #fff;
}

.user-badge {
    margin-left: 20px;
    font-size: 14px;
    color: rgba(226, 232, 240, 0.85);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 24px;
}

.login-card {
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.45);
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 26px;
    color: #e2e8f0;
}

.login-card p {
    margin: 0 0 24px;
    color: rgba(226, 232, 240, 0.75);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-form label span {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: rgba(226, 232, 240, 0.8);
}

.login-form input {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.75);
    color: #e2e8f0;
    font-size: 16px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25);
}

.login-submit {
    width: 100%;
    justify-content: center;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 24px;
}

.hero {
    padding: 80px 0 60px;
    color: #e2e8f0;
}

.hero-grid {
    display: grid;
    gap: 48px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    align-items: stretch;
}

.hero h1 {
    font-size: clamp(32px, 4vw, 48px);
    line-height: 1.08;
    margin-bottom: 20px;
}

.hero p {
    font-size: 18px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.hero-card {
    background: #ffffff;
    color: var(--text);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 24px 55px -30px rgba(15, 23, 42, 0.32);
}

.hero-card ul {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
}

.hero-card li {
    font-size: 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.hero-tag {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 12px;
    color: rgba(15, 23, 42, 0.55);
    margin-bottom: 18px;
}

.metric {
    font-weight: 600;
    color: var(--text);
}

.note {
    font-size: 14px;
    color: rgba(248, 250, 252, 0.64);
}

.btn {
    appearance: none;
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 15px;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 12px 30px -12px rgba(37, 99, 235, 0.7);
}

.btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px -18px rgba(37, 99, 235, 0.8);
}

.btn.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid rgba(15, 23, 42, 0.2);
}

.table-card .btn.ghost {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text);
    border-color: rgba(15, 23, 42, 0.25);
}

.table-card .btn.ghost:hover,
.table-card .btn.ghost:focus {
    background: rgba(15, 23, 42, 0.12);
    border-color: rgba(15, 23, 42, 0.35);
}

.btn.small {
    padding: 8px 14px;
    font-size: 14px;
}

.btn.file {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cta-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.card-note {
    font-size: 13px;
    color: var(--text-muted);
}

.section {
    background: #f8fafc;
    padding: 68px 0;
}

.section.alt {
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, #eef2ff 100%);
}

.section-header h2 {
    margin: 0 0 12px;
    font-size: clamp(26px, 3vw, 36px);
    color: var(--text);
}

.section-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 16px;
}

.item-form {
    background: #fff;
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 20px 50px -32px rgba(15, 23, 42, 0.35);
}

.planner-grid {
    display: grid;
    gap: 32px;
    align-items: start;
    margin-top: 32px;
}

@media (min-width: 960px) {
    .planner-grid {
        grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    }
}

.planner-column {
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.planner-summary {
    position: static;
}

@media (min-width: 960px) {
    .planner-summary {
        position: sticky;
        top: 96px;
    }
}

.item-form .grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

label span {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

input, select {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 15px;
    font-family: inherit;
}

input:focus, select:focus {
    outline: 2px solid rgba(37, 99, 235, 0.3);
    border-color: rgba(37, 99, 235, 0.7);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.capture-actions {
    margin-top: 16px;
    display: none;
    flex-direction: column;
    gap: 8px;
}

.capture-actions.visible {
    display: flex;
}

.capture-actions .btn {
    align-self: flex-start;
}

.status-text.small {
    font-size: 12px;
    margin: 0;
    display: none;
}

.table-card {
    margin-top: 36px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px -32px rgba(15, 23, 42, 0.3);
    overflow: hidden;
}

.table-card header,
.table-card footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.02);
}

.table-card h3 {
    margin: 0;
    font-size: 18px;
}

.table-wrap {
    overflow-x: auto;
}

.table-card table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

thead {
    background: rgba(15, 23, 42, 0.04);
}

thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 15px;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr.empty td {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
}

.table-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.table-footer .totals {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    color: var(--text-muted);
}

.table-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.status-text {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--text-muted);
}

.status-text.success {
    color: #15803d;
}

.status-text.error {
    color: #b91c1c;
}

.results-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: 32px;
}

.result-card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 20px 45px -32px rgba(15, 23, 42, 0.32);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid rgba(15, 23, 42, 0.1);
    color: var(--text);
}

.result-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-card .vendor {
    font-size: 13px;
    color: var(--text-muted);
}

.pill {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pill[data-category="perfect_fit"] {
    background: #dcfce7;
    color: #047857;
}

.pill[data-category="cut_down"] {
    background: #fee2d5;
    color: #9a3412;
}

.pill[data-category="cascade"] {
    background: #dbeafe;
    color: #1d4ed8;
}

.result-card h3 {
    margin: 0;
    font-size: 20px;
    color: var(--text);
}

dl {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px 18px;
}

dl div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

dl dt {
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.55);
    letter-spacing: 0.08em;
}

dl dd {
    margin: 0;
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
}

.empty-state {
    grid-column: 1 / -1;
    background: rgba(15, 23, 42, 0.05);
    border-radius: 18px;
    padding: 36px;
    text-align: center;
    color: var(--text-muted);
}

.faq-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: 28px;
}

.faq-grid article {
    background: rgba(255, 255, 255, 0.88);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 18px 40px -30px rgba(15, 23, 42, 0.25);
}

.footer {
    background: rgba(15, 23, 42, 0.9);
    color: rgba(226, 232, 240, 0.8);
    padding: 24px 0;
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-links a {
    color: inherit;
    text-decoration: none;
    margin-left: 18px;
}

.footer-links a:hover {
    color: #fff;
}

@media (max-width: 720px) {
    .nav {
        display: none;
    }

    .topbar .container {
        justify-content: center;
    }

    .cta-row {
        width: 100%;
        justify-content: stretch;
    }

    .cta-row .btn {
        flex: 1 1 auto;
    }

    .hero-card {
        order: -1;
    }

    .table-card table {
        min-width: 100%;
        border-collapse: separate;
    }

    .table-card thead {
        display: none;
    }

    .table-card tbody,
    .table-card tr,
    .table-card td {
        display: block;
        width: 100%;
    }

    .table-card tbody tr {
        margin-bottom: 16px;
        border: 1px solid rgba(15, 23, 42, 0.1);
        border-radius: 16px;
        padding: 12px 16px;
        background: #fff;
        box-shadow: 0 12px 30px -24px rgba(15, 23, 42, 0.28);
    }

    .table-card tbody tr:last-child {
        margin-bottom: 0;
    }

    .table-card tbody tr.empty {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .table-card tbody tr.empty td {
        padding: 24px 16px;
    }

    .table-card td {
        padding: 10px 0;
        border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    }

    .table-card td:last-child {
        border-bottom: none;
    }

    .table-card td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        color: rgba(15, 23, 42, 0.55);
        letter-spacing: 0.08em;
        margin-bottom: 4px;
    }

    .table-card td[data-label="Actions"] {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .table-card td[data-label="Actions"] button {
        flex: 1 1 auto;
    }

    .footer .container {
        flex-direction: column;
        text-align: center;
    }
}

@media (prefers-color-scheme: dark) {
    .section.alt {
        background: linear-gradient(180deg, rgba(248, 250, 252, 0.95) 0%, #eef2ff 100%);
    }

    .result-card,
    .hero-card {
        background: rgba(15, 23, 42, 0.9);
        color: #f8fafc;
        border: 1px solid rgba(148, 163, 184, 0.2);
        box-shadow: none;
    }

    .result-card h3,
    .result-card dd {
        color: #f8fafc;
    }

    .result-card .vendor,
    dl dt,
    .hero-card .card-note {
        color: rgba(226, 232, 240, 0.72);
    }

    .metric {
        color: #f8fafc;
    }

    .hero-tag {
        color: rgba(226, 232, 240, 0.72);
    }

    .pill[data-category="perfect_fit"] {
        background: rgba(34, 197, 94, 0.28);
        color: #bbf7d0;
    }

    .pill[data-category="cut_down"] {
        background: rgba(249, 115, 22, 0.28);
        color: #fed7aa;
    }

    .pill[data-category="cascade"] {
        background: rgba(59, 130, 246, 0.28);
        color: #bfdbfe;
    }

    .btn.ghost {
        color: #e2e8f0;
        border: 1px solid rgba(226, 232, 240, 0.3);
    }

    .table-card .btn.ghost {
        background: rgba(226, 232, 240, 0.1);
        border-color: rgba(226, 232, 240, 0.35);
    }

    .table-card .btn.ghost:hover,
    .table-card .btn.ghost:focus {
        background: rgba(226, 232, 240, 0.2);
        border-color: rgba(226, 232, 240, 0.45);
    }

    input,
    select {
        border: 1px solid rgba(255, 255, 255, 0.16);
        background: rgba(15, 23, 42, 0.6);
    }

    thead {
        background: rgba(148, 163, 184, 0.12);
    }

    tbody td {
        border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    }

    .empty-state {
        background: rgba(15, 23, 42, 0.8);
    }

    @media (max-width: 720px) {
        .table-card tbody tr {
            background: rgba(15, 23, 42, 0.85);
            border: 1px solid rgba(148, 163, 184, 0.25);
            box-shadow: none;
        }

        .table-card td {
            border-bottom: 1px solid rgba(148, 163, 184, 0.2);
        }

        .table-card td[data-label]::before {
            color: rgba(226, 232, 240, 0.72);
        }
    }
}
