/* ==========================================================================
   Sentinel Beekeeping — "Black Label" Theme
   Derived from Brett's product labels:
   - Matte black background, warm undertone
   - Thin double gold frame (the printed label border)
   - Antique gold serif headings, letter-spaced caps
   - Flowing gold ribbon arcs (the mead sticker swoosh)
   ========================================================================== */

:root {
    --bg-deep:        #0e0c0a;
    --bg-base:        #14110d;
    --bg-panel:       #17130f;
    --bg-input:       #1f1a14;
    --border:         #3a3226;
    --border-strong:  #8a6d2e;

    --gold:           #c9a24b;
    --gold-bright:    #e6c87e;
    --gold-deep:      #8a6d2e;
    --gold-glow:      rgba(201, 162, 75, 0.28);

    /* Sampled straight off the printed "Cinnamon Creamed Honey" label so the
       site and the jar match: cream banner, dark ink text for it, bright gold
       outer frame over a dark bronze inner rule. */
    --cream:          #f8efd5;
    --ink:            #1f1e1c;
    --gold-frame:     #d5a948;
    --gold-label:     #eeca77;
    --bronze:         #6c5338;

    --amber:          #e0952d;
    --amber-soft:     rgba(224, 149, 45, 0.14);

    --text:           #f3ead8;
    --text-muted:     #c7b99e;
    --text-dim:       #8f8471;

    --danger:         #c45a5a;
    --success:        #8fae6a;

    --font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-serif: 'Georgia', 'Playfair Display', 'Times New Roman', serif;
}

/* --- Reset ----------------------------------------------------------------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font-sans);
    color: var(--text);
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(ellipse 120% 60% at 50% -10%, rgba(201, 162, 75, 0.10) 0%, transparent 60%),
        linear-gradient(115deg, transparent 55%, rgba(201, 162, 75, 0.06) 62%, rgba(224, 149, 45, 0.05) 68%, transparent 75%),
        linear-gradient(115deg, transparent 62%, rgba(201, 162, 75, 0.04) 70%, transparent 82%),
        linear-gradient(180deg, var(--bg-base) 0%, var(--bg-deep) 55%);
    background-attachment: fixed, fixed, fixed, fixed;
    background-repeat: no-repeat;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Shared application navigation ------------------------------------------ */
