:root {
    --color-bg: #f7f5f2;
    --color-surface: #ffffff;
    --color-text: #262321;
    --color-text-muted: #6b6560;
    --color-border: #e5e0da;
    --color-accent: #b45309;
    --color-accent-dark: #92400e;
    --color-danger: #b91c1c;
    --color-success: #15803d;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    font-size: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    padding-bottom: 90px; /* room for the floating cart bar */
}

a { color: var(--color-accent-dark); }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 14px 16px;
}

.site-header h1 {
    margin: 0 0 10px;
    font-size: 1.35rem;
}

.search-box {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
}

.item-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: opacity .15s ease;
}

.item-card.is-sold-out {
    opacity: 0.55;
}

.item-photo-wrap {
    aspect-ratio: 1 / 1;
    background: var(--color-bg);
    position: relative;
    overflow: hidden;
}

.item-photo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-photo-wrap .no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.sold-out-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
}

.item-body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.item-title {
    font-weight: 600;
    font-size: 0.98rem;
    line-height: 1.25;
    margin: 0;
}

.item-desc {
    font-size: 0.83rem;
    color: var(--color-text-muted);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-price-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-top: auto;
}

.item-price {
    font-weight: 700;
    font-size: 1.05rem;
}

.item-stock {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.item-add-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.qty-input {
    width: 54px;
    padding: 7px 4px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.95rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    flex: 1;
}

.btn-primary:hover { background: var(--color-accent-dark); }

.btn-primary:disabled {
    background: #c9c2b8;
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-block { width: 100%; }

.added-flash {
    font-size: 0.75rem;
    color: var(--color-success);
    font-weight: 600;
    display: none;
}

.cart-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background: var(--color-text);
    color: #fff;
    padding: 12px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.15);
}

.cart-bar.is-visible { display: flex; }

.cart-bar-info { font-size: 0.92rem; }
.cart-bar-info strong { font-size: 1.05rem; }

.cart-bar .btn-primary {
    flex: none;
}

.empty-state {
    text-align: center;
    color: var(--color-text-muted);
    padding: 60px 16px;
}

/* ---- Checkout page ---- */
.checkout-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.checkout-table th, .checkout-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.checkout-table th { color: var(--color-text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; }

.checkout-total-row td {
    font-weight: 700;
    border-bottom: none;
}

.remove-link {
    color: var(--color-danger);
    font-size: 0.8rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.form-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-top: 16px;
}

.form-field { margin-bottom: 14px; }

.form-field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.alert-error { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }

.back-link {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 0.88rem;
    color: var(--color-text-muted);
    text-decoration: none;
}

.confirmation-box {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 20px;
    text-align: center;
}

.confirmation-box h1 { margin-top: 0; }

/* ---- Admin ---- */
.admin-shell { max-width: 640px; margin: 0 auto; padding: 16px; }

.admin-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.admin-nav a {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.88rem;
    font-weight: 600;
}

.admin-nav a.is-active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.login-shell {
    max-width: 360px;
    margin: 60px auto;
    padding: 0 16px;
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.admin-item-row {
    display: flex;
    gap: 12px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.admin-item-row img,
.admin-item-row .no-photo {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--color-bg);
}

.admin-item-row .no-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    font-size: 0.65rem;
    text-align: center;
}

.admin-item-info { flex: 1; min-width: 0; }
.admin-item-info .title { font-weight: 600; font-size: 0.92rem; }
.admin-item-info .meta { font-size: 0.78rem; color: var(--color-text-muted); }

.admin-item-actions { display: flex; flex-direction: column; gap: 6px; }
.admin-item-actions a, .admin-item-actions button {
    font-size: 0.8rem;
    padding: 6px 10px;
}

.claim-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-bottom: 12px;
}

.claim-card .claim-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.claim-card .claim-name { font-weight: 700; }
.claim-card .claim-phone { font-size: 0.9rem; }
.claim-card .claim-phone a { text-decoration: none; }
.claim-card .claim-time { font-size: 0.75rem; color: var(--color-text-muted); }

.claim-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.88rem; }

.status-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
}
.status-new { background: #fef3c7; color: #92400e; }
.status-contacted { background: #dcfce7; color: #15803d; }
.status-completed { background: #dbeafe; color: #1d4ed8; }
.status-cancelled { background: #f3f4f6; color: #6b7280; }

.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #166534; }

.helper-text { font-size: 0.8rem; color: var(--color-text-muted); }

.photo-preview {
    width: 100%;
    max-width: 260px;
    border-radius: var(--radius);
    margin-top: 8px;
    display: none;
}

.photo-picker-row {
    display: flex;
    gap: 8px;
}

.photo-picker-row .btn {
    flex: 1;
}

/* ---- Condition (New/Used) toggle buttons ---- */
.condition-toggle {
    display: flex;
    gap: 8px;
}

.condition-toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.condition-toggle label {
    flex: 1;
    text-align: center;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    background: var(--color-surface);
}

.condition-toggle input[type="radio"]:checked + label {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.condition-toggle input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--color-accent-dark);
    outline-offset: 1px;
}

/* ---- Category select + "add new category" field ---- */
.form-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--color-surface);
}

/* ---- Storefront badges (category / condition) ---- */
.badge-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    padding: 3px 8px;
    border-radius: 999px;
    line-height: 1.3;
}

.badge-category { background: #eee7dc; color: #6b5a3e; }
.badge-new { background: #dcfce7; color: #15803d; }
.badge-used { background: #e0e7ff; color: #3730a3; }

/* ---- Storefront filter row ---- */
.filter-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.filter-row .search-box { flex: 1; }

.category-filter {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.9rem;
    max-width: 160px;
}

@media (min-width: 480px) {
    .category-filter { max-width: 200px; }
}

@media (min-width: 640px) {
    .item-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ---- Admin dashboard stat row ---- */
.stat-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--color-text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 2px;
}

/* ---- Category landing page ---- */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.category-tile {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 12px;
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
}

.category-tile-all {
    background: var(--color-accent);
    color: #fff;
}

.category-tile-name { font-size: 1rem; }

.category-tile-count {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.category-tile-all .category-tile-count { color: rgba(255,255,255,0.85); }

.category-heading {
    margin: 4px 0 14px;
    font-size: 1.1rem;
}

/* ---- PIN gate splash ---- */
.pin-gate-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding-bottom: 0;
}

.pin-gate-shell {
    max-width: 360px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px;
    text-align: center;
}

.pin-gate-logo {
    max-width: 220px;
    width: 100%;
    height: auto;
    margin: 0 auto 20px;
    display: block;
}

.pin-gate-title {
    margin-bottom: 20px;
}

.pin-gate-label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 8px;
}

.pin-gate-input {
    width: 100%;
    padding: 14px;
    font-size: 1.6rem;
    letter-spacing: .3em;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 14px;
}
