/* CYRUS design system -- tokens and shared components (KAN-128, 2.18.0).
 *
 * Plan: docs/Design and Development/DESIGN_ui_design_system.md
 * References: docs/design/references/ ; preview: docs/design/command_center_preview.html
 *
 * Templates use the semantic tokens below, never a hex. Dark is the default
 * (<html data-theme="dark">, set before paint in base.html); light is its own
 * set of steps, not an inversion. Per-org branding supplies --primary-color,
 * --secondary-color and --accent-color inline in base.html; this file reads
 * them only for the brand mark and accents, never for surfaces or text, so a
 * customer's colours cannot make a page unreadable.
 *
 * Moved here from the <style> block in templates/base.html, class names
 * unchanged. There is no compatibility layer: pages write the tokens (or the
 * token utilities in base.html's tailwind.config) themselves.
 */

/* ======================================================================= TOKENS */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f18;
  --surface-1: #111a28;
  --surface-2: #162133;
  --surface-3: #1c2940;
  --surface-sunk: #0d1420;
  --border: #1f2c41;
  --border-strong: #2a3a55;

  --text: #e6edf6;
  --text-secondary: #b6c2d3;
  --text-muted: #93a3ba;
  --text-faint: #64748b;
  --text-on-action: #ffffff;

  --action: #4d8dff;
  --action-hover: #6ba1ff;
  --action-soft: rgba(77, 141, 255, 0.14);
  --focus-ring: 0 0 0 3px rgba(77, 141, 255, 0.35);

  /* status: reserved for state, always with an icon or label */
  --ok: #22c55e;       --ok-soft: rgba(34, 197, 94, 0.14);       --ok-text: #86efac;
  --warn: #fab219;     --warn-soft: rgba(250, 178, 25, 0.14);    --warn-text: #fcd06a;
  --danger: #d03b3b;   --danger-soft: rgba(208, 59, 59, 0.18);   --danger-text: #ff8a8a;
  --info: #4da3ff;     --info-soft: rgba(77, 163, 255, 0.14);    --info-text: #9fd0ff;

  /* risk bands -- names match risk_bands.py */
  --band-critical: #d03b3b; --band-critical-soft: rgba(208, 59, 59, 0.18); --band-critical-text: #ff8a8a;
  --band-high:     #ec835a; --band-high-soft:     rgba(236, 131, 90, 0.16); --band-high-text:     #f6a383;
  --band-medium:   #fab219; --band-medium-soft:   rgba(250, 178, 25, 0.14); --band-medium-text:   #fcd06a;
  --band-low:      #0ca30c; --band-low-soft:      rgba(12, 163, 12, 0.16);  --band-low-text:      #86efac;

  /* machine fast, human verified */
  --machine: #a78bfa; --machine-soft: rgba(167, 139, 250, 0.14);
  --human:   #34d399; --human-soft:   rgba(52, 211, 153, 0.12);
  --waiting: #fbbf24; --waiting-soft: rgba(251, 191, 36, 0.12);

  /* charts: fixed order; validated on --surface-1 (dataviz validator) */
  --series-1: #22a685;
  --series-2: #6b7cf6;
  --glow: #4da3ff;
  /* Categorical identity for scatter-type charts: three slots only -- the
     dataviz reference palette validates all-pairs for its first three, so a
     fourth category folds into "Other" (--text-faint). Dark steps. */
  --cat-1: #3987e5;
  --cat-2: #d95926;
  --cat-3: #199e70;
  /* Regulatory map: in-force law count, 4 ordinal steps of one blue ramp,
     least to most (validated --ordinal on --surface-1; dark runs dark->light). */
  --map-1: #184f95; --map-2: #2a78d6; --map-3: #6da7ec; --map-4: #b7d3f6;

  /* shell */
  --topbar-bg: rgba(10, 15, 24, 0.92);
  --nav-bg: #0d1420;
  --nav-text: rgba(230, 237, 246, 0.72);
  --nav-text-active: #ffffff;
  --nav-hover: rgba(255, 255, 255, 0.06);
  --nav-active: rgba(77, 141, 255, 0.14);
  --nav-label: rgba(230, 237, 246, 0.38);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
  --overlay: rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface-1: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --surface-sunk: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #1f2937;
  --text-secondary: #374151;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;

  --action: #0b63c5;
  --action-hover: #0a52a3;
  --action-soft: #e8f1fc;
  --focus-ring: 0 0 0 3px rgba(11, 99, 197, 0.2);

  --ok-soft: #e9f7e9;      --ok-text: #166534;
  --warn-soft: #fff6e0;    --warn-text: #854d0e;
  --danger-soft: #fdecec;  --danger-text: #9b1c1c;
  --info-soft: #e8f1fc;    --info-text: #1e40af;

  --band-critical-soft: #fdecec; --band-critical-text: #9b1c1c;
  --band-high-soft:     #fdf0ea; --band-high-text:     #9a3412;
  --band-medium-soft:   #fff6e0; --band-medium-text:   #854d0e;
  --band-low-soft:      #e9f7e9; --band-low-text:      #166534;

  --cat-1: #2a78d6;
  --cat-2: #eb6834;
  --cat-3: #1baf7a;
  --map-1: #86b6ef; --map-2: #3987e5; --map-3: #1c5cab; --map-4: #0d366b;

  --machine: #6d28d9; --machine-soft: #f3edfd;
  --human:   #047857; --human-soft:   #e6f5ef;
  --waiting: #92400e; --waiting-soft: #fef3e2;

  --topbar-bg: #ffffff;
  --nav-bg: #14202f;
  --nav-label: rgba(255, 255, 255, 0.4);

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --overlay: rgba(0, 0, 0, 0.45);
}

