body {
    background: radial-gradient(circle at top right, #20050d 0%, #0d0205 55%, #070103 100%);
    background-attachment: fixed;
}
.panel {
    background: rgba(25, 6, 11, 0.55);
    border: 1px solid rgba(72, 15, 30, 0.8);
    border-radius: 1rem;
    padding: 1.1rem;
    backdrop-filter: blur(8px);
}
.lbl {
    display: block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: #cbd5e1; margin-bottom: 0.4rem;
}
.input {
    width: 100%; background: rgba(12, 2, 5, 0.85); border: 1px solid rgba(109, 22, 46, 0.7);
    border-radius: 0.65rem; padding: 0.45rem 0.7rem; font-size: 0.82rem; color: #e2e8f0;
}
.input:focus { outline: none; border-color: #d4af37; }
.btn-gold {
    padding: 0.45rem 0.9rem; border-radius: 0.7rem; font-weight: 700; color: #0c0205;
    background: linear-gradient(90deg, #d4af37, #f0c75e); box-shadow: 0 4px 14px -6px rgba(212,175,55,.5);
    transition: filter .15s, transform .1s;
}
.btn-gold:hover { filter: brightness(1.08); }
.btn-gold:active { transform: scale(.97); }
.btn-gold:disabled { opacity: .45; pointer-events: none; }
.btn-ghost {
    padding: 0.45rem 0.9rem; border-radius: 0.7rem; border: 1px solid rgba(109, 22, 46, 0.8);
    color: #cbd5e1; background: rgba(25, 6, 11, 0.6);
}
.btn-ghost:hover { border-color: rgba(212,175,55,.5); color: #fff; }
.btn-ghost:disabled { opacity: .35; pointer-events: none; }
.chip {
    padding: 0.28rem 0.7rem; border-radius: 999px; font-size: 0.75rem; white-space: nowrap;
    background: rgba(45, 9, 19, 0.6); border: 1px solid rgba(109, 22, 46, 0.6); color: #cbd5e1;
}
.chip:hover { border-color: rgba(212,175,55,.5); }
.chip.active { background: linear-gradient(135deg, #9b2041, #6d162e); border-color: #d4af37; color: #fff; }
.chip .cnt { color: #94a3b8; font-size: 0.65rem; margin-left: .25rem; }
.pbtn {
    padding: 0.3rem 0; border-radius: 0.5rem; font-size: 0.72rem; font-weight: 600;
    background: rgba(25, 6, 11, 0.7); border: 1px solid rgba(72, 15, 30, 0.9); color: #94a3b8;
}
.pbtn.active { background: rgba(212,175,55,.15); border-color: #d4af37; color: #dfc56c; }
.badge { display: inline-flex; align-items: center; gap: .2rem; font-size: .65rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; border-width: 1px; }
.vbtn { padding: .3rem .7rem; border-radius: .55rem; color: #94a3b8; }
.vbtn.active { background: rgba(212,175,55,.15); color: #ebdc9f; }
.th { padding: .6rem .75rem; text-align: left; font-weight: 600; white-space: nowrap; }
.th.sortable { cursor: pointer; user-select: none; }
.th.sortable:hover { color: #ebdc9f; }
.th.sorted { color: #dfc56c; }
.sort-ind { display: inline-block; width: .9em; margin-left: .2rem; }
.td { padding: .55rem .75rem; border-top: 1px solid rgba(72, 15, 30, .55); vertical-align: middle; }
tr.row:hover { background: rgba(72, 15, 30, .35); cursor: pointer; }

.wine-card { transition: transform .2s, border-color .2s, box-shadow .2s; }
.wine-card:hover { transform: translateY(-3px); border-color: rgba(212,175,55,.45); box-shadow: 0 18px 30px -12px rgba(0,0,0,.6); }

/* multiselect */
.ms { position: relative; }
.ms-btn { display: flex; justify-content: space-between; align-items: center; gap: .5rem; text-align: left; }
.ms-btn .ms-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-pop {
    position: absolute; z-index: 30; left: 0; right: 0; margin-top: .25rem; max-height: 18rem; overflow: auto;
    background: #12040a; border: 1px solid rgba(212,175,55,.35); border-radius: .75rem; padding: .4rem;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,.8);
}
.ms-opt { display: flex; align-items: center; gap: .5rem; padding: .3rem .4rem; border-radius: .45rem; font-size: .8rem; cursor: pointer; }
.ms-opt:hover { background: rgba(72, 15, 30, .6); }
.ms-opt .cnt { margin-left: auto; color: #64748b; font-size: .7rem; }
.ms-opt input { accent-color: #d4af37; }

.spinner { width: 2rem; height: 2rem; border-radius: 999px; border: 3px solid rgba(212,175,55,.25); border-top-color: #d4af37; animation: spin 1s linear infinite; }
.spinner.sm { width: 1rem; height: 1rem; border-width: 2px; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0c0205; }
::-webkit-scrollbar-thumb { background: #480f1e; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #d4af37; }

/* elements only admins see (import, price search, user management) */
body:not(.is-admin) .admin-only { display: none !important; }
/* nothing is shown until the login check has finished (AWS version) */
body.auth-pending main, body.auth-pending header #statsBar { visibility: hidden; }

/* ------------------------------------------------------------ header buttons */
.hbtn {
    display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .6rem; border-radius: .6rem;
    border-width: 1px; line-height: 1.2; white-space: nowrap;
}
.hbtn:hover { background: rgba(212,175,55,.08); }

/* ------------------------------------------------------------ phones & tablets (< 1024px) */
html, body { overflow-x: hidden; }
@media (max-width: 1023px) {
    /* filter sidebar becomes a bottom sheet */
    #filterAside {
        position: fixed; inset: 0; z-index: 55; display: none;
        background: rgba(0, 0, 0, .7); backdrop-filter: blur(3px);
    }
    #filterAside.open { display: block; }
    #filterPanel {
        position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
        overscroll-behavior: contain; border-radius: 1.25rem 1.25rem 0 0; background: #14040a;
        padding-bottom: 0; animation: sheet-up .2s ease-out;
    }
    .filter-apply {
        position: sticky; bottom: 0; margin: 0 -1.1rem; padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
        background: #14040a; border-top: 1px solid rgba(72, 15, 30, .9);
    }
    body.sheet-open { overflow: hidden; }
    .wine-card:hover { transform: none; }
}
@keyframes sheet-up { from { transform: translateY(30%); opacity: .4; } to { transform: none; opacity: 1; } }

/* iOS zooms into inputs with a font below 16px */
@media (max-width: 640px) {
    .input, select.input { font-size: 16px; }
    .panel { padding: .9rem; }
    .filter-apply { margin: 0 -.9rem; }
}

/* ------------------------------------------------------------ cost dashboard (dark palette, validated) */
.viz-root {
    color-scheme: dark;
    --surface-1: #19060b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --grid: rgba(148, 163, 184, .14);
    --series-1: #3987e5;   /* blue   */
    --series-2: #d95926;   /* orange */
    --series-3: #199e70;   /* aqua   */
    --series-4: #c98500;   /* yellow */
    --series-other: #6b6a66;
}
.kpi { border: 1px solid rgba(72, 15, 30, .8); background: rgba(12, 2, 5, .55); border-radius: .9rem; padding: .75rem .9rem; }
.kpi .k-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); }
.kpi .k-value { font-size: 1.45rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.kpi .k-sub { font-size: .72rem; color: var(--text-secondary); }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; vertical-align: -1px; }
.cost-bar rect.seg { transition: opacity .1s; }
.cost-bar:hover rect.seg { opacity: .55; }
.cost-bar g.day:hover rect.seg { opacity: 1; }
.viz-tip {
    position: fixed; z-index: 70; pointer-events: none; background: #0c0205; border: 1px solid rgba(212,175,55,.4);
    border-radius: .6rem; padding: .5rem .65rem; font-size: .75rem; color: var(--text-primary); box-shadow: 0 10px 25px -8px #000;
    min-width: 10rem;
}
.meter { height: .5rem; border-radius: 999px; background: rgba(72, 15, 30, .7); overflow: hidden; }
.meter > div { height: 100%; border-radius: 999px; }
.ctable td, .ctable th { padding: .4rem .5rem; border-top: 1px solid rgba(72, 15, 30, .55); }
.ctable th { font-weight: 600; color: var(--text-secondary); font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; border-top: 0; }
