/* The UI's own styling, on top of vendored Bootstrap 5 (docs/design/ui-conventions.md, Style).
   Colors are tokens here, never hard-coded on a screen. They are built from Bootstrap's own variables, so light and dark
   (data-bs-theme, set by ui.js from the browser's setting) both work without a second set of colors. */

/* The UI's own styling, on top of vendored Bootstrap 5 (docs/design/ui-conventions.md, Style).

   THE PALETTE LIVES IN THIS FILE'S TOKENS (CORE-122), light and dark side by side. Colors are tokens here, never hard-coded on a screen.
   To change the look (brand colors, a logo's navy), change the --ui-* values in the two blocks below and nothing else: the mapping
   block after them points Bootstrap's own variables at them, and the components read those. The pairs that must stay readable are
   checked by tests/test_theme.py (WCAG contrast), so a bad choice fails a test. Light and dark follow the browser (data-bs-theme,
   set by ui.js). Direction: restraint and consistency, a calm deep blue, a dark navy menu, white panels on a light grey page. */

:root, [data-bs-theme="light"] {
  /* The frame (CORE-121). */
  --ui-sidebar-width: 14rem;
  --ui-sidebar-collapsed-width: 3.5rem;
  --ui-topbar-height: 3.25rem;

  /* Page and panels. */
  --ui-page-bg: #f3f5f9;
  --ui-surface: #ffffff;
  --ui-surface-muted: #eef2f8;      /* a table's header, a hovered row */
  --ui-border: #d9e0ea;
  --ui-border-strong: #b9c4d3;      /* a button's edge */
  --ui-border-input: #7f8da1;       /* a field's or a checkbox's edge: 3:1 against the surface */
  --ui-text: #1f2a37;
  --ui-text-muted: #5b6676;

  /* The one accent: a calm, deep blue. */
  --ui-primary: #1d4f91;
  --ui-primary-rgb: 29, 79, 145;
  --ui-primary-hover: #173f74;
  --ui-primary-active: #123360;
  --ui-primary-on: #ffffff;         /* text on a primary button */
  --ui-primary-subtle: #dce8f8;     /* the "active" badge, a selected row */
  --ui-primary-subtle-border: #b6cdee;
  --ui-primary-emphasis: #0f3466;   /* text on the subtle blue */
  --ui-link-rgb: 29, 79, 145;
  --ui-link-hover-rgb: 18, 51, 96;
  --ui-focus: #2f6fc7;              /* the focus ring: 3:1 against the page and the panels */

  /* The top bar and the menu. */
  --ui-brand: #14233a;
  --ui-sidebar-bg: #2b4a73;         /* a mid slate blue: dull, but not dark */
  --ui-sidebar-fg: #e4ebf5;
  --ui-sidebar-fg-muted: #aebfd8;   /* an item for a screen that is not built yet */
  --ui-sidebar-hover: rgba(255, 255, 255, .10);
  --ui-sidebar-active-bg: #3d6299;
  --ui-sidebar-active-fg: #ffffff;
  --ui-sidebar-accent: #9ccbff;
  --ui-count-bg: #fff3cd;            /* a menu count's fill (CORE-215): the attention badge's colours */
  --ui-count-fg: #664d03;
  --ui-env-local-bg: #e9ecf1;        /* the environment's badge (CORE-235): Local grey, Development blue, Staging a strong amber */
  --ui-env-local-fg: #3d4652;
  --ui-env-development-bg: #dbe7f7;
  --ui-env-development-fg: #1d4f91;
  --ui-env-staging-bg: #b45309;
  --ui-env-staging-fg: #ffffff;
  --ui-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --ui-shadow-raised: 0 .5rem 1rem rgba(16, 24, 40, .18);

  /* Charts and the map (CORE-159): the categorical slots, in fixed order (a group keeps its slot), validated with the dataviz
     palette checks for this theme's surface (lightness, chroma, colorblind separation). Some sit under 3:1 on the light surface, so a
     mark always carries relief: a ring, a legend and a label or tooltip, and a table view. Slot 9 and beyond share "other". */
  --ui-series-1: #2a78d6;
  --ui-series-2: #eb6834;
  --ui-series-3: #1baf7a;
  --ui-series-4: #eda100;
  --ui-series-5: #e87ba4;
  --ui-series-6: #008300;
  --ui-series-7: #6250d6;
  --ui-series-8: #e34948;
  --ui-series-other: #7f8da1;
  --ui-map-land: #e8edf4;
  --ui-map-border: #ffffff;

  /* The sign-in page's brand panel (CORE-179): the brand navy, the one place a screen uses a brand color (ui-conventions.md, Brand). */
  --ui-auth-brand-bg: #1b2f4b;
  --ui-auth-brand-fg: #ffffff;
  --ui-auth-brand-fg-muted: #c3cfe0;
  --ui-auth-brand-edge: #1b2f4b;
  --ui-auth-brand-accent: #f2a33a;  /* the brand amber: the panel's one link (CORE-181) */
}