:root {
  /* CYRUS's own mark (placeholder until design delivers the logo). Not per-org. */
  --brand-mark: #fcb813;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 60px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  /* Kept for the templates that still read them (sidebar partial, pages). */
  --sidebar-bg: var(--nav-bg);
  --sidebar-hover: var(--nav-hover);
  --sidebar-active: var(--nav-active);
  --sidebar-text: var(--nav-text);
  --sidebar-text-active: var(--nav-text-active);
}

/* ========================================================================= BASE */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}
a { color: var(--action); }
a:hover { color: var(--action-hover); }
h1, h2, h3 { color: var(--text); margin-bottom: 1rem; }
h4, h5, h6 { color: var(--text); }
hr { border: 0; border-top: 1px solid var(--border); }
code, pre { background: var(--surface-2); color: var(--text-secondary); border-radius: 4px; }
.num, td.num { font-variant-numeric: tabular-nums; }

/* Bare controls: ~455 inputs, selects and textareas carry no class. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
select, textarea {
  background-color: var(--surface-1);
  color: var(--text);
  border-color: var(--border-strong);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: var(--focus-ring); border-color: var(--action); }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }

/* ======================================================================= TOPBAR */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1100;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.sidebar-toggle { display: none; }
.topbar-logo {
  font-size: 1.2rem; font-weight: 700; text-decoration: none; color: var(--text);
  display: flex; align-items: center; gap: 0.5rem; white-space: nowrap;
}
.topbar-logo img { height: 34px; max-width: 160px; object-fit: contain; }
/* No org logo uploaded: the CYRUS logo (static/brand), one per theme. The
   dark-theme file is the horizontal reverse assembled from the designer's
   reverse artwork (approved 2026-10-05); the light one is as supplied. */
.brand-logo-light { display: none; }
:root[data-theme="light"] .brand-logo-dark { display: none; }
:root[data-theme="light"] .brand-logo-light { display: inline-block; }
@media print {
  .brand-logo-dark { display: none !important; }
  .brand-logo-light { display: inline-block !important; }
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
/* Kept for pages that still render the text wordmark. */
.topbar-wordmark { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.15em; color: var(--text); }
.topbar-wordmark::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  background: var(--brand-mark); margin-right: 0.55rem; vertical-align: 0.1em;
}
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }

