/*
 * COVR console design tokens and styles.
 *
 * Every color is a token. Light and dark values were chosen for WCAG 2.2 AA:
 * text >= 4.5:1 on the surfaces it sits on, borders of controls and the focus ring
 * >= 3:1. html[data-theme] is always "light" or "dark": the user's choice, else the
 * system preference.
 */

:root {
  color-scheme: light;

  /* Surfaces */
  --surface-app: #f5f6f8;
  --surface-raised: #fff;
  --surface-sunken: #eef0f3;
  --surface-hover: #e9ecf1;
  --surface-selected: #e3eafb;
  --surface-nav: #fbfbfc;
  --surface-overlay: rgb(16 20 27 / 45%);

  /* Text */
  --text-strong: #11151b;
  --text: #1f252d;
  --text-muted: #4d5562;
  --text-on-accent: #fff;

  /* Lines */
  --border: #dde1e7;
  --border-control: #767e8b;
  --border-strong: #5c6470;

  /* Accent and focus */
  --accent: #2550c4;
  --accent-hover: #1d42a6;
  --accent-text: #2048b5;
  --focus-ring: #2550c4;

  /* Status tones: background, text and border for chips and banners */
  --tone-info-bg: #e7eefc;
  --tone-info-text: #1c45a8;
  --tone-info-border: #6f8fdb;
  --tone-success-bg: #e5f4ea;
  --tone-success-text: #155f2c;
  --tone-success-border: #5fa576;
  --tone-warning-bg: #fdf0d5;
  --tone-warning-text: #744600;
  --tone-warning-border: #c58a1a;
  --tone-danger-bg: #fde8e6;
  --tone-danger-text: #9e2218;
  --tone-danger-border: #d06a60;
  --tone-neutral-bg: #eceef2;
  --tone-neutral-text: #3c434e;
  --tone-neutral-border: #8a919c;

  /* Type */
  --font-sans:
    "Inter var", "Inter", system-ui, -apple-system, "Segoe UI", roboto,
    "Helvetica Neue", arial, sans-serif;
  --font-mono:
    ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", menlo, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;

  /* Space, radius, elevation */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-raised: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-overlay:
    0 12px 32px rgb(16 24 40 / 18%), 0 2px 6px rgb(16 24 40 / 10%);
  --nav-width: 232px;
  --topbar-height: 56px;
  --form-footer-height: 4.5rem;
  --motion-fast: 120ms;
}

/* Dark. The head script and the theme service always set data-theme, from the user's
 * choice or else the system preference. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-app: #0d1015;
  --surface-raised: #161a21;
  --surface-sunken: #11151b;
  --surface-hover: #212732;
  --surface-selected: #1c2a4a;
  --surface-nav: #11151b;
  --surface-overlay: rgb(0 0 0 / 60%);
  --text-strong: #f2f4f7;
  --text: #e2e6ec;
  --text-muted: #a5adba;
  --text-on-accent: #0d1015;
  --border: #2a303b;
  --border-control: #77808e;
  --border-strong: #8d96a3;
  --accent: #85a9ff;
  --accent-hover: #a6c0ff;
  --accent-text: #93b3ff;
  --focus-ring: #93b3ff;
  --tone-info-bg: #16264a;
  --tone-info-text: #a8c2ff;
  --tone-info-border: #4d6fbf;
  --tone-success-bg: #11301d;
  --tone-success-text: #86dca2;
  --tone-success-border: #3f8a58;
  --tone-warning-bg: #36270a;
  --tone-warning-text: #f3c46a;
  --tone-warning-border: #a77a22;
  --tone-danger-bg: #3a1714;
  --tone-danger-text: #ffa39a;
  --tone-danger-border: #b35a51;
  --tone-neutral-bg: #232832;
  --tone-neutral-text: #c9cfd8;
  --tone-neutral-border: #6c7584;
  --shadow-raised: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-overlay: 0 16px 40px rgb(0 0 0 / 55%);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-fast: 0ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Base ---------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  /* Keep focused or scrolled-to elements clear of the sticky top bar and the sticky
     form footer (WCAG 2.4.11, focus not obscured). The page itself is the scroller. */
  scroll-padding-top: calc(var(--topbar-height) + var(--space-4));
  scroll-padding-bottom: calc(var(--form-footer-height) + var(--space-4));
  font-size: 16px;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-app);
  font-feature-settings: "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text-strong);
  line-height: 1.25;
  font-weight: 600;
}