.main-nav {
    position: sticky;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 0.7rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0;
    background: rgba(14, 12, 10, 0.97);
    backdrop-filter: blur(6px);
    /* Was 0 10px 26px -- that 26px blur fell onto the cream label band and
       shaded its top 12px, so the paper looked smudged. The nav already has
       its own bottom border for separation; this just tightens the depth cue. */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

.main-nav-brand {
    color: var(--gold-bright);
    font-family: var(--font-serif);
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
}

.main-nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.main-nav a:not(.main-nav-brand) {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.main-nav a:hover { color: var(--gold-bright); }
.main-nav-signout { margin-left: auto; }

/* --- Staff strip on the public shop ----------------------------------------- */
/* The storefront is a customer page, so it shows this one slim line instead of
   the ERP menu. Rendered only for a signed-in session (_staff_bar.html). */
.staff-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem 0.9rem;
    padding: 0.4rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: rgba(14, 12, 10, 0.88);
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.staff-bar-label { color: var(--gold); }
.staff-bar-user { color: var(--text-dim); }
.staff-bar a { color: var(--text-muted); text-decoration: none; }
.staff-bar a:hover { color: var(--gold-bright); }
.staff-bar-signout { margin-left: 0.4rem; }

/* --- Panels framed like the printed label ----------------------------------- */
/* The padding lives in custom properties so the cream banner below can cancel
   it with negative margins and still bleed to the frame edge at every
   breakpoint (instead of hard-coding four different negative values). */
.container {
    --pad-x: 2.5rem;
    --pad-y: 2.5rem;
    background: var(--bg-panel);
    padding: var(--pad-y) var(--pad-x);
    border-radius: 4px;
    border: 1px solid rgba(213, 169, 72, 0.7);
    outline: 1px solid rgba(108, 83, 40, 0.9);
    outline-offset: -6px;
    box-shadow:
        0 14px 44px rgba(0, 0, 0, 0.65),
        inset 0 1px 0 rgba(230, 200, 126, 0.06);
    width: min(100% - 2rem, 1440px);
    margin: 1.5rem auto;
    position: relative;
}

/* The label's cream banner, carried inside the frame. It is absolutely
   positioned on the padding box, so it meets the gold border at the top, left
   and right -- and, unlike negative margins, it can never widen the panel and
   cause a horizontal scrollbar on a phone. The panel reserves the band's
   height in top padding so content starts below it.
   Dark ink on cream; the label's gold would be illegible on this ground.
   The public shop keeps its own lighter header, hence the :not(). */
.container:not(.shop-container) {
    --banner-h: 2.6rem;
    padding-top: calc(var(--pad-y) + var(--banner-h));
    /* The label's double frame: bright gold outside, bronze hairline 6px inside.
       At 1px and 70% opacity the gold disappeared into the cream band, so the
       frame read as a single thin line instead of the label's two. */
    border-color: var(--gold-frame);
    outline-color: var(--bronze);
    outline-offset: -8px;
}

@media (min-width: 421px) {
    /* 2px like the printed frame. Above 420px only: the phone breakpoint drops
       the side borders on purpose for a full-bleed panel. */
    .container:not(.shop-container) { border-width: 2px; }
}

.container:not(.shop-container)::before {
    content: var(--brand-banner, "SENTINEL HONEY PRODUCTS");
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--banner-h);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px 3px 0 0;
    background: var(--cream);
    /* The label's inner hairline: bronze, 6px in from the gold frame. It has to
       be painted BY the band -- the panel's own outline sits underneath and the
       band, being a child box, covers it completely (which is why the frame
       looked single). Sides stop at 6px so they line up with the panel outline
       at 8px from its outer edge. */
    background-image:
        linear-gradient(var(--bronze), var(--bronze)),
        linear-gradient(var(--bronze), var(--bronze)),
        linear-gradient(var(--bronze), var(--bronze));
    background-size: calc(100% - 12px) 1px, 1px 100%, 1px 100%;
    background-position: 6px 6px, 6px 0, calc(100% - 6px) 0;
    background-repeat: no-repeat;
    border-bottom: 2px solid var(--gold-frame);
    box-shadow: 0 1px 0 rgba(108, 83, 40, 0.55), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-indent: 0.3em;      /* re-centre: letter-spacing pads the last glyph too */
    text-transform: uppercase;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
}

/* --- Headings -------------------------------------------------------------- */
h1, h2, h3 {
    font-family: var(--font-serif);
    color: var(--gold-bright);
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
    font-weight: 400;
    color: var(--gold-label);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

h2 {
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

p { color: var(--text-muted); line-height: 1.65; margin-bottom: 1rem; }

/* --- Brand header ------------------------------------------------------------ */
.brand-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

/* Compact shop header: small mark, inline brand, search-first layout. */
.brand-header.shop-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    text-align: left;
    margin-bottom: 1.25rem;
    padding-bottom: 0.9rem;
}

.brand-header.shop-brand img {
    max-width: 58px;
    max-height: 58px;
    margin: 0;
    display: block;
}

.shop-brand-link { display: block; line-height: 0; }

.shop-brand-text { display: flex; flex-direction: column; min-width: 0; }

.shop-brand-name {
    color: var(--gold-bright);
    font-family: var(--font-serif);
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.shop-brand-tag {
    color: var(--text-dim);
    font-size: 0.6rem;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-search {
    margin-left: auto;
    flex: 0 1 320px;
    /* Control sizing comes from the shared .search-form rules. */
}

/* --- Category filter chips ---------------------------------------------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.chip {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--text-muted);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.chip:hover { color: var(--gold-bright); border-color: var(--gold); }

.chip-active {
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    border-color: var(--gold);
    color: #191307;
}

.chip-active:hover { color: #191307; }

.result-note {
    color: var(--text-dim);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1.25rem;
}

.result-note a { color: var(--gold); text-decoration: none; }
.result-note a:hover { color: var(--gold-bright); }

.brand-header img {
    max-width: 210px;
    height: auto;
    margin: 0 auto 0.75rem;
    display: block;
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.7));
}

.brand-header .tagline {
    color: var(--text-dim);
    font-size: 0.72rem;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    margin: 0;
}

/* --- Navigation ---------------------------------------------------------------- */
.nav, .shop-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.nav a, .nav span, .shop-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s;
}

.nav a:hover, .shop-nav a:hover { color: var(--gold-bright); }

/* --- Forms ----------------------------------------------------------------- */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

input[type="text"],
input[type="search"],
input[type="url"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font-sans);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-glow);
}

button, .btn {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, #9c7a35 100%);
    color: #191307;
    border: 1px solid #6e5620;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 240, 200, 0.35);
    text-decoration: none;
    text-align: center;
}

button:hover, .btn:hover {
    background: linear-gradient(180deg, #f3dd9a 0%, var(--gold-bright) 55%, var(--gold) 100%);
    box-shadow: 0 4px 14px var(--gold-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

button:active, .btn:active { transform: translateY(0); }

/* --- Search rows -------------------------------------------------------------- */
/* One set of metrics for every "field + button" row, so the two boxes are always
   the same height and sit level. Add .search-form to the form element itself.
   Written after the control rules above so its padding/font-size win. */
.search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-form input,
.search-form select,
.search-form button,
.search-form .btn {
    height: 2.5rem;
    margin-bottom: 0;
    padding: 0 0.9rem;
    line-height: 1;
}

.search-form input,
.search-form select {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
}

.search-form button,
.search-form .btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    font-size: 0.8rem;
}

.btn-outline {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--gold);
    color: #191307;
    box-shadow: 0 4px 12px var(--gold-glow);
}

/* --- Settings helpers --------------------------------------------------------- */
.settings-help, .settings-warning {
    color: var(--text-dim);
    font-size: 0.82rem;
}

.settings-warning {
    color: #e8c28b;
    margin: 0.5rem 0 0;
}

/* --- Error / flash ---------------------------------------------------------- */
.error {
    background: rgba(196, 90, 90, 0.12);
    color: #e8a3a3;
    padding: 0.75rem 1rem;
    border-radius: 3px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(196, 90, 90, 0.45);
}

.success {
    background: rgba(143, 174, 106, 0.12);
    color: #b5d194;
    padding: 0.75rem 1rem;
    border-radius: 3px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid rgba(143, 174, 106, 0.45);
}

/* --- Operations dashboard ---------------------------------------------------- */
.dashboard-heading, .panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.dashboard-heading { margin-bottom: 2rem; }
.dashboard-heading h1 { margin-bottom: 0.4rem; }
.dashboard-heading p { margin-bottom: 0; }
.dashboard-kpis .stat-card { text-decoration: none; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.dashboard-panel {
    min-width: 0;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.25rem;
}

.panel-heading { margin-bottom: 1rem; }
.panel-heading h2 { margin-bottom: 0; font-size: 1rem; }
.panel-heading a { color: var(--gold); font-size: 0.7rem; text-decoration: none; text-transform: uppercase; letter-spacing: 0.1em; }
.dashboard-list { display: grid; }
.dashboard-list-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.dashboard-list-row:last-child { border-bottom: 0; }
.dashboard-list-row:hover strong { color: var(--gold-bright); }
.dashboard-list-row span { min-width: 0; }
.dashboard-list-row strong { display: block; color: var(--text); font-size: 0.9rem; }
.dashboard-list-row small { display: block; color: var(--text-dim); margin-top: 0.2rem; }
.empty-state { color: var(--text-dim); font-size: 0.9rem; margin: 0.5rem 0; }
.positive { color: var(--success); }
.negative { color: #e8a3a3; }

/* --- Stats / cards ----------------------------------------------------------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-input);
    padding: 1.25rem 1rem;
    border-radius: 3px;
    text-align: center;
    border: 1px solid var(--border);
    transition: border-color 0.2s, transform 0.2s;
}

.stat-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.stat-value {
    font-family: var(--font-serif);
    font-size: 1.7rem;
    color: var(--gold-bright);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

/* --- Sortable table headers ------------------------------------------------- */
/* Column headers become links built by app/erp/listing.py's sort_url(), which
   keeps the current search term and page filters in the query string. */
.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link:hover { color: var(--gold-bright); }

.sort-link.active { color: var(--gold-bright); }

.sort-arrow { font-size: 0.72em; line-height: 1; }
.sort-arrow.muted { opacity: 0.35; }


/* --- Tables ---------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow: hidden;
}

/* Wide admin tables remain usable on phones without distorting columns. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 620px; }

th, td {
    padding: 0.8rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--gold);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    background: var(--bg-input);
}

td { color: var(--text); }

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(201, 162, 75, 0.05); }

/* --- User list --------------------------------------------------------------- */
.user-list { list-style: none; margin-top: 1rem; }

.user-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.user-item:last-child { border-bottom: none; }

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-bright), #9c7a35);
    color: #191307;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.user-info { flex: 1; }
.user-name { color: var(--text); font-weight: 600; }
.user-role {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 0.15rem;
}

/* --- Login ---------------------------------------------------------------- */
.login-container { max-width: 420px; }
.login-title { text-align: center; margin-bottom: 0.25rem; }

.login-subtitle {
    text-align: center;
    color: var(--text-dim);
    margin-bottom: 2rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.32em;
}

/* --- Error page --------------------------------------------------------------- */
.error-page { text-align: center; max-width: 420px; }

.error-code {
    font-family: var(--font-serif);
    font-size: 5rem;
    color: var(--gold-bright);
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
}

.error-page .message {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.85rem;
}

.error-page a {
    color: var(--gold);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gold);
    padding-bottom: 2px;
}

.error-page a:hover { color: var(--gold-bright); border-bottom-color: var(--gold-bright); }

/* --- Section titles / footer ------------------------------------------------- */
.section-title {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    font-weight: 600;
}

.brand-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.68rem;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    padding: 1.5rem 1rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--border);
}

