/* ==========================================================================
   Holdings design system
   ========================================================================== */

:root {
  --color-primary: #4f46e5;
  --color-primary-dark: #4338ca;
  --color-primary-light: #6366f1;
  --color-accent: #06b6d4;

  /* Softer, warmer neutrals than plain gray — closer to the pale-blue/white
     "airy SaaS" surfaces this was asked to move toward, still restrained
     enough for a finance tool (no decorative accent colors). */
  --color-bg: #eef2fb;
  --color-surface: #ffffff;
  --color-surface-alt: #f4f6fc;
  --color-border: #e1e5f2;
  --color-text: #171933;
  --color-text-muted: #666b8a;

  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;

  /* Fixed status palette for the queue dashboard (dataviz skill) — same steps in light and
     dark, deliberately distinct from the pill/--color-success family above so a chart status
     mark never impersonates a categorical series. Never themed. */
  --viz-status-good: #0ca30c;
  --viz-status-warning: #fab219;
  --viz-status-critical: #d03b3b;

  /* Categorical palette for the dealer allocation bar — fixed hue order,
     CVD-safe adjacent pairs (validated per the dataviz skill's default palette). */
  --dealer-color-1: #2a78d6;
  --dealer-color-2: #eb6834;
  --dealer-color-3: #1baf7a;
  --dealer-color-4: #eda100;
  --dealer-color-5: #e87ba4;
  --dealer-color-6: #008300;
  --dealer-color-7: #4a3aa7;
  --dealer-color-8: #e34948;

  /* Tighter than the previous pass — 10-28px read as a consumer/marketing-site
     look under real comparison (Stripe's own dashboard uses ~4-8px). A finance
     tool earns trust by looking precise, not soft. */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(23, 25, 51, 0.05);
  --shadow-md: 0 2px 6px rgba(23, 25, 51, 0.07);
  --shadow-lg: 0 6px 16px rgba(23, 25, 51, 0.1);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition: all 0.18s var(--ease);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  /* :not([data-bs-theme="light"]) is the whole fix — without it, this block has
     no idea an explicit "Light" choice (Settings toggle) exists, and silently
     wins back over it since prefers-color-scheme keeps matching regardless of
     the attribute. Bootstrap's own dark-mode CSS is attribute-gated (that's
     why tables, a native Bootstrap component, were the one thing that already
     respected the toggle correctly) — everything using our own --color-*
     variables needs the same guard. */
  :root:not([data-bs-theme="light"]) {
    --color-bg: #0f1120;
    --color-surface: #171a2e;
    --color-surface-alt: #1e2138;
    --color-border: #2a2e4a;
    --color-text: #eef0fb;
    --color-text-muted: #9498b8;
    --color-success-bg: rgba(22, 163, 74, 0.16);
    --color-danger-bg: rgba(220, 38, 38, 0.18);
    --color-warning-bg: rgba(217, 119, 6, 0.18);

    --dealer-color-1: #3987e5;
    --dealer-color-2: #d95926;
    --dealer-color-3: #199e70;
    --dealer-color-4: #c98500;
    --dealer-color-5: #d55181;
    --dealer-color-6: #008300;
    --dealer-color-7: #9085e9;
    --dealer-color-8: #e66767;

    color-scheme: dark;
  }
}

/* Same values, driven by the data-bs-theme attribute the inline layout script
   sets before paint — this is what actually keeps Bootstrap's own component
   colors (.text-muted, .card, .dropdown-menu, etc.) in sync with ours. */
:root[data-bs-theme="dark"] {
  --color-bg: #0f1120;
  --color-surface: #171a2e;
  --color-surface-alt: #1e2138;
  --color-border: #2a2e4a;
  --color-text: #eef0fb;
  --color-text-muted: #9498b8;
  --color-success-bg: rgba(22, 163, 74, 0.16);
  --color-danger-bg: rgba(220, 38, 38, 0.18);
  --color-warning-bg: rgba(217, 119, 6, 0.18);

  --dealer-color-1: #3987e5;
  --dealer-color-2: #d95926;
  --dealer-color-3: #199e70;
  --dealer-color-4: #c98500;
  --dealer-color-5: #d55181;
  --dealer-color-6: #008300;
  --dealer-color-7: #9085e9;
  --dealer-color-8: #e66767;

  color-scheme: dark;
}