[data-bs-theme="dark"] {
  --ui-page-bg: #0e1521;
  --ui-surface: #162030;
  --ui-surface-muted: #1d2a3d;
  --ui-border: #2a3648;
  --ui-border-strong: #3a4960;
  --ui-border-input: #6b7b93;
  --ui-text: #dde5f0;
  --ui-text-muted: #9aa8bd;

  --ui-primary: #2f6fc7;
  --ui-primary-rgb: 47, 111, 199;
  --ui-primary-hover: #2863b3;
  --ui-primary-active: #21539a;
  --ui-primary-on: #ffffff;
  --ui-primary-subtle: #1c3556;
  --ui-primary-subtle-border: #2a4f84;
  --ui-primary-emphasis: #9ec5f7;
  --ui-link-rgb: 138, 184, 245;
  --ui-link-hover-rgb: 180, 210, 250;
  --ui-focus: #6aa8f0;

  --ui-brand: #e6edf7;
  --ui-sidebar-bg: #0a111c;
  --ui-sidebar-fg: #c5d0e0;
  --ui-sidebar-fg-muted: #7f8fa8;
  --ui-sidebar-hover: rgba(255, 255, 255, .07);
  --ui-sidebar-active-bg: #1f3a63;
  --ui-sidebar-active-fg: #ffffff;
  --ui-sidebar-accent: #6aa8f0;
  --ui-count-bg: #332701;
  --ui-count-fg: #ffda6a;
  --ui-env-local-bg: #2a3648;
  --ui-env-local-fg: #c9d3e0;
  --ui-env-development-bg: #1d3a63;
  --ui-env-development-fg: #cfe0f7;
  --ui-env-staging-bg: #b45309;
  --ui-env-staging-fg: #ffffff;
  --ui-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  --ui-shadow-raised: 0 .5rem 1rem rgba(0, 0, 0, .55);

  --ui-series-1: #3987e5;
  --ui-series-2: #d95926;
  --ui-series-3: #199e70;
  --ui-series-4: #c98500;
  --ui-series-5: #d55181;
  --ui-series-6: #0ca30c;
  --ui-series-7: #9085e9;
  --ui-series-8: #e66767;
  --ui-series-other: #6b7b93;
  --ui-map-land: #24324a;
  --ui-map-border: #162030;

  --ui-auth-brand-bg: #1b2f4b;
  --ui-auth-brand-fg: #ffffff;
  --ui-auth-brand-fg-muted: #c3cfe0;
  --ui-auth-brand-edge: #2a3648;    /* a line between the panel and the dark surface, which are close in tone */
  --ui-auth-brand-accent: #f2a33a;
}

/* The mapping: Bootstrap's own variables read the tokens above, so its links, borders, text and subtle colors follow the palette. */
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
  --bs-body-bg: var(--ui-page-bg);
  --bs-body-color: var(--ui-text);
  --bs-heading-color: var(--ui-text);
  --bs-secondary-color: var(--ui-text-muted);
  --bs-secondary-bg: var(--ui-surface-muted);
  --bs-tertiary-bg: var(--ui-surface-muted);
  --bs-border-color: var(--ui-border);
  --bs-primary: var(--ui-primary);
  --bs-primary-rgb: var(--ui-primary-rgb);
  --bs-primary-text-emphasis: var(--ui-primary-emphasis);
  --bs-primary-bg-subtle: var(--ui-primary-subtle);
  --bs-primary-border-subtle: var(--ui-primary-subtle-border);
  --bs-link-color-rgb: var(--ui-link-rgb);
  --bs-link-hover-color-rgb: var(--ui-link-hover-rgb);
  --bs-code-color: var(--ui-primary-emphasis);
  --bs-body-font-size: .9375rem;
  --bs-body-line-height: 1.5;
}

:root {
  /* The six badge tones. */
  --ui-tone-neutral-fg: var(--bs-secondary-color);
  --ui-tone-neutral-bg: transparent;
  --ui-tone-neutral-border: var(--bs-border-color);
  --ui-tone-active-fg: var(--bs-primary-text-emphasis);
  --ui-tone-active-bg: var(--bs-primary-bg-subtle);
  --ui-tone-done-fg: var(--bs-success-text-emphasis);
  --ui-tone-done-bg: var(--bs-success-bg-subtle);
  --ui-tone-attention-fg: var(--bs-warning-text-emphasis);
  --ui-tone-attention-bg: var(--bs-warning-bg-subtle);
  --ui-tone-ended-fg: var(--bs-secondary-text-emphasis);
  --ui-tone-ended-bg: var(--bs-secondary-bg-subtle);
  --ui-tone-problem-fg: var(--bs-danger-text-emphasis);
  --ui-tone-problem-bg: var(--bs-danger-bg-subtle);
}

/* Type: the system font stack (nothing is downloaded), a little tighter than Bootstrap's, with clear headings. */
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; letter-spacing: -.005em; }
h1, .h1 { font-size: 1.5rem; }
h2, .h2 { font-size: 1.25rem; }
h3, .h3 { font-size: 1.125rem; }
h4, .h4 { font-size: 1.0625rem; }
h5, .h5 { font-size: 1rem; }
a { text-underline-offset: .15em; }
code { font-size: .875em; }

/* Badges: a word on a tone. Never color alone. */
.badge[class*="badge-tone-"] { font-weight: 500; border: 1px solid transparent; }
.badge-tone-neutral   { color: var(--ui-tone-neutral-fg);   background: var(--ui-tone-neutral-bg);   border-color: var(--ui-tone-neutral-border) !important; }
.badge-tone-active    { color: var(--ui-tone-active-fg);    background: var(--ui-tone-active-bg); }
.badge-tone-done      { color: var(--ui-tone-done-fg);      background: var(--ui-tone-done-bg); }
.badge-tone-attention { color: var(--ui-tone-attention-fg); background: var(--ui-tone-attention-bg); }
.badge-tone-ended     { color: var(--ui-tone-ended-fg);     background: var(--ui-tone-ended-bg); }
.badge-tone-problem   { color: var(--ui-tone-problem-fg);   background: var(--ui-tone-problem-bg); }

/* Money: tabular figures so columns line up; a negative figure carries the danger color. */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money-negative { color: var(--bs-danger-text-emphasis); }

