/* ============================
   GLOBAL
============================ */

html {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    font-size: 16px;
    line-height: 1.4;
    background: #fdfdfd;
    color: #222;
    /* Viewport must be the scroller or Chrome/Android edge-swipe
       history navigation never fires ("swipe back does nothing"). */
    height: 100%;
    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior-x: auto;
    overscroll-behavior-y: auto;
    touch-action: pan-x pan-y pinch-zoom;
}

body {
    margin: 0;
    padding: 10px;
    min-height: 100%;
    height: auto;
    overflow: visible;
    overscroll-behavior-x: auto;
    touch-action: pan-x pan-y pinch-zoom;
}

h2, h3 {
    margin-top: 0;
    font-weight: 600;
}

input, button, textarea {
    font-family: inherit;
    font-size: 16px;
    box-sizing: border-box;
}

button {
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #888;
    background: #eee;
    cursor: pointer;
}

    button:hover {
        background: #e0e0e0;
    }

/* ============================
   LAYOUT — cards only, full width
============================ */

#orders-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    gap: 16px;
    min-height: calc(100vh - 20px);
}

#recent-orders {
    width: 100%;
    min-width: 0;
}

#order-details {
    display: none !important;
}

.page-top-links {
    margin-bottom: 8px;
}

.dashboard-link {
    color: #555;
    text-decoration: none;
    font-size: 0.95rem;
}

/* ============================
   ORDER CARDS
============================ */

.order-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-card {
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.order-card.selected {
    border-color: #8b5e3c;
    box-shadow: 0 0 0 2px rgba(139, 94, 60, 0.18);
}

.order-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px 12px;
}

.item-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.item-field label {
    font-size: 0.8em;
    color: #555;
}

.item-field input,
.item-field select,
.item-field textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.order-card-header {
    padding: 12px 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    background: #fafafa;
}

    .order-card-header:active {
        background: #f0f0f0;
    }

.order-card-summary {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.35;
    min-width: 0;
}

    .order-card-summary .vendor {
        font-weight: 600;
        display: block;
    }

    .order-card-summary .meta {
        color: #555;
        font-size: 0.85rem;
    }

.order-card-body {
    display: none;
    padding: 8px 12px 12px;
    border-top: 1px solid #eee;
    max-width: 100%;
    box-sizing: border-box;
}

.order-card.expanded .order-card-body {
    display: block;
}

/* ============================
   CARD EDITOR (expanded)
============================ */

.card-order-header {
    padding: 4px 0 8px;
    border-bottom: 1px solid #eee;
    margin-bottom: 6px;
}

.card-header-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.card-header-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 100px;
}

    .card-header-field label {
        font-size: 0.7rem;
        color: #666;
        margin-bottom: 2px;
    }

    .card-header-field input {
        padding: 6px 8px;
        border: 1px solid #ccc;
        border-radius: 6px;
        width: 100%;
        font-size: 0.95rem;
    }

@media (min-width: 360px) {
    .card-header-row {
        flex-wrap: nowrap;
    }

    .card-header-field {
        flex: 1 1 0;
    }
}

.card-toolbar {
    padding: 4px 0 10px;
}

    .card-toolbar button {
        width: 100%;
        padding: 10px;
        font-weight: 600;
    }

.card-items {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-item {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px;
    background: #fafafa;
}

.card-item-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
    word-break: break-word;
}

.card-item-warn {
    background: #fff8e1;
    border-color: #ffe082;
}

.card-warn-tag {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #f57f17;
    background: #ffecb3;
    padding: 2px 8px;
    border-radius: 10px;
    vertical-align: middle;
}

.card-aisle {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1565c0;
    background: #e3f2fd;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
    vertical-align: middle;
}

.card-item-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    width: 100%;
}

    .card-item-grid label {
        display: flex;
        flex-direction: column;
        gap: 2px;
        font-size: 0.8rem;
        color: #555;
        min-width: 0;
    }

    .card-item-grid input {
        width: 100%;
        min-width: 0;
        padding: 8px 10px;
        border: 1px solid #ccc;
        border-radius: 6px;
    }

.card-add-item {
    padding: 12px 0 4px;
}

    .card-add-item button {
        width: 100%;
        padding: 12px;
        font-weight: 600;
    }

