:root {
    color-scheme: light;
    --paper: #fbfaf7;
    --panel: #ffffff;
    --linen: #efe7da;
    --linen-strong: #dac7ad;
    --ink: #29231d;
    --muted: #756b61;
    --gold: #b98a42;
    --gold-dark: #8a622b;
    --olive: #475246;
    --danger: #9b2d2d;
    --danger-soft: #fff0ef;
    --success: #2e6f4f;
    --shadow: 0 18px 50px rgba(79, 61, 38, 0.13);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.8), rgba(239, 231, 218, 0.72)),
        var(--paper);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(460px, 100%);
    padding: 36px;
    border: 1px solid rgba(185, 138, 66, 0.24);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    margin-bottom: 22px;
    border: 1px solid var(--linen-strong);
    background: var(--ink);
    color: #fff8ef;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold-dark);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

h1 {
    margin-bottom: 8px;
    font-size: clamp(30px, 5vw, 46px);
    line-height: 1.02;
}

h2 {
    margin-bottom: 0;
    font-size: 24px;
}

h3 {
    margin-bottom: 10px;
    font-size: 18px;
    line-height: 1.25;
}

.login-copy,
.empty-state p {
    color: var(--muted);
}

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

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 48px;
    border: 1px solid #d8cdbf;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    padding: 0 14px;
    outline: none;
}

input[type="file"] {
    padding: 12px 14px;
}

input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(185, 138, 66, 0.16);
}

.primary-button,
.secondary-button,
.ghost-button {
    min-height: 48px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    padding: 0 18px;
    font-weight: 800;
    cursor: pointer;
}

.primary-button {
    background: linear-gradient(135deg, var(--ink), var(--olive));
    color: #fff8ef;
    box-shadow: 0 12px 24px rgba(41, 35, 29, 0.16);
}

.secondary-button {
    border: 1px solid var(--linen-strong);
    background: #fff;
    color: var(--ink);
}

.ghost-button {
    border: 1px solid rgba(41, 35, 29, 0.16);
    background: rgba(255, 255, 255, 0.72);
    color: var(--ink);
}

.notice {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 20;
    width: min(360px, calc(100vw - 32px));
    margin-bottom: 0;
    padding: 14px 16px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid var(--linen-strong);
    box-shadow: 0 14px 36px rgba(41, 35, 29, 0.16);
    font-weight: 700;
    animation: toast-in 0.28s ease-out both;
}

.notice.is-hiding {
    animation: toast-out 0.34s ease-in both;
}

.notice.success {
    color: var(--success);
}

.notice.error {
    color: var(--danger);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(24px);
    }

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

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px clamp(18px, 5vw, 56px);
    border-bottom: 1px solid rgba(185, 138, 66, 0.18);
    background: rgba(251, 250, 247, 0.9);
    backdrop-filter: blur(14px);
}

.topbar h1 {
    margin: 0;
    font-size: 26px;
}

.workspace {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    margin-bottom: 24px;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.add-link {
    white-space: nowrap;
}

.add-section,
.inventory {
    padding: 26px;
    border: 1px solid rgba(185, 138, 66, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 12px 34px rgba(79, 61, 38, 0.08);
}

.inventory {
    margin-top: 0;
}

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

.product-form {
    grid-template-columns: minmax(240px, 1.1fr) minmax(220px, 0.9fr) 190px auto;
    align-items: end;
}

.add-page {
    max-width: 980px;
    margin: 0 auto;
}

.split-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.add-product-form {
    grid-template-columns: minmax(240px, 1fr) minmax(260px, 0.9fr);
}

.add-product-form .primary-button {
    align-self: end;
}

.file-picker {
    position: relative;
    min-height: 120px;
    align-content: start;
    padding: 16px;
    border: 1px dashed var(--gold);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(239, 231, 218, 0.5)),
        #fff;
    cursor: pointer;
}

.file-picker input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-picker strong {
    width: fit-content;
    margin-top: 8px;
    padding: 11px 16px;
    border-radius: 6px;
    background: var(--ink);
    color: #fff8ef;
    font-size: 14px;
}

.file-picker small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 22px;
}

.product-card {
    position: relative;
    display: grid;
    grid-template-rows: 220px 1fr auto;
    overflow: hidden;
    border: 1px solid rgba(185, 138, 66, 0.22);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 14px 34px rgba(79, 61, 38, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.product-card:hover {
    transform: translateY(-2px);
    border-color: rgba(185, 138, 66, 0.38);
    box-shadow: 0 20px 44px rgba(79, 61, 38, 0.14);
}

.product-card.sold-out {
    border-color: rgba(155, 45, 45, 0.46);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 240, 239, 0.95)),
        var(--panel);
    box-shadow: 0 18px 44px rgba(155, 45, 45, 0.12);
}