/* Dense on purpose: a back office shows as much as fits. Tables: a quietly shaded header, a soft row hover, numbers set by .money. */
.table {
  --bs-table-bg: transparent; --bs-table-color: var(--ui-text); --bs-table-border-color: var(--ui-border);
  --bs-table-hover-bg: var(--ui-surface-muted); --bs-table-hover-color: var(--ui-text);
}
.table > thead > tr > th {
  background: var(--ui-surface-muted); color: var(--ui-text-muted); font-size: .8125rem; font-weight: 600;
  border-bottom: 1px solid var(--ui-border-strong);
}
th { white-space: nowrap; }

/* The busy indicator on a region HTMX is updating (htmx's own styles are off: the page's CSP forbids inline styles).
   The region keeps its size so the page does not jump. */
.htmx-indicator { opacity: 0; transition: opacity 150ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
[aria-busy="true"] { opacity: .6; }

/* Visible focus, always. */
:focus-visible { outline: 2px solid var(--ui-focus); outline-offset: 2px; }


/* ---- The frame (CORE-121): a slim top bar and a left-side menu. ---- */
.app-topbar {
  background: var(--ui-surface); min-height: var(--ui-topbar-height); border-bottom-color: var(--ui-border) !important;
  box-shadow: var(--ui-shadow); position: relative; z-index: 2;
}
.app-topbar .navbar-brand { color: var(--ui-brand); font-weight: 700; letter-spacing: .01em; }
.app-footer { background: var(--ui-surface); border-top-color: var(--ui-border) !important; }
.app-column { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-column > .app-main { flex: 1 0 auto; }
.app-body { display: flex; min-height: 0; flex: 1 0 auto; }
.app-main { flex: 1 1 auto; min-width: 0; }
.app-main.container-fluid { padding: 1.5rem; }  /* min-width 0: a wide table scrolls inside itself, never the whole page */
.app-backdrop { display: none; }

.app-sidebar {
  flex: 0 0 var(--ui-sidebar-width); width: var(--ui-sidebar-width);
  background: var(--ui-sidebar-bg); padding: .5rem;
  transition: flex-basis 150ms ease, width 150ms ease;
}
.app-sidebar .nav-link {
  display: flex; align-items: center; gap: .75rem; padding: .5rem .65rem; border-radius: .375rem;
  color: var(--ui-sidebar-fg); white-space: nowrap;
}
.app-sidebar a.nav-link:hover { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-active-fg); }
.app-sidebar .nav-link.active {
  background: var(--ui-sidebar-active-bg); color: var(--ui-sidebar-active-fg); font-weight: 500; box-shadow: inset 3px 0 0 var(--ui-sidebar-accent);
}
.app-sidebar .nav-link.disabled { color: var(--ui-sidebar-fg-muted); cursor: default; }
.app-sidebar :focus-visible { outline-color: var(--ui-sidebar-accent); }
.app-sidebar .icon, .nav-toggle .icon { flex: 0 0 auto; }

/* Collapsed to a strip of icons (a wide window, with script). The labels stay for screen readers: visually hidden, not removed. */
@media (min-width: 992px) {
  html.nav-collapsed .app-sidebar { flex-basis: var(--ui-sidebar-collapsed-width); width: var(--ui-sidebar-collapsed-width); }
  html.nav-collapsed .app-sidebar .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
  html.nav-collapsed .app-sidebar .nav-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

/* A narrow window. With script the menu is off-screen until the button is pressed, then slides over the page; without script it simply
   stacks above the page, so the page still works. */
@media (max-width: 991.98px) {
  html:not(.js) .app-body { flex-direction: column; }
  html:not(.js) .app-sidebar { flex-basis: auto; width: auto; }
  html.js .app-sidebar {
    position: fixed; top: var(--ui-topbar-height); bottom: 0; left: 0; z-index: 1030; overflow-y: auto;
    transform: translateX(-100%); transition: transform 150ms ease;
  }
  html.js.nav-open .app-sidebar { transform: translateX(0); box-shadow: var(--ui-shadow-raised); }
  html.js.nav-open .app-backdrop {
    display: block; position: fixed; top: var(--ui-topbar-height); right: 0; bottom: 0; left: 0; z-index: 1029; background: rgba(0, 0, 0, .35);
  }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar { transition: none; } }


/* ---- Panels, buttons, forms (CORE-122). ---- */

/* A panel: the white surface content sits on. A list, a detail section and a form are each one. */
.ui-panel {
  background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: .5rem; box-shadow: var(--ui-shadow);
  padding: 1rem 1.25rem;
}
.ui-panel > :last-child { margin-bottom: 0; }
.ui-panel-title { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }
.ui-panel .table { margin-bottom: 0; }

.btn { --bs-btn-font-weight: 500; --bs-btn-border-radius: .375rem; }
.btn-primary {
  --bs-btn-color: var(--ui-primary-on); --bs-btn-bg: var(--ui-primary); --bs-btn-border-color: var(--ui-primary);
  --bs-btn-hover-color: var(--ui-primary-on); --bs-btn-hover-bg: var(--ui-primary-hover); --bs-btn-hover-border-color: var(--ui-primary-hover);
  --bs-btn-active-color: var(--ui-primary-on); --bs-btn-active-bg: var(--ui-primary-active); --bs-btn-active-border-color: var(--ui-primary-active);
  --bs-btn-disabled-color: var(--ui-primary-on); --bs-btn-disabled-bg: var(--ui-primary); --bs-btn-disabled-border-color: var(--ui-primary);
  --bs-btn-focus-shadow-rgb: var(--ui-primary-rgb);
}
.btn-outline-secondary {
  --bs-btn-color: var(--ui-text-muted); --bs-btn-border-color: var(--ui-border-strong);
  --bs-btn-hover-color: var(--ui-text); --bs-btn-hover-bg: var(--ui-surface-muted); --bs-btn-hover-border-color: var(--ui-border-input);
  --bs-btn-active-color: var(--ui-text); --bs-btn-active-bg: var(--ui-surface-muted); --bs-btn-active-border-color: var(--ui-border-input);
  --bs-btn-disabled-color: var(--ui-text-muted); --bs-btn-disabled-border-color: var(--ui-border);
  --bs-btn-focus-shadow-rgb: var(--ui-primary-rgb);
}

/* The information message takes the palette's blue (Bootstrap's own info color is a teal that does not belong to it). */
.alert-info {
  --bs-alert-color: var(--ui-primary-emphasis); --bs-alert-bg: var(--ui-primary-subtle);
  --bs-alert-border-color: var(--ui-primary-subtle-border); --bs-alert-link-color: var(--ui-primary-emphasis);
}

.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .25rem; }
.form-control, .form-select { background-color: var(--ui-surface); color: var(--ui-text); border-color: var(--ui-border-input); }
.form-control:focus, .form-select:focus {
  background-color: var(--ui-surface); color: var(--ui-text); border-color: var(--ui-primary);
  box-shadow: 0 0 0 .2rem rgba(var(--ui-primary-rgb), .25);
}
.form-check-input { background-color: var(--ui-surface); border-color: var(--ui-border-input); }
.form-check-input:checked { background-color: var(--ui-primary); border-color: var(--ui-primary); }
.form-check-input:focus { border-color: var(--ui-primary); box-shadow: 0 0 0 .2rem rgba(var(--ui-primary-rgb), .25); }

.dropdown-menu {
  --bs-dropdown-bg: var(--ui-surface); --bs-dropdown-color: var(--ui-text); --bs-dropdown-border-color: var(--ui-border);
  --bs-dropdown-link-hover-bg: var(--ui-surface-muted); box-shadow: var(--ui-shadow-raised);
}

/* The style guide's color swatches (classes, because the page's policy forbids inline styles). */
.swatch { display: inline-block; width: 2rem; height: 2rem; border: 1px solid var(--ui-border-strong); border-radius: .375rem; vertical-align: middle; }
.swatch-page { background: var(--ui-page-bg); }
.swatch-surface { background: var(--ui-surface); }
.swatch-surface-muted { background: var(--ui-surface-muted); }
.swatch-primary { background: var(--ui-primary); }
.swatch-primary-subtle { background: var(--ui-primary-subtle); }
.swatch-sidebar { background: var(--ui-sidebar-bg); }
.swatch-text { background: var(--ui-text); }
.swatch-text-muted { background: var(--ui-text-muted); }
.swatch-border { background: var(--ui-border-input); }

/* The Platform home map of auctions (CORE-159). The outlines are drawn on the server; a pin is a dot in its group's color with a ring of
   the surface, so it stands off the land and off its neighbours. The legend and the tooltip name the group: color is never alone. */
/* The whole map always fits on the screen: as wide as the panel, but never taller than the window below the page's header and the
   legend (about 16rem), and never smaller than 18rem tall. When the height is the limit, the drawing scales down and centers. */
.us-map { width: 100%; height: auto; max-height: max(18rem, calc(100vh - 16rem)); display: block; margin: 0 auto; }
.us-map .map-states path { fill: var(--ui-map-land); stroke: var(--ui-map-border); stroke-width: .75; }
.us-map .map-states path:hover { fill: var(--ui-surface-muted); }
.us-map .map-nation { fill: none; stroke: var(--ui-border-input); stroke-width: .75; }
.us-map .map-pin circle { stroke: var(--ui-surface); stroke-width: 2; cursor: default; }
.us-map .map-pin:hover circle, .us-map .map-pin:focus circle { stroke: var(--ui-text); }
.us-map .map-pin:focus { outline: none; }
.us-map .map-pin:focus-visible circle { stroke: var(--ui-focus); stroke-width: 3; }
.map-wrap { position: relative; }
.map-tooltip { position: absolute; pointer-events: none; background: var(--ui-surface); color: var(--ui-text); border: 1px solid var(--ui-border);
  border-radius: .375rem; box-shadow: var(--ui-shadow-raised); padding: .375rem .5rem; font-size: .8125rem; line-height: 1.3;
  white-space: nowrap; transform: translate(-50%, calc(-100% - 12px)); z-index: 5; }
.map-tooltip[hidden] { display: none; }
.map-swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 50%; vertical-align: -.05rem;
  box-shadow: 0 0 0 2px var(--ui-surface), 0 0 0 3px var(--ui-border); }
