:root {
    --red: #ef4035;        /* Lard Oil logo red */
    --blue: #0055a5;       /* Lard Oil logo blue */
    --bg: #f4f6f9;
    --surface: #ffffff;
    --text: #1c2430;
    --muted: #667085;
    --border: #d9dee7;
    --primary: #0055a5;
    --primary-text: #ffffff;
    --ok-bg: #e6f4ea;
    --ok-text: #14532d;
    --err-bg: #fdecec;
    --err-text: #8a1c1c;
    --warn-bg: #fff4d6;
    --warn-text: #7a5200;
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12161d;
        --surface: #1b212b;
        --text: #e6e9ef;
        --muted: #9aa4b2;
        --border: #2f3846;
        --primary: #6ea0ff;
        --primary-text: #0b1220;
        --ok-bg: #12301f;
        --ok-text: #9be3b3;
        --err-bg: #3a1717;
        --err-text: #ffb4b4;
        --warn-bg: #3b2f10;
        --warn-text: #ffd98a;
    }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; }
h2 { font-size: 1.2rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); font-size: .85rem; }
.red { color: var(--red); }

/* ---- top bar ---------------------------------------------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .6rem 1rem;
    background: var(--surface);
    border-bottom: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; white-space: nowrap; }
.brand img { height: 34px; width: auto; display: block; }
.brand-sub { color: var(--muted); font-weight: 600; font-size: .95rem; padding-left: .75rem; border-left: 2px solid var(--border); }
@media (max-width: 480px) { .brand img { height: 28px; } .brand-sub { display: none; } }
/* The logo's dark-blue letters need a light background in dark mode. */
@media (prefers-color-scheme: dark) { .brand img, .auth-logo { background: #fff; padding: 4px 8px; border-radius: 6px; } }
.auth-logo { display: block; height: 52px; width: auto; max-width: 100%; margin: 0 auto 1rem; }

.nav { display: flex; align-items: center; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { padding: .45rem .7rem; border-radius: 8px; text-decoration: none; color: var(--text); }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--primary); color: var(--primary-text); }
.nav-spacer { flex: 1; }
.nav-user { font-weight: 600; }

.nav-toggle { display: none; }
.nav-burger { display: none; margin-left: auto; cursor: pointer; padding: .5rem; }
.nav-burger span { display: block; width: 24px; height: 3px; margin: 4px 0; background: var(--text); border-radius: 2px; }

@media (max-width: 760px) {
    .nav-burger { display: block; }
    .nav { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; }
    .nav-toggle:checked ~ .nav { display: flex; }
    .nav a { padding: .7rem .6rem; }
    .nav-spacer { display: none; }
}

/* ---- layout ------------------------------------------------------------------------------------------------ */
.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 560px; margin: 1.5rem auto; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1.5rem 1rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1rem;
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }

/* ---- forms ------------------------------------------------------------------------------------------------- */
.field { margin-bottom: .9rem; display: flex; flex-direction: column; gap: .25rem; }
.field label { font-weight: 600; font-size: .92rem; }
.field.check { flex-direction: row; align-items: center; gap: .5rem; }
.field.check label { font-weight: 400; }

/* One look for every text-like control (an untyped <input> is a text box too). */
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=submit]):not([type=button]):not([type=range]),
select, textarea {
    width: 100%;
    min-height: 2.6rem;
    padding: .55rem .7rem;
    font: inherit;
    line-height: 1.3;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    -webkit-appearance: none;
    appearance: none;
}
textarea { min-height: 4.5rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type=date] { color-scheme: light dark; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }

/* Drop-downs: our own arrow so they match the text boxes in every browser. */
select:not([size]), select[size="1"] {
    padding-right: 2.2rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 1.15rem) 50%, calc(100% - .8rem) 50%;
    background-size: .35rem .35rem, .35rem .35rem;
    background-repeat: no-repeat;
}
/* Lists (select with several rows visible) */
select[size]:not([size="1"]) { padding: .25rem; }
select[size]:not([size="1"]) option { padding: .35rem .5rem; border-radius: 6px; }

input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
input[readonly] { background-color: var(--bg); }
input[type=checkbox], input[type=radio] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); }

/* Blazor validation state */
input.invalid, select.invalid, textarea.invalid { border-color: var(--red) !important; outline-color: var(--red); }

/* File picker */
input[type=file] { width: 100%; font: inherit; color: var(--text); padding: .4rem; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface); }
input[type=file]::file-selector-button {
    font: inherit; font-weight: 600; margin-right: .75rem; padding: .45rem .9rem;
    color: var(--primary-text); background: var(--primary); border: 0; border-radius: 8px; cursor: pointer;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 1rem; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; align-items: end; margin-bottom: 1rem; }
.filters .field { margin: 0; }

.actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }

.btn {
    display: inline-block;
    padding: .6rem 1.1rem;
    font: inherit; font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }

/* ---- messages ---------------------------------------------------------------------------------------------- */
.alert { padding: .65rem .9rem; border-radius: 8px; margin: .6rem 0; }
.alert-error { background: var(--err-bg); color: var(--err-text); }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-info { background: var(--warn-bg); color: var(--warn-text); }
.validation-message { color: var(--err-text); font-size: .85rem; }
ul.validation-errors, .validation-errors { margin: 0; padding-left: 1.2rem; }

/* ---- tables ------------------------------------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
table.data th.num, table.data td.num { text-align: right; }
table.data tfoot th { color: var(--text); font-size: .95rem; text-transform: none; border-top: 2px solid var(--border); }
table.data tbody tr:hover { background: var(--bg); }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-pending { background: var(--warn-bg); color: var(--warn-text); }
.badge-done { background: var(--ok-bg); color: var(--ok-text); }

.pager { display: flex; justify-content: center; gap: 1rem; margin: 1rem 0; flex-wrap: wrap; }

/* ---- stat tiles -------------------------------------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: var(--text); }
.tile .big { font-size: 1.8rem; font-weight: 700; }
.tile.on { border-color: var(--primary); outline: 2px solid var(--primary); }

/* ---- order summary ----------------------------------------------------------------------------------------- */
.summary-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem 1.2rem; margin: .5rem 0 1rem; }
dl.facts dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---- order form -------------------------------------------------------------------------------------------- */
.product-list { display: grid; gap: .5rem; }
.product-row { display: grid; grid-template-columns: 1fr 9rem; gap: .75rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.product-row .gal { display: flex; align-items: center; gap: .4rem; }
.product-row input { text-align: right; }
@media (max-width: 480px) { .product-row { grid-template-columns: 1fr 7rem; } }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .5rem; }
.slot { display: flex; align-items: center; gap: .55rem; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.slot:has(input:checked) { border-color: var(--primary); background: var(--bg); outline: 1px solid var(--primary); }
.slot.disabled { opacity: .45; cursor: not-allowed; }
.slot-group h3 { font-size: .9rem; margin: .8rem 0 .4rem; color: var(--muted); }

/* ---- day list / print -------------------------------------------------------------------------------------- */
.slot-section { margin-bottom: 1.2rem; break-inside: avoid; }
.slot-section h2 { background: var(--bg); padding: .4rem .6rem; border-radius: 6px; }
.day-order { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; margin-bottom: .6rem; break-inside: avoid; }
.day-order .lines { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; margin: .3rem 0; }

@media print {
    body { background: #fff; color: #000; font-size: 11pt; }
    .no-print { display: none !important; }
    .container { max-width: none; padding: 0; }
    .card, .day-order { border-color: #999; }
    a { color: #000; text-decoration: none; }
}

#blazor-error-ui { background: #ffffe0; color: #000; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .reload { margin-left: 8px; }

/* ---- login ------------------------------------------------------------------------------------------------- */
.auth-title { font-size: 1.25rem; text-align: center; margin-bottom: 1.1rem; }
.auth-card .actions { flex-direction: column; align-items: stretch; gap: .8rem; text-align: center; }
.auth-card .btn-primary { width: 100%; padding: .7rem 1.1rem; }

/* Ordering-hours notice: the heading and anything bold are shown in the Lard Oil red. */
.notice h2, .notice strong, .notice b { color: var(--red); }

/* Dispatcher new-order alerts */
.alert-toggle { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 999px; padding: .3rem .8rem; font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.alert-toggle::before { content: ""; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); }
.alert-toggle:hover { background: var(--bg); }
.alert-toggle.on { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-text); }
.alert-toggle.on::before { background: #1a9c4b; box-shadow: 0 0 0 3px rgba(26,156,75,.25); }
@media (max-width: 760px) { .alert-toggle { align-self: flex-start; margin: .3rem .6rem; } }
#order-alert-banner { position: fixed; top: 4.5rem; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; max-width: min(24rem, calc(100vw - 2rem)); }
#order-alert-banner .order-toast { background: var(--surface); border: 2px solid var(--red); border-left-width: 8px; border-radius: 10px; padding: .7rem .9rem; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#order-alert-banner .order-toast strong { color: var(--red); }
#order-alert-banner .order-toast a { font-weight: 600; margin-right: .75rem; }

/* Order history entries (click to see the order at that point) */
.hist-item { border-bottom: 1px solid var(--border); padding: .5rem 0; }
.hist-item > summary { cursor: pointer; }
.hist-item .hist-body { margin: .6rem 0 .3rem 1rem; padding: .7rem .9rem; background: var(--bg); border-radius: 8px; }

/* Account requests */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.notice-requests { border-left: 6px solid var(--blue); }
