html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Clickable table rows — used on Batches, Ingredients list pages */
tr.row-link {
    cursor: pointer;
}

.card-hover {
    transition: box-shadow 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
    cursor: pointer;
}

.card-hover:hover {
    background-color: rgba(13, 110, 253, 0.04);
    box-shadow: 0 0.3rem 0.9rem rgba(0,0,0,.15) !important;
    transform: translateY(-2px);
}

/* Tappable list card — the mobile stand-in for a data-table row. Shared across list pages;
   pair with `d-md-none` (cards) and `d-none d-md-block` (the table) to swap by breakpoint. */
.list-card {
    display: block;
    width: 100%;
    text-align: left;
    padding: .7rem .85rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .65rem;
    background: var(--bs-card-bg, var(--bs-body-bg));
    cursor: pointer;
    transition: background-color .1s ease;
}

    .list-card:active {
        background: var(--bs-secondary-bg);
    }

/* Circular user avatar (image or initials-on-colour). Size/colour come from inline styles. */
.user-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    color: #fff;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
    vertical-align: middle;
    user-select: none;
}

    .user-avatar img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

/* Account switcher dropdown (avatar menu in the top bar / app bar) */
.switch-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

.user-switch-menu {
    position: absolute;
    right: 0;
    top: calc(100% + .4rem);
    z-index: 1041;
    min-width: 12.5rem;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .6rem;
    overflow: hidden;
    padding-bottom: .25rem;
}

.usm-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    padding: .5rem .75rem;
    border: 0;
    background: none;
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: .9rem;
    text-align: left;
}

    .usm-item:hover {
        background: var(--bs-secondary-bg);
    }

.usm-icon {
    width: 28px;
    text-align: center;
    font-size: 1.1rem;
}

.min-w-0 {
    min-width: 0;
}

/* Owner avatar badge in a card corner; the name reveals on hover (desktop) or tap-focus (mobile). */
.owner-badge {
    position: absolute;
    bottom: .5rem;
    right: .5rem;
    z-index: 3;
    outline: none;
    cursor: default;
}

    .owner-badge .user-avatar {
        box-shadow: 0 0 0 2px var(--bs-card-bg, var(--bs-body-bg));
    }

.owner-badge-name {
    position: absolute;
    right: 0;
    bottom: calc(100% + 5px);
    z-index: 4;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--bs-emphasis-color);
    color: var(--bs-body-bg);
    font-size: .72rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease;
}

    .owner-badge:hover .owner-badge-name,
    .owner-badge:focus .owner-badge-name,
    .owner-badge:focus-within .owner-badge-name {
        opacity: 1;
    }

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--bs-link-color);
}

/* Primary buttons are left to Bootstrap so themes can recolour them via --bs-btn-* vars. */

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

.battery-bar {
    display: inline-block;
    width: 34px;
    height: 12px;
    border: 1px solid var(--bs-border-color, #ced4da);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

    /* The nub on the end of a battery symbol. */
    .battery-bar::after {
        content: "";
        position: absolute;
        right: -3px;
        top: 3px;
        width: 2px;
        height: 6px;
        background: var(--bs-border-color, #ced4da);
    }

.battery-bar-fill {
    display: block;
    height: 100%;
}

#blazor-error-ui,
#app-update-ui {
    color-scheme: light only;
    background: lightyellow;
    /* Fixed light background, so fixed dark text — inheriting the theme's text color made it
       near-white on yellow in dark themes. */
    color: #212529;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui a,
    #app-update-ui a {
        color: #0a58ca;
        font-weight: 600;
    }

    #app-update-ui {
        display: block;
        background: #e7f1ff;
    }

    #app-update-ui[hidden] {
        display: none;
    }

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* Loading screen — a little mead bottle that fills with amber as the app loads. Blazor sets
   --blazor-load-percentage (e.g. "42%") during startup; the fill gradient's stop reads it. */