.brand-footer a { color: var(--gold); text-decoration: none; }
/* ==========================================================================
   Shop / ERP components
   ========================================================================== */

.shop-container { max-width: 1440px; }

.shop-nav { margin-bottom: 2rem; }
.shop-nav a { margin-right: 1.25rem; }
.shop-nav a:last-child { margin-right: 0; }

/* --- Storefront hero (black label style) ----------------------------------- */
.shop-hero {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 2rem;
    align-items: center;
    background:
        linear-gradient(115deg, transparent 55%, rgba(201, 162, 75, 0.07) 64%, rgba(224, 149, 45, 0.06) 70%, transparent 78%),
        var(--bg-base);
    border: 1px solid var(--border-strong);
    outline: 1px solid rgba(201, 162, 75, 0.22);
    outline-offset: -6px;
    border-radius: 4px;
    padding: 2.5rem;
    margin-bottom: 2.5rem;
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
}

.shop-hero h1 {
    font-size: 2.3rem;
    letter-spacing: 0.16em;
    margin-bottom: 0.75rem;
}

.shop-hero .hero-kicker {
    color: var(--gold);
    font-size: 0.72rem;
    letter-spacing: 0.34em;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.shop-hero p { color: var(--text-muted); max-width: 34rem; }

.shop-hero-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.6));
}