.card-save-status {
    padding: 8px 10px;
    margin: 0 0 8px;
    border-radius: 6px;
    font-size: 0.9em;
    text-align: center;
}

    .card-save-status.ok {
        color: #1b5e20;
        background: #e8f5e9;
    }

    .card-save-status.err {
        color: #c62828;
        background: #ffebee;
    }

@media (max-width: 480px) {
    .card-item-grid {
        grid-template-columns: 1fr;
    }
}

.card-item-summary {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.card-item-meta {
    font-size: 0.85rem;
    color: #555;
    white-space: nowrap;
}

.card-item-detail {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

    .card-item-detail[hidden] {
        display: none;
    }

.card-header-note {
    margin-top: 8px;
}

    .card-header-note label {
        font-size: 0.7rem;
        color: #666;
        display: block;
        margin-bottom: 2px;
    }

    .card-header-note input {
        width: 100%;
        padding: 6px 8px;
        border: 1px solid #ccc;
        border-radius: 6px;
        font-size: 0.95rem;
        box-sizing: border-box;
    }

/* ============================
   SEARCHABLE SUGGESTIONS
============================ */

.item-suggestion-box {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 240px;
    overflow-y: auto;
    min-width: 260px;
    font-size: 0.95em;
}

    .item-suggestion-box > div {
        padding: 10px 12px;
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
    }

        .item-suggestion-box > div:hover {
            background: #f0f7ff;
        }

        .item-suggestion-box > div:last-child {
            border-bottom: none;
        }

/* ============================
   PRICES PAGE
============================ */

.prices-list {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.prices-item {
    display: grid;
    grid-template-columns: 1fr 70px;
    gap: 12px;
    align-items: start;
    background: white;
    border-radius: 14px;
    padding: 16px 18px;
    border: 1px solid #eee;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

    .prices-item .name {
        font-size: 1.05rem;
        font-weight: 600;
        line-height: 1.35;
        word-break: break-word;
    }

    .prices-item .price {
        font-size: 1.05rem;
        font-weight: 600;
        color: #111;
        white-space: nowrap;
        text-align: right;
        padding-top: 1px;
    }

.prices-search {
    max-width: 480px;
    margin: 0 auto 14px;
}

    .prices-search input {
        width: 100%;
        padding: 12px 14px;
        border: 1px solid #ccc;
        border-radius: 10px;
        font-size: 1rem;
    }

.prices-empty {
    text-align: center;
    color: #888;
    padding: 24px 12px;
}

.prices-add-btn {
    margin-top: 12px;
    padding: 12px 16px;
    width: 100%;
    max-width: 320px;
    font-weight: 600;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 8px;
    cursor: pointer;
}

    .prices-add-btn:hover {
        background: #c8e6c9;
    }

/* ============================
   DASHBOARD
============================ */

.dashboard-body {
    background-image: url("../images/pantry-background.jpg");
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    padding: 20px 16px 40px;
    min-height: 100vh;
    position: relative;
}

/* Soft warm overlay so cards stay readable over the photo */
.dashboard-body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at center, transparent 35%, rgba(40, 25, 12, 0.22) 100%),
        linear-gradient(180deg, rgba(255, 248, 235, 0.18) 0%, rgba(250, 240, 220, 0.1) 50%, rgba(40, 25, 12, 0.15) 100%);
    pointer-events: none;
    z-index: 0;
}

.dashboard-body > * {
    position: relative;
    z-index: 1;
}

.dashboard-header {
    text-align: center;
    margin-bottom: 28px;
    padding: 18px 16px 14px;
    background: rgba(255, 252, 245, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(139, 94, 60, 0.15);
    box-shadow: 0 4px 20px rgba(45, 28, 15, 0.08);
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

    .dashboard-header h1 {
        font-size: 1.7rem;
        font-weight: 700;
        letter-spacing: -0.02em;
        margin: 0;
        color: #3d2a1a;
    }

    .dashboard-header .dashboard-sub {
        color: #6b4a2f !important;
    }

.dashboard-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    margin: 0 auto;
}

.dashboard-card {
    display: block;
    background: rgba(255, 252, 245, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-radius: 16px;
    padding: 20px 18px;
    text-decoration: none;
    color: #2f2218;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 6px 24px rgba(45, 28, 15, 0.12);
    border: 1px solid rgba(139, 94, 60, 0.16);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

    .dashboard-card:hover {
        background: rgba(255, 252, 245, 0.95);
        box-shadow: 0 10px 32px rgba(45, 28, 15, 0.16);
        transform: translateY(-2px);
    }

    .dashboard-card:active {
        transform: scale(0.98);
    }

.dashboard-sign-in {
    display: block;
    text-align: center;
    margin-top: 28px;
    font-size: 1rem;
    color: #5c3a1e;
    text-decoration: none;
    font-weight: 500;
    background: rgba(255, 252, 245, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    max-width: 200px;
    margin-left: auto;
    margin-right: auto;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(139, 94, 60, 0.15);
}

    .dashboard-sign-in:hover {
        background: rgba(255, 252, 245, 0.9);
    }

.dashboard-privacy-link {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    background: #fffdf9;
    border: 1px solid rgba(139, 94, 60, 0.15);
    color: #5c3a1e;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
}

    .dashboard-privacy-link:hover {
        background: #fff;
    }

/* ============================
   LOGIN
============================ */

.login-box {
    max-width: 360px;
    margin: 40px auto 0;
    background: white;
    border-radius: 16px;
    padding: 28px 24px;
    border: 1px solid #eee;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

    .login-box label {
        display: block;
        font-weight: 600;
        margin-bottom: 6px;
        font-size: 0.95rem;
    }

    .login-box input {
        width: 100%;
        padding: 12px 14px;
        border: 1px solid #ccc;
        border-radius: 10px;
        margin-bottom: 18px;
    }

    .login-box button {
        width: 100%;
        padding: 14px;
        border: none;
        border-radius: 12px;
        background: #111;
        color: white;
        font-size: 1.05rem;
        font-weight: 600;
    }

.login-error {
    color: #c62828;
    font-size: 0.9rem;
    margin-bottom: 14px;
    display: none;
}

/* ============================
   ACCOUNT
============================ */

#account-layout {
    max-width: 420px;
    margin: 0 auto;
    padding: 12px 12px 40px;
}

.account-title {
    margin: 28px 0 4px;
    font-size: 1.5rem;
}

.account-sub {
    color: #666;
    font-size: 0.9em;
    margin: 0 0 20px;
}

.account-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 18px 16px;
    margin-bottom: 14px;
}

.account-label {
    font-weight: 600;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 6px;
}

.account-select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #ccc;
    border-radius: 10px;
    margin-bottom: 14px;
}

.account-save-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: #111;
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
}

/* ============================
   ANALYST
============================ */

#analyst-layout {
    max-width: 480px;
    margin: 0 auto;
    padding: 12px;
}

.order-card.problem {
    border-left: 4px solid #e74c3c;
}

.problem-reasons {
    font-size: 0.8em;
    color: #a94442;
    margin-top: 4px;
}

.validated-btn {
    width: 100%;
    padding: 12px;
    margin-top: 12px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
}

/* ============================
   MISC
============================ */

.sign-out-link {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 0.9em;
    color: #666;
    text-decoration: none;
}

.back-link {
    display: block;
    text-align: center;
    margin: 28px 0 10px;
    color: #666;
    text-decoration: none;
}

.loading, .error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* 
   =========================
    SNAP TOGGLE
   =========================
*/

.prices-toolbar {
    max-width: 480px;
    margin: 0 auto 10px;
    display: flex;
    gap: 8px;
}

.snap-toggle {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.9rem;
}

    .snap-toggle.active {
        background: #e8f5e9;
        border-color: #81c784;
        color: #1b5e20;
    }

/* ============================
    ITEM REVIEW
   ============================ */

.review-toolbar {
    max-width: 480px;
    margin: 0 auto 14px;
    display: flex;
    gap: 8px;
}

.review-tab {
    flex: 1;
    padding: 10px 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.9rem;
}

    .review-tab.active {
        background: #e3f2fd;
        border-color: #90caf9;
        color: #0d47a1;
    }

.review-boundary {
    max-width: 480px;
    margin: 0 auto 18px;
    padding: 12px 14px;
    background: #fafafa;
    border: 1px dashed #ccc;
    border-radius: 10px;
}

    .review-boundary label {
        font-weight: 600;
        font-size: 0.9rem;
        display: block;
        margin-bottom: 6px;
    }

    .review-boundary input[type="date"] {
        width: 100%;
        max-width: 200px;
        padding: 8px 10px;
        border: 1px solid #ccc;
        border-radius: 8px;
        opacity: 0.6;
    }

.review-list {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.review-section-title {
    max-width: 480px;
    margin: 20px auto 6px;
    font-size: 1.05rem;
}

.review-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
    overflow: hidden;
}

.review-card-dup {
    border-left: 4px solid #42a5f5;
}

.review-card-weird {
    border-left: 4px solid #ef6c00;
}

.review-card-neutral {
    border-left: 4px solid #bdbdbd;
}

/* Header is the tappable area — mirrors .order-card-header */
.review-card-header {
    padding: 14px 16px;
    cursor: pointer;
    background: #fafafa;
}

.review-card-header:active {
    background: #f0f0f0;
}

.review-card-head {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.review-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

    .review-badge.dup {
        background: #e3f2fd;
        color: #1565c0;
    }

    .review-badge.weird {
        background: #fff3e0;
        color: #e65100;
    }

    .review-badge.neutral {
        background: #f5f5f5;
        color: #616161;
    }

.review-meta {
    font-size: 0.8rem;
    color: #666;
}

/* Body only visible when expanded — same pattern as order cards */
.review-card-body {
    display: none;
    padding: 0 16px 14px;
    border-top: 1px solid #eee;
}

.review-card.expanded .review-card-body {
    display: block;
}

.review-line {
    font-size: 0.9rem;
    padding: 8px 0;
    border-top: 1px solid #f3f3f3;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.review-line:first-child {
    border-top: none;
    padding-top: 10px;
}

    .review-line .sku {
        font-family: monospace;
        font-size: 0.85rem;
        margin-right: 6px;
    }

.keep-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    border-radius: 8px;
    color: #0d47a1;
    cursor: pointer;
}

.keep-btn:active {
    background: #bbdefb;
}

.muted {
    color: #888;
}

.small {
    font-size: 0.85rem;
}

/* ============================
    TOP 10 / POPULAR
   ============================ */

.popular-list {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.popular-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

    .popular-item .rank {
        font-weight: 700;
        font-size: 0.9rem;
        color: #1565c0;
        min-width: 2rem;
        padding-top: 2px;
    }

    .popular-item .name {
        font-weight: 600;
        font-size: 1.05rem;
        line-height: 1.35;
        word-break: break-word;
    }

    .popular-item .meta {
        font-size: 0.9rem;
        color: #555;
        margin-top: 4px;
        display: flex;
        gap: 12px;
    }
/* ============================
   HELP SYSTEM (floating + panel)
============================ */

.pantry-help-root {
    position: fixed;
    z-index: 9990;
    /* Do not cover the viewport when closed — that blocks Chrome edge-swipe. */
    inset: auto;
    pointer-events: none;
}

.pantry-help-root.is-open {
    inset: 0;
}

.pantry-help-root > * {
    pointer-events: auto;
}

/* Floating ? button */
.pantry-help-btn {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(139, 94, 60, 0.22);
    background: rgba(255, 252, 245, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #3d2a1a;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(45, 28, 15, 0.14);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    z-index: 9992;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pantry-help-btn:hover {
    background: rgba(255, 252, 245, 1);
    box-shadow: 0 8px 28px rgba(45, 28, 15, 0.2);
    transform: translateY(-2px);
}

.pantry-help-btn:active {
    transform: scale(0.96);
}

/* On non-dashboard (white) pages, make the button a touch more solid */
body:not(.dashboard-body) .pantry-help-btn {
    background: #fffaf3;
    border-color: rgba(139, 94, 60, 0.28);
}

/* Overlay */
.pantry-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(40, 25, 12, 0.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 9991;
}

.pantry-help-root.is-open .pantry-help-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Panel – desktop right drawer, mobile bottom sheet */
.pantry-help-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(380px, 100vw);
    height: 100%;
    background: #fffdf9;
    border-left: 1px solid rgba(139, 94, 60, 0.14);
    box-shadow: -12px 0 40px rgba(45, 28, 15, 0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 9993;
    overflow: hidden;
}

.pantry-help-root.is-open .pantry-help-panel {
    transform: translateX(0);
}

@media (max-width: 520px) {
    .pantry-help-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: min(78vh, 640px);
        border-left: none;
        border-radius: 18px 18px 0 0;
        border-top: 1px solid rgba(139, 94, 60, 0.14);
        box-shadow: 0 -8px 32px rgba(45, 28, 15, 0.14);
        transform: translateY(105%);
    }
    .pantry-help-root.is-open .pantry-help-panel {
        transform: translateY(0);
    }
}

.pantry-help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(139, 94, 60, 0.1);
    flex-shrink: 0;
}

.pantry-help-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: #3d2a1a;
}

.pantry-help-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 1.6rem;
    line-height: 1;
    color: #6b4a2f;
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
}

