:root {
    --teal: #17B3AE;
    --teal-deep: #0C7F7C;
    --pink: #F0368C;
    --pink-deep: #D11A72;
    --sun: #FFD23F;
    --sun-tint: #FFF4C9;
    --grape: #9D6BDB;
    --ground: #FFFDF9;
    --ink: #2C2144;
    --muted: #84789B;
    --line: #EDE6F0;
    --profit: #1E9E5A;
    --loss: #E23D3D;

    --grape-tint: #EEE6FA;
    --orange: #E8791A;
    --orange-tint: #FCE8D2;

    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
    --script: Georgia, "Times New Roman", serif;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(44, 33, 68, 0.08), 0 1px 2px rgba(44, 33, 68, 0.06);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background-color: var(--ground);
    /* Memphis confetti from the approved brand renders — low opacity so cards stay legible */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='190' height='190'%3E%3Cpolyline points='12,26 24,12 36,26 48,12' fill='none' stroke='%23F0368C' stroke-width='3' opacity='.13'/%3E%3Ccircle cx='142' cy='40' r='7' fill='none' stroke='%2317B3AE' stroke-width='3' opacity='.14'/%3E%3Crect x='60' y='120' width='13' height='13' fill='%23FFD23F' opacity='.16' transform='rotate(28 66 126)'/%3E%3Cpolyline points='120,158 132,144 144,158 156,144' fill='none' stroke='%239D6BDB' stroke-width='3' opacity='.13'/%3E%3Ccircle cx='30' cy='90' r='4' fill='%23F0368C' opacity='.12'/%3E%3C/svg%3E");
    background-repeat: repeat;
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.45;
}

h1, h2, h3, h4 {
    margin: 0 0 0.5rem 0;
    font-weight: 700;
}

a {
    color: var(--teal-deep);
}

/* ---------- App shell ---------- */

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.side {
    background: var(--teal-deep);
    color: var(--ground);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1.25rem;
    gap: 2rem;
}

.brand {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-script {
    font-family: var(--script);
    font-style: italic;
    font-size: 1.4rem;
    color: var(--sun);
}

.brand-holler {
    font-family: var(--sans);
    font-weight: 800;
    letter-spacing: 0.12em;
    font-size: 1.15rem;
    color: var(--ground);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

    .nav a {
        color: rgba(255, 255, 255, 0.8);
        text-decoration: none;
        padding: 0.6rem 0.75rem;
        border-radius: var(--radius-sm);
        font-weight: 600;
    }

        .nav a:hover {
            background: rgba(255, 255, 255, 0.08);
            color: var(--ground);
        }

        .nav a.active {
            background: rgba(255, 210, 63, 0.16);
            color: var(--sun);
            border-left: 3px solid var(--sun);
            padding-left: calc(0.75rem - 3px);
        }

.foot {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.main {
    padding: 2rem 2.5rem;
    max-width: 1100px;
}

.main-head {
    margin-bottom: 1.5rem;
}

.sub {
    color: var(--muted);
    margin: 0;
}

.loading {
    padding: 2rem;
    color: var(--muted);
}

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--teal-deep);
}

.login-card {
    background: var(--ground);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

    .login-card form {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        margin-top: 1.25rem;
    }

    .login-card label {
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--muted);
        margin-top: 0.5rem;
    }

.login-error {
    color: var(--loss);
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.1rem;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    background: var(--line);
    color: var(--ink);
}

.btn-primary {
    background: var(--pink);
    color: var(--ground);
}

    .btn-primary:hover {
        background: var(--pink-deep);
    }

.btn-quiet {
    background: transparent;
    color: var(--teal-deep);
    border: 1px solid var(--line);
}

    .btn-quiet:hover {
        background: var(--sun-tint);
    }

.btn-danger-quiet {
    background: transparent;
    color: var(--loss);
    border: 1px solid var(--line);
}

    .btn-danger-quiet:hover {
        background: #FBE4E4;
    }

/* ---------- Cards / inputs / fields ---------- */

.card {
    background: var(--ground);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.4rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-bottom: 0.75rem;
}

    .field label {
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--muted);
    }

.f-row {
    display: flex;
    gap: 1rem;
}

    .f-row > .field {
        flex: 1;
    }

.input {
    font-family: var(--sans);
    font-size: 0.95rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--ground);
    color: var(--ink);
}

    .input:focus {
        outline: none;
        border-color: var(--teal);
        box-shadow: 0 0 0 3px rgba(23, 179, 174, 0.15);
    }

.input.mono {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.form-error {
    color: var(--loss);
    font-size: 0.85rem;
    margin: 0.4rem 0;
}

.hint {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 0.25rem 0 0.75rem;
}

/* ---------- Chips / pills / tags ---------- */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--ground);
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

    .chip.on {
        background: var(--grape);
        border-color: var(--grape);
        color: var(--ground);
    }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.p-sourced {
    background: var(--grape-tint);
    color: var(--grape);
}