/* --- Range strip (the label family) ---------------------------------------- */
.range-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 3rem;
}

.range-card {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    text-align: center;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s;
}

.range-card:hover {
    border-color: var(--gold);
    transform: translateY(-3px);
}

.range-card img {
    width: 100%;
    height: auto;
    display: block;
}

.range-card .range-name {
    display: block;
    font-family: var(--font-serif);
    color: var(--gold-bright);
    font-size: 0.95rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.75rem 0.5rem 0.9rem;
}

/* --- Product grid (storefront) ----------------------------------------------- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.product-card {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    text-decoration: none;
    transition: border-color 0.2s, transform 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-3px);
}

.product-thumb {
    aspect-ratio: 1 / 1;
    flex: none;
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image::before {
    content: "No image";
    color: var(--text-dim);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

/* Cards in a grid row must line up line-by-line, so every card reserves the
   same slots: a category line, two name lines, the price, and a badge row.
   The bottom control row is always present too - a sold-out card gets an
   equal-height note where the quantity box and button would be. */
.product-card-link {
    display: flex;
    flex: 1;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.product-info {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 1rem;
}

.product-info h3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    min-height: 2.5em;       /* two lines reserved, however long the name is */
    margin-bottom: 0.5rem;
}

.product-cat {
    display: block;
    min-height: 1em;         /* reserved even for uncategorised products */
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 0.35rem;
}

.product-price {
    font-family: var(--font-serif);
    color: var(--amber);
    font-size: 1.15rem;
    margin-bottom: 0.6rem;
}