.pantry-help-close:hover {
    background: rgba(139, 94, 60, 0.08);
}

.pantry-help-search {
    padding: 12px 16px 4px;
    flex-shrink: 0;
}

.pantry-help-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd0c0;
    border-radius: 10px;
    background: #fff;
    font-size: 0.95rem;
}

.pantry-help-context-title {
    padding: 12px 18px 4px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #8a6a4a;
    flex-shrink: 0;
}

.pantry-help-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 14px 16px;
    -webkit-overflow-scrolling: touch;
}

.pantry-help-card {
    background: #fff;
    border: 1px solid rgba(139, 94, 60, 0.12);
    border-radius: 12px;
    padding: 14px 14px 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(45, 28, 15, 0.04);
}

.pantry-help-card h3 {
    margin: 0 0 6px;
    font-size: 1rem;
    font-weight: 600;
    color: #2f2218;
}

.pantry-help-card p {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
    color: #4a3a2a;
}

.pantry-help-empty {
    text-align: center;
    color: #888;
    padding: 24px 12px;
    font-size: 0.95rem;
}

.pantry-help-footer {
    flex-shrink: 0;
    padding: 14px 16px 20px;
    border-top: 1px solid rgba(139, 94, 60, 0.1);
    background: rgba(255, 252, 245, 0.7);
}