h1 {
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--text-lg);
}

h3 {
  font-size: var(--text-md);
}

p {
  margin: 0;
}

a {
  color: var(--accent-text);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

[tabindex="-1"]:focus {
  outline: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.95em;

  /* Hashes, references and file names have no spaces: let them wrap rather than make
     the page scroll sideways at 320 px (WCAG 1.4.10). */
  overflow-wrap: anywhere;
}

/* Placeholders are text: the browser default grey is 3.8:1 in the dark theme (1.4.3). */
::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

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

.icon {
  width: 1rem;
  height: 1rem;
  flex: none;
  vertical-align: -0.15em;
}

/* Skip link ------------------------------------------------------------------ */

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--surface-raised);
  color: var(--accent-text);
  border: 2px solid var(--focus-ring);
  border-radius: var(--radius-md);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* App shell ------------------------------------------------------------------ */

.shell {
  display: grid;
  grid-template-columns: var(--nav-width) minmax(0, 1fr);
  min-height: 100vh;

  /* Paint the navigation column on the shell so it runs the full page height. */
  background: linear-gradient(
    to right,
    var(--surface-nav) calc(var(--nav-width) - 1px),
    var(--border) calc(var(--nav-width) - 1px) var(--nav-width),
    transparent var(--nav-width)
  );
}

.side-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  gap: var(--space-2);
}

.nav-section .nav-heading {
  margin-top: 0;
  margin-bottom: 2px;
}

.product {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-2);
  color: var(--text-strong);
  text-decoration: none;
}

.covr-mark {
  width: 2.5rem;
  height: auto;
  flex: none;
}

.product-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.product-area {
  color: var(--text-muted);
  font-weight: 500;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-heading {
  margin: var(--space-2) var(--space-2) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-heading-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: var(--space-2) 0 var(--space-1);
  padding: 0.2rem var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.nav-heading-btn:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.nav-chevron {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  transition: transform var(--motion-fast) ease;
}

.nav-chevron.expanded {
  transform: rotate(90deg);
}

.nav-link-recent {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* Topbar notification bell & slide-out drawer */
.notification-trigger {
  position: relative;
}

.bell-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--tone-danger-text);
  color: var(--text-on-accent);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
}

.drawer-scrim {
  position: fixed;
  inset: 0;
  border: 0;
  background: var(--surface-overlay);
  cursor: pointer;
}

.notification-drawer {
  position: relative;
  z-index: 1;
  width: min(400px, 92vw);
  height: 100%;
  background: var(--surface-raised);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-overlay);
  display: flex;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.drawer-header h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.drawer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.notification-item {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-app);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.notification-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-control);
}

.notification-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.notification-title {
  font-weight: 600;
  color: var(--text-strong);
}

.notification-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.notification-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

/* Internal staff chat drawer */
.chat-compliance-banner {
  padding: 0.45rem var(--space-5);
  font-size: var(--text-xs);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
}

.chat-title-block {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-claim-link {
  margin-top: 0.15rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: var(--text-xs);
  cursor: pointer;
  text-decoration: underline;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-bubble {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-app);
}

.chat-bubble.mine {
  background: var(--surface-selected);
  border-color: var(--tone-info-border);
}

.chat-bubble-meta {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.chat-bubble-body {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-strong);
  white-space: pre-wrap;
}

.chat-composer {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
}

.chat-composer .input {
  flex: 1;
}

.chat-new-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-new-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.22rem var(--space-2);
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.nav-link:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  background: var(--surface-selected);
  color: var(--accent-text);
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-count {
  margin-left: auto;
  min-width: 1.5rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--tone-danger-bg);
  color: var(--tone-danger-text);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
}