.product-badge-slot {
    display: flex;
    align-items: center;
    min-height: 1.5rem;      /* one badge row, occupied or not */
    margin-top: auto;
}

/* The bottom row. The control row and the sold-out note share one height. */
.product-add, .product-out {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
    align-items: center;
}

.product-add > *,
.product-out > span { height: 2.25rem; }

.product-add input[type=number] {
    width: 4.25rem;
    margin-bottom: 0;
    padding: 0 0.35rem;
    text-align: center;
    font-size: 0.85rem;
}

.product-add button {
    flex: 1;
    padding: 0 0.5rem;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
}

.product-out > span {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border);
    border-radius: 3px;
    color: var(--text-dim);
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.product-price-lg {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

/* --- Status badges ------------------------------------------------------------ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
}

.badge-gold {
    color: var(--gold-bright);
    border-color: var(--gold-deep);
    background: var(--amber-soft);
}

.badge-out, .badge-cancelled {
    color: #e8a3a3;
    border-color: rgba(196, 90, 90, 0.5);
    background: rgba(196, 90, 90, 0.1);
}

.badge-new, .badge-pending, .badge-draft { color: var(--text-muted); }

.badge-sent, .badge-confirmed {
    color: var(--gold-bright);
    border-color: var(--gold-deep);
}

.badge-shipping {
    color: var(--amber);
    border-color: rgba(224, 149, 45, 0.5);
    background: var(--amber-soft);
}

.badge-received, .badge-fulfilled {
    color: #b5d194;
    border-color: var(--success);
    background: rgba(143, 174, 106, 0.12);
}

/* --- Product detail layout ------------------------------------------------------ */
.product-detail {
    display: grid;
    grid-template-columns: minmax(220px, 340px) 1fr;
    gap: 2rem;
    align-items: start;
}

.product-detail-thumb {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 4px;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-detail-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stock-note {
    font-size: 0.78rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--gold);
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.back-link:hover { color: var(--gold-bright); }

/* --- Inline forms inside tables / rows ---------------------------------------- */
.inline-form { display: inline; }

.inline-form input[type="number"] {
    width: 4.5rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    color: var(--text);
}

.btn-link {
    background: none;
    border: none;
    color: var(--gold);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0;
    width: auto;
    box-shadow: none;
}

.btn-link:hover {
    color: var(--gold-bright);
    transform: none;
    box-shadow: none;
}

.btn-danger { color: #e8a3a3; }
.btn-danger:hover { color: #f2bcbc; }

.actions a {
    color: var(--gold);
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-right: 0.75rem;
}

.actions a:hover { color: var(--gold-bright); }

.actions form { display: inline; }

.erp-nav > div a { margin-right: 1rem; }
.erp-nav > div a:last-child { margin-right: 0; }

/* --- User management -------------------------------------------------------- */
.admin-grid {
    display: grid;
    grid-template-columns: minmax(240px, 0.75fr) minmax(320px, 1.25fr);
    gap: 2rem;
    align-items: start;
}

.admin-section {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.5rem;
}

.user-management-item {
    align-items: flex-start;
    gap: 0.85rem;
}

.user-login {
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 0.35rem;
}

.password-details {
    min-width: 145px;
    text-align: right;
}

.delete-user-form {
    margin-left: 0.5rem;
    align-self: center;
}

.delete-user-form .btn-danger {
    color: #e8a3a3;
    font-size: 0.7rem;
}

.password-details summary {
    color: var(--gold);
    cursor: pointer;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.password-details form {
    margin-top: 1rem;
    min-width: 210px;
    text-align: left;
}

.password-details input {
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.7rem;
    font-size: 0.9rem;
}

.password-details button {
    padding: 0.6rem 0.8rem;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
}

@media (min-width: 761px) {
    /* Horizontal padding only. This used to set the `padding` shorthand with
       three selector parts, which out-specified the banner's reserved
       padding-top and let page content slide up under the cream band. */
    .container:not(.login-container):not(.error-page) {
        --pad-x: clamp(2rem, 4vw, 5rem);
        padding-inline: var(--pad-x);
    }
}

@media (max-width: 760px) {
    .container { --pad-x: 1rem; --pad-y: 1.5rem; width: calc(100% - 1rem); padding: var(--pad-y) var(--pad-x); margin: 0.75rem auto; }
    .container:not(.shop-container) { --banner-h: 2.2rem; }
    .container:not(.shop-container)::before {
        font-size: 0.68rem;
        letter-spacing: 0.2em;
        text-indent: 0.2em;
    }
    .main-nav { align-items: flex-start; flex-direction: column; padding: 0.7rem 1rem; }
    .brand-header.shop-brand { flex-wrap: wrap; row-gap: 0.75rem; }
    .shop-search { margin-left: 0; flex-basis: 100%; }
    .shop-brand-text { flex: 1; }
    .main-nav-links { width: 100%; }
    .main-nav-signout { margin-left: 0; }
    .admin-grid { grid-template-columns: 1fr; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    h1 { font-size: clamp(1.35rem, 7vw, 2rem); letter-spacing: 0.08em; }
    h2 { font-size: 1.15rem; letter-spacing: 0.08em; }
    .nav, .shop-nav { align-items: flex-start; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.25rem; }
    .nav > span, .shop-nav > div { max-width: 100%; }
    .shop-brand-name { font-size: 0.95rem; }
    .shop-brand-tag { letter-spacing: 0.12em; }
    .shop-search button { min-width: 5rem; }
    button, .btn { min-height: 44px; padding: 0.7rem 1rem; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 0.75rem; }
    .product-info { padding: 0.75rem; }
    .product-info h3 { font-size: 0.9rem; letter-spacing: 0.05em; }
    .range-strip { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    .product-detail { grid-template-columns: 1fr; gap: 1rem; }
    .product-detail-thumb { max-width: 360px; width: 100%; margin: 0 auto; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .user-item { align-items: flex-start; flex-wrap: wrap; }
    .user-info { min-width: 0; }
    .table-scroll { margin-right: -1rem; margin-left: -1rem; padding: 0 1rem; }
    .erp-nav { align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
    .erp-nav > div { line-height: 2; }
    .user-management-item { flex-wrap: wrap; }
    .password-details { width: 100%; text-align: left; margin-left: 3.5rem; }
    .delete-user-form { margin-left: 3.5rem; }
}

@media (min-width: 761px) and (max-width: 1100px) {
    .container { --pad-y: 2rem; width: calc(100% - 2rem); padding: var(--pad-y) var(--pad-x); }
    .main-nav { padding-inline: 1rem; }
    .main-nav-links { gap: 0.6rem 0.75rem; }
    .staff-bar { padding-inline: 1rem; gap: 0.3rem 0.7rem; }
    .main-nav a:not(.main-nav-brand) { font-size: 0.65rem; }
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
    .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
    .container { width: 100%; border-left: 0; border-right: 0; border-radius: 0; }
    .container:not(.shop-container)::before { border-radius: 0; }
    .main-nav { border-left: 0; border-right: 0; }
    .staff-bar { border-left: 0; border-right: 0; justify-content: center; }
    .stats { grid-template-columns: 1fr; }
    .shop-search { flex-direction: column; }
    .shop-search button { width: 100%; }
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .range-strip { grid-template-columns: 1fr; }
}

/* --- Shop cart & checkout flow ------------------------------------------------ */
.shop-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.shop-steps a { color: var(--text-muted); text-decoration: none; }
.shop-steps a:hover { color: var(--gold-bright); }
.shop-steps .is-done { color: var(--text-dim); }
.shop-steps .is-current,
.shop-steps .is-current a { color: var(--gold-bright); }

.details-fieldset {
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 1.25rem 1.5rem 1.5rem;
    margin-bottom: 1.5rem;
}

.details-fieldset legend {
    padding: 0 0.6rem;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold);
}

.choice-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1.25rem; }
.choice { display: flex; align-items: center; }

.cart-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}
.cart-actions .btn, .cart-actions button { width: auto; }

.stock-note { display: block; color: var(--text-dim); font-size: 0.7rem; margin-top: 0.35rem; }

/* --- Maintenance notice (public shop) ----------------------------------------- */
.maintenance-panel {
    max-width: 720px;
    margin: 2.5rem auto;
    padding: 2.5rem 2rem;
    text-align: center;
}

.maintenance-panel h1 { margin-bottom: 1.25rem; }

.maintenance-message {
    white-space: pre-line;
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.7;
}

.maintenance-contact {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.maintenance-contact a { color: var(--gold); }

@media (max-width: 760px) {
    .maintenance-panel { margin: 1.5rem auto; padding: 1.75rem 1.25rem; }
}

/* --- Settings: grouped sections with a section navigator --------------------- */
.settings-side {
    position: sticky;
    top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-nav { display: flex; flex-direction: column; gap: 0.15rem; padding: 1rem; }
.settings-nav h2 {
    margin: 0 0 0.5rem;
    font-size: 0.66rem;
    letter-spacing: 0.22em;
    color: var(--text-dim);
}

.settings-link {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    border-left: 2px solid transparent;
    border-radius: 3px;
    box-shadow: none;
    padding: 0.55rem 0.7rem;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    transform: none;
    transition: background-color 0.15s, color 0.15s;
}
.settings-link:hover {
    background: var(--bg-input);
    color: var(--text);
    box-shadow: none;
    transform: none;
}
.settings-link.active {
    background: var(--bg-input);
    border-left-color: var(--gold);
    color: var(--gold-bright);
}

.settings-save { font-size: 0.74rem; letter-spacing: 0.14em; }
.settings-side .settings-help { padding: 0 0.15rem; }

.settings-panels { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.settings-section h2 { margin-bottom: 1rem; }
.settings-section.settings-hidden { display: none; }
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}
.toggle-row input[type="checkbox"] { width: auto; margin: 0; }
.toggle-row span {
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.95rem;
    color: var(--text);
}

/* Mail agent: reveal the saved app password on demand */
.password-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.password-row input { flex: 1 1 auto; margin-bottom: 0; }
.settings-reveal {
    width: auto;
    flex: 0 0 auto;
    padding: 0.7rem 0.9rem;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    white-space: nowrap;
    box-shadow: none;
}
.saved-secret {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.7rem;
    background: var(--bg-input);
    border: 1px dashed var(--border-strong);
    border-radius: 4px;
    color: var(--gold-bright);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    word-break: break-all;
}

@media (max-width: 900px) {
    .settings-layout { grid-template-columns: 1fr; }
    .settings-side { position: static; }
    .settings-nav { flex-direction: row; flex-wrap: wrap; }
    .settings-nav h2 { display: none; }
    .settings-link { width: auto; border-left: 0; }
    .settings-save { width: 100%; }
}

/* --- Purchase order lines: the per-line "Stock" flag -------------------------- */
.po-line {
    display: grid;
    grid-template-columns: auto minmax(9rem, 2fr) minmax(8rem, 1.3fr) 5rem 8rem 7rem;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
}

.po-line input,
.po-line select {
    width: 100%;
    margin-bottom: 0;
    padding: 0.6rem;
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.9rem;
}

.po-line .po-flag {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
}

.po-line .po-flag input { width: auto; margin: 0; padding: 0; }

/* "Track as stock" action on an unlinked purchase line */
.flag-stock {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.6rem;
}

.flag-stock input {
    width: auto;
    margin-bottom: 0;
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
}

.flag-stock button {
    width: auto;
    padding: 0.5rem 0.8rem;
    font-size: 0.6rem;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .po-line { grid-template-columns: 1fr 1fr; }
    .po-line .po-flag { grid-column: 1 / -1; }
}

/* --- In-app help: floating Help link + slide-in drawer ----------------------- */
.help-toggle {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    width: auto;
    padding: 0.6rem 0.95rem;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
}
.help-toggle-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    background: var(--gold);
    color: var(--bg-deep);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
}
.help-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(0, 0, 0, 0.55);
}
.help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 71;
    display: flex;
    flex-direction: column;
    width: min(28rem, 92vw);
    height: 100%;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-strong);
    box-shadow: -14px 0 44px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    transition: transform 0.2s ease;
}
.help-drawer.open { transform: translateX(0); }
.help-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.help-drawer-head h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.06em;
    color: var(--gold-bright);
}
.help-close {
    width: auto;
    padding: 0.15rem 0.55rem;
    background: none;
    border: 0;
    box-shadow: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
}
.help-close:hover {
    color: var(--gold-bright);
    box-shadow: none;
    transform: none;
}
.help-drawer-body {
    overflow-y: auto;
    padding: 1.25rem;
    color: var(--text);
}
.help-intro {
    margin-bottom: 1rem;
    color: var(--text-muted);
    line-height: 1.6;
}
.help-points {
    margin: 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.help-points li { line-height: 1.55; color: var(--text); }
.help-link { margin: 0; }
.help-link a { color: var(--gold-bright); font-weight: 600; }

/* --- Security setup guide (templates/help/security.html) --------------------- */
.guide h2 { margin-top: 1.8rem; }
.guide pre {
    background: var(--bg-deep);
    color: #f3e9d2;
    border: 1px solid rgba(212, 164, 62, 0.25);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin: 0.75rem 0;
    overflow-x: auto;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.85rem;
    line-height: 1.55;
}
.guide code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9em;
    background: rgba(212, 164, 62, 0.12);
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
}
.guide pre code { background: transparent; padding: 0; }
.guide ol { padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; }
.guide ul { padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; }
.guide-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0 1rem;
    font-size: 0.9rem;
}
.guide-table th, .guide-table td {
    text-align: left;
    border: 1px solid rgba(212, 164, 62, 0.22);
    padding: 0.5rem 0.7rem;
    vertical-align: top;
}
.guide-table th { background: rgba(212, 164, 62, 0.1); }

/* --- Orders: shipping details + status controls ------------------------------ */
.track-link {
    color: var(--gold-bright);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 1px solid transparent;
}
.track-link:hover { border-bottom-color: var(--gold-bright); }

.shipping-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 1rem;
    align-items: end;
    margin-top: 1rem;
}
.shipping-form input { margin-bottom: 0; }
.shipping-form button { width: auto; margin-bottom: 0; }

.status-form {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}
.status-form select { width: auto; margin-bottom: 0; }
.status-form button { width: auto; margin-bottom: 0; }

.order-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}
.order-quick-actions form { margin: 0; }
.order-quick-actions button { width: auto; }