.user-info { display: flex; flex-direction: column; align-items: flex-end; font-size: 0.85rem; line-height: 1.3; }
.user-name { font-weight: 600; color: var(--text); }
.user-org  { font-size: 0.75rem; color: var(--text-muted); }
.user-role {
  font-size: 0.7rem; background: var(--surface-3); color: var(--text-secondary);
  padding: 0.05rem 0.45rem; border-radius: 10px; margin-top: 0.1rem;
}

/* User menu: the name opens Usage and Change password. */
.user-menu { position: relative; }
.user-menu-btn {
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem; cursor: pointer; font-family: inherit; text-align: right;
}
.user-menu-btn:hover, .user-menu.active .user-menu-btn { background: var(--surface-2); border-color: var(--border); }
.user-menu-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.35rem; z-index: 1200;
}
.user-menu.active .user-menu-dropdown { display: block; }
.user-menu-dropdown a {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: 0.875rem;
}
.user-menu-dropdown a i { width: 16px; text-align: center; color: var(--text-muted); }
.user-menu-dropdown a:hover { background: var(--surface-2); color: var(--text); }

.btn-topbar {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  padding: 0.35rem 0.9rem; border-radius: var(--radius-sm);
  text-decoration: none; font-size: 0.85rem; transition: background 0.2s; white-space: nowrap;
  cursor: pointer; font-family: inherit;
}
.btn-topbar:hover { background: var(--surface-2); color: var(--text); }

.notification-bell, .theme-toggle {
  position: relative; color: var(--text-secondary); font-size: 1.1rem;
  padding: 0.4rem 0.5rem; text-decoration: none; border-radius: var(--radius-sm);
  transition: background 0.2s; background: transparent; border: 0; cursor: pointer;
}
.notification-bell:hover, .theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.notification-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: #fff;
  border-radius: 8px; padding: 1px 5px; font-size: 0.65rem; font-weight: bold;
}