.pantry-help-footer-text {
    margin: 0 0 10px;
    font-size: 0.92rem;
    color: #5c3a1e;
    text-align: center;
}

.pantry-help-ticket-btn {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(139, 94, 60, 0.25);
    background: #3d2a1a;
    color: #fffaf3;
    font-weight: 600;
    font-size: 0.98rem;
    cursor: pointer;
}

.pantry-help-ticket-btn:hover {
    background: #2f2218;
}

/* Ticket form */
.pantry-help-ticket {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 24px;
}

.pantry-help-ticket h3 {
    margin: 0 0 14px;
    font-size: 1.1rem;
    color: #3d2a1a;
}

.pantry-help-ticket label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #3d2a1a;
}

.pantry-help-ticket input,
.pantry-help-ticket textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 10px 12px;
    border: 1px solid #ddd0c0;
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
}

.pantry-help-ticket .optional {
    font-weight: 400;
    color: #888;
    font-size: 0.85em;
}

.pantry-help-ticket-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.pantry-help-ticket-cancel {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: #f5f0e8;
    cursor: pointer;
    font-weight: 500;
}

.pantry-help-ticket-submit {
    flex: 1.4;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: #3d2a1a;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.pantry-help-ticket-submit:disabled {
    opacity: 0.65;
    cursor: wait;
}