.nav-soon {
  margin-left: auto;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: var(--tone-neutral-bg);
  color: var(--tone-neutral-text);
  font-size: var(--text-xs);
  font-weight: 500;
}

.nav-footer {
  margin-top: auto;
  padding: var(--space-3) var(--space-2) 0;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--space-6);
  background: color-mix(in srgb, var(--surface-app) 92%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.topbar .menu-button,
.side-nav .nav-close {
  display: none;
}

.palette-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: min(440px, 100%);
  height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.palette-trigger:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.palette-trigger .label {
  flex: 1;
  text-align: left;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 0.35em;
  border: 1px solid var(--border-control);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  line-height: 1.5;
  text-align: center;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: var(--space-2);
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface-selected);
  color: var(--accent-text);
  font-size: var(--text-xs);
  font-weight: 700;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta .role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

main {
  flex: 1;
  padding: var(--space-6) var(--space-6) var(--space-8);
}

.page {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 1360px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-header .subtitle {
  margin-top: var(--space-1);
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.breadcrumbs li + li::before {
  content: "/";
  margin-right: var(--space-2);
  color: var(--text-muted);
}

/* Buttons -------------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 2.25rem;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-strong);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background var(--motion-fast),
    border-color var(--motion-fast);
}

.button:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--text-on-accent);
}

.button.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.button.subtle {
  border-color: transparent;
  background: transparent;
  color: var(--text);
}

.button.subtle:hover {
  background: var(--surface-hover);
}

.button.small {
  height: 1.875rem;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.button.icon-only {
  width: 2.25rem;
  padding: 0;
}

.button[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Cards and sections --------------------------------------------------------- */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.card-header .hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.card-body {
  padding: var(--space-4) var(--space-5);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.grid-main-side {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-5);
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* Summary strip -------------------------------------------------------------- */

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
}

.metric-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-weight: 500;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 650;
  color: var(--text-strong);
  line-height: 1.1;
}

.metric-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.metric.danger {
  border-color: var(--tone-danger-border);
  box-shadow: inset 3px 0 0 var(--tone-danger-border);
}

.metric.danger .metric-label {
  color: var(--tone-danger-text);
}

.metric.warning {
  border-color: var(--tone-warning-border);
  box-shadow: inset 3px 0 0 var(--tone-warning-border);
}

.metric.warning .metric-label {
  color: var(--tone-warning-text);
}

/* Chips ---------------------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.05rem 0.5rem 0.05rem 0.4rem;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.chip .icon {
  width: 0.8rem;
  height: 0.8rem;
}

.chip.info {
  --chip-bg: var(--tone-info-bg);
  --chip-text: var(--tone-info-text);
  --chip-border: var(--tone-info-border);
}

.chip.success {
  --chip-bg: var(--tone-success-bg);
  --chip-text: var(--tone-success-text);
  --chip-border: var(--tone-success-border);
}

.chip.warning {
  --chip-bg: var(--tone-warning-bg);
  --chip-text: var(--tone-warning-text);
  --chip-border: var(--tone-warning-border);
}

.chip.danger {
  --chip-bg: var(--tone-danger-bg);
  --chip-text: var(--tone-danger-text);
  --chip-border: var(--tone-danger-border);
}

.chip.neutral {
  --chip-bg: var(--tone-neutral-bg);
  --chip-text: var(--tone-neutral-text);
  --chip-border: var(--tone-neutral-border);
}

.tag {
  display: inline-block;
  padding: 0 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Tables --------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

table.data caption {
  padding: 0;
  text-align: left;
}

table.data th,
table.data td {
  padding: 0.55rem var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

table.data th:first-child,
table.data td:first-child {
  padding-left: var(--space-5);
}

table.data th:last-child,
table.data td:last-child {
  padding-right: var(--space-5);
}

table.data thead th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

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

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

table.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data .claim-link {
  font-family: var(--font-mono);
  font-weight: 600;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.cell-stack .secondary {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.due {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: 600;
}

.due.overdue {
  color: var(--tone-danger-text);
}

.due.today {
  color: var(--tone-warning-text);
}

.mandatory {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
}

/* Filters and paging ---------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.filters .field {
  min-width: 150px;
}

.filters .field.search {
  flex: 1 1 260px;
}

.result-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.pager-buttons {
  display: flex;
  gap: var(--space-2);
}

/* Forms ---------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field label,
.field .label,
fieldset legend {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-strong);
}

.field .help {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.required-mark {
  color: var(--tone-danger-text);
  font-weight: 600;
}

input[type="text"],
input[type="search"],
input[type="date"],
input[type="tel"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 2.25rem;
  padding: 0.4rem var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-strong);
  font: inherit;
}

textarea {
  min-height: 5rem;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
input[type="date"]:focus,
input[type="month"]:focus,
input[type="time"]:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
  border-color: var(--focus-ring);
}

[aria-invalid="true"] {
  border-color: var(--tone-danger-border) !important;
  box-shadow: inset 3px 0 0 var(--tone-danger-border);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--tone-danger-text);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-grid .span-2 {
  grid-column: span 2;
}

.form-grid .span-4 {
  grid-column: 1 / -1;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding-top: var(--space-1);
}

.radio-row label,
.check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
  color: var(--text);
}

input[type="radio"],
input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.repeat-item {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.repeat-item + .repeat-item {
  margin-top: var(--space-3);
}

.repeat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.form-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-raised);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.form-footer .note {
  margin-right: auto;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* Banners: errors, warnings ---------------------------------------------------- */

.banner {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--banner-border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--banner-bg);
  color: var(--text);
}

.banner .icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--banner-text);
}