/* Org switcher */
.org-switcher { position: relative; }
.org-switcher-btn {
  display: flex; align-items: center; gap: 0.4rem;
  background: var(--surface-1); border: 1px solid var(--border-strong); color: var(--text-secondary);
  padding: 0.35rem 0.8rem; border-radius: 999px; cursor: pointer; font-size: 0.82rem;
  transition: background 0.2s; font-family: inherit;
}
.org-switcher-btn:hover { background: var(--surface-2); color: var(--text); }
.org-switcher-badge {
  background: var(--warn); color: #1a1205;
  padding: 0.1rem 0.4rem; border-radius: 8px; font-size: 0.65rem; font-weight: 600;
}
.org-switcher-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface-1); border: 1px solid var(--border);
  min-width: 300px; max-height: 380px; overflow-y: auto;
  box-shadow: var(--shadow); border-radius: var(--radius); z-index: 1200;
}
.org-switcher.active .org-switcher-dropdown { display: block; }
.org-switcher-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--text); font-size: 0.9rem; }
.org-switcher-search { padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); }
.org-switcher-search input { width: 100%; padding: 0.4rem 0.6rem; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 0.85rem; }
.org-switcher-list { max-height: 220px; overflow-y: auto; }
.org-switcher-item {
  padding: 0.65rem 1rem; cursor: pointer; transition: background 0.15s;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.org-switcher-item:hover { background: var(--surface-2); }
.org-switcher-item.active { background: var(--action-soft); font-weight: 600; }
.org-switcher-item-name { color: var(--text); font-size: 0.88rem; }
.org-switcher-item-badge { background: var(--action); color: var(--text-on-action); padding: 0.1rem 0.45rem; border-radius: 8px; font-size: 0.68rem; }
.org-switcher-footer { padding: 0.65rem 1rem; border-top: 1px solid var(--border); text-align: center; }
.org-switcher-reset { color: var(--action); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.org-switcher-reset:hover { text-decoration: underline; }

/* ====================================================================== SIDEBAR */
.sidebar {
  position: fixed; top: var(--topbar-height); left: 0;
  width: var(--sidebar-width); height: calc(100vh - var(--topbar-height));
  background: var(--nav-bg); border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  transition: width 0.28s ease; z-index: 1050; pointer-events: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar-tab {
  background: rgba(255, 255, 255, 0.08); border: none; color: var(--nav-text);
  width: 28px; height: 28px; border-radius: 4px; cursor: pointer; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
}

.sidebar-section {
  padding: 1.25rem 0.85rem 0.3rem; font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--nav-label); white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .sidebar-section { opacity: 0; pointer-events: none; }

.sidebar-link {
  display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 1rem;
  color: var(--nav-text); text-decoration: none; font-size: 0.875rem;
  white-space: nowrap; overflow: hidden;
  transition: background 0.18s, color 0.18s; border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--nav-hover); color: var(--nav-text-active); }
.sidebar-link.active {
  background: var(--nav-active); color: var(--nav-text-active);
  border-left-color: var(--accent-color, #fcb813); font-weight: 600;
}
.sidebar-link i { width: 18px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.sidebar-link .link-text { transition: opacity 0.2s; }
.sidebar.collapsed .sidebar-link .link-text { opacity: 0; width: 0; }

.sidebar-group-header {
  display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 1rem;
  color: var(--nav-text); cursor: pointer; font-size: 0.875rem;
  white-space: nowrap; overflow: hidden;
  transition: background 0.18s, color 0.18s; border-left: 3px solid transparent; user-select: none;
}
.sidebar-group-header:hover { background: var(--nav-hover); color: var(--nav-text-active); }
.sidebar-group.has-active > .sidebar-group-header { color: var(--nav-text-active); border-left-color: rgba(255, 255, 255, 0.3); }
.sidebar-group-header i.icon { width: 18px; text-align: center; font-size: 0.95rem; flex-shrink: 0; }
.sidebar-group-header .label { flex: 1; transition: opacity 0.2s; }
.sidebar.collapsed .sidebar-group-header .label { opacity: 0; width: 0; }
.sidebar-chevron { font-size: 0.65rem; transition: transform 0.25s; flex-shrink: 0; }
.sidebar.collapsed .sidebar-chevron { opacity: 0; width: 0; }
.sidebar-group.open > .sidebar-group-header .sidebar-chevron { transform: rotate(180deg); }

.sidebar-group-items {
  list-style: none; overflow: hidden; max-height: 0;
  transition: max-height 0.28s ease; background: rgba(0, 0, 0, 0.18);
}
.sidebar-group.open > .sidebar-group-items { max-height: 800px; }
.nav-sublabel {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--nav-label); padding: 0.5rem 1rem 0.15rem 2.85rem;
  margin-top: 0.2rem; border-top: 1px solid rgba(255, 255, 255, 0.08); pointer-events: none;
}
.sidebar.collapsed .sidebar-group-items { max-height: 0 !important; }
.sidebar-group-items a {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 1rem 0.55rem 2.85rem;
  color: var(--nav-text); text-decoration: none; font-size: 0.82rem;
  transition: background 0.15s, color 0.15s; border-left: 3px solid transparent;
}
.sidebar-group-items a:hover { background: var(--nav-hover); color: var(--nav-text-active); }
.sidebar-group-items a.active {
  color: var(--nav-text-active); font-weight: 600;
  background: var(--nav-active); border-left-color: var(--accent-color, #fcb813);
}
.sidebar-group-items a i { width: 14px; text-align: center; font-size: 0.8rem; flex-shrink: 0; opacity: 0.7; }

/* ======================================================================= LAYOUT */
.layout-wrapper {
  margin-top: var(--topbar-height); margin-left: var(--sidebar-width);
  transition: margin-left 0.28s ease;
  min-height: calc(100vh - var(--topbar-height));
  display: flex; flex-direction: column;
}
.layout-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed-width); }
.main-content { flex: 1; padding: 2rem; isolation: isolate; }
.container { max-width: 1400px; margin: 0 auto; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 1040; }

.footer {
  background: var(--surface-sunk); border-top: 1px solid var(--border);
  color: var(--text-muted); padding: 1.5rem 2rem; text-align: center; font-size: 0.85rem;
}

/* =================================================================== COMPONENTS */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; margin-bottom: 2rem;
  box-shadow: var(--shadow); color: var(--text);
}

.btn {
  display: inline-block; padding: 0.7rem 1.4rem;
  border: 1px solid transparent; border-radius: var(--radius-sm); font-size: 0.95rem;
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, opacity 0.2s; text-align: center; font-family: inherit;
}
.btn-primary, .btn-success, .btn-info, .btn-view { background: var(--action); color: var(--text-on-action); }
.btn-primary:hover, .btn-success:hover, .btn-info:hover, .btn-view:hover { background: var(--action-hover); color: var(--text-on-action); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); color: var(--text); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.88; color: #fff; }
.btn-warning { background: var(--warn); color: #1a1205; }
.btn-warning:hover { opacity: 0.88; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.82rem; }

/* Page headers were brand gradients with white text; now a plain heading on
   the page, as in the references. The brand shows in the accent rule. */
.page-header, .branding-header, .admin-header, .page-header-modern {
  background: var(--surface-1); border: 1px solid var(--border);
  border-left: 4px solid var(--accent-color, #fcb813);
  color: var(--text); padding: 1.5rem 1.75rem; border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.page-header h1, .page-header h2,
.branding-header h1, .branding-header h2,
.admin-header h1, .admin-header h2,
.page-header-modern h1, .page-header-modern h2 {
  color: var(--text); margin: 0 0 0.35rem; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em;
}
.page-header p, .branding-header p, .admin-header p, .page-header-modern p {
  color: var(--text-muted); margin: 0; font-size: 0.98rem;
}

.alert { padding: 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: var(--ok-soft); border-color: var(--ok-soft); color: var(--ok-text); }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger-text); }
.alert-info    { background: var(--info-soft); border-color: var(--info-soft); color: var(--info-text); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn-soft); color: var(--warn-text); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--border-strong);
  font-weight: 600; color: var(--text-muted); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-sunk);
}
.table td { padding: 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 0.88rem; color: var(--text); }
.table tbody tr:hover { background: var(--surface-2); }
.table-container { overflow-x: auto; }