/* Bootstrap's own utilities aren't aware of our palette — pin the ones we use
   directly so they never fall back to light-mode-only colors on a dark page. */
.text-muted {
  color: var(--color-text-muted) !important;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  margin-bottom: 0;
  min-height: 100vh;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-primary-dark);
}

h1, h2, h3, h4, h5 {
  color: var(--color-text);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   Page load animation
   ========================================================================== */

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-content {
  animation: fade-in-up 0.45s var(--ease) both;
}

@media (prefers-reduced-motion: reduce) {
  .page-content, * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   Content area
   ========================================================================== */

.app-content {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
}

@media (max-width: 767.98px) {
  .app-content {
    padding: 1.25rem 1rem 2.5rem;
  }
}

/* ==========================================================================
   App shell — sidebar + topbar
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  flex-direction: column;
  padding: 1.5rem 1.1rem;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--color-text) !important;
  padding: 0.4rem 0.5rem;
  margin-bottom: 1.5rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--color-primary) 45%, transparent);
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sidebar-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--color-text-muted) !important;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-nav-link:hover {
  color: var(--color-text) !important;
  background: var(--color-surface-alt);
}

/* Sub-items under a sidebar link (Capture -> each supplier), indented under its icon. */
.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  margin: -0.1rem 0 0.2rem 1.45rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--color-border, rgba(127, 127, 127, 0.25));
}

.sidebar-nav-sublink {
  color: var(--color-text-muted) !important;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.sidebar-nav-sublink:hover {
  color: var(--color-text) !important;
  background: var(--color-surface-alt);
}

.sidebar-nav-sublink.active {
  color: var(--color-primary) !important;
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  font-weight: 700;
}

.capture-card {
  transition: var(--transition);
}

.capture-card:hover {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--color-primary) 40%, transparent);
}

.sidebar-nav-link.active {
  color: var(--color-primary) !important;
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  font-weight: 700;
  /* inset, not a positioned pseudo-element — .app-sidebar's overflow-y: auto
     implicitly forces overflow-x: auto too, which would clip anything drawn
     outside the link's own box. */
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Mock mode (a SuperAdmin viewing as someone else): a bar pinned to the bottom of every page,
   the same loud amber in both themes so it can't be missed. */
.mock-banner {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 1060;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  background: #fbbf24;
  color: #1f1300;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
}

.mock-banner-meta {
  margin-left: 0.5rem;
  opacity: 0.8;
}

.mock-banner-blocked {
  margin-top: 0.15rem;
  font-weight: 600;
}

.app-main:has(.mock-banner) {
  padding-bottom: 4.5rem;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.75rem;
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1030;
  transition: var(--transition);
}

.topbar-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  flex-shrink: 0;
  transition: var(--transition);
}

.topbar-menu-btn:hover {
  background: var(--color-surface-alt);
}

.topbar-menu-btn svg {
  width: 18px;
  height: 18px;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.topbar-actions {
  flex-shrink: 0;
}

.offcanvas {
  background: var(--color-surface);
  color: var(--color-text);
}

.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: none;
  background: transparent;
  padding: 0.3rem 0.6rem 0.3rem 0.3rem;
  border-radius: var(--radius-pill);
  transition: var(--transition);
  color: var(--color-text) !important;
}

.user-menu-toggle:hover {
  background: var(--color-surface-alt);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-menu-toggle::after {
  display: none;
}

/* ==========================================================================
   Cards / surfaces
   ========================================================================== */

.surface-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  transition: var(--transition);
}

/* ==========================================================================
   Sectioned forms (invoice capture, etc.) — labeled zones instead of one
   undifferentiated card, so a form with several distinct concerns (document,
   supplier, totals, dealers) reads as a sequence of clear steps.
   ========================================================================== */

.form-section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}

.form-section + .form-section {
  border-top: 1px solid var(--color-border);
  margin-top: 1.5rem;
  padding-top: 1.5rem;
}