.banner h2,
.banner h3 {
  color: var(--banner-text);
  font-size: var(--text-md);
}

.banner ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-5);
}

.banner li a {
  display: inline-block;
  min-height: 24px;
  line-height: 24px;
}

.banner .banner-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.banner a {
  color: var(--banner-text);
  font-weight: 600;
}

.banner.danger {
  --banner-bg: var(--tone-danger-bg);
  --banner-border: var(--tone-danger-border);
  --banner-text: var(--tone-danger-text);
}

.banner.warning {
  --banner-bg: var(--tone-warning-bg);
  --banner-border: var(--tone-warning-border);
  --banner-text: var(--tone-warning-text);
}

/* The inline "Discard your changes?" ask that Escape shows on a form with typed input
   (modifiers/escape-closes.js). */
.escape-confirm {
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-3);
}

.escape-confirm p {
  margin: 0;
  color: var(--banner-text);
  font-weight: 600;
}

.escape-confirm-actions {
  display: flex;
  gap: var(--space-2);
}

.banner.info {
  --banner-bg: var(--tone-info-bg);
  --banner-border: var(--tone-info-border);
  --banner-text: var(--tone-info-text);
}

/* Claim page ------------------------------------------------------------------- */

.claim-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}

.claim-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.claim-title h1 {
  font-family: var(--font-mono);
  font-size: 1.375rem;
  letter-spacing: 0;
}

.claim-facts {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, auto));
  justify-content: start;
  gap: var(--space-2) var(--space-8);
  margin: 0;
}

.claim-facts div,
.facts div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.claim-facts dt,
.facts dt {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.claim-facts dd,
.facts dd {
  margin: 0;
  color: var(--text-strong);
  font-weight: 500;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
}

.facts .wide {
  grid-column: 1 / -1;
}

.tabs {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0 var(--space-5);
  list-style: none;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3);
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-strong);
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent-text);
}