.form-select, .form-control {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 0.9rem; background: var(--surface-1); color: var(--text); font-family: inherit;
}
.form-select:focus, .form-control:focus { border-color: var(--action); outline: none; box-shadow: var(--focus-ring); }
.form-label { display: block; margin-bottom: 0.35rem; font-size: 0.88rem; color: var(--text-secondary); }
.fw-semibold { font-weight: 600; }
.text-danger { color: var(--danger-text); }
.text-muted { color: var(--text-muted); }

.loading { text-align: center; padding: 3rem; color: var(--text-muted); }
.spinner {
  border: 4px solid var(--surface-3); border-top: 4px solid var(--action);
  border-radius: 50%; width: 50px; height: 50px;
  animation: spin 1s linear infinite; margin: 0 auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.assessment-context-bar {
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text);
  padding: 0.85rem 1.25rem; border-radius: var(--radius);
  margin-bottom: 2rem; display: flex; align-items: center; gap: 1rem;
}
.context-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; white-space: nowrap; }
.context-icon  { font-size: 1.1rem; }
.context-selector {
  flex: 1; padding: 0.5rem 0.85rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 0.95rem; font-weight: 500;
  cursor: pointer; transition: border-color 0.2s;
}
.context-selector:hover { border-color: var(--action); }
.context-selector:focus { outline: none; border-color: var(--action); box-shadow: var(--focus-ring); }
.clear-filter {
  color: var(--text-secondary); text-decoration: none; padding: 0.5rem 1rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-weight: 500; transition: background 0.2s; white-space: nowrap;
}
.clear-filter:hover { background: var(--surface-2); color: var(--text); }