.pantry-help-ticket-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}

.pantry-help-ticket-status.ok {
    background: #e8f5e9;
    color: #1b5e20;
}

.pantry-help-ticket-status.err {
    background: #fff3e0;
    color: #bf360c;
}

.pantry-help-ticket-status a {
    color: inherit;
    font-weight: 600;
}

/* First-visit toast */
.pantry-help-toast {
    position: fixed;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%) translateY(12px);
    max-width: min(320px, calc(100vw - 32px));
    padding: 12px 16px;
    background: rgba(61, 42, 26, 0.92);
    color: #fffaf3;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.4;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9994;
    pointer-events: none;
    text-align: center;
}

.pantry-help-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.pantry-help-toast strong {
    font-weight: 700;
}

/* ============================
   PRIVACY STATEMENT
============================ */

.privacy-wrap {
    max-width: 560px;
    margin: 0 auto;
    padding: 8px 12px 40px;
}

.privacy-top-links {
    max-width: 560px;
    margin: 0 auto 8px;
}

    .privacy-top-links .dashboard-link {
        display: inline-block;
        padding: 8px 14px;
        border-radius: 999px;
        background: #fffdf9;
        border: 1px solid rgba(139, 94, 60, 0.15);
        color: #5c3a1e;
        font-weight: 500;
    }