.series-1 { fill: var(--ui-series-1); background: var(--ui-series-1); }
.series-2 { fill: var(--ui-series-2); background: var(--ui-series-2); }
.series-3 { fill: var(--ui-series-3); background: var(--ui-series-3); }
.series-4 { fill: var(--ui-series-4); background: var(--ui-series-4); }
.series-5 { fill: var(--ui-series-5); background: var(--ui-series-5); }
.series-6 { fill: var(--ui-series-6); background: var(--ui-series-6); }
.series-7 { fill: var(--ui-series-7); background: var(--ui-series-7); }
.series-8 { fill: var(--ui-series-8); background: var(--ui-series-8); }
.series-other { fill: var(--ui-series-other); background: var(--ui-series-other); }

/* A row's actions (CORE-162): a quiet kebab button in the row's last cell, the menu opening at its right edge. */
td.row-actions { width: 1%; white-space: nowrap; text-align: end; }
.row-menu-toggle { color: var(--ui-text-muted); padding: .125rem .25rem; line-height: 1; border: 1px solid transparent; }
.row-menu-toggle:hover, .row-menu-toggle[aria-expanded="true"] { color: var(--ui-text); background: var(--ui-surface-muted); border-color: var(--ui-border); }
.row-menu-toggle .icon { width: 18px; height: 18px; }
.row-menu .dropdown-menu { font-size: .875rem; }