.product-card.sold-out .product-photo {
    filter: grayscale(0.25) saturate(0.82);
}

.product-card.sold-out .product-body {
    border-top-color: rgba(155, 45, 45, 0.15);
}

.sold-ribbon {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.sold-ribbon::before {
    content: "";
    position: absolute;
    width: 140%;
    height: 58px;
    transform: rotate(-32deg);
    background:
        linear-gradient(90deg, rgba(122, 29, 29, 0.94), rgba(174, 50, 47, 0.98), rgba(122, 29, 29, 0.94));
    box-shadow: 0 16px 34px rgba(155, 45, 45, 0.28);
}

.sold-ribbon span {
    position: relative;
    transform: rotate(-32deg);
    display: inline-grid;
    place-items: center;
    min-width: 250px;
    min-height: 42px;
    border-top: 1px solid rgba(255, 248, 239, 0.56);
    border-bottom: 1px solid rgba(255, 248, 239, 0.56);
    color: #fff8ef;
    text-align: center;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 0 rgba(41, 35, 29, 0.2);
}

.product-photo,
.dialog-photo {
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(218, 199, 173, 0.26), rgba(255, 255, 255, 0.64)),
    var(--linen);
    color: var(--gold-dark);
    font-size: 32px;
    font-weight: 900;
}

.product-photo {
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.product-photo::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    height: 62px;
    background: linear-gradient(180deg, rgba(41, 35, 29, 0), rgba(41, 35, 29, 0.14));
    pointer-events: none;
}

.product-photo img,
.dialog-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-body {
    padding: 20px 20px 16px;
    border-top: 1px solid rgba(185, 138, 66, 0.12);
}

.product-body h3 {
    margin-bottom: 18px;
    font-size: 22px;
    line-height: 1.16;
    text-transform: uppercase;
}

.stock-label {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.product-body strong {
    font-size: 38px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.product-card.sold-out .product-body strong {
    color: var(--danger);
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 0 20px 20px;
}

.card-actions form {
    display: grid;
}

.action-button {
    min-height: 46px;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    padding: 0 16px;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
    box-shadow: 0 10px 20px rgba(41, 35, 29, 0.09);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.action-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(41, 35, 29, 0.14);
    filter: saturate(1.04);
}

.sell-button {
    background: linear-gradient(135deg, var(--ink), var(--olive));
    color: #fff8ef;
}

.restock-button {
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    color: #fff8ef;
}

.danger-button {
    border: 1px solid rgba(155, 45, 45, 0.22);
    background: linear-gradient(135deg, #fffafa, #ffe9e7);
    color: var(--danger);
    box-shadow: 0 10px 20px rgba(155, 45, 45, 0.08);
}

.empty-state {
    padding: 28px;
    border: 1px dashed var(--linen-strong);
    border-radius: 8px;
    background: rgba(239, 231, 218, 0.34);
}

.sell-dialog {
    width: min(520px, calc(100% - 26px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
}

.sell-dialog::backdrop {
    background: rgba(41, 35, 29, 0.38);
    backdrop-filter: blur(4px);
}

.sell-form {
    position: relative;
    padding: 24px;
    background: var(--panel);
}

.dialog-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 1px solid var(--linen-strong);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.dialog-product {
    display: grid;
    grid-template-columns: 126px 1fr;
    gap: 18px;
    align-items: center;
}

.dialog-photo {
    width: 126px;
    height: 126px;
    overflow: hidden;
    border-radius: 8px;
}

.dialog-stock {
    color: var(--muted);
}

@media (max-width: 840px) {
    .toolbar,
    .search-form,
    .product-form,
    .add-product-form {
        grid-template-columns: 1fr;
    }

    .add-link {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .login-panel,
    .add-section,
    .inventory {
        padding: 20px;
    }

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

    .topbar form,
    .topbar button {
        width: 100%;
    }

    .dialog-product {
        grid-template-columns: 1fr;
    }

    .dialog-photo {
        width: 100%;
        height: 190px;
    }

    .notice {
        top: 14px;
        right: 14px;
    }

    .split-heading {
        flex-direction: column;
    }

    .split-heading .ghost-button {
        width: 100%;
    }

    .product-grid {
        grid-template-columns: 1fr;
    }

    .product-card {
        grid-template-rows: 200px 1fr auto;
    }

    .card-actions {
        grid-template-columns: 1fr;
    }

    .sold-ribbon::before {
        height: 52px;
    }

    .sold-ribbon span {
        font-size: 15px;
        min-width: 220px;
    }
}