.p-listed {
    background: var(--sun-tint);
    color: #8A6A00;
}

.p-sold {
    background: #DFF3E7;
    color: var(--profit);
}

.p-returned {
    background: var(--orange-tint);
    color: var(--orange);
}

.p-kept {
    background: var(--grape-tint);
    color: var(--muted);
}

.p-donated {
    background: var(--grape-tint);
    color: var(--grape);
}

.p-writtenoff {
    background: var(--line);
    color: var(--muted);
}

.bin-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--sun-tint);
    color: #8A6A00;
    font-weight: 700;
    font-size: 0.78rem;
}

    .bin-tag.none {
        background: var(--line);
        color: var(--muted);
    }

/* ---------- Money / numbers ---------- */

.money, .sku, .num {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.sku {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---------- Dashboard stats ---------- */

.stat-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

    .stat .lab {
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .stat .val {
        font-family: var(--mono);
        font-variant-numeric: tabular-nums;
        font-size: 1.5rem;
        font-weight: 700;
    }

        .stat .val.pos {
            color: var(--profit);
        }

        .stat .val.neg {
            color: var(--loss);
        }

.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.pnl {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pnl-line {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px dashed var(--line);
}

    .pnl-line.total {
        border-bottom: none;
        border-top: 2px solid var(--ink);
        font-weight: 700;
        padding-top: 0.6rem;
        margin-top: 0.25rem;
    }

.recent {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.r-line {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--line);
}

    .r-line .grow {
        flex: 1;
    }

.r-net {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

    .r-net.pos {
        color: var(--profit);
    }

    .r-net.neg {
        color: var(--loss);
    }

/* ---------- Quick add ---------- */

.qa-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    max-width: 640px;
}

.qa-form {
    display: flex;
    flex-direction: column;
}

.qa-foot {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.lot {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

    .lot .lot-total {
        flex: 2;
    }

    .lot .lot-count {
        flex: 1;
    }

/* ---------- Search ---------- */

.search-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.results {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hit {
    display: flex;
    align-items: center;
    gap: 1rem;
}

    .hit .t {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    .hit .name {
        font-weight: 700;
    }

    .hit .meta {
        display: flex;
        gap: 0.5rem;
        align-items: center;
        color: var(--muted);
        font-size: 0.85rem;
    }

/* ---------- Detail page ---------- */

.det-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.facts {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.fact {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--line);
}

    .fact .k {
        color: var(--muted);
        font-weight: 600;
    }

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.bin-row .fact {
    align-items: center;
}

    .bin-row .fact > span {
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }

.marksold {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.hero-ph {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

    .hero-ph.placeholder {
        height: 200px;
    }

.strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.thumb {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

/* ---------- Calculator ---------- */

.calc {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 480px;
}

.seg {
    display: flex;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: fit-content;
}

    .seg > * {
        padding: 0.45rem 1rem;
        background: var(--ground);
        border: none;
        font-weight: 600;
        cursor: pointer;
        color: var(--ink);
    }

.seg-target.on, .seg-forward.on {
    background: var(--teal);
    color: var(--ground);
}

.answer {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-top: 0.5rem;
}

    .answer .k {
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
        text-transform: uppercase;
    }

    .answer .v {
        font-family: var(--mono);
        font-variant-numeric: tabular-nums;
        font-size: 1.75rem;
        font-weight: 700;
        color: var(--teal-deep);
    }

.breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.fee-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* ---------- Bins ---------- */

.bin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.bin-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

    .bin-card .top {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .bin-card .zone {
        color: var(--muted);
        font-size: 0.8rem;
    }

    .bin-card .row {
        display: flex;
        justify-content: space-between;
    }

    .bin-card .k {
        color: var(--muted);
    }

/* ---------- Boot spinner & error boundary ---------- */

.loading-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
}

.loading-progress circle:nth-child(1) {
    fill: none;
    stroke: var(--teal);
    stroke-width: 4;
    stroke-dasharray: 251.2;
    stroke-dashoffset: var(--blazor-load-percentage);
    opacity: 1;
    animation: blazor-rotate linear 2s infinite;
}

.loading-progress circle:nth-child(2) {
    fill: none;
    stroke: rgba(23, 179, 174, 0.2);
    stroke-width: 4;
}

@keyframes blazor-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-progress-text {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 60px));
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    text-align: center;
}

.loading-progress-text::after {
    content: "Loading...";
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--loss);
    color: white;
    padding: 1rem 1.5rem;
    font-weight: 500;
    z-index: 9999;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#blazor-error-ui .dismiss:hover {
    opacity: 1;
}

#blazor-error-ui a.reload {
    color: white;
    text-decoration: underline;
    font-weight: 600;
    white-space: nowrap;
}