/* CORE-165: the top bar names the place ("UAMS · Acme Auto Auction Group"); the area switch sits at the bottom of the menu, which
   stays in the window (sticky) so the switch is always in view just above the footer, however long the page. */
/* CORE-178: the Lanes mark before the name in the top bar. */
.app-topbar .navbar-brand { display: inline-flex; align-items: center; gap: .5rem; }
.app-topbar .brand-mark { flex: 0 0 auto; width: 23px; height: 24px; }
.app-topbar .brand-mark-dark, [data-bs-theme="dark"] .app-topbar .brand-mark-light { display: none; }
[data-bs-theme="dark"] .app-topbar .brand-mark-dark { display: inline; }
/* The menu button is borderless (CORE-178 follow-up), so it doesn't read as a second box beside the mark; it keeps its hover and focus. */
.app-topbar .nav-toggle { border-color: transparent; color: var(--ui-text-muted); }
.app-topbar .nav-toggle:hover, .app-topbar .nav-toggle[aria-expanded]:active { background: var(--ui-surface-muted); color: var(--ui-text); }
.app-topbar .brand-place { font-weight: 400; color: var(--ui-text-muted); }
/* CORE-219: the top bar keeps to the window at a phone's width. The place name shrinks to an ellipsis (the whole name in its tooltip),
   the button, the mark, "UAMS" and Sign out never shrink, and below 576px the person's name gives way to an icon. */