.loading-bottle {
    position: absolute;
    inset: 18vh 0 auto 0;
    margin: 0 auto;
    width: 5.5rem;
    height: 10rem;
    /* Wine/mead-bottle silhouette: long neck, sloped shoulders, straight body. */
    --bottle: polygon(
        40% 6%, 60% 6%, 60% 26%,
        80% 36%, 86% 46%, 86% 94%, 82% 100%,
        18% 100%, 14% 94%, 14% 46%, 20% 36%, 40% 26%);
}

    .loading-bottle-glass,
    .loading-bottle-fill,
    .loading-bottle-shine {
        position: absolute;
        inset: 0;
        clip-path: var(--bottle);
    }

    /* Empty bottle — a faint amber-tinted glass silhouette. */
    .loading-bottle-glass {
        background: rgba(230, 184, 92, 0.16);
    }

    /* The mead: an amber gradient filled from the bottom up to the load percentage, transparent
       above the surface so the empty glass shows through. */
    .loading-bottle-fill {
        background: linear-gradient(to top,
            #cf8420 0%,
            #f0c85f var(--blazor-load-percentage, 0%),
            transparent var(--blazor-load-percentage, 0%));
    }

    /* Soft glass highlight down the left edge. */
    .loading-bottle-shine {
        background: linear-gradient(to right, rgba(255, 255, 255, 0.28) 0 12%, transparent 20%);
        pointer-events: none;
    }

    /* Cork plugging the neck. */
    .loading-bottle-cork {
        position: absolute;
        top: 0;
        left: 41%;
        width: 18%;
        height: 7%;
        background: linear-gradient(to bottom, #b07a43, #895f31);
        border-radius: 3px 3px 2px 2px;
    }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: var(--bs-body-color, #333);
    inset: calc(18vh + 10.75rem) 0 auto 0;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: var(--bs-code-color, #c02d76);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* --- Vessel QR label (Containers → Print label) ---
   Sized in physical units because these exist to come out of a printer: 1.5in square-ish, so a
   sheet tiles several across. On screen that renders at the CSS 96px/in, which is a true preview.
   The outline is a dashed cut line, not a border — it marks where to cut and shouldn't read as
   part of the label, so it stays square-cornered and light. */
.vessel-label {
    width: 1.5in;
    box-sizing: border-box;
    border: 1px dashed #bbb;
    padding: 6pt 5pt;
    text-align: center;
    background: #fff;
}

.vessel-label-name {
    font-size: 8.5pt;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4pt;
    word-break: break-word;
}

.vessel-label-qr svg {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.vessel-label-meta {
    margin-top: 4pt;
    color: #444;
    font-size: 6.5pt;
}

.vessel-label-brand {
    margin-top: 1pt;
    font-size: 4.5pt;
    letter-spacing: .15em;
    text-transform: uppercase;
    color: #aaa;
}

/* Print only the label — hide app chrome and any .no-print content. */
/* Printed matter that has no business on screen — the QR labels a page can print. Paired with
   .no-print, which hides everything else when printing. */
.print-only {
    display: none;
}

@media print {
    .sidebar, .top-row, .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .page, main, .content {
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
    }

    body {
        background: #fff !important;
    }

    .vessel-label {
        border-color: #999;
        margin: 0 auto;
        page-break-inside: avoid;
    }

    .recipe-panel, .recipe-panel-backdrop {
        display: none !important;
    }
}

/* Batch label sheet — multiple container labels tiled for printing. */
.label-sheet {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

@media print {
    .label-sheet {
        gap: .12in;
    }
    /* Tile left-to-right on the sheet instead of centering each label. */
    .label-sheet .vessel-label {
        margin: 0;
    }
}

/* --- Slide-in recipe-prescription panel (batch detail) — rendered only when open --- */
.recipe-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(420px, 92vw);
    background: var(--bs-body-bg);
    border-left: 1px solid var(--bs-border-color);
    box-shadow: -0.3rem 0 0.9rem rgba(0, 0, 0, .15);
    overflow-y: auto;
    z-index: 1050;
    padding: 1rem;
    animation: rp-slide-in .2s ease;
}

@keyframes rp-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.recipe-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .25);
    z-index: 1040;
}

.checklist-done {
    opacity: .55;
    text-decoration: line-through;
}

.checklist-upcoming {
    background: var(--bs-warning-bg-subtle);
    border-left: 3px solid var(--bs-warning-border-subtle);
}

/* Container QR scanner overlay (batch creation) */
.qr-scan-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.qr-scan-box {
    background: var(--bs-body-bg, #fff);
    color: var(--bs-body-color, #212529);
    border-radius: .5rem;
    padding: 1rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.qr-scan-video {
    width: 100%;
    max-height: 60vh;
    border-radius: .375rem;
    background: #000;
    object-fit: cover;
}

/* --- Generic mobile bottom sheet (pair .sheet-backdrop + .bottom-sheet, toggled by page state) --- */
.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1085;
    background: rgba(0, 0, 0, .4);
    animation: sheet-fade .15s ease;
}

.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1090;
    background: var(--bs-body-bg);
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    padding: .5rem 1rem calc(env(safe-area-inset-bottom) + 1rem);
    box-shadow: 0 -0.5rem 1.5rem rgba(0, 0, 0, .25);
    animation: sheet-slide .2s ease;
}

.sheet-grabber {
    width: 2.5rem;
    height: .25rem;
    border-radius: 1rem;
    background: var(--bs-border-color);
    margin: .25rem auto .75rem;
}

.sheet-title {
    font-weight: 600;
    text-align: center;
    margin-bottom: .75rem;
}

@keyframes sheet-slide {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

@keyframes sheet-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Contextual mobile action bar — sits just above the fixed bottom tab bar --- */
.mobile-actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(3.5rem + env(safe-area-inset-bottom));
    z-index: 1025;
    display: flex;
    gap: .5rem;
    padding: .5rem .75rem;
    background: var(--brew-topbar-bg);
    border-top: 1px solid var(--brew-topbar-border);
}

@media (min-width: 768px) {
    .mobile-actionbar {
        display: none;
    }
}

/* ============================================================
   Themes
   ------------------------------------------------------------
   "light" and "dark" are Bootstrap's built-in modes, selected
   via the data-bs-theme attribute the loader sets. Extra themes
   layer CSS-variable overrides on top of a light or dark base.

   To add a theme:
     1. Add an entry to Helpers/ThemeCatalog.cs (key, name, base).
     2. Add a :root[data-theme="<key>"] block below overriding the
        Bootstrap variables you want to change.
   Nothing else (JS loader, server, DTOs, Profile UI) changes.
   ============================================================ */

/* Fixes that apply to every dark-based theme (dark, monokai, …):
   Bootstrap's .table-light is a fixed light tint that otherwise
   leaves a glaring light header on dark pages. */
:root[data-bs-theme="dark"] .table-light {
    --bs-table-color: var(--bs-body-color);
    --bs-table-bg: var(--bs-tertiary-bg);
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-hover-color: var(--bs-body-color);
}

/* Navbar / sidebar + top-bar palette — consumed by the scoped layout CSS
   (MainLayout.razor.css, NavMenu.razor.css). Each theme sets its own accent.
   The :root values are the light-base defaults; a new theme overrides what it needs. */
/* Chart palette — data-viz slot 1 (blue), stepped per surface. Keyed off the
   Bootstrap base rather than a theme key so any future dark theme inherits it.
   Contrast vs surface: 4.42:1 light, 4.24:1 dark, 4.08:1 monokai (gate 3:1). */
:root {
    --brew-chart-series-1: #2a78d6;
    --brew-chart-series-2: #b45309;
    --brew-chart-grid: rgba(0, 0, 0, .10);
    --brew-chart-axis-text: var(--bs-secondary-color);
    --brew-chart-surface: var(--bs-body-bg);
    --brew-chart-crosshair: rgba(0, 0, 0, .28);
    /* The gradient line is drawn over the gravity curve, so it can't be the curve's own colour.
       White on a dark plot, near-black on a light one — the point is contrast against the series,
       not a particular colour. */
    --brew-chart-tangent: #111418;
}

:root[data-bs-theme="dark"] {
    --brew-chart-series-1: #3987e5;
    --brew-chart-series-2: #eb9950;
    --brew-chart-grid: rgba(255, 255, 255, .12);
    --brew-chart-crosshair: rgba(255, 255, 255, .34);
    --brew-chart-tangent: #ffffff;
}

:root {
    --brew-sidebar-bg: #f4f5f7;
    --brew-sidebar-color: #3f4652;
    --brew-sidebar-hover-bg: rgba(0, 0, 0, .06);
    --brew-sidebar-brand-bg: rgba(0, 0, 0, .04);
    --brew-accent: #0d6efd;
    --brew-accent-color: #ffffff;
    --brew-topbar-bg: #ffffff;
    --brew-topbar-border: #dee2e6;
}

:root[data-theme="dark"] {
    --brew-sidebar-bg: #16181b;
    --brew-sidebar-color: #c7ccd1;
    --brew-sidebar-hover-bg: rgba(255, 255, 255, .07);
    --brew-sidebar-brand-bg: rgba(0, 0, 0, .35);
    --brew-accent: #0d6efd;
    --brew-accent-color: #ffffff;
    --brew-topbar-bg: #1a1d20;
    --brew-topbar-border: #2b3035;
}

:root[data-theme="monokai"] {
    --brew-sidebar-bg: #1e1f1c;
    --brew-sidebar-color: #cfd0c2;
    --brew-sidebar-hover-bg: rgba(166, 226, 46, .12);
    --brew-sidebar-brand-bg: rgba(0, 0, 0, .30);
    --brew-accent: #a6e22e;
    --brew-accent-color: #1e1f1c;
    --brew-topbar-bg: #1e1f1c;
    --brew-topbar-border: #3a3b32;
}

/* Monokai — sits on the dark base. */
:root[data-theme="monokai"] {
    --bs-body-bg: #272822;
    --bs-body-bg-rgb: 39, 40, 34;
    --bs-body-color: #f8f8f2;
    --bs-body-color-rgb: 248, 248, 242;
    --bs-emphasis-color: #f8f8f2;
    --bs-emphasis-color-rgb: 248, 248, 242;

    --bs-secondary-bg: #3a3b32;
    --bs-secondary-bg-rgb: 58, 59, 50;
    --bs-tertiary-bg: #31322b;
    --bs-tertiary-bg-rgb: 49, 50, 43;

    --bs-secondary-color: rgba(248, 248, 242, .65);
    --bs-tertiary-color: rgba(248, 248, 242, .5);

    --bs-border-color: #49483e;
    --bs-border-color-translucent: rgba(248, 248, 242, .12);

    --bs-heading-color: #f8f8f2;
    --bs-link-color: #66d9ef;
    --bs-link-color-rgb: 102, 217, 239;
    --bs-link-hover-color: #a1e9f5;
    --bs-link-hover-color-rgb: 161, 233, 245;
    --bs-code-color: #f92672;

    --bs-primary: #a6e22e;
    --bs-primary-rgb: 166, 226, 46;
    --bs-primary-text-emphasis: #c7f04e;
    --bs-primary-bg-subtle: #2f3a17;
    --bs-primary-border-subtle: #4a5c24;

    /* Card surface a touch lighter than the body for depth. */
    --bs-card-bg: #2f302a;
    --bs-card-cap-bg: #34352d;
    --bs-card-border-color: #3f4034;
}

/* Monokai: recolour primary buttons to the signature green with dark text. */
:root[data-theme="monokai"] .btn-primary {
    --bs-btn-color: #1e1f1c;
    --bs-btn-bg: #a6e22e;
    --bs-btn-border-color: #a6e22e;
    --bs-btn-hover-color: #1e1f1c;
    --bs-btn-hover-bg: #b6ee4a;
    --bs-btn-hover-border-color: #b6ee4a;
    --bs-btn-active-color: #1e1f1c;
    --bs-btn-active-bg: #96d21e;
    --bs-btn-active-border-color: #96d21e;
    --bs-btn-disabled-color: #1e1f1c;
    --bs-btn-disabled-bg: #a6e22e;
    --bs-btn-disabled-border-color: #a6e22e;
}