.form-section-title {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.form-actions {
  display: flex;
  gap: 0.6rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.6rem;
  margin: 0;
}

.page-header .page-subtitle {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-top: 0.15rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.5rem 1.1rem;
  transition: var(--transition);
  border: 1px solid transparent;
}

.btn:active {
  transform: scale(0.97);
}

/* Flat, not gradient+glow+lift — a CTA-button treatment reads as a marketing
   site, not a tool people use all day. A solid fill with a plain darken on
   hover is what Stripe/Linear-style app buttons actually do. */
.btn-primary {
  background: var(--color-primary);
  border: none;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.btn-secondary {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-border);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger);
  border: none;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-outline-secondary {
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

.btn-link {
  font-weight: 600;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--color-primary) 25%, transparent);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  margin-bottom: 0;
  color: var(--color-text);
}

.table thead th {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  font-weight: 700;
  border-bottom: 1px solid var(--color-border);
  padding: 0.85rem 1.1rem;
}

/* A sortable column's heading (Invoices list): the heading itself is the link. */
.table thead th .sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.table thead th .sort-link:hover,
.table thead th .sort-link.is-sorted {
  color: var(--color-primary);
}

.table thead th .sort-arrow {
  margin-left: 0.3rem;
  opacity: 0.45;
}

.table thead th .sort-link.is-sorted .sort-arrow {
  opacity: 1;
}

.table td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.table tbody tr {
  transition: var(--transition);
  animation: fade-in-up 0.35s var(--ease) both;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--color-surface-alt);
}

.table-actions a, .table-actions .btn-link {
  font-weight: 600;
  margin-right: 0.75rem;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

/* "Page 2 of 3" on the left, the page links on the right; stacked on a phone. */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pager-status {
  color: var(--color-text-muted);
  font-size: 0.88rem;
}

.pagination {
  gap: 0.3rem;
  flex-wrap: wrap;
}

.page-link {
  min-width: 2.25rem;
  text-align: center;
  white-space: nowrap;
}

.page-item.disabled .page-link.page-gap {
  border-color: transparent;
  background: transparent;
  opacity: 1;
}

.page-item:not(:first-child) .page-link {
  margin-left: 0;
}

.page-link {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm) !important;
  color: var(--color-text-muted);
  background: var(--color-surface);
  font-weight: 600;
  font-size: 0.88rem;
  transition: var(--transition);
}

.page-link:hover {
  color: var(--color-text);
  background: var(--color-surface-alt);
  border-color: var(--color-border);
}

.page-item.active .page-link {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.page-item.disabled .page-link {
  color: var(--color-text-muted);
  opacity: 0.5;
  background: var(--color-surface);
  border-color: var(--color-border);
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--color-text);
  margin-bottom: 0.3rem;
}

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0.55rem 0.85rem;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary);
}

.form-check-input {
  border-radius: 5px;
  border: 1px solid var(--color-border);
}

.form-check-input:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.form-text {
  color: var(--color-text-muted);
}

.dealer-checkbox-list {
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border) !important;
  padding: 0.4rem;
}

/* Deliberately not Bootstrap's .form-check (float + negative-margin checkbox
   positioning) — a custom padding override on that pattern is exactly what let
   a checkbox visually drift from the row it belonged to, so a click could land
   on the wrong dealer. The whole row is a <label>, plain flex, no floats. */
.dealer-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.dealer-row:hover {
  background: var(--color-surface);
}

.dealer-row input[type="checkbox"] {
  flex-shrink: 0;
  width: 1.05em;
  height: 1.05em;
  margin: 0;
  border-radius: 5px;
  border: 1px solid var(--color-border);
}

.dealer-row input[type="checkbox"]:checked {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.dealer-row-name {
  color: var(--color-text);
  font-weight: 500;
}

.dealer-group-heading {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  padding: 0.6rem 0.6rem 0.2rem;
}

.dealer-group-heading:first-child {
  padding-top: 0.2rem;
}

.dealer-row-location {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  margin-left: 0.4rem;
}

.dealer-chip-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.dealer-chip-group-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.15rem;
}