.app-topbar { min-width: 0; }
.app-topbar .nav-toggle, .app-topbar .topbar-person { flex: 0 0 auto; }
.app-topbar .navbar-brand { min-width: 0; flex: 0 1 auto; margin-right: 0; white-space: nowrap; }
.app-topbar .brand-place { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The person menu (CORE-239): a round avatar, the name and a chevron; a card when open. */
.person-menu-toggle { display: inline-flex; align-items: center; gap: .5rem; color: var(--ui-text); padding: .2rem .5rem .2rem .25rem;
  border: 1px solid transparent; border-radius: 999px; }
.person-menu-toggle:hover, .person-menu-toggle[aria-expanded="true"] { background: var(--ui-surface-muted); border-color: var(--ui-border); }
.person-menu-toggle .person-name { font-weight: 500; white-space: nowrap; }
.person-chevron .icon { width: 14px; height: 14px; color: var(--ui-text-muted); vertical-align: middle; }
.avatar { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 1.875rem; height: 1.875rem;
  border-radius: 50%; background: var(--ui-primary-subtle); color: var(--ui-primary-emphasis); border: 1px solid var(--ui-primary-subtle-border); }
.avatar .icon { width: 18px; height: 18px; }
.avatar-lg { width: 2.5rem; height: 2.5rem; }
.avatar-lg .icon { width: 22px; height: 22px; }
.person-menu-card { min-width: 16rem; padding: .5rem 0; border-radius: .5rem; }
.person-menu-head { display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; }
.person-menu-who { display: flex; flex-direction: column; min-width: 0; }
.person-menu-name { font-weight: 600; color: var(--ui-text); }
.person-menu-email { font-size: .8125rem; color: var(--ui-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-menu-card .dropdown-item { display: flex; align-items: center; gap: .6rem; padding: .45rem 1rem; }
.person-menu-card .dropdown-item .icon { width: 18px; height: 18px; flex: 0 0 auto; }
.person-menu-card .dropdown-item.disabled { color: var(--ui-text-muted); pointer-events: auto; cursor: default; background: none; }
.person-menu-card .person-menu-signout { color: var(--bs-danger-text-emphasis); }
html.js .no-js-only { display: none !important; }
@media (max-width: 575.98px) {
  .app-topbar { padding-left: .5rem !important; padding-right: .5rem !important; }
  .person-menu-toggle { padding: .2rem; }
  .person-chevron { display: none; }
  .app-topbar .topbar-person .person-name { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important;
    margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
}
@media (min-width: 992px) {
  /* 2026-11-25: the menu runs from the top bar to the bottom of the window; the top bar stays put, the footer sits under the page. */
  .app-topbar { position: sticky; top: 0; z-index: 1020; }
  .app-sidebar { position: sticky; top: var(--ui-topbar-height); align-self: flex-start; height: calc(100vh - var(--ui-topbar-height));
    overflow-y: auto; }
}
.app-sidebar { display: flex; flex-direction: column; }
/* CORE-205: the UAMS Community Portal's entry, at the foot of the menu above the area switch; the small arrow says it opens a new tab. */
.menu-foot { margin-top: auto; padding-top: .5rem; border-top: 1px solid rgba(255, 255, 255, .12); }
.menu-foot + .area-switcher { margin-top: .5rem; }
.community-link .nav-label { display: inline-flex; align-items: center; gap: .35rem; }
.community-link .nav-label .icon { width: 13px; height: 13px; opacity: .75; }
.area-switcher { margin-top: auto; display: flex; gap: 2px; padding: 3px; border-radius: .5rem; background: rgba(0, 0, 0, .18); }
.area-switcher .area-option { flex: 1; display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .35rem .5rem;
  border-radius: .375rem; color: var(--ui-sidebar-fg); text-decoration: none; font-size: .875rem; }
.area-switcher .area-option .icon { width: 16px; height: 16px; }
.area-switcher .area-option.current { background: var(--ui-sidebar-active-bg); color: var(--ui-sidebar-active-fg); font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.area-switcher .area-option:not(.current):hover { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-active-fg); }
@media (min-width: 992px) {
  html.nav-collapsed .area-switcher { flex-direction: column; }
  html.nav-collapsed .area-switcher .area-option { padding: .4rem 0; }
}

/* CORE-237: Work or Records, at the top of the Auction area's menu: the area switcher's segmented look, with buttons (it posts). */
.menu-switch { display: flex; gap: 2px; padding: 3px; margin-bottom: .75rem; border-radius: .5rem; background: rgba(0, 0, 0, .18); }
.menu-switch .menu-switch-option { flex: 1; display: flex; align-items: center; justify-content: center; gap: .4rem; padding: .3rem .5rem;
  border: 0; border-radius: .375rem; background: transparent; color: var(--ui-sidebar-fg); font-size: .875rem; }
.menu-switch .menu-switch-option .icon { width: 16px; height: 16px; }
.menu-switch .menu-switch-option.current { background: var(--ui-sidebar-active-bg); color: var(--ui-sidebar-active-fg); font-weight: 500;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18); }
.menu-switch .menu-switch-option:not(.current):hover { background: var(--ui-sidebar-hover); color: var(--ui-sidebar-active-fg); }
.menu-switch .menu-switch-option:focus-visible { outline: 2px solid var(--ui-sidebar-active-fg); outline-offset: 1px; }
@media (min-width: 992px) {
  html.nav-collapsed .menu-switch { flex-direction: column; }
  html.nav-collapsed .menu-switch .menu-switch-option { padding: .4rem 0; }
}
/* CORE-237: a record's tabs (an auction's Details, Address, Bank accounts...): each a page of its own, so plain links. */
.record-tabs { margin-bottom: 1rem; }

/* CORE-165: the filter section's count, at its right; the picker's single-auction text; columns only as wide as their content;
   status badges a little larger and lighter. */
.filter-bar .filter-count { font-size: .9375rem; color: var(--ui-text-muted); align-self: center; }
.picker-single { display: inline-block; padding: .25rem 0; font-size: .875rem; }
.col-tight { width: 1%; white-space: nowrap; padding-right: 1.25rem !important; }
.badge[class*="badge-tone-"] { font-size: .8125rem; font-weight: 400; padding: .3em .6em; }

/* CORE-167: the foot of a paged list, under the table. */
.pager { border-top: 1px solid var(--ui-border); }
.pager-range { font-size: .9375rem; }

/* CORE-151: a balance of $0.00 reads as settled, in the success tone (ui-conventions.md, Money). */
.settled, .settled .money { color: var(--ui-tone-done-fg); }

/* A vehicle's charges: a charge's credits sit under it, indented; a note marks what was posted after a settlement froze. */
.charges-table .credit-row td { border-top-style: dashed; }
.late-note { font-size: .75rem; color: var(--ui-tone-attention-fg); white-space: nowrap; }

/* CORE-171: a vehicle's listings, each with its deals under it. */
.listings-table .deal-row td { border-top-style: dashed; }
.current-note { font-size: .75rem; color: var(--ui-text-muted); }
.deal-of-listing { padding-left: 1.5rem !important; color: var(--ui-text-muted); font-size: .875rem; }

/* A vehicle's two charge tables (consignor, buyer) share fixed column widths, so their columns line up; each ends in a total. */
.charges-table { table-layout: fixed; min-width: 40rem; }
.charges-table .w-charge { width: 34%; } .charges-table .w-owed { width: 24%; } .charges-table .w-status { width: 12%; }
.charges-table .w-amount { width: 12%; } .charges-table .w-charged { width: 18%; }
.charges-table .total-row th, .charges-table .total-row td { font-weight: 600; border-bottom: 0; }
.charges-table .total-row.pending th, .charges-table .total-row.pending td { font-weight: 400; color: var(--ui-text-muted); }

/* Printing (CORE-153): the page alone, for the deposit slip: no top bar, menu, footer, breadcrumbs or buttons. */
@media print {
  .app-topbar, .app-sidebar, .app-backdrop, .app-footer, .breadcrumb, .page-actions, .no-print, .modal { display: none !important; }
  .app-main.container-fluid { padding: 0; }
  .ui-panel { box-shadow: none; border-color: var(--ui-text); }
}
.deposit-totals { width: auto; min-width: 16rem; }
.picker-codes { font-size: .875rem; color: var(--ui-text-muted); white-space: nowrap; }

/* CORE-179: the sign-in page, a layout of its own. A brand panel beside the form on a wide window, a strip above it on a narrow one. */
html:not(.js) .js-only { display: none !important; }
body.auth-page { background: var(--ui-surface); }
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.auth-brand { background: var(--ui-auth-brand-bg); color: var(--ui-auth-brand-fg); border-right: 1px solid var(--ui-auth-brand-edge);
  display: flex; flex-direction: column; padding: 3rem 2.5rem 2.5rem; }
.auth-brand-inner, .auth-community { width: 100%; max-width: 24rem; margin-left: auto; margin-right: auto; }
.auth-brand-inner { margin-top: auto; margin-bottom: auto; padding: 2rem 0; }
.auth-mark { display: block; width: 72px; height: auto; }
.auth-wordmark { display: none; font-size: 1.25rem; font-weight: 600; letter-spacing: .02em; margin: 0; }
.auth-welcome { font-size: 2.25rem; font-weight: 600; line-height: 1.15; margin: 1.5rem 0 1rem; }
.auth-tagline { color: var(--ui-auth-brand-fg-muted); font-size: 1.0625rem; line-height: 1.55; margin: 0; }
.auth-motto { font-size: 1.0625rem; font-weight: 600; margin: 1rem 0 0; }
.auth-community { border-top: 1px solid rgba(255, 255, 255, .16); padding-top: 1.25rem; }
.auth-community-title { font-weight: 600; margin: 0 0 .25rem; }
.auth-community-text { color: var(--ui-auth-brand-fg-muted); font-size: .9375rem; margin: 0 0 .5rem; }
.auth-community-link { color: var(--ui-auth-brand-accent); font-size: .9375rem; font-weight: 500; text-decoration: none; }
.auth-community-link:hover { text-decoration: underline; }
.auth-community-link:focus-visible { outline: 2px solid var(--ui-auth-brand-accent); outline-offset: 2px; border-radius: 2px; }
.auth-main { display: flex; flex-direction: column; min-width: 0; }
.auth-form { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 25rem;
  margin: 0 auto; padding: 3rem 1.5rem; }
.auth-env { margin: 0 0 1rem; }
/* The environment's badge (CORE-235): its word in its own colour, on the sign-in page and in the top bar. */
.env-badge { font-weight: 600; letter-spacing: .02em; }
.env-badge-local { background: var(--ui-env-local-bg); color: var(--ui-env-local-fg); }
.env-badge-development { background: var(--ui-env-development-bg); color: var(--ui-env-development-fg); }
.env-badge-staging { background: var(--ui-env-staging-bg); color: var(--ui-env-staging-fg); }
.app-topbar .env-badge { flex: 0 0 auto; margin-left: .5rem; }
.auth-title { font-size: 1.75rem; font-weight: 600; margin: 0 0 .375rem; }
.auth-lead { color: var(--ui-text-muted); margin: 0 0 1.75rem; }
.auth-form .form-label { font-size: .875rem; font-weight: 500; }
.auth-password { position: relative; }
.auth-password .form-control { padding-right: 4.5rem; }
.auth-reveal { position: absolute; top: 50%; right: .5rem; transform: translateY(-50%); font-size: .875rem; font-weight: 500;
  text-decoration: none; padding: .25rem .5rem; }
.auth-caps { color: var(--ui-tone-attention-fg, var(--ui-text)); margin: .375rem 0 0; }
.auth-help { color: var(--ui-text-muted); font-size: .875rem; margin: 1.5rem 0 0; }
.auth-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1rem; padding: 1.25rem 1.5rem;
  font-size: .8125rem; color: var(--ui-text-muted); }
@media (max-width: 767.98px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { justify-content: flex-start; padding: .875rem 1.25rem; border-right: 0; border-bottom: 1px solid var(--ui-auth-brand-edge); }
  .auth-brand-inner { display: flex; align-items: center; gap: .625rem; max-width: none; margin: 0; padding: 0; }
  .auth-mark { width: 26px; }
  .auth-wordmark { display: block; }
  .auth-welcome, .auth-tagline, .auth-motto, .auth-community { display: none; }
  .auth-form { justify-content: flex-start; padding-top: 2.5rem; }
}

/* The UAMS Community Portal's landing page (CORE-205): its own frame (no menu), panels in two columns, lists with a divider between
   items, and cards for playbooks. Tokens only. */
.community-main .ui-panel { margin-bottom: 1.5rem; }
.community-main .ui-panel-title { display: flex; align-items: center; gap: .5rem; }
.community-search { flex: 1 1 16rem; width: auto; }
.community-list .community-item { padding: .6rem 0; border-top: 1px solid var(--ui-border); }
.community-list .community-item:first-child { border-top: 0; padding-top: 0; }
.community-card { padding: .75rem; border: 1px solid var(--ui-border); border-radius: .5rem; background: var(--ui-surface-muted); }
.community-champion { border-color: var(--ui-primary-subtle-border); background: var(--ui-primary-subtle); color: var(--ui-primary-emphasis); }
.community-later { border-style: dashed; }
.btn .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* ---- Where a sale stands (CORE-212): the step tracker and the Next step bar, on a deal's and a vehicle's page ---- */
.sale-steps {
  list-style: none; margin: 0 0 .75rem; padding: 0;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: .75rem;
}
.sale-step {
  position: relative; text-align: center; font-size: .8rem; color: var(--ui-text-muted); padding-top: 1.6rem;
}
.sale-step::before {  /* the line between steps */
  content: ""; position: absolute; top: .65rem; left: 0; right: 0; height: 3px; background: var(--ui-border);
}
.sale-step:first-child::before { left: 50%; }
.sale-step:last-child::before { right: 50%; }
.sale-step-dot {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1;
  width: 1.35rem; height: 1.35rem; border-radius: 50%; border: 3px solid var(--ui-border-input); background: var(--ui-surface);
  display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; line-height: 1;
}
.sale-step-done { color: var(--ui-tone-done-fg); }
.sale-step-done::before { background: var(--ui-tone-done-fg); }
.sale-step-done .sale-step-dot { background: var(--ui-tone-done-fg); border-color: var(--ui-tone-done-fg); color: var(--ui-surface); }
.sale-step-next { color: rgb(var(--ui-link-rgb)); font-weight: 600; }  /* the link colour: 4.5:1 in both themes */
.sale-step-next .sale-step-dot { border-color: var(--ui-primary); background: var(--ui-primary-subtle); }
.sale-step-skipped .sale-step-dot { border-style: dashed; color: var(--ui-text-muted); }
@media (max-width: 767.98px) {  /* a tablet's width down: two rows of four */
  .sale-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .sale-step:nth-child(4)::before { right: 50%; }
  .sale-step:nth-child(5)::before { left: 50%; }
}
.next-step {
  background: var(--ui-primary-subtle); border: 1px solid var(--ui-primary-subtle-border); border-radius: .5rem;
  padding: .6rem .9rem; margin-bottom: 1rem; color: var(--ui-primary-emphasis);
}
.next-step .btn-outline-primary {  /* on the subtle blue, the primary blue is too faint in dark: use the text colour made for it */
  --bs-btn-color: var(--ui-primary-emphasis); --bs-btn-border-color: var(--ui-primary-emphasis);
}
.next-step-complete { background: var(--ui-tone-done-bg); border-color: var(--ui-tone-done-bg); color: var(--ui-tone-done-fg); }
.next-step-line { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin: 0; padding: .2rem 0; }
.next-step-line + .next-step-line { border-top: 1px solid var(--ui-primary-subtle-border); }
.next-step-complete .next-step-line + .next-step-line { border-top-color: var(--ui-tone-done-fg); }

/* ---- A success message with the step that follows it (CORE-213) ---- */
.done-alert { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; }
.done-alert-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.done-alert .btn-outline-success {  /* Bootstrap's green is too faint on the subtle green: use the alert's own text colour */
  --bs-btn-color: var(--ui-tone-done-fg); --bs-btn-border-color: var(--ui-tone-done-fg);
}

/* ---- Before you close a month (CORE-216): a row with work waiting shows its count in the attention tone, which the badges use ---- */
.before-close-waiting td:first-child { color: var(--ui-tone-attention-fg); background: var(--ui-tone-attention-bg); border-radius: .25rem; }

/* ---- The Auction area's Home page (CORE-183): auction cards and Today's work ---- */
.home-welcome { margin-bottom: 1rem; }
.auction-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.auction-card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: .5rem; box-shadow: var(--ui-shadow); overflow: hidden;
  display: flex; flex-direction: column; }
.auction-card-band {  /* the city photo's place; until photos are chosen, a navy band with the code (no gradient) */
  background: var(--ui-sidebar-bg); color: var(--ui-sidebar-fg); height: 4rem; display: flex; align-items: flex-end; padding: .4rem .9rem;
  font-weight: 600; letter-spacing: .04em; }
.auction-card-body { padding: .75rem .9rem .9rem; display: flex; flex-direction: column; gap: .6rem; flex: 1; }
.auction-card-name { font-size: 1.05rem; margin: 0; }
.auction-card-meta { margin: -.4rem 0 0; font-size: .85rem; color: var(--ui-text-muted); }
.auction-card-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.auction-figure { display: flex; flex-direction: column; padding: .45rem .55rem; border: 1px solid var(--ui-border); border-radius: .375rem;
  text-decoration: none; color: var(--ui-text); }
.auction-figure:hover, .auction-figure:focus-visible { background: var(--ui-surface-muted); }
.auction-figure-value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.auction-figure-label { font-size: .8rem; color: var(--ui-text-muted); }
.auction-figure-sub { color: var(--ui-text); font-variant-numeric: tabular-nums; }
.auction-figure.settled .auction-figure-value { color: var(--ui-tone-done-fg); }
.auction-card-tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: auto; }
.auction-card-tags a.badge { text-decoration: none; }
.work-stage { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ui-text-muted); margin: 1rem 0 .4rem; font-weight: 600; }
.work-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .6rem; }
.work-tile { display: flex; flex-direction: column; gap: .15rem; padding: .6rem .75rem; border: 1px solid var(--ui-border); border-radius: .5rem;
  text-decoration: none; color: var(--ui-text); background: var(--ui-surface); }