/* Collapsible list sections -- used across admin pages */
.collapsible-header {
  display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
  padding: 0.5rem 0.6rem; background: var(--surface-2); border-radius: var(--radius-sm);
  margin-bottom: 0.25rem; user-select: none;
}
.collapsible-header:hover { background: var(--surface-3); }
.collapsible-header .ch-icon { font-size: 0.65rem; color: var(--text-faint); transition: transform 0.15s; width: 12px; text-align: center; }
.collapsible-header.open .ch-icon { transform: rotate(90deg); }
.collapsible-header .ch-title { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.collapsible-header .ch-count {
  font-size: 0.68rem; background: var(--surface-3); color: var(--text-muted);
  padding: 0.1rem 0.4rem; border-radius: 8px; margin-left: auto;
}
.sidebar .collapsible-body { display: none; padding-left: 0.25rem; }
.sidebar .collapsible-body.open { display: block; }

/* ---- new: chips, bands, panels, stat tiles, decision band ------------------ */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip-machine { background: var(--machine-soft); color: var(--machine); }
.chip-human   { background: var(--human-soft); color: var(--human); }
.chip-waiting { background: var(--waiting-soft); color: var(--waiting); }

.band {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px;
  padding: 2px 8px 2px 6px; border-radius: 6px; white-space: nowrap;
}
.band::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.band-critical { background: var(--band-critical-soft); color: var(--band-critical-text); }
.band-high     { background: var(--band-high-soft);     color: var(--band-high-text); }
.band-medium   { background: var(--band-medium-soft);   color: var(--band-medium-text); }
.band-low      { background: var(--band-low-soft);      color: var(--band-low-text); }

.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { font-size: 14px; font-weight: 600; margin: 0; }
.panel-head .meta { color: var(--text-faint); font-size: 12px; }
.panel-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 14px 16px; }