.tab .tag {
  font-weight: 500;
}

.people {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.person {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.person:last-child {
  border-bottom: 0;
}

.person .name {
  font-weight: 600;
  color: var(--text-strong);
}

.person .details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-size: var(--text-sm);
}

.incident-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4) var(--space-5);
  list-style: none;
}

.incident {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  font-size: var(--text-sm);
}

.incident h3 {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.incident dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px var(--space-3);
  margin: 0;
}

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

.incident dd {
  margin: 0;
  color: var(--text-strong);
}

/* Timeline --------------------------------------------------------------------- */

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--space-5) + 1rem - 1px);
  width: 2px;
  background: var(--border);
}

.timeline-item:first-child::before {
  top: 50%;
}

.timeline-item:last-child::before {
  bottom: 50%;
}

.timeline-item:only-child::before {
  display: none;
}

.timeline-marker {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-control);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--text-muted);
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.timeline-title {
  color: var(--text-strong);
  font-weight: 600;
}

.timeline-detail,
.timeline-meta {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.timeline-time {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.part-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.part-filters legend {
  margin-bottom: var(--space-2);
}

.toggle-chip {
  position: relative;
  display: inline-flex;
}

.toggle-chip input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.toggle-chip span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border-control);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
}

.toggle-chip input:checked + span {
  border-color: var(--accent);
  background: var(--surface-selected);
  color: var(--accent-text);
  font-weight: 600;
}