.work-tile:hover, .work-tile:focus-visible { background: var(--ui-surface-muted); }
.work-tile-waiting { border-color: var(--ui-tone-attention-fg); box-shadow: inset 3px 0 0 var(--ui-tone-attention-fg); }
.work-tile-count { font-size: 1.5rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.work-tile:not(.work-tile-waiting) .work-tile-count { color: var(--ui-text-muted); }
.work-tile-label { font-weight: 500; }
.work-tile-detail { font-size: .8rem; color: var(--ui-text-muted); }
.work-tile-action { margin-top: auto; padding-top: .25rem; font-size: .8rem; font-weight: 600; color: rgb(var(--ui-link-rgb)); }

/* ---- The menu grouped by stage, with counts (CORE-215) ---- */
.app-sidebar .nav-group { margin: .75rem 0 .15rem; }
.app-sidebar .nav-group:first-child { margin-top: 0; }
.app-sidebar .nav-group-label { display: block; padding: 0 .65rem; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ui-sidebar-fg); opacity: .85; }
.app-sidebar .nav-link { position: relative; }
.app-sidebar .nav-count {  /* work waiting: the attention badge's colours, which pass the contrast tests in both themes */
  margin-left: auto; min-width: 1.5rem; padding: 0 .4rem; border-radius: 1rem; text-align: center; font-size: .75rem; font-weight: 600;
  line-height: 1.35rem; font-variant-numeric: tabular-nums; background: var(--ui-count-bg); color: var(--ui-count-fg); }
@media (min-width: 992px) {
  /* Collapsed: the headings are said, not shown; a count becomes a dot on its icon (its number is in the tooltip and said to screen readers). */
  html.nav-collapsed .app-sidebar .nav-group { margin: .4rem 0 0; }
  html.nav-collapsed .app-sidebar .nav-group-label {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  html.nav-collapsed .app-sidebar .nav-count {
    position: absolute; top: .3rem; right: .55rem; min-width: 0; width: .6rem; height: .6rem; padding: 0; font-size: 0; line-height: 0;
    border: 2px solid var(--ui-count-fg);
  }
}