.chip-filter {
  display: inline-block;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.22rem 0.7rem;
  border-radius: var(--radius-pill);
  transition: var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.chip-filter:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chip-filter-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

/* ==========================================================================
   Supplier autocomplete (invoice capture)
   ========================================================================== */

.supplier-search-field {
  position: relative;
}

.supplier-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: 0.25rem;
  max-height: 280px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.supplier-suggestion {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

.supplier-suggestion:hover,
.supplier-suggestion.active {
  background: var(--color-surface-alt);
}

.supplier-suggestion-name {
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.supplier-suggestion-meta {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.supplier-match-hint {
  margin-top: 0.4rem;
}

.supplier-match-hint:empty {
  display: none;
}

/* ==========================================================================
   Allocation bar (draggable dealer split)
   ========================================================================== */

.allocation-bar {
  display: flex;
  height: 56px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  transition: var(--transition);
}

.allocation-bar-over {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-danger) 25%, transparent);
}

.allocation-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-width: 3px;
  transition: width 0.12s var(--ease);
}

.allocation-segment-unallocated {
  background-image: repeating-linear-gradient(
    45deg,
    var(--color-surface-alt),
    var(--color-surface-alt) 6px,
    var(--color-border) 6px,
    var(--color-border) 12px
  );
}

.allocation-segment-label {
  color: white;
  font-size: 0.78rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
  pointer-events: none;
}

.allocation-divider {
  width: 12px;
  margin: 0 -6px;
  z-index: 2;
  flex-shrink: 0;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.allocation-divider::after {
  content: "";
  width: 4px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border);
  transition: var(--transition);
}

.allocation-divider:hover::after,
.allocation-divider:focus-visible::after {
  background: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.allocation-divider:focus-visible {
  outline: none;
}

.allocation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin-top: 0.6rem;
}

.allocation-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.allocation-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ==========================================================================
   Badges / status pills
   ========================================================================== */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.pill-role {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
}

.pill-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.pill-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.pill-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.pill-muted {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert {
  border-radius: var(--radius-md);
  border: 1px solid transparent;
}

.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.alert-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* ==========================================================================
   Feature icon (auth result pages — LoginFailed, NotRegistered)
   ========================================================================== */

.feature-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 1.25rem 0;
  margin-top: 3rem;
}

/* ==========================================================================
   Theme toggle (Settings)
   ========================================================================== */

.theme-toggle {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.3rem;
  background: var(--color-surface-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: var(--transition);
  cursor: pointer;
}

.theme-option svg {
  width: 16px;
  height: 16px;
}

.theme-option:hover {
  color: var(--color-text);
}

.theme-option-active {
  background: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Auth / centered card pages
   ========================================================================== */

.auth-card-wrap {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  max-width: 420px;
  width: 100%;
  text-align: center;
}

/* ==========================================================================
   Orchestrator queue dashboard (filter pills, KPI tiles, status bar)
   ========================================================================== */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1.25rem;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-tile {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem 1.25rem;
}

.stat-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.stat-tile-icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.stat-tile-icon-primary {
  background: color-mix(in srgb, var(--color-primary) 12%, transparent);
  color: var(--color-primary);
}

.stat-tile-icon-good {
  background: color-mix(in srgb, var(--viz-status-good) 16%, transparent);
  color: var(--viz-status-good);
}

.stat-tile-icon-warning {
  background: color-mix(in srgb, var(--viz-status-warning) 22%, transparent);
  color: var(--viz-status-warning);
}

.stat-tile-icon-critical {
  background: color-mix(in srgb, var(--viz-status-critical) 16%, transparent);
  color: var(--viz-status-critical);
}

.stat-tile-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.15;
}

.stat-tile-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.status-bar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.status-bar-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.status-bar {
  display: flex;
  height: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface-alt);
}

.status-bar-segment {
  height: 100%;
}

.status-bar-segment:not(:last-child) {
  margin-right: 2px;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.5rem;
  margin-top: 0.9rem;
}

.status-legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.status-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* "New version / signed out" banner - see the version check in site.js. */
.app-version-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1090;
  width: min(40rem, calc(100% - 2rem));
  margin: 0;
}

/* Feedback - a thread's messages; the Holdings team's answers sit to the right, tinted. */
.feedback-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.feedback-message {
  max-width: 48rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}

.feedback-message-answer {
  align-self: flex-end;
  background: var(--color-surface-alt);
  border-left: 3px solid var(--color-primary);
}

.feedback-message-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.feedback-message-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