.toggle-chip input:focus-visible + span {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.toggle-chip .check-icon {
  display: none;
}

.toggle-chip input:checked + span .check-icon {
  display: inline;
}

/* Empty, error and placeholder states ------------------------------------------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.state-icon .icon {
  width: 1.5rem;
  height: 1.5rem;
}

.state.error .state-icon {
  background: var(--tone-danger-bg);
  border-color: var(--tone-danger-border);
  color: var(--tone-danger-text);
}

.state p {
  max-width: 52ch;
  color: var(--text-muted);
}

.state .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

.problem-code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Command palette ------------------------------------------------------------- */

dialog.palette {
  width: min(640px, calc(100vw - 2rem));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
}

dialog.palette::backdrop {
  background: var(--surface-overlay);
}

.palette-search {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.palette-search input {
  border: 0;
  padding: var(--space-2) 0;
  background: transparent;
  font-size: var(--text-lg);
}

.palette-search input:focus-visible {
  outline: none;
}

.palette-search:focus-within {
  box-shadow: inset 0 -2px 0 var(--focus-ring);
}

.palette-list {
  max-height: 50vh;
  margin: 0;
  padding: var(--space-2);
  overflow-y: auto;
  list-style: none;
}

.palette-group {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.palette-group-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.palette-empty {
  padding: 0 var(--space-5) var(--space-4);
  color: var(--text-muted);
}

.palette-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.palette-option[aria-selected="true"] {
  background: var(--surface-selected);
  color: var(--accent-text);
  box-shadow: inset 0 0 0 2px var(--focus-ring);
}

.palette-option .secondary {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.palette-footer {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Responsive ---------------------------------------------------------------------- */

@media (width <= 1100px) {
  .grid-main-side {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .claim-facts {
    grid-template-columns: repeat(3, minmax(0, auto));
  }

  .incident-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (width <= 760px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    background: none;
  }

  /* On a phone the form footer wraps to several lines, so it scrolls with the form
     rather than covering fields. */
  :root {
    --form-footer-height: 0rem;
  }

  .form-footer {
    position: static;
  }

  .nav-close {
    align-self: flex-end;
  }

  .side-nav {
    background: var(--surface-nav);
    border-right: 1px solid var(--border);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(300px, 85vw);
    box-shadow: var(--shadow-overlay);
    transform: translateX(-105%);
    transition: transform var(--motion-fast);
    visibility: hidden;
  }

  .shell.nav-open .side-nav {
    transform: none;
    visibility: visible;
  }

  .topbar .menu-button,
  .side-nav .nav-close {
    display: inline-flex;
  }

  .topbar {
    padding: 0 var(--space-3);
  }

  .palette-trigger .label,
  .palette-trigger kbd,
  .user-meta {
    display: none;
  }

  .palette-trigger {
    width: 2.25rem;
    justify-content: center;
    padding: 0;
  }

  main {
    padding: var(--space-4) var(--space-3) var(--space-6);
  }

  .summary-strip,
  .grid-2,
  .facts,
  .incident-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .claim-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3) var(--space-4);
  }

  .claim-header,
  .card-header,
  .card-body {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .tabs {
    padding: 0 var(--space-2);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  table.data th:first-child,
  table.data td:first-child {
    padding-left: var(--space-4);
  }

  .person,
  .timeline-item {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .timeline-item {
    grid-template-columns: 2rem minmax(0, 1fr);
  }

  .timeline-item::before {
    left: calc(var(--space-4) + 1rem - 1px);
  }

  .timeline-time {
    grid-column: 2;
    text-align: left;
  }

  /* Tables marked stack-mobile become one card per row on phones. */
  table.data.stack-mobile thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  table.data.stack-mobile tr {
    display: block;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }

  table.data.stack-mobile tbody tr:last-child {
    border-bottom: 0;
  }

  table.data.stack-mobile td,
  table.data.stack-mobile tbody th {
    position: relative;
    display: block;
    min-height: 1.5rem;
    padding: var(--space-1) 0 var(--space-1) 7.5rem !important;
    border: 0;
    white-space: normal;
    text-align: left;
  }

  table.data.stack-mobile td::before,
  table.data.stack-mobile tbody th::before {
    content: attr(data-label);
    position: absolute;
    top: var(--space-1);
    left: 0;
    width: 7rem;
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.6;
    text-transform: uppercase;
  }

  .nav-scrim {
    position: fixed;
    inset: 0;
    z-index: 40;
    border: 0;
    background: var(--surface-overlay);
  }
}

@media (forced-colors: active) {
  .chip,
  .tag,
  .metric,
  .banner,
  .toggle-chip span {
    border: 1px solid CanvasText;
  }

  .nav-link[aria-current="page"],
  .tab.active {
    outline: 2px solid Highlight;
  }
}

.soon-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.soon-list li {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
}

.cell-stack > .chip {
  align-self: flex-start;
}

table.data td {
  white-space: nowrap;
}

table.data td.wrap {
  white-space: normal;
  min-width: 16rem;
}

.repeat-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-strong);
}

/* Policies ------------------------------------------------------------------------ */

.filters.policy-filters {
  display: grid;
  grid-template-columns:
    minmax(9rem, 1fr) minmax(12rem, 1.6fr) repeat(2, minmax(9rem, 1fr))
    minmax(9rem, 1fr) minmax(9rem, 1fr) auto;
  align-items: start;
}

.filters.policy-filters .field {
  min-width: 0;
}

.filter-submit .label {
  display: block;
}

@media (width <= 1100px) {
  .filters.policy-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.policy-insured-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: calc(var(--space-2) * -1);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-strong);
}

.source-line,
.card-footnote {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.card-footnote {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
}

.facts.one-col {
  grid-template-columns: minmax(0, 1fr);
}

.big-number {
  font-size: var(--text-xl);
  font-weight: 650;
}

.block {
  display: block;
}

.vehicle-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

table.data tbody th[scope="row"],
table.data tfoot th[scope="row"] {
  font-weight: 600;
  color: var(--text-strong);
  text-align: left;
}

table.data tfoot td,
table.data tfoot th {
  border-top: 2px solid var(--border-strong);
  background: var(--surface-sunken);
}

table.data .strong {
  font-weight: 650;
  color: var(--text-strong);
}

@media (width <= 1100px) {
  .vehicle-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Section tab strip: a fade and a chevron show which edge hides more tabs. */
.tab-strip {
  position: relative;
}

.tab-strip::before,
.tab-strip::after {
  content: "";
  position: absolute;
  top: 1px;
  bottom: 2px;
  z-index: 1;
  width: 3rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--motion-fast);
  background-repeat: no-repeat;
  background-size: 0.9rem 0.9rem;
}

.tab-strip::before {
  left: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235c6470' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3.5L5.5 8l4.5 4.5'/%3E%3C/svg%3E"),
    linear-gradient(to right, var(--surface-raised) 45%, transparent);
  background-position:
    0.4rem center,
    0 0;
  background-size:
    0.9rem 0.9rem,
    100% 100%;
  border-radius: 0 0 0 var(--radius-lg);
}

.tab-strip::after {
  right: 0;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235c6470' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5l4.5 4.5L6 12.5'/%3E%3C/svg%3E"),
    linear-gradient(to left, var(--surface-raised) 45%, transparent);
  background-position:
    calc(100% - 0.4rem) center,
    0 0;
  background-size:
    0.9rem 0.9rem,
    100% 100%;
  border-radius: 0 0 var(--radius-lg);
}

:root[data-theme="dark"] .tab-strip::before {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a5adba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 3.5L5.5 8l4.5 4.5'/%3E%3C/svg%3E"),
    linear-gradient(to right, var(--surface-raised) 45%, transparent);
}

:root[data-theme="dark"] .tab-strip::after {
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23a5adba' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5l4.5 4.5L6 12.5'/%3E%3C/svg%3E"),
    linear-gradient(to left, var(--surface-raised) 45%, transparent);
}

.tab-strip[data-more-before]::before,
.tab-strip[data-more-after]::after {
  opacity: 1;
}

.tab-strip .tabs {
  scrollbar-width: none;
}

/* The tab strip scrolls, which would clip an outside focus ring: draw it inside. */
.tab:focus-visible {
  outline-offset: -3px;
}

/* Admin user invitations */
.invite-ready-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  border-color: var(--ok-border, var(--border));
}

.invite-ready-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.invite-ready-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.invite-form {
  display: grid;
  gap: 1rem;
}

/* Dynamic department workspace switcher & banner */
.workspace-switcher {
  position: relative;
  padding: 0 0.75rem 0.75rem;
}

.workspace-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  min-height: 34px;
  padding: 0.35rem 0.65rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--text-strong);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
}

.workspace-trigger:hover {
  border-color: var(--border-strong, var(--border));
}

.workspace-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.workspace-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-menu {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: calc(100% - 0.5rem);
  z-index: 40;
  display: grid;
  gap: 0.15rem;
  padding: 0.35rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 8px 24px rgb(0 0 0 / 12%));
}

.workspace-menu-item {
  width: 100%;
  min-height: 30px;
  padding: 0.35rem 0.6rem;
  font-size: 0.84rem;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm, 6px);
  text-align: left;
  cursor: pointer;
}

.workspace-menu-item:hover,
.workspace-menu-item:focus-visible {
  background: var(--surface-hover, var(--surface-sunken));
  color: var(--text-strong);
}

.workspace-menu-item.active {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft, var(--surface-sunken));
}

.workspace-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.workspace-banner-copy {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.workspace-banner-copy h2 {
  margin: 0 0 0.2rem;
  font-size: 1rem;
}

.workspace-banner-copy p {
  margin: 0;
  font-size: 0.88rem;
}

.workspace-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Full-screen sign-in gate & loading state (no console chrome before auth) */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background: var(--surface-sunken, var(--bg));
}

.auth-gate .page {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.auth-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 2.25rem 2.5rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.auth-loading-title {
  margin: 0.25rem 0 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-strong);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.auth-brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-strong);
}

.auth-full-btn {
  width: 100%;
  justify-content: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