.kpi { padding: 14px 16px; }
.kpi .kpi-label { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.kpi .kpi-value { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; color: var(--text); }
.kpi .kpi-delta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.decide-band { border-left: 3px solid var(--accent-color, #fcb813); }

/* Public demo (demo_access.py): the login page's entry and the read-only banner. */
.demo-entry { text-align: center; }
.demo-entry-lead { margin: 0 0 1.25rem; color: var(--text); line-height: 1.5; }
.demo-entry-form { text-align: left; }
.demo-check { display: flex; gap: 0.55rem; align-items: flex-start; font-weight: 400; font-size: 0.85rem;
  line-height: 1.45; margin-bottom: 0.5rem; }
.demo-check input { width: auto; margin-top: 0.2rem; }
.demo-entry-note { margin-top: 0.4rem; font-size: 0.8rem; color: var(--text-muted); }
.demo-banner { margin: 0 0 1rem; padding: 0.6rem 0.9rem; border-radius: 8px; font-size: 0.88rem;
  background: var(--machine-soft); border: 1px solid var(--machine); color: var(--text); }
.demo-banner a { color: var(--action); margin-left: 0.4rem; }

/* The demo tour (demo_tour.py): a callout on each page and the welcome page. */
.demo-callout { display: flex; gap: 1rem; align-items: flex-start; margin: 0 0 1rem;
  padding: 0.9rem 1rem; border-radius: var(--radius); background: var(--surface-1);
  border: 1px solid var(--border); border-left: 4px solid var(--machine); box-shadow: var(--shadow); }
.demo-callout[hidden] { display: none; }
.demo-callout-text { flex: 1; font-size: 0.9rem; color: var(--text-secondary); }
.demo-callout-text p { margin: 0.3rem 0 0; }
.demo-callout-title { margin: 0; font-size: 0.98rem; font-weight: 600; color: var(--text); }
.demo-callout-title i { color: var(--machine); margin-right: 0.3rem; }
.demo-callout-about { margin-top: 0.45rem; }
.demo-callout-about summary { cursor: pointer; color: var(--action); font-weight: 500; }
.demo-callout-about p { line-height: 1.55; }
.demo-callout-look { margin-top: 0.55rem; }
.demo-callout-look > strong { color: var(--text); }
.demo-callout-look ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.demo-callout-look li { margin: 0.2rem 0; }
.demo-callout-look-label { color: var(--text); font-weight: 600; }
.demo-callout-show { margin-left: 0.35rem; padding: 0.05rem 0.45rem; font-size: 0.78rem;
  border: 1px solid var(--machine); border-radius: var(--radius-sm); background: none;
  color: var(--machine); cursor: pointer; white-space: nowrap; }
.demo-callout-show:hover { background: var(--surface-2); }
.demo-callout-show:focus-visible { outline: 2px solid var(--focus-ring); }
.demo-callout-show[hidden] { display: none; }
/* The Locations page map (static/js/location-map.js). */
.loc-map { width: 100%; height: 420px; }
.loc-map-legend { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.loc-map-key { display: inline-flex; align-items: center; gap: 0.25rem; }
.loc-map-dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 1px solid var(--border-strong);
  display: inline-block; }
/* What "Show me" points at. Outline, not border, so nothing on the page moves. */
.demo-spotlight { outline: 3px solid var(--machine); outline-offset: 4px;
  border-radius: var(--radius-sm); animation: demo-spotlight-pulse 1.2s ease-in-out 3; }
@keyframes demo-spotlight-pulse {
  0%, 100% { outline-color: var(--machine); }
  50% { outline-color: transparent; } }
.demo-callout-close { background: none; border: 0; color: var(--text-muted); font-size: 1.3rem;
  line-height: 1; cursor: pointer; padding: 0 0.2rem; }
.demo-callout-close:hover { color: var(--text); }
.demo-callout-close:focus-visible { outline: 2px solid var(--focus-ring); border-radius: var(--radius-sm); }
.demo-welcome { max-width: 960px; }
.demo-welcome-story { margin-bottom: 1.5rem; }
.demo-welcome-story p { margin: 0 0 0.7rem; color: var(--text-secondary); line-height: 1.6; }
.demo-welcome-story p:last-child { margin-bottom: 0; }
.demo-welcome-heading { font-size: 1.05rem; font-weight: 600; margin: 0 0 0.75rem; }
.demo-welcome-paths { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.demo-welcome-path { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.9rem 1rem;
  height: 100%; color: var(--text); text-decoration: none; }
.demo-welcome-path:hover, .demo-welcome-path:focus-visible { border-color: var(--action); }
.demo-welcome-path-title { font-weight: 600; color: var(--action); }
.demo-welcome-path-line { font-size: 0.88rem; color: var(--text-muted); }
.demo-welcome-note { font-size: 0.85rem; color: var(--text-muted); }

/* ==================================================================== RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-width); transform: translateX(-100%); transition: transform 0.28s ease; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .layout-wrapper { margin-left: 0 !important; }
  .main-content { padding: 1.25rem; }
  .user-org, .user-role { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Printing is always light: exports and printed reports. */
@media print {
  :root, :root[data-theme] { color-scheme: light; --bg: #fff; --surface-1: #fff; --surface-2: #fff; --surface-3: #f3f4f6;
          --border: #d1d5db; --text: #111827; --text-secondary: #374151; --text-muted: #4b5563; }
  .topbar, .sidebar, .sidebar-overlay, #vciso-fab { display: none !important; }
  .layout-wrapper { margin: 0 !important; }
}