.privacy-card {
    background: #fffdf9;
    border-radius: 16px;
    border: 1px solid rgba(139, 94, 60, 0.15);
    box-shadow: 0 4px 20px rgba(45, 28, 15, 0.08);
    padding: 22px 20px 24px;
    color: #2f2218;
}

    .privacy-card h2 {
        font-size: 1.05rem;
        margin: 20px 0 8px;
        color: #3d2a1a;
    }

        .privacy-card h2:first-of-type {
            margin-top: 4px;
        }

    .privacy-card p,
    .privacy-card li {
        font-size: 0.95rem;
        line-height: 1.5;
        color: #4a3a2a;
        margin: 0 0 10px;
    }

    .privacy-card ul {
        margin: 0 0 10px;
        padding-left: 1.25em;
    }

    .privacy-card a {
        color: #5c3a1e;
    }

/* ============================
   PAGE HEADERS (order / account / on-hand)
   Single source of truth – change height or overlay here
============================ */

.page-header {
    position: relative;
    width: 100%;
    height: 180px; /* ← only place to change header height */
    overflow: hidden;
    margin: -10px -10px 16px; /* counteract body padding so header is full-bleed */
    background-color: #f5f5f0;
}

.page-header__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.page-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient( to bottom, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.58) 100% );
    pointer-events: none;
}

.page-header__content {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    padding: 14px 16px;
    z-index: 1;
}

    .page-header__content h1 {
        margin: 0;
        font-size: 1.5rem;
        font-weight: 600;
        color: #2c2c2c;
        text-shadow: 0 1px 3px rgba(255, 255, 255, 0.7);
    }

/* On-hand image is heavily right-weighted – keep the shelf in frame */
.page-header--onhand .page-header__img {
    object-position: right center;
}

@media (min-width: 640px) {
    .page-header {
        height: 220px;
    }

    .page-header__content h1 {
        font-size: 1.75rem;
    }
}

/* ---- Admin page (admin.html) ---- */
body.admin-body {
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    background: #f4f5f7;
    color: #111;
}

.admin-wrap,
body.admin-body .wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px;
}

body.admin-body h1 {
    font-size: 1.25rem;
    margin: 0 0 4px;
}

body.admin-body .sub {
    color: #666;
    font-size: 0.9rem;
    margin: 0 0 20px;
}

body.admin-body a.back {
    color: #2563eb;
    text-decoration: none;
    font-size: 0.9rem;
}

body.admin-body .card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 16px;
}

body.admin-body .card h2 {
    font-size: 1.05rem;
    margin: 0 0 10px;
}

body.admin-body .card p.hint,
body.admin-body .hint {
    font-size: 0.85rem;
    color: #666;
    margin: 0 0 12px;
}

body.admin-body label {
    display: block;
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 4px;
}

body.admin-body input[type="number"],
body.admin-body input[type="text"],
body.admin-body select {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1em;
    max-width: 280px;
    box-sizing: border-box;
}

body.admin-body button {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 0.95em;
}

body.admin-body button.primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

body.admin-body button.primary:hover {
    background: #1d4ed8;
}

body.admin-body button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

body.admin-body .row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 8px;
}

body.admin-body .field-block {
    margin: 12px 0;
}

body.admin-body .status {
    font-size: 0.85rem;
    color: #166534;
    margin-left: 8px;
}

body.admin-body .status.err {
    color: #b91c1c;
}

body.admin-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

body.admin-body th,
body.admin-body td {
    text-align: left;
    padding: 8px 6px;
    border-bottom: 1px solid #f0f0f0;
}

body.admin-body th {
    color: #666;
    font-weight: 600;
    font-size: 0.8rem;
}

body.admin-body .role-select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #ccc;
}

body.admin-body .empty {
    color: #888;
    padding: 12px 0;
}

body.admin-body .links {
    margin-bottom: 16px;
}

body.admin-body .links a {
    margin-right: 14px;
    color: #2563eb;
    text-decoration: none;
    font-size: 0.9rem;
}

body.admin-body .denied {
    max-width: 480px;
    margin: 60px auto;
    text-align: center;
    color: #555;
}

body.admin-body .help-article-row {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: #fafafa;
}

body.admin-body [hidden] {
    display: none !important;
}