@media (max-width: 720px) {
    .shipping-form { grid-template-columns: 1fr; }
}

/* Order editing: one row per line item */
.order-line {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) 6rem 8rem auto;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.75rem;
}
.order-line select,
.order-line input { margin-bottom: 0; }
.order-line .order-line-remove { width: auto; font-size: 0.65rem; }

@media (max-width: 720px) {
    .order-line { grid-template-columns: 1fr 1fr; }
    .order-line select { grid-column: 1 / -1; }
}

/* Order lines: link each to the production batch it was fulfilled from */
.batch-cell { min-width: 13rem; }
.text-dim { color: var(--text-dim); font-size: 0.85rem; }
.batch-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.45rem;
}
.batch-form select {
    width: auto;
    margin-bottom: 0;
    padding: 0.4rem 0.5rem;
    font-size: 0.8rem;
}
.batch-form button {
    width: auto;
    padding: 0.45rem 0.6rem;
    font-size: 0.58rem;
}

/* --- Bulk selection (multi-select list pages) ----------------------------------
   One .bulk-form per list page owns the ticked rows; row checkboxes and the
   table's master checkbox join it via the HTML form="<id>" attribute, so the
   per-row delete forms inside a table never end up nested. */
.bulk-form { margin: 0; }

.bulk-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 3px;
}

.bulk-bar .bulk-count {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}

.bulk-bar .bulk-spacer { margin-left: auto; }

/* Bar buttons are deliberately smaller than the page actions. */
.bulk-bar button {
    width: auto;
    padding: 0.45rem 0.9rem;
    margin: 0;
    font-size: 0.7rem;
}

.bulk-bar .btn-link { padding: 0; }

.bulk-check { width: 1%; white-space: nowrap; }

.bulk-check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    min-width: 1rem;
    margin: 0;
    padding: 0;
    vertical-align: middle;
    accent-color: var(--gold);
    cursor: pointer;
}

tr.bulk-selected td { background: rgba(201, 162, 75, 0.12); }

.btn.btn-danger-outline {
    background: transparent;
    color: #e8a3a3;
    border: 1px solid var(--danger);
    box-shadow: none;
}

.btn.btn-danger-outline:hover {
    background: rgba(196, 90, 90, 0.18);
    color: #f2bcbc;
    box-shadow: none;
}

button:disabled, .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 720px) {
    .bulk-bar .bulk-spacer { display: none; }
}
