/* Winery Manager, server edition. Phone first; wider screens get more columns. Colours are tokens, with their own
   dark-mode values.

   Look (2026-11-21): a deep cellar-navy bar over a cool, light workspace; one green for every action; wine red only
   where wine is (vessel fill gauges), so the colour means something. Manrope (SIL OFL, fonts/OFL.txt) is bundled, so
   pages never wait on an outside font server. */
@font-face {
    font-family: "Manrope";
    src: url("fonts/manrope-latin.woff2") format("woff2");
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --cellar: #10273a;      /* the bar and the sign-in backdrop */
    --cellar-ink: #e9f0f5;
    --cellar-muted: #9fb3c3;
    --bg: #f2f5f7;
    --surface: #ffffff;
    --ink: #13222e;
    --ink-2: #44566a;
    --muted: #677a89;
    --line: #d8e0e6;
    --accent: #1d7f5f;      /* actions: buttons, links, the current page */
    --accent-hover: #166a4e;
    --accent-ink: #ffffff;
    --accent-soft: #e3f2ec;
    --wine: #8e1f3f;        /* wine in a vessel */
    --overdue-bg: #fbe9e7;
    --overdue-ink: #a3301f;
    --soon-bg: #fff3d9;
    --soon-ink: #7a5300;
    --info-bg: #e6eff7;
    --info-ink: #1f4f7a;
    --focus: #2f7fd0;
    --radius: 10px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --cellar: #08141e;
        --cellar-ink: #e3ebf1;
        --cellar-muted: #8ea3b4;
        --bg: #0e1b25;
        --surface: #152633;
        --ink: #e6edf2;
        --ink-2: #b7c5d0;
        --muted: #8b9dab;
        --line: #26394a;
        --accent: #4cc39a;
        --accent-hover: #6fd3ae;
        --accent-ink: #062117;
        --accent-soft: #163a2f;
        --wine: #d2607f;
        --overdue-bg: #3d1c18;
        --overdue-ink: #f4a597;
        --soon-bg: #372a10;
        --soon-ink: #f1c868;
        --info-bg: #162b3e;
        --info-ink: #9cc6ec;
        --focus: #7fb7ee;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 1.65rem; line-height: 1.2; font-weight: 800; letter-spacing: -0.015em; margin: 0.75rem 0 1rem; }
h2 { font-size: 1.15rem; line-height: 1.3; font-weight: 700; margin: 1.75rem 0 0.6rem; }
p { max-width: 70ch; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1:focus { outline: none; } /* focused after each page change so screen readers start at the title */

/* ---- shell ---- */
.bar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 1.25rem;
    padding: 0 1rem;
    background: var(--cellar);
    color: var(--cellar-ink);
}
.brand {
    padding: 0.8rem 0;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--cellar-ink);
    text-decoration: none;
}
.bar .brand:hover { color: #fff; }
.nav { display: flex; gap: 0.25rem; order: 3; width: 100%; overflow-x: auto; margin: 0 -0.5rem; }
.nav a {
    padding: 0.7rem 0.75rem 0.6rem;
    border-bottom: 3px solid transparent;
    color: var(--cellar-muted);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}
.nav a:hover { color: var(--cellar-ink); }
.nav a.active { color: var(--cellar-ink); border-bottom-color: var(--accent); }
.who { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.who .muted { color: var(--cellar-muted); }
.who button.link { color: var(--cellar-ink); }
.page { padding: 0.75rem 1rem 3rem; max-width: 1100px; margin: 0 auto; }

@media (min-width: 720px) {
    .bar { flex-wrap: nowrap; padding: 0 1.5rem; }
    .nav { order: 0; width: auto; margin: 0; align-self: stretch; }
    .nav a { display: flex; align-items: center; padding: 0 0.85rem; }
    .page { padding: 1.25rem 1.5rem 3rem; }
}

/* ---- forms ---- */
label { display: block; margin: 0 0 1rem; color: var(--ink-2); font-size: 0.9rem; font-weight: 600; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 500;
    min-height: 44px;
}
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input.code { font-size: 1.5rem; font-weight: 700; letter-spacing: 0.25em; text-align: center; }
button {
    min-height: 44px;
    padding: 0.5rem 1.25rem;
    border: 1.5px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
}
button:hover { border-color: var(--ink-2); }
button.primary { width: 100%; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.link { min-height: 0; padding: 0.25rem; border: 0; border-radius: 4px; background: none; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 0.15em; }
.error {
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    background: var(--overdue-bg);
    color: var(--overdue-ink);
    font-weight: 600;
}

/* ---- sign-in: the card on the cellar backdrop ---- */
.signin {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 12vh 1rem 2rem;
    background: var(--cellar);
}
.signin .card {
    width: 100%;
    max-width: 420px;
    padding: 1.75rem 1.5rem;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(3, 12, 20, 0.35);
}
.signin .card h1 { margin-top: 0.25rem; }
.signin .brand { padding: 0; color: var(--accent); margin: 0; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: 1rem; }
.qr { background: #fff; padding: 8px; border-radius: 8px; width: fit-content; }
.qr svg { display: block; width: 260px; max-width: 70vw; height: auto; aspect-ratio: 1; }
.key { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; word-spacing: 0.3em; }

/* ---- figures ---- */
.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
@media (min-width: 720px) { .figures { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.figure { padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.figure .label { color: var(--ink-2); font-size: 0.85rem; font-weight: 600; }
.figure .value { margin-top: 0.15rem; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* ---- notices ---- */
.notices { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.notice {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    align-items: baseline;
    padding: 0.7rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 8px;
}
.notice .tag { font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; }
.notice .area { font-weight: 700; }
.notice .text { flex: 1 1 14rem; }
.notice.overdue { border-left-color: var(--overdue-ink); }
.notice.overdue .tag { background: var(--overdue-bg); color: var(--overdue-ink); }
.notice.soon { border-left-color: var(--soon-ink); }
.notice.soon .tag { background: var(--soon-bg); color: var(--soon-ink); }
.notice.info { border-left-color: var(--info-ink); }
.notice.info .tag { background: var(--info-bg); color: var(--info-ink); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-size: 0.8rem; font-weight: 700; white-space: nowrap; background: var(--bg); }
tbody tr:hover td { background: var(--accent-soft); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.undone td { color: var(--muted); text-decoration: line-through; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0; }
.facts dt { color: var(--ink-2); font-weight: 600; }
.facts dd { margin: 0; }

/* ---- vessels ---- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.filters input { grid-column: 1 / -1; }
.filters input, .filters select { margin: 0; }
.filters button { grid-column: 1 / -1; }
@media (min-width: 720px) {
    .filters { grid-template-columns: 2fr 1fr 1fr auto; }
    .filters input, .filters button { grid-column: auto; }
}
.vessels { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.65rem; }
.vessel {
    display: block;
    padding: 0.75rem 0.85rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
}
.vessel:hover { color: var(--ink); border-color: var(--accent); }
.vessel.attention { border-color: var(--soon-ink); }
.vessel .row { display: flex; justify-content: space-between; align-items: baseline; }
.vessel b { font-weight: 800; }
.vessel .alert { color: var(--soon-ink); font-weight: 600; }
/* How full a vessel is, in the colour of wine. */
.fill { height: 10px; margin: 0.5rem 0; background: var(--line); border-radius: 999px; overflow: hidden; }
.fill span { display: block; height: 100%; background: var(--wine); border-radius: 999px; }

/* ---- cellar work ---- */
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin: 0 0 1.25rem; }
@media (min-width: 720px) { .actions { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }
.actions a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0.5rem;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
    text-align: center;
}
.actions a:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.work { max-width: 560px; }
.work > button:not(.primary):not(.default-submit) { margin: 0 0 1rem; }
.work .primary { margin-top: 0.5rem; }
fieldset.line { margin: 0 0 1rem; padding: 0.85rem 1rem 0.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
fieldset.line legend { padding: 0 0.35rem; color: var(--ink-2); font-size: 0.85rem; font-weight: 700; }
fieldset.line .link { margin: 0 0 0.6rem; }
label.check { display: flex; gap: 0.6rem; align-items: center; min-height: 44px; color: var(--ink); font-size: 1rem; font-weight: 500; }
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }
.ticks { max-height: 22rem; overflow-y: auto; }
.tests { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.75rem; }
@media (min-width: 720px) { .tests { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.buttons .primary { width: auto; margin: 0; }
/* The first button in a form, so Enter saves; kept out of sight and out of the tab order. */
.default-submit { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }
.flash { margin: 0.5rem 0 1rem; padding: 0.7rem 0.9rem; border-radius: 8px; background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--accent); font-weight: 600; }
.flash.warn { background: var(--soon-bg); color: var(--soon-ink); border-left-color: var(--soon-ink); }
.flash p { margin: 0.15rem 0; }
.orders { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
.order { padding: 0.7rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.order .row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 0.75rem; align-items: baseline; }
.order.undone { color: var(--muted); }
.order.undone b { text-decoration: line-through; }

@media (prefers-reduced-motion: no-preference) {
    a, button, input, select, textarea, .vessel, .actions a { transition: background-color 0.12s, border-color 0.12s, color 0.12s; }
}
