/* ============================================================
   SHIFTEZ DESIGN SYSTEM — "Clean Minimal"
   Linear/Vercel/Stripe-inspired modern design
   Part 1 of 3: Tokens, Reset, Typography, Shell, States,
                Operations, Workspace, Data Tables
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
  /* --- Color Palette --- */
  --bg-strong: #0f172a;
  --bg-soft: #f8fafc;
  --bg-body: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-raised: #ffffff;
  --ink-primary: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --success: #047857;
  --success-soft: #ecfdf5;
  --error: #be123c;
  --error-soft: #fff1f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --focus: #2563eb;
  --ink-on-accent: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* --- Typography --- */
  --font-display: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "Red Hat Mono", ui-monospace, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.875rem;
  --text-3xl: 2.25rem;
  --text-4xl: 3rem;
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.55;
  --weight-light: 300;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  /* --- Spacing --- */
  --space-0: 0;
  --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;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* --- Radii --- */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* --- Shadows --- */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 32px rgba(15, 23, 42, 0.1), 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 56px rgba(15, 23, 42, 0.12), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-inset: inset 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus);

  /* --- Motion --- */
  --duration-fast: 130ms;
  --duration-normal: 220ms;
  --duration-slow: 380ms;
  --duration-slower: 550ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* --- Layout --- */
  --sidebar-width: 16rem;
  --sidebar-collapsed: 4rem;
  --header-height: 4rem;
  --control-hit-target: 2.5rem;
  --control-hit-target-mobile: 2.75rem;
  --content-max: 100%;
  --z-base: 0;
  --z-sticky: 100;
  --z-sidebar: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
  --z-tooltip: 600;

  /* --- Grain texture --- */
  --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
}

/* --- Fallback for browsers without color-mix() --- */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  :root {
    --accent-soft: rgba(37, 99, 235, 0.1);
    --success-soft: rgba(22, 163, 74, 0.1);
    --warning-soft: rgba(234, 179, 8, 0.1);
    --error-soft: rgba(239, 68, 68, 0.1);
    --info-soft: rgba(59, 130, 246, 0.1);
  }
}

/* --- Dark Mode (explicit) --- */
[data-theme="dark"] {
  --bg-strong: #060a12;
  --bg-soft: #111827;
  --bg-body: #0c1322;
  --surface: #1e293b;
  --surface-alt: #1a2536;
  --surface-raised: #243044;
  --ink-primary: #e8eef5;
  --ink-secondary: #c8d5e4;
  --ink-muted: #8899ad;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-soft: #172554;
  --success: #34d399;
  --success-soft: #064e3b;
  --error: #fb7185;
  --error-soft: #4c0519;
  --warning: #fbbf24;
  --warning-soft: #451a03;
  --info: #38bdf8;
  --info-soft: #0c4a6e;
  --focus: #60a5fa;
  --ink-on-accent: #ffffff;
  --border: #2d3f54;
  --border-strong: #3d5068;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* --- Dark Mode (system preference) --- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-strong: #060a12;
    --bg-soft: #111827;
    --bg-body: #0c1322;
    --surface: #1e293b;
    --surface-alt: #1a2536;
    --surface-raised: #243044;
    --ink-primary: #e8eef5;
    --ink-secondary: #c8d5e4;
    --ink-muted: #8899ad;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-soft: #172554;
    --success: #34d399;
    --success-soft: #064e3b;
    --error: #fb7185;
    --error-soft: #4c0519;
    --warning: #fbbf24;
    --warning-soft: #451a03;
    --info: #38bdf8;
    --info-soft: #0c4a6e;
    --focus: #60a5fa;
    --ink-on-accent: #ffffff;
    --border: #2d3f54;
    --border-strong: #3d5068;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.2);
  }
}


/* ============================================================
   2. RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  tab-size: 4;
  -moz-tab-size: 4;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--ink-primary);
  background: var(--bg-body);
  background-image: linear-gradient(
    168deg,
    color-mix(in srgb, var(--accent) 3%, var(--bg-body)) 0%,
    var(--bg-body) 50%
  );
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent);
}

img,
video,
svg {
  max-width: 100%;
  display: block;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

[hidden] {
  display: none !important;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  background-clip: content-box;
  border: 2px solid transparent;
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

@supports (scrollbar-width: thin) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
}


/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */
h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-extrabold);
  line-height: var(--leading-tight);
  color: var(--ink-primary);
  letter-spacing: -0.025em;
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--ink-primary);
  letter-spacing: -0.02em;
}

h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  color: var(--ink-primary);
  letter-spacing: -0.015em;
}

h4 {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  color: var(--ink-primary);
}

h5 {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
}

h6 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

p {
  line-height: var(--leading-normal);
}

p:not(:last-child) {
  margin-bottom: var(--space-3);
}

strong {
  font-weight: var(--weight-semibold);
}

em {
  font-style: italic;
}

small {
  font-size: var(--text-xs);
}

.content a,
a.link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast);
}

.content a:hover,
a.link:hover {
  color: var(--accent-hover);
}

.text-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.text-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.text-display {
  font-family: var(--font-display);
  font-weight: var(--weight-extrabold);
}

code,
kbd,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  padding: 2px 6px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}

pre {
  padding: var(--space-4);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

pre code {
  padding: 0;
  background: none;
  border-radius: 0;
}

kbd {
  padding: 2px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 var(--border);
  font-size: 0.85em;
}


/* ============================================================
   4. SHELL LAYOUT
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  height: 100vh;
  max-width: var(--content-max);
  margin: 0 auto;
  overflow: hidden;
}

.shell-header,
.shell__header,
.shell > .header {
  grid-area: header;
  background: var(--surface);
}

.shell-sidebar,
.shell__sidebar,
.shell > .sidebar {
  grid-area: sidebar;
}

.shell-main {
  grid-area: main;
  --_pad: var(--space-8);
  padding: var(--_pad);
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.shell-main__subheader {
  margin: calc(-1 * var(--_pad)) calc(-1 * var(--_pad)) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.shell-main__content,
.shell-main > [role="tabpanel"] {
  max-width: 80rem;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

.shell--sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .shell-sidebar,
  .shell > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-sidebar);
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-out);
  }

  .shell--sidebar-open .shell-sidebar,
  .shell--sidebar-open > .sidebar {
    transform: translateX(0);
  }

  body.body--sidebar-overlay-open {
    overflow: hidden;
  }

  .sidebar-mobile-toggle {
    display: inline-flex;
  }
}

@media (max-width: 768px) {
  .header-toolbar__btn,
  .header__tool-btn,
  .header__user-btn,
  .header-tool,
  .header-avatar,
  .sidebar-mobile-toggle,
  .sidebar-toggle,
  .sidebar-header__toggle {
    width: var(--control-hit-target-mobile);
    height: var(--control-hit-target-mobile);
  }

  .header-toolbar__btn--search {
    min-width: var(--control-hit-target-mobile);
    padding-inline: var(--space-2);
  }

  .shell-main {
    --_pad: var(--space-4);
    padding: var(--_pad);
  }
}

@media (max-width: 480px) {
  .shell-main {
    --_pad: var(--space-3);
    padding: var(--_pad);
  }
}


/* ============================================================
   5. SHELL SIDEBAR
   ============================================================ */
.shell-sidebar,
.shell__sidebar,
.shell > .sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--duration-slow) var(--ease-out);
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  overflow: hidden;
}

.sidebar-brand__logo,
.sidebar-header__logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar-brand__name {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-primary);
  transition: opacity var(--duration-normal) var(--ease-out),
    width var(--duration-normal) var(--ease-out);
}

.sidebar-toggle,
.sidebar-header__toggle {
  width: var(--control-hit-target);
  height: var(--control-hit-target);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  flex-shrink: 0;
  background: none;
  border: none;
}

.sidebar-toggle:hover,
.sidebar-header__toggle:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.sidebar-toggle:focus-visible,
.sidebar-header__toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sidebar-toggle svg,
.sidebar-header__toggle svg {
  width: 18px;
  height: 18px;
}

.sidebar-mobile-toggle {
  display: none;
}

.sidebar-surface-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  background: var(--accent-soft);
  color: var(--accent);
  margin: var(--space-3) var(--space-4);
  transition: opacity var(--duration-normal) var(--ease-out),
    width var(--duration-normal) var(--ease-out);
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-surface-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  flex-shrink: 0;
}

.sidebar-nav,
.sidebar__inner {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.sidebar-nav__group,
.sidebar-group,
.sidebar__group {
  margin-bottom: var(--space-2);
}

.sidebar-group__title,
.sidebar__group-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: var(--space-2) var(--space-3);
  margin: 0;
}

.sidebar-group__list,
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  list-style: none;
  margin: 0;
  padding: 0;
  padding-top: var(--space-1);
}

.sidebar-nav__group-header,
.sidebar-nav__group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--duration-fast);
  background: none;
  border: none;
  width: 100%;
}

.sidebar-nav__group-header:hover,
.sidebar-nav__group-toggle:hover {
  background: var(--surface-alt);
}

.sidebar-nav__group-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  user-select: none;
  transition: opacity var(--duration-normal) var(--ease-out),
    width var(--duration-normal) var(--ease-out);
}

.sidebar-nav__group-chevron {
  width: 16px;
  height: 16px;
  color: var(--ink-muted);
  transition: transform var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.sidebar-nav__group--collapsed .sidebar-nav__group-chevron {
  transform: rotate(-90deg);
}

.sidebar-nav__group--collapsed .sidebar-nav__group-items,
.sidebar-nav__group--collapsed .sidebar-nav__items {
  display: none;
}

.sidebar-nav__group-items,
.sidebar-nav__items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-top: var(--space-1);
  list-style: none;
  margin: 0;
  padding-left: 0;
  padding-top: var(--space-1);
}

.sidebar-nav__item,
.sidebar-link,
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  transition: all var(--duration-fast);
  cursor: pointer;
  text-decoration: none;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav__item:hover,
.sidebar-link:hover,
.sidebar__link:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.sidebar-nav__item:focus-visible,
.sidebar-link:focus-visible,
.sidebar__link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.sidebar-nav__item--active,
.sidebar-link--active,
.sidebar__link--active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.sidebar-nav__item--active::before,
.sidebar-link--active::before,
.sidebar__link--active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.sidebar-nav__icon,
.sidebar-link__icon,
.sidebar__link > svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav__item--active .sidebar-nav__icon,
.sidebar-link--active .sidebar-link__icon,
.sidebar__link--active > svg {
  opacity: 1;
}

.sidebar-nav__item:hover .sidebar-nav__icon,
.sidebar-link:hover .sidebar-link__icon,
.sidebar__link:hover > svg {
  opacity: 1;
}

.sidebar-nav__label,
.sidebar-link__label,
.sidebar__link > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--duration-normal) var(--ease-out),
    width var(--duration-normal) var(--ease-out);
}

.sidebar-nav__badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--ink-on-accent);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  transition: opacity var(--duration-normal) var(--ease-out),
    width var(--duration-normal) var(--ease-out);
}

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  margin-top: auto;
  flex-shrink: 0;
}

.sidebar-footer__version {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

/* --- Sidebar Collapsed State --- */
.shell--sidebar-collapsed .shell-sidebar,
.shell--sidebar-collapsed > .sidebar {
  width: var(--sidebar-collapsed);
}

.shell--sidebar-collapsed .sidebar-brand__name,
.shell--sidebar-collapsed .sidebar-nav__label,
.shell--sidebar-collapsed .sidebar-link__label,
.shell--sidebar-collapsed .sidebar-nav__badge,
.shell--sidebar-collapsed .sidebar-nav__group-label,
.shell--sidebar-collapsed .sidebar-nav__group-chevron,
.shell--sidebar-collapsed .sidebar-surface-badge,
.shell--sidebar-collapsed .sidebar-group__title,
.shell--sidebar-collapsed .sidebar__group-label,
.shell--sidebar-collapsed .sidebar__link > span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.shell--sidebar-collapsed .sidebar-nav__item,
.shell--sidebar-collapsed .sidebar-link,
.shell--sidebar-collapsed .sidebar__link {
  justify-content: center;
  padding: var(--space-2);
}

.shell--sidebar-collapsed .sidebar-nav__icon,
.shell--sidebar-collapsed .sidebar-link__icon,
.shell--sidebar-collapsed .sidebar__link > svg {
  margin: 0;
}

.shell--sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: var(--space-4) var(--space-2);
}

.shell--sidebar-collapsed .sidebar-footer {
  padding: var(--space-3) var(--space-2);
  text-align: center;
}

/* --- Sidebar Mobile Overlay --- */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.sidebar-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   6. SHELL HEADER
   ============================================================ */
.header-bar,
.header__row--primary {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.header-brand,
.brand-lockup,
.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.header-brand__logo,
.brand-lockup__logo,
.header__logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-mark {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.header-brand__wordmark,
.header-brand__name,
.brand-lockup__text,
.header__wordmark {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  white-space: nowrap;
}

.header-toolbar,
.header__toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.header-toolbar__btn,
.header__tool-btn,
.header__user-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-hit-target);
  height: var(--control-hit-target);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  transition: all var(--duration-fast);
  cursor: pointer;
  background: none;
  border: none;
}

.header-toolbar__btn:hover,
.header__tool-btn:hover,
.header__user-btn:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.header-toolbar__btn:focus-visible,
.header__tool-btn:focus-visible,
.header__user-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.header-toolbar__btn svg,
.header__tool-btn svg,
.header__user-btn svg {
  width: 20px;
  height: 20px;
}

.header-toolbar__btn--theme,
.header-tool[data-action="theme-toggle"],
.header__tool-btn--theme-dark,
.header__tool-btn--theme-light {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-secondary);
}

.header-toolbar__btn--theme[data-theme-state="light"],
.header-tool[data-action="theme-toggle"][data-theme-state="light"],
.header__tool-btn--theme-dark[data-theme-state="light"],
.header__tool-btn--theme-light[data-theme-state="light"] {
  border-color: var(--border);
  color: var(--ink-secondary);
  background: var(--surface);
}

.header-toolbar__btn--theme[data-theme-state="dark"],
.header-tool[data-action="theme-toggle"][data-theme-state="dark"],
.header__tool-btn--theme-dark[data-theme-state="dark"],
.header__tool-btn--theme-light[data-theme-state="dark"] {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 64%, var(--surface));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.header__tool-btn--theme-dark[data-theme-state="dark"],
.header__tool-btn--theme-light[data-theme-state="light"] {
  display: none;
}

.header-toolbar__btn--theme[data-theme-state="light"] .icon-sun,
.header-tool[data-action="theme-toggle"][data-theme-state="light"] .icon-sun {
  display: none;
}

.header-toolbar__btn--theme[data-theme-state="dark"] .icon-moon,
.header-tool[data-action="theme-toggle"][data-theme-state="dark"] .icon-moon {
  display: none;
}

.header-toolbar__btn--theme[data-theme-state="dark"] .icon-sun,
.header-tool[data-action="theme-toggle"][data-theme-state="dark"] .icon-sun {
  display: block;
}

.header-toolbar__btn--has-badge::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--error);
  border: 2px solid var(--surface);
}

.header-toolbar__badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--error);
  border: 2px solid var(--surface);
  pointer-events: none;
}

.header__badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.header-toolbar__btn--search {
  width: auto;
  display: inline-flex;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  height: var(--control-hit-target);
  color: var(--ink-muted);
}

.header-toolbar__btn--search:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.header-toolbar__btn-label {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  white-space: nowrap;
}

.kbd-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-medium);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  line-height: 1.4;
}

/* --- Portal Header Tools (icon buttons) --- */
.header-tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-hit-target);
  height: var(--control-hit-target);
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  transition: all var(--duration-fast);
  cursor: pointer;
  background: none;
  border: none;
}

.header-tool:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.header-tool:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.header-tool__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--error);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* --- Portal Avatar --- */
.header-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-hit-target);
  height: var(--control-hit-target);
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--weight-medium);
  font-size: var(--text-xs);
  cursor: pointer;
  border: none;
  transition: box-shadow var(--duration-fast);
}

.header-avatar:hover {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.header-avatar:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.header-avatar__initials {
  font-family: var(--font-body);
  user-select: none;
}

/* --- Portal Surface Tabs --- */
.header-surfaces {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
}

.header-surface {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: all var(--duration-fast);
  white-space: nowrap;
}

.header-surface:hover {
  color: var(--ink-primary);
}

.header-surface--active,
.header-surface[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: var(--weight-medium);
}

/* --- Portal Breadcrumbs --- */
.header-breadcrumb {
  font-size: var(--text-sm);
}

.header-breadcrumb__list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.header-breadcrumb__item {
  display: inline-flex;
  align-items: center;
  color: var(--ink-muted);
}

.header-breadcrumb__item + .header-breadcrumb__item::before {
  content: "/";
  margin-right: var(--space-1);
  color: var(--ink-muted);
  opacity: 0.4;
  font-size: var(--text-xs);
}

.header-breadcrumb__item a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--duration-fast);
}

.header-breadcrumb__item a:hover {
  color: var(--ink-primary);
}

.header-breadcrumb__item[aria-current="page"] {
  color: var(--ink-secondary);
  font-weight: var(--weight-medium);
}

/* --- Portal Title Heading --- */
.header-title__heading {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  margin: 0;
}

/* --- Portal Workbench Tabs --- */
.header-workbench__tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
}

.header-workbench__tab:hover {
  color: var(--ink-primary);
}

.header-workbench__tab--active,
.header-workbench__tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: var(--weight-medium);
}

.header-workbench__tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* --- Surface Controls --- */
.header-surface-controls,
.surface-controls,
.header__surfaces {
  display: flex;
  align-items: center;
  padding: var(--space-1) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.surface-tabs,
.header__tab-list {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 2px;
  gap: 2px;
}

.surface-tab,
.header__tab {
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius-lg) - 2px);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  white-space: nowrap;
  border: none;
  background: none;
}

.surface-tab:hover,
.header__tab:hover {
  color: var(--ink-primary);
}

.surface-tab[aria-selected="true"],
.header__tab[aria-selected="true"],
.header__tab--active {
  background: var(--surface);
  color: var(--ink-primary);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-sm);
}

.surface-tab:focus-visible,
.header__tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px; /* Inset focus to prevent overflow clipping */
}

/* --- Role Selector --- */
.header-role-selector,
.role-selector,
.header__role {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.header-role-selector__label,
.role-selector__label {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  white-space: nowrap;
}

.role-select,
.role-selector__select,
.header__role-select {
  appearance: none;
  -webkit-appearance: none;
  padding: var(--space-1) var(--space-8) var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 8px center;
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--ink-primary);
  cursor: pointer;
  transition: border-color var(--duration-fast);
  outline: none;
}

.role-select:hover,
.role-selector__select:hover,
.header__role-select:hover {
  border-color: var(--border-strong);
}

.role-select:focus-visible,
.role-selector__select:focus-visible,
.header__role-select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Title Row --- */
.header-title,
.title-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
}

.header-title h1,
.title-area h1,
.title-area__h1,
.header__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
  margin: 0;
}

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

.header-title__status {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

/* --- Command Bar --- */
.header-command-bar,
.header__row--secondary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  margin: 0 var(--space-4);
  border-radius: var(--radius-lg);
}

.command-bar__left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

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

.header__command-bar {
  display: flex;
  align-items: center;
  min-width: min(24rem, 100%);
  flex: 1 1 22rem;
}

.header__command-input-wrap {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0 var(--space-2);
  min-height: 36px;
}

.header__command-icon {
  color: var(--ink-muted);
  flex-shrink: 0;
}

.header__command-input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  outline: none;
}

.header__command-input::placeholder {
  color: var(--ink-muted);
}

.header__command-kbd {
  flex-shrink: 0;
  padding: 2px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-muted);
}

.command-bar__right {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

.command-bar__context {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

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

.command-bar__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.command-bar__chip--success {
  background: var(--success-soft);
  color: var(--success);
}

.command-bar__chip--info {
  background: var(--info-soft);
  color: var(--info);
}

.command-bar__chip--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.command-bar__chip--error {
  background: var(--error-soft);
  color: var(--error);
}

.command-bar__actions {
  display: flex;
  gap: var(--space-2);
  margin-left: auto;
}

/* --- Snapshot Panel --- */
.header-snapshot,
.snapshot,
.header__snapshot {
  margin: var(--space-1) var(--space-4);
  padding: var(--space-2);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--duration-normal) var(--ease-out);
}

.header-snapshot[hidden],
.snapshot[hidden] {
  display: none;
}

.header-snapshot__toggle,
.snapshot__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
  cursor: pointer;
  background: none;
  border: none;
  padding: var(--space-1) 0;
  width: 100%;
  text-align: left;
}

.header-snapshot__toggle:hover,
.snapshot__toggle:hover {
  color: var(--ink-primary);
}

.header-snapshot__toggle:focus-visible,
.snapshot__toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.header-snapshot__toggle svg,
.snapshot__toggle svg,
.snapshot__chevron {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast) var(--ease-out);
  flex-shrink: 0;
}

.snapshot__toggle-label {
  /* label inherits from toggle */
}

.header-snapshot--expanded .header-snapshot__toggle svg,
.snapshot--expanded .snapshot__chevron,
.snapshot__toggle[aria-expanded="true"] .snapshot__chevron {
  transform: rotate(180deg);
}

.header-snapshot__grid,
.snapshot__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  padding-top: var(--space-3);
}

.header-snapshot__item,
.snapshot__kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-snapshot__item-value,
.snapshot__kpi-value {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.header-snapshot__item-label,
.snapshot__kpi-label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* --- Workbench Tabs --- */
.header-workbench {
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}

.header__workbench {
  display: flex;
  align-items: center;
  padding: 0;
  border-bottom: none;
}

.workbench-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}

.header__workbench-tabs {
  display: flex;
  align-items: center;
  gap: 0;
}

.workbench-tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  white-space: nowrap;
}

.workbench-tab:hover {
  color: var(--ink-primary);
}

.workbench-tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: var(--weight-medium);
}

.workbench-tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

@media (max-width: 768px) {
  .header-bar {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-3);
  }

  .header-surface-controls {
    padding: var(--space-1) var(--space-3);
    overflow-x: auto;
  }

  .header-role-selector {
    padding: var(--space-2) var(--space-3);
  }

  .header-title {
    padding: var(--space-3);
  }

  .header-command-bar {
    margin: 0 var(--space-3) var(--space-2);
    padding: var(--space-3);
    flex-direction: column;
    align-items: flex-start;
  }

  .header__row--secondary {
    align-items: flex-start;
    gap: var(--space-3);
  }

  .header__surfaces,
  .header__role,
  .header__title,
  .header__command-bar,
  .header__snapshot,
  .header__workbench {
    width: 100%;
  }

  .header__command-bar {
    min-width: 0;
    flex: 0 1 auto;
  }

  .header__snapshot {
    margin: 0;
  }

  .header__workbench {
    overflow-x: auto;
    padding: 0;
  }

  .header__workbench-tabs {
    width: max-content;
    min-width: max-content;
  }

  .command-bar__actions {
    margin-left: 0;
    width: 100%;
  }

  .header-snapshot {
    margin: var(--space-2) var(--space-3);
  }

  .header-snapshot__grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .header-workbench {
    padding: 0 var(--space-3);
    overflow-x: auto;
  }

  .workbench-tabs {
    flex-shrink: 0;
  }
}

@media (max-width: 820px) {
  .shell-header,
  .shell__header,
  .header__row,
  .header__row--secondary,
  .header__workbench,
  .header__workbench-tabs,
  .meta-grid,
  .panel,
  .panel__body,
  .op-cards,
  .op-card {
    min-width: 0;
    max-width: 100%;
  }

  .op-card__desc {
    overflow-wrap: anywhere;
  }
}


/* ============================================================
   7. STATE BANNERS
   ============================================================ */
.state-banner {
  padding: var(--space-6);
}

.state-banner[hidden] {
  display: none;
}

/* --- Loading State --- */
.state-banner--loading {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.skeleton {
  display: block;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 50%,
    transparent 100%
  );
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.skeleton--heading {
  height: 2rem;
  width: 60%;
  margin-bottom: var(--space-2);
}

.skeleton--text {
  height: 1rem;
  margin-bottom: var(--space-2);
}

.skeleton--bar {
  height: 0.85rem;
  margin-bottom: var(--space-2);
}

.skeleton--w60 {
  width: 60%;
}

.skeleton--w80 {
  width: 80%;
}

.skeleton--w45 {
  width: 45%;
}

.skeleton--text:nth-child(2) {
  width: 80%;
}

.skeleton--text:nth-child(3) {
  width: 45%;
}

.skeleton--card {
  height: 120px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
}

.skeleton--table-row {
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
}

.skeleton--avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton--stat {
  height: 80px;
  border-radius: var(--radius-lg);
}

/* --- Empty State --- */
.state-banner--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-16) var(--space-6);
  min-height: 300px;
}

.empty-state__icon {
  width: 96px;
  height: 96px;
  margin-bottom: var(--space-6);
  color: var(--ink-muted);
  opacity: 0.5;
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  margin-bottom: var(--space-2);
}

.empty-state__description {
  font-size: var(--text-base);
  color: var(--ink-muted);
  max-width: 400px;
  margin-bottom: var(--space-6);
  line-height: var(--leading-normal);
}

.empty-state__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  cursor: pointer;
  transition: all var(--duration-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  background: var(--accent);
  color: var(--ink-on-accent);
  border-color: var(--accent);
}

.empty-state__cta:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.empty-state__cta:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Error State --- */
.state-banner--error {
  padding: var(--space-6);
}

.error-card {
  background: var(--error-soft);
  border: 1px solid color-mix(in srgb, var(--error) 20%, transparent);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.error-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.error-card__icon {
  width: 24px;
  height: 24px;
  color: var(--error);
  flex-shrink: 0;
}

.error-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--error);
}

.error-card__type {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-bottom: var(--space-2);
  word-break: break-all;
}

.error-card__detail {
  font-size: var(--text-base);
  color: var(--ink-secondary);
  margin-bottom: var(--space-4);
  line-height: var(--leading-normal);
}

.error-card__instance {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-bottom: var(--space-4);
}

.error-card__actions {
  display: flex;
  gap: var(--space-3);
}

.error-card__technical {
  margin-top: var(--space-4);
}

.error-card__technical-toggle {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  cursor: pointer;
}

.error-card__technical[open] .error-card__type,
.error-card__technical[open] .error-card__instance {
  display: block;
  margin-top: var(--space-2);
}

/* --- Success State --- */
.state-banner--success {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--success) 12%, var(--surface-elevated));
  border: 1px solid color-mix(in srgb, var(--success) 28%, transparent);
  color: var(--success);
}

/* --- Progress Bar --- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: var(--z-toast);
  background: transparent;
}

.progress-bar[hidden] {
  display: none;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  transition: width var(--duration-normal) var(--ease-out);
  width: 0%;
}

.progress-bar--indeterminate .progress-bar__fill {
  width: 40%;
  animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}


/* ============================================================
   8. OPERATIONS PANEL
   ============================================================ */
.operations-panel {
  margin-bottom: var(--space-8);
}

.operations-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.operations-panel__header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.operation-card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.operation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--duration-fast);
  cursor: pointer;
}

.operation-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.operation-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.operation-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.operation-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
}

.operation-card__description {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-3);
}

.operation-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.operation-card__cta {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color var(--duration-fast);
}

.operation-card__cta:hover {
  color: var(--accent-hover);
}

/* --- Root Quick Operation Cards --- */
.op-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.op-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(
      148deg,
      color-mix(in srgb, var(--accent) 4%, var(--surface)) 0%,
      var(--surface) 54%
    );
  box-shadow: var(--shadow-sm);
  min-height: 214px;
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.op-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: var(--shadow-md);
}

.op-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent), var(--shadow-md);
}

.op-card__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.op-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  color: var(--ink-primary);
}

.op-card__desc {
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--ink-secondary);
}

.op-card__status {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
}

.op-card__status[data-state="running"],
.op-card[aria-busy="true"] .op-card__status {
  color: var(--accent);
}

.op-card__status[data-state="success"] {
  color: var(--success);
}

.op-card__status[data-state="error"] {
  color: var(--error);
}

.op-card[aria-busy="true"] .op-card__icon {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
}

.op-card.op-card--running {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow-md);
}

.op-card__action {
  margin-top: auto;
}

@media (max-width: 1180px) {
  .op-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .op-cards {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .op-card {
    min-height: 0;
  }
}

.operation-card__cta:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Status Badges --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  line-height: 1.4;
}

.status-badge--completed,
.status-badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge--in_progress,
.status-badge--active,
.status-badge--running {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-badge--pending,
.status-badge--queued {
  background: var(--surface-alt);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.status-badge--failed,
.status-badge--error {
  background: var(--error-soft);
  color: var(--error);
}

.status-badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.status-badge__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

.status-badge--accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-badge--muted {
  background: var(--surface-alt);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

/* --- Status Chips --- */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  line-height: 1.4;
}

.status-chip--in-progress {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-chip--completed {
  background: var(--success-soft);
  color: var(--success);
}

.status-chip--failed {
  background: var(--error-soft);
  color: var(--error);
}

/* --- Health Chips --- */
.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  line-height: 1.4;
}

.health-chip--success {
  background: var(--success-soft);
  color: var(--success);
}

.health-chip--info {
  background: var(--info-soft);
  color: var(--info);
}

.health-chip--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.health-chip--error {
  background: var(--error-soft);
  color: var(--error);
}

/* --- Run Start Form --- */
.run-start-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-top: var(--space-4);
}

.run-start-form[hidden] {
  display: none;
}

.run-start-form__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.run-start-form__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.run-start-form__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  background: none;
  border: none;
}

.run-start-form__close:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.run-start-form__close:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.run-start-form__close svg {
  width: 18px;
  height: 18px;
}

/* --- Form Fields (Shared) --- */
.form-field {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
  margin-bottom: var(--space-2);
}

.form-label--required::after {
  content: " *";
  color: var(--error);
}

.form-input {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--ink-primary);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  outline: none;
}

.form-input:hover {
  border-color: var(--border-strong);
}

.form-input:focus {
  border-color: var(--focus);
  box-shadow: var(--shadow-focus);
}

.form-input::placeholder {
  color: var(--ink-muted);
}

.form-input--error {
  border-color: var(--error);
}

.form-input--error:focus {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--error);
}

.form-select {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 var(--space-8) 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 8px center;
  font-size: var(--text-sm);
  color: var(--ink-primary);
  cursor: pointer;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-select:hover {
  border-color: var(--border-strong);
}

.form-select:focus {
  border-color: var(--focus);
  box-shadow: var(--shadow-focus);
}

.form-textarea {
  display: block;
  width: 100%;
  min-height: 80px;
  height: auto;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--ink-primary);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  outline: none;
  resize: vertical;
  line-height: var(--leading-normal);
}

.form-textarea:hover {
  border-color: var(--border-strong);
}

.form-textarea:focus {
  border-color: var(--focus);
  box-shadow: var(--shadow-focus);
}

.form-textarea::placeholder {
  color: var(--ink-muted);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--error);
  margin-top: var(--space-1);
}

.run-start-form__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.run-start-form__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.feedback-area {
  padding: var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  margin-top: var(--space-3);
}

.feedback-area--success {
  background: var(--success-soft);
  color: var(--success);
}

.feedback-area--error {
  background: var(--error-soft);
  color: var(--error);
}


/* ============================================================
   9. WORKSPACE PANEL
   ============================================================ */
.workspace-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.workspace-panel[hidden] {
  display: none;
}

.workspace-panel__section-nav {
  margin-bottom: var(--space-4);
}

/* --- Segmented Control --- */
.segment-control {
  display: inline-flex;
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 2px;
  gap: 2px;
}

.segment-control__btn {
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius-lg) - 2px);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  border: none;
  background: none;
  white-space: nowrap;
}

.segment-control__btn:hover {
  color: var(--ink-primary);
}

.segment-control__btn--active {
  background: var(--surface);
  color: var(--ink-primary);
  font-weight: var(--weight-medium);
  box-shadow: var(--shadow-sm);
}

.segment-control__btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: all var(--duration-fast);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card__value {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
}

.stat-card__context {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.stat-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.stat-card__trend--up {
  color: var(--success);
}

.stat-card__trend--down {
  color: var(--error);
}

.stat-card__trend--neutral {
  color: var(--ink-muted);
}

.stat-card__trend-icon {
  width: 14px;
  height: 14px;
}

/* --- Action Rail --- */
.action-rail {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* --- Action Buttons --- */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  cursor: pointer;
  transition: all var(--duration-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

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

.action-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.action-btn:disabled,
.action-btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.action-btn__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.action-btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--ink-on-accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.action-btn--primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.action-btn--loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.action-btn--loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

.action-btn--secondary {
  background: transparent;
  color: var(--ink-primary);
  border-color: var(--border);
}

.action-btn--secondary:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.action-btn--danger {
  background: transparent;
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}

.action-btn--danger:hover {
  background: var(--error-soft);
  border-color: var(--error);
}

.action-btn--ghost {
  background: transparent;
  color: var(--ink-secondary);
  border-color: transparent;
}

.action-btn--ghost:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.action-btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.action-btn--lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
}

.action-btn--icon-only {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
}

/* --- Generic Button Component (.btn) --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-primary);
  cursor: pointer;
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    box-shadow var(--duration-fast),
    transform var(--duration-fast);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--surface-alt);
  border-color: var(--ink-muted);
}

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

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

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: var(--ink-on-accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3);
}

.btn--primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border-color: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.btn--secondary {
  background: transparent;
  color: var(--ink-primary);
  border-color: var(--border);
}

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

.btn--ghost {
  background: transparent;
  color: var(--ink-secondary);
  border-color: transparent;
}

.btn--ghost:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.btn--danger {
  background: transparent;
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}

.btn--danger:hover {
  background: var(--error-soft);
  border-color: var(--error);
}

.btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
}

.btn--lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
}

.btn--block {
  width: 100%;
}

.btn--loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.btn--loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

/* --- Workspace Content --- */
.workspace-content {
  flex-grow: 1;
  min-height: 0;
}

.workspace-section {
  margin-bottom: var(--space-8);
}

.workspace-section[hidden] {
  display: none;
}

.workspace-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.workspace-section__header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.workspace-section__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-3);
  }

  .action-rail {
    gap: var(--space-2);
  }

  .segment-control {
    width: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
  }

  .stat-card {
    padding: var(--space-3);
  }

  .stat-card__value {
    font-size: var(--text-xl);
  }
}


/* ============================================================
   10. DATA TABLES
   ============================================================ */

/* --- Table Chrome --- */
.data-table-chrome {
  margin-bottom: var(--space-6);
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

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

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

/* --- Table Search --- */
.table-search {
  position: relative;
  display: flex;
  align-items: center;
}

.table-search__icon {
  position: absolute;
  left: var(--space-3);
  width: 16px;
  height: 16px;
  color: var(--ink-muted);
  pointer-events: none;
}

.table-search__input {
  width: 280px;
  height: 40px;
  padding: 0 var(--space-3) 0 calc(var(--space-3) + 20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--ink-primary);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.table-search__input:hover {
  border-color: var(--border-strong);
}

.table-search__input:focus {
  border-color: var(--focus);
  box-shadow: var(--shadow-focus);
}

.table-search__input::placeholder {
  color: var(--ink-muted);
}

/* --- Table Presets --- */
.table-presets {
  display: flex;
  gap: var(--space-1);
}

.table-preset {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.table-preset:hover {
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

.table-preset--active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.table-preset:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Table Toolbar Buttons --- */
.table-columns-btn,
.table-export-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: 1.4;
  cursor: pointer;
  transition: all var(--duration-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  background: transparent;
  color: var(--ink-secondary);
}

.table-columns-btn:hover,
.table-export-btn:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.table-columns-btn:focus-visible,
.table-export-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.table-columns-btn svg,
.table-export-btn svg {
  width: 14px;
  height: 14px;
}

/* --- Filter Chips --- */
.table-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.table-filters:empty {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  background: var(--accent-soft);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.filter-chip__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: transparent;
  cursor: pointer;
  color: var(--accent);
  transition: background var(--duration-fast);
  border: none;
  padding: 0;
}

.filter-chip__remove:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.filter-chip__remove:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.filter-chip__remove svg {
  width: 10px;
  height: 10px;
}

/* --- Table Wrapper & Structure --- */
.data-table-wrapper,
.data-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

/* --- Table Head --- */
.data-table thead {
  background: var(--surface-alt);
}

.data-table thead th {
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  position: relative;
  cursor: default;
}

.data-table thead th[aria-sort] {
  cursor: pointer;
  color: var(--ink-secondary);
}

.data-table thead th[aria-sort]:hover {
  color: var(--ink-primary);
}

.data-table thead th[aria-sort]::after {
  margin-left: var(--space-1);
  font-size: 10px;
}

.data-table thead th[aria-sort="ascending"]::after {
  content: "\25B2";
}

.data-table thead th[aria-sort="descending"]::after {
  content: "\25BC";
}

.data-table thead th[aria-sort="none"]::after {
  content: "\25B2\25BC";
  opacity: 0.3;
  font-size: 8px;
}

/* --- Table Body --- */
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background-color var(--duration-fast);
}

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

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-alt) 60%, transparent);
}

.data-table td {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  color: var(--ink-primary);
  vertical-align: middle;
}

.data-table td.cell--mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-secondary);
}

.data-table td.cell--right {
  text-align: right;
}

.data-table td.cell--center {
  text-align: center;
}

.data-table__row-empty {
  background: var(--surface-elevated);
}

.data-table__empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

/* --- Cell Badge --- */
.cell-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
}

.cell-badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.cell-badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.cell-badge--error {
  background: var(--error-soft);
  color: var(--error);
}

.cell-badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.cell-badge--neutral {
  background: var(--surface-alt);
  color: var(--ink-muted);
}

/* --- Cell Meter (Progress Bar) --- */
.cell-meter {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cell-meter__bar {
  flex-grow: 1;
  height: 6px;
  background: var(--surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.cell-meter__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width var(--duration-slow) var(--ease-out);
}

.cell-meter__fill--high {
  background: var(--success);
}

.cell-meter__fill--medium {
  background: var(--warning);
}

.cell-meter__fill--low {
  background: var(--error);
}

.cell-meter__value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  min-width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Rich Cell (Two Lines) --- */
.cell-rich__primary {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
}

.cell-rich__detail {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 1px;
}

/* --- Pagination --- */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.pagination-info {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

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

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--duration-fast);
  color: var(--ink-secondary);
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--ink-primary);
}

.pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.pagination-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.pagination-btn svg {
  width: 16px;
  height: 16px;
}

.pagination-size {
  appearance: none;
  -webkit-appearance: none;
  height: 32px;
  padding: 0 var(--space-6) 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 6px center;
  font-size: var(--text-xs);
  cursor: pointer;
  color: var(--ink-primary);
  outline: none;
  transition: border-color var(--duration-fast);
}

.pagination-size:hover {
  border-color: var(--border-strong);
}

.pagination-size:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Table Empty and Loading States --- */
.table-empty {
  text-align: center;
  padding: var(--space-10);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.table-loading {
  padding: var(--space-4);
}

.table-loading .skeleton--table-row {
  height: 48px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-md);
}

.table-loading .skeleton--table-row:last-child {
  margin-bottom: 0;
}

/* --- Mobile Responsive Table --- */
@media (max-width: 768px) {
  .table-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-toolbar__left {
    width: 100%;
  }

  .table-toolbar__right {
    width: 100%;
    justify-content: flex-end;
  }

  .table-search__input {
    width: 100%;
  }

  .table-search {
    flex-grow: 1;
  }

  .table-presets {
    flex-wrap: wrap;
  }

  .table-pagination {
    flex-direction: column;
    gap: var(--space-3);
    align-items: center;
  }

  .data-table-scroll {
    position: relative;
  }

  .data-table td:first-child,
  .data-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
  }

  .data-table thead th:first-child {
    background: var(--surface-alt);
  }

  .data-table tbody tr:hover td:first-child {
    background: color-mix(in srgb, var(--surface-alt) 60%, var(--surface));
  }

  .data-table td:first-child::after,
  .data-table thead th:first-child::after {
    content: "";
    position: absolute;
    top: 0;
    right: -8px;
    bottom: 0;
    width: 8px;
    background: linear-gradient(
      90deg,
      rgba(15, 23, 42, 0.06) 0%,
      transparent 100%
    );
    pointer-events: none;
  }
}

@media (max-width: 480px) {
  .data-table td,
  .data-table thead th {
    padding: var(--space-2) var(--space-3);
  }

  .table-pagination {
    padding: var(--space-2) var(--space-3);
  }

  .pagination-info {
    font-size: var(--text-xs);
  }
}
/* ============================================================
   ShiftEZ Design System — Part 2 of 3 (Sections 11–20)
   Depends on design tokens defined in main-part1.css
   ============================================================ */

/* ------------------------------------------------------------
   SECTION 11: Workspace Detail Panel
   ------------------------------------------------------------ */

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: calc(100vw - var(--space-4));
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-overlay);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
}

.detail-panel--open {
  transform: translateX(0);
}

.detail-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.detail-panel__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
}

.detail-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  border: none;
  background: none;
}

.detail-panel__close:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.detail-panel__close:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.detail-panel__close svg {
  width: 20px;
  height: 20px;
}

.detail-panel__body {
  flex-grow: 1;
  overflow-y: auto;
  padding: var(--space-5);
  min-height: 0;
}

.detail-panel__section {
  margin-bottom: var(--space-6);
}

.detail-panel__section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
}

.detail-panel__field {
  margin-bottom: var(--space-4);
}

.detail-panel__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: var(--space-1);
}

.detail-panel__value {
  font-size: var(--text-sm);
  color: var(--ink-primary);
  line-height: var(--leading-normal);
}

.detail-panel__value--mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.detail-panel__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.detail-panel__tag {
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  background: var(--surface-alt);
  color: var(--ink-secondary);
  border: 1px solid var(--border);
}

.detail-panel__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  z-index: calc(var(--z-overlay) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal);
}

.detail-panel__backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

/* ------------------------------------------------------------
   SECTION 12: Activity Feed
   ------------------------------------------------------------ */

.activity-feed {
  display: flex;
  flex-direction: column;
}

.activity-feed__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.activity-feed__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.activity-feed__list {
  display: flex;
  flex-direction: column;
}

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

.activity-feed__item:last-child {
  border-bottom: none;
}

.activity-feed__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink-muted);
}

.activity-feed__icon svg {
  width: 16px;
  height: 16px;
}

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

.activity-feed__actor {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
}

.activity-feed__action {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: var(--leading-normal);
}

.activity-feed__time {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 2px;
}

.activity-feed__load-more {
  display: flex;
  justify-content: center;
  padding: var(--space-4);
}

.activity-feed__load-more-btn {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: var(--space-2) var(--space-4);
}

.activity-feed__load-more-btn:hover {
  text-decoration: underline;
}

.activity-feed__load-more-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   SECTION 13: Export Queue
   ------------------------------------------------------------ */

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

.export-queue[hidden] {
  display: none;
}

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

.export-queue__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.export-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
}

.export-item:hover {
  border-color: var(--border-strong);
}

.export-item__format {
  display: inline-flex;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  background: var(--surface-alt);
  color: var(--ink-secondary);
}

.export-item__status {
  font-size: var(--text-sm);
  color: var(--ink-primary);
}

.export-item__status--ready {
  color: var(--success);
}

.export-item__status--processing {
  color: var(--accent);
}

.export-item__status--failed {
  color: var(--error);
}

.export-item__time {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-left: auto;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.export-item__download {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-left: var(--space-3);
}

.export-item__download:hover {
  text-decoration: underline;
}

.export-item__download:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.export-item__download svg {
  width: 16px;
  height: 16px;
}

/* ------------------------------------------------------------
   SECTION 14: Analytics Cards
   ------------------------------------------------------------ */

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.analytics-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration-fast);
}

.analytics-card:hover {
  box-shadow: var(--shadow-md);
}

.analytics-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.analytics-card__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
}

.analytics-card__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.analytics-card__action:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.analytics-card__action:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.analytics-card__body {
  padding: var(--space-4);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Donut chart (CSS conic-gradient) */

.chart-donut {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  margin: 0 auto;
}

.chart-donut::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 60%;
  border-radius: var(--radius-full);
  background: var(--surface);
}

.chart-donut__center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  text-align: center;
}

.chart-donut__center-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  display: block;
}

.chart-donut__center-label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.chart-donut__legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.chart-donut__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}

.chart-donut__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Bar chart (CSS grid) */

.chart-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.chart-bar__row {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: var(--space-3);
}

.chart-bar__label {
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar__track {
  height: 28px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.chart-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-md);
  transition: width 0.6s var(--ease-out);
}

.chart-bar__value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  min-width: 3ch;
  text-align: right;
}

/* Sparkline */

.chart-sparkline {
  display: inline-block;
  width: 80px;
  height: 24px;
  vertical-align: middle;
}

.chart-sparkline svg {
  width: 100%;
  height: 100%;
}

.chart-sparkline path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
}

/* KPI card */

.kpi-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-6);
}

.kpi-card__value {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: var(--weight-extrabold);
  color: var(--ink-primary);
  line-height: 1.1;
}

.kpi-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-top: var(--space-2);
}

.kpi-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  margin-top: var(--space-2);
}

.kpi-card__trend--up {
  color: var(--success);
}

.kpi-card__trend--down {
  color: var(--error);
}

/* ------------------------------------------------------------
   SECTION 15: Trial Intake Card
   ------------------------------------------------------------ */

.trial-intake {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.trial-intake[hidden] {
  display: none;
}

.trial-intake__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.trial-intake__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.trial-intake__body {
  padding: var(--space-5);
}

.trial-intake__section {
  margin-bottom: var(--space-6);
}

.trial-intake__section:last-child {
  margin-bottom: 0;
}

.trial-intake__section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-secondary);
  margin-bottom: var(--space-3);
}

/* Upload zone */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  background: var(--surface);
}

.upload-zone:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.upload-zone--dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone__icon {
  width: 48px;
  height: 48px;
  color: var(--ink-muted);
  margin: 0 auto var(--space-3);
  opacity: 0.6;
}

.upload-zone__text {
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  margin-bottom: var(--space-1);
}

.upload-zone__hint {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.upload-zone input[type="file"] {
  display: none;
}

/* Settings profile selector */

.settings-profiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.settings-profile {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast);
  text-align: center;
}

.settings-profile:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.settings-profile--selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.settings-profile__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
  margin-bottom: var(--space-1);
}

.settings-profile__description {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* Metric editor */

.metric-editor {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}

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

.metric-editor__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
}

.metric-editor__input {
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--ink-primary);
  background: var(--surface);
  transition: border-color var(--duration-fast);
}

.metric-editor__input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

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

/* Pipeline stages */

.pipeline-stages {
  display: flex;
  align-items: center;
  gap: 0;
  margin: var(--space-4) 0;
  overflow-x: auto;
}

.pipeline-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2);
}

.pipeline-stage__dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast);
  flex-shrink: 0;
}

.pipeline-stage__dot--completed {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.pipeline-stage__dot--completed svg {
  width: 14px;
  height: 14px;
}

.pipeline-stage__dot--active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.pipeline-stage__dot--pending {
  background: var(--surface);
  border-color: var(--border);
}

.pipeline-stage__label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  white-space: nowrap;
}

.pipeline-connector {
  flex-grow: 1;
  height: 2px;
  background: var(--border);
  min-width: 24px;
}

.pipeline-connector--completed {
  background: var(--success);
}

/* Comparison cards */

.comparison-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.comparison-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  text-align: center;
}

.comparison-card__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-secondary);
  margin-bottom: var(--space-3);
}

.comparison-card__value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
}

.comparison-card__detail {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-2);
}

.comparison-card--baseline {
  border-color: var(--border);
}

.comparison-card--optimized {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 30%, var(--surface));
}

/* ------------------------------------------------------------
   SECTION 16: Timeline / Execution
   ------------------------------------------------------------ */

.execution-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.execution-panel[hidden] {
  display: none;
}

/* Timeline */

.timeline {
  position: relative;
}

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

.timeline__header h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.timeline__list {
  display: flex;
  flex-direction: column;
}

.timeline-step {
  display: flex;
  gap: var(--space-4);
  position: relative;
  padding-bottom: var(--space-6);
}

.timeline-step:last-child {
  padding-bottom: 0;
}

.timeline-step:last-child .timeline-step__connector {
  display: none;
}

/* Connector line */

.timeline-step__connector {
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

/* Step marker */

.timeline-step__marker {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  transition: all var(--duration-fast);
}

.timeline-step__marker svg {
  width: 16px;
  height: 16px;
}

.timeline-step__marker--completed {
  background: var(--success-soft);
  border: 2px solid var(--success);
  color: var(--success);
}

.timeline-step__marker--in_progress {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  color: var(--accent);
  animation: pulse 2s infinite;
}

.timeline-step__marker--pending {
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--ink-muted);
}

.timeline-step__marker--failed {
  background: var(--error-soft);
  border: 2px solid var(--error);
  color: var(--error);
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 var(--accent-soft);
  }
  50% {
    box-shadow: 0 0 0 6px transparent;
  }
}

/* Step body */

.timeline-step__body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
  padding-top: 4px;
}

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

.timeline-step__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
}

.timeline-step__summary {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-1);
  line-height: var(--leading-normal);
}

.timeline-step__time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-1);
}

.timeline-step--active {
  background: color-mix(in srgb, var(--accent-soft) 30%, transparent);
  margin: calc(-1 * var(--space-2));
  padding: var(--space-2);
  padding-bottom: calc(var(--space-6) + var(--space-2));
  border-radius: var(--radius-lg);
}

.timeline-step--active:last-child {
  padding-bottom: var(--space-2);
}

/* Step detail panel */

.step-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.step-detail__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.step-detail__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  border: none;
  background: none;
}

.step-detail__close:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.step-detail__close:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.step-detail__body {
  padding: var(--space-5);
}

.step-detail__section {
  margin-bottom: var(--space-6);
}

.step-detail__section:last-child {
  margin-bottom: 0;
}

.step-detail__section-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin-bottom: var(--space-3);
}

/* Context card */

.step-detail__context {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}

/* Key-value card */

.step-detail__kv-card {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.step-detail__kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.step-detail__kv-row:last-child {
  border-bottom: none;
}

.step-detail__kv-key {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

.step-detail__kv-value {
  font-size: var(--text-sm);
  color: var(--ink-primary);
  font-family: var(--font-mono);
  text-align: right;
}

/* Artifacts */

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

.step-detail__artifact {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--accent);
  cursor: pointer;
  transition: all var(--duration-fast);
  background: none;
  text-decoration: none;
}

.step-detail__artifact:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.step-detail__artifact:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.step-detail__artifact svg {
  width: 16px;
  height: 16px;
}

/* Events chronology */

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

.step-detail__event {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.step-detail__event-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  flex-shrink: 0;
  min-width: 60px;
}

.step-detail__event-text {
  color: var(--ink-secondary);
}

.step-detail__event-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border);
  flex-shrink: 0;
  margin-top: 6px;
}

/* Human interaction form */

.human-interaction-form {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-top: var(--space-4);
}

.human-interaction-form[hidden] {
  display: none;
}

.human-interaction-form__header {
  margin-bottom: var(--space-5);
}

.human-interaction-form__header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

.human-interaction-form__description {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-top: var(--space-2);
  line-height: var(--leading-normal);
}

.hi-field {
  margin-bottom: var(--space-5);
}

.hi-field__label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
  margin-bottom: var(--space-2);
}

.hi-field__help {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: var(--space-1);
}

.hi-field__input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--ink-primary);
  background: var(--surface);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.hi-field__input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.hi-field__select {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--space-8) 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--ink-primary);
  background: var(--surface);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  transition: border-color var(--duration-fast);
}

.hi-field__select:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.hi-field__textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--ink-primary);
  background: var(--surface);
  resize: vertical;
  line-height: var(--leading-normal);
  transition: border-color var(--duration-fast);
}

.hi-field__textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.hi-field__date {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--ink-primary);
  background: var(--surface);
  transition: border-color var(--duration-fast);
}

.hi-field__date:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

/* Toggle switch */

.hi-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.hi-toggle__track {
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: background var(--duration-fast);
  position: relative;
  flex-shrink: 0;
}

.hi-toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast);
}

.hi-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.hi-toggle input:checked + .hi-toggle__track {
  background: var(--accent);
}

.hi-toggle input:checked + .hi-toggle__track .hi-toggle__thumb {
  transform: translateX(20px);
}

.hi-toggle input:focus-visible + .hi-toggle__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.hi-toggle__label {
  font-size: var(--text-sm);
  color: var(--ink-primary);
}

.human-interaction-form__actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------
   SECTION 17: Command Palette
   ------------------------------------------------------------ */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  justify-content: center;
  padding-top: 15vh;
}

.command-palette--hidden {
  display: none;
}

.command-palette__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: -1;
}

.command-palette__dialog {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 640px;
  max-width: calc(100vw - var(--space-8));
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  z-index: 1;
  overflow: hidden;
  animation: scaleIn var(--duration-normal) var(--ease-out);
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.command-palette__search-icon {
  width: 20px;
  height: 20px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.command-palette__input {
  flex-grow: 1;
  border: none;
  background: transparent;
  font-size: var(--text-lg);
  color: var(--ink-primary);
  outline: none;
  font-family: var(--font-body);
}

.command-palette__input::placeholder {
  color: var(--ink-muted);
}

.command-palette__shortcut {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  padding: 2px var(--space-2);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.command-palette__results {
  overflow-y: auto;
  padding: var(--space-2);
}

.command-palette__group {
  margin-bottom: var(--space-2);
}

.command-palette__group:last-child {
  margin-bottom: 0;
}

.command-palette__group-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  padding: var(--space-2) var(--space-3);
}

.command-palette__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.command-palette__item:hover,
.command-palette__item--highlighted {
  background: var(--surface-alt);
}

.command-palette__item--active {
  background: var(--accent-soft);
  color: var(--accent);
}

.command-palette__item-icon {
  width: 20px;
  height: 20px;
  color: var(--ink-muted);
  flex-shrink: 0;
}

.command-palette__item--active .command-palette__item-icon,
.command-palette__item--highlighted .command-palette__item-icon {
  color: inherit;
}

.command-palette__item-label {
  font-size: var(--text-sm);
  flex-grow: 1;
  color: var(--ink-primary);
}

.command-palette__item--active .command-palette__item-label {
  color: var(--accent);
}

.command-palette__item-shortcut {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  padding: 2px var(--space-2);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}

.command-palette__empty {
  padding: var(--space-8);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.command-palette__empty[hidden] {
  display: none;
}

/* ------------------------------------------------------------
   SECTION 18: Notification Center
   ------------------------------------------------------------ */

.notification-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: calc(100vw - var(--space-4));
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-overlay);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
  display: flex;
  flex-direction: column;
}

.notification-drawer--open {
  transform: translateX(0);
}

.notification-drawer__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notification-drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  flex-grow: 1;
}

.notification-drawer__mark-read {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.notification-drawer__mark-read:hover {
  text-decoration: underline;
}

.notification-drawer__mark-read:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.notification-drawer__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  border: none;
  background: none;
}

.notification-drawer__close:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.notification-drawer__close:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.notification-drawer__close svg {
  width: 20px;
  height: 20px;
}

.notification-drawer__filters {
  display: flex;
  gap: 0;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.notification-filter {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: all var(--duration-fast);
  white-space: nowrap;
}

.notification-filter:hover {
  color: var(--ink-primary);
}

.notification-filter--active,
.notification-filter[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: var(--weight-medium);
}

.notification-filter:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px; /* Inset focus to prevent overflow clipping */
}

.notification-drawer__list {
  overflow-y: auto;
  flex-grow: 1;
  min-height: 0;
}

.notification-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--duration-fast);
  position: relative;
}

.notification-item:hover {
  background: var(--surface-alt);
}

.notification-item--unread::before {
  content: "";
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent);
}

.notification-item--unread {
  padding-left: calc(var(--space-5) + 16px);
}

.notification-item__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--ink-muted);
}

.notification-item__icon svg {
  width: 18px;
  height: 18px;
}

.notification-item__icon--success {
  background: var(--success-soft);
  color: var(--success);
}

.notification-item__icon--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.notification-item__icon--error {
  background: var(--error-soft);
  color: var(--error);
}

.notification-item__icon--info {
  background: var(--info-soft);
  color: var(--info);
}

.notification-item__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex-grow: 1;
}

.notification-item__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-item__text {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notification-item__time {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 4px;
  white-space: nowrap;
}

/* ------------------------------------------------------------
   SECTION 19: Onboarding Overlay
   ------------------------------------------------------------ */

.onboarding-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.onboarding-backdrop[hidden] {
  display: none !important;
}

.onboarding-backdrop .onboarding {
  position: relative;
  inset: auto;
  z-index: 1;
  display: block;
  width: min(760px, calc(100vw - (var(--space-4) * 2)));
  max-height: calc(100vh - (var(--space-4) * 2));
  overflow: auto;
  padding: var(--space-6);
  background: var(--surface);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
}

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.onboarding-overlay[hidden] {
  display: none !important;
}

.onboarding-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.onboarding-overlay__panel,
.onboarding-overlay__dialog {
  position: relative;
  z-index: 1;
  width: min(560px, calc(100vw - (var(--space-4) * 2)));
  max-height: calc(100vh - (var(--space-4) * 2));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-5);
}

.onboarding-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.onboarding-overlay__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
}

.onboarding-overlay__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.onboarding-overlay__step {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: var(--space-3);
}

.onboarding-overlay__step-icon {
  color: var(--ink-muted);
}

.onboarding-overlay__step-text {
  color: var(--ink-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.onboarding-overlay__step--active .onboarding-overlay__step-icon,
.onboarding-overlay__step--active .onboarding-overlay__step-text {
  color: var(--accent);
  font-weight: var(--weight-medium);
}

.onboarding-overlay__footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.onboarding__header {
  margin-bottom: var(--space-5);
}

.onboarding__title {
  margin: 0 0 var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
}

.onboarding__subtitle {
  margin: 0;
  font-size: var(--text-base);
  color: var(--ink-secondary);
}

.onboarding__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}

.onboarding__step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: var(--space-3);
  align-items: start;
}

.onboarding__step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  color: var(--ink-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.onboarding__step--active .onboarding__step-number {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.onboarding__step-content {
  min-width: 0;
}

.onboarding__step-desc {
  margin: 0;
  font-size: var(--text-base);
  color: var(--ink-secondary);
  line-height: var(--leading-normal);
}

.onboarding__footer {
  margin-top: var(--space-6);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.onboarding {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding--hidden {
  display: none;
}

.onboarding__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.onboarding__dialog {
  background: var(--surface);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 540px;
  max-width: calc(100vw - var(--space-8));
  z-index: 1;
  animation: scaleIn var(--duration-slow) var(--ease-out);
}

.onboarding__progress {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  padding: var(--space-5) var(--space-6) 0;
}

.onboarding__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: all var(--duration-fast);
}

.onboarding__dot--active {
  background: var(--accent);
  transform: scale(1.25);
}

.onboarding__dot--completed {
  background: var(--success);
}

.onboarding__content {
  padding: var(--space-6) var(--space-8);
  text-align: center;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.onboarding__illustration {
  width: 120px;
  height: 100px;
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
}

.onboarding__step-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  margin-bottom: var(--space-3);
}

.onboarding__step-text {
  font-size: var(--text-base);
  color: var(--ink-secondary);
  line-height: var(--leading-normal);
  max-width: 400px;
}

.onboarding__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6) var(--space-6);
  gap: var(--space-3);
}

.onboarding__btn-prev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-body);
  color: var(--ink-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.onboarding__btn-prev:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.onboarding__btn-prev:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.onboarding__btn-prev[hidden] {
  visibility: hidden;
}

.onboarding__btn-skip,
.onboarding__skip {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-body);
}

.onboarding__btn-skip:hover,
.onboarding__skip:hover {
  color: var(--ink-primary);
}

.onboarding__btn-skip:focus-visible,
.onboarding__skip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.onboarding__btn-next,
.onboarding__next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-body);
  color: white;
  background: var(--accent);
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-sm);
}

.onboarding__btn-next:hover,
.onboarding__next:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.onboarding__btn-next:focus-visible,
.onboarding__next:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.onboarding__btn-next:active,
.onboarding__next:active {
  transform: scale(0.98);
}

.onboarding__btn-complete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-body);
  color: white;
  background: var(--accent);
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: var(--shadow-sm);
}

.onboarding__btn-complete:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-md);
}

.onboarding__btn-complete:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.onboarding__btn-complete:active {
  transform: scale(0.98);
}

.onboarding__btn-complete[hidden] {
  display: none;
}

/* ------------------------------------------------------------
   SECTION 20: Theme Toggle
   ------------------------------------------------------------ */

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  transition: all var(--duration-fast);
  border: none;
  color: var(--ink-muted);
}

.theme-toggle:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

.theme-toggle__icon {
  transition: transform var(--duration-normal) var(--ease-out);
  display: block;
}

.theme-toggle__icon--sun {
  display: none;
}

.theme-toggle__icon--moon {
  display: block;
}

[data-theme="dark"] .theme-toggle__icon--sun {
  display: block;
}

[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

.theme-toggle__tooltip {
  position: absolute;
  bottom: calc(-100% - 8px);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  color: var(--surface);
  background: var(--ink-primary);
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
  z-index: var(--z-tooltip);
}

.theme-toggle:hover .theme-toggle__tooltip {
  opacity: 1;
}
/* ============================================================
   ShiftEZ Design System — Part 3 of 3 (Sections 21–29)
   Tokens defined in main-part1.css; consumed here via var().
   Fonts: var(--font-display)=Syne, var(--font-body)=Outfit,
          var(--font-mono)=Red Hat Mono.
   ============================================================ */

/* ------------------------------------------------------------
   SECTION 21: Calendar View
   ------------------------------------------------------------ */

.calendar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar[hidden] {
  display: none;
}

/* Toolbar */

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

.calendar__view-select {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.calendar__view-select button {
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.calendar__view-select button:hover {
  color: var(--ink-primary);
}

.calendar__view-select button[aria-pressed="true"],
.calendar__view-select button.is-active {
  background: var(--surface);
  color: var(--ink-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-sm);
}

.calendar__view-select button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.calendar__nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.calendar__nav-btn:hover {
  border-color: var(--border-strong);
  color: var(--ink-primary);
  background: var(--surface-alt);
}

.calendar__nav-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.calendar__nav-btn svg {
  width: 16px;
  height: 16px;
}

.calendar__today-btn {
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
  cursor: pointer;
  background: var(--surface);
  transition: all var(--duration-fast);
  font-family: var(--font-body);
}

.calendar__today-btn:hover {
  background: var(--surface-alt);
  border-color: var(--border-strong);
}

.calendar__today-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.calendar__period {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
}

/* Month grid */

.calendar__grid--month {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.calendar__day-header {
  padding: var(--space-2);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.calendar__cell {
  min-height: 100px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: var(--space-2);
  position: relative;
  transition: background var(--duration-fast);
}

.calendar__cell:nth-child(7n) {
  border-right: none;
}

.calendar__cell:hover {
  background: var(--surface-alt);
}

.calendar__cell--today {
  background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface));
}

.calendar__cell--today .calendar__date {
  color: var(--accent);
  font-weight: var(--weight-bold);
}

.calendar__cell--outside {
  opacity: 0.35;
}

.calendar__date {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
  margin-bottom: var(--space-1);
}

.calendar__shifts {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar__shift {
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all var(--duration-fast);
  line-height: 1.5;
}

.calendar__shift:hover {
  opacity: 0.85;
}

.calendar__shift--morning {
  background: var(--info-soft);
  color: var(--info);
}

.calendar__shift--afternoon {
  background: var(--warning-soft);
  color: var(--warning);
}

.calendar__shift--night {
  background: var(--surface-raised);
  color: var(--ink-muted);
}

.calendar__shift--open {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px dashed var(--accent);
}

.calendar__shift--day-off {
  background: var(--success-soft);
  color: var(--success);
}

/* Week grid */

.calendar__grid--week {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  grid-auto-rows: 60px;
}

.calendar__time-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-align: right;
  padding-right: var(--space-2);
  padding-top: var(--space-1);
  border-right: 1px solid var(--border);
}

.calendar__week-header {
  padding: var(--space-2);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--surface-alt);
}

.calendar__hour-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  position: relative;
}

/* Day grid */

.calendar__grid--day {
  display: grid;
  grid-template-columns: 60px 1fr;
  grid-auto-rows: 60px;
}

/* Calendar responsive — mobile */

@media (max-width: 528px) {
  .calendar__cell {
    min-height: 60px;
    padding: var(--space-1);
  }

  .calendar__shift {
    font-size: 0;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    padding: 0;
    display: inline-block;
    overflow: visible;
    text-overflow: unset;
    white-space: normal;
  }

  .calendar__shifts {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
  }
}

/* ------------------------------------------------------------
   SECTION 22: Dashboard / Charts
   ------------------------------------------------------------ */

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.dashboard-grid[hidden] {
  display: none;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--duration-fast);
}

.chart-card:hover {
  box-shadow: var(--shadow-md);
}

.chart-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.chart-card__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
}

.chart-card__body {
  padding: var(--space-4);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Donut chart */

.donut-chart {
  position: relative;
  width: 140px;
  height: 140px;
  border-radius: var(--radius-full);
  margin: 0 auto;
}

.donut-chart::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  height: 65%;
  border-radius: var(--radius-full);
  background: var(--surface);
}

.donut-chart__center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  text-align: center;
}

.donut-chart__value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  display: block;
}

.donut-chart__label {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.donut-chart__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.donut-chart__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-secondary);
}

.donut-chart__legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Bar chart */

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2);
}

.bar-chart__item {
  display: grid;
  grid-template-columns: 90px 1fr 40px;
  align-items: center;
  gap: var(--space-3);
}

.bar-chart__label {
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-chart__track {
  height: 28px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.bar-chart__fill {
  height: 100%;
  border-radius: var(--radius-md);
  transition: width 0.6s var(--ease-out);
  background: var(--accent);
}

.bar-chart__fill--empty {
  width: 0;
}

.bar-chart__value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--ink-muted);
  text-align: right;
}

/* Sparkline */

.sparkline {
  display: inline-flex;
  align-items: center;
  width: 80px;
  height: 24px;
  vertical-align: middle;
}

.sparkline svg {
  width: 100%;
  height: 100%;
}

.sparkline__line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------
   SECTION 23: Settings Panel
   ------------------------------------------------------------ */

.settings-panel {
  max-width: 640px;
}

.settings-panel[hidden] {
  display: none;
}

.settings-section {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--ink-primary);
  margin-bottom: var(--space-1);
}

.settings-section__description {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-bottom: var(--space-5);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
}

.settings-row + .settings-row {
  border-top: 1px solid var(--border);
}

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

.settings-row__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
}

.settings-row__help {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 2px;
}

.settings-row__control {
  flex-shrink: 0;
}

/* Toggle switch */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch__track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--border);
  transition: background var(--duration-fast);
}

.toggle-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast);
}

.toggle-switch input:checked + .toggle-switch__track {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-switch__track::after {
  transform: translateX(20px);
}

.toggle-switch input:focus-visible + .toggle-switch__track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.settings-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  padding-top: var(--space-6);
}

/* --- Settings Form Fields (Portal) --- */
.settings-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.settings-field__label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-secondary);
}

.settings-field__input,
.settings-field__select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--ink-primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
}

.settings-field__input:hover,
.settings-field__select:hover {
  border-color: var(--ink-muted);
}

.settings-field__input:focus,
.settings-field__select:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--focus);
}

.settings-field__select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 4.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

/* --- Settings Toggle (Portal) --- */
.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
}

.settings-toggle:last-child {
  border-bottom: none;
}

.settings-toggle__label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  flex: 1;
}

.settings-toggle__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
}

.settings-toggle__desc {
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.settings-toggle__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.settings-toggle__switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}

.settings-toggle__switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast);
}

.settings-toggle__input:checked ~ .settings-toggle__switch {
  background: var(--accent);
}

.settings-toggle__input:checked ~ .settings-toggle__switch::after {
  transform: translateX(20px);
}

.settings-toggle__input:focus-visible ~ .settings-toggle__switch {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Form Feedback --- */
.form-feedback {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.form-feedback:empty {
  display: none;
}

.form-feedback--success {
  background: var(--success-soft, color-mix(in srgb, var(--success) 10%, transparent));
  color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 20%, transparent);
}

.form-feedback--error {
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid color-mix(in srgb, var(--error) 20%, transparent);
}

/* ------------------------------------------------------------
   SECTION 24: Self-Service Cards
   ------------------------------------------------------------ */

.self-service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.self-service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  cursor: pointer;
  transition: all var(--duration-fast);
  text-decoration: none;
}

.self-service-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: var(--accent);
}

.self-service-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.self-service-card:active {
  transform: translateY(0);
}

.self-service-card__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.self-service-card__icon svg {
  width: 24px;
  height: 24px;
}

.self-service-card__title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--ink-primary);
}

.self-service-card__description {
  font-size: var(--text-sm);
  color: var(--ink-muted);
  line-height: var(--leading-normal);
}

.self-service-card__cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--accent);
  margin-top: auto;
}

.self-service-card__cta::after {
  content: "\2192";
  transition: transform var(--duration-fast);
}

.self-service-card:hover .self-service-card__cta::after {
  transform: translateX(4px);
}

/* ------------------------------------------------------------
   SECTION 25: Toast Notifications
   ------------------------------------------------------------ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-3);
  pointer-events: none;
}

.toast-container:empty {
  display: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 360px;
  max-width: 420px;
  pointer-events: auto;
  animation: slideInRight var(--duration-slow) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.toast--success {
  border-left: 4px solid var(--success);
}

.toast--error {
  border-left: 4px solid var(--error);
}

.toast--warning {
  border-left: 4px solid var(--warning);
}

.toast--info {
  border-left: 4px solid var(--info);
}

.toast__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast--success .toast__icon {
  color: var(--success);
}

.toast--error .toast__icon {
  color: var(--error);
}

.toast--warning .toast__icon {
  color: var(--warning);
}

.toast--info .toast__icon {
  color: var(--info);
}

.toast__body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
}

.toast__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
}

.toast__message {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 2px;
}

.toast__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  flex-shrink: 0;
  background: none;
  border: none;
}

.toast__close:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.toast__close svg {
  width: 14px;
  height: 14px;
}

.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 0 var(--radius-lg);
  animation: toastShrink linear forwards;
}

.toast--success .toast__progress {
  background: var(--success);
}

.toast--error .toast__progress {
  background: var(--error);
}

.toast--warning .toast__progress {
  background: var(--warning);
}

.toast--info .toast__progress {
  background: var(--info);
}

@keyframes toastShrink {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}

/* ------------------------------------------------------------
   SECTION 26: Utility Components
   ------------------------------------------------------------ */

/* Breadcrumb */

.breadcrumb {
  font-size: var(--text-sm);
}

.breadcrumb__list {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

.breadcrumb__item {
  display: inline-flex;
  align-items: center;
  color: var(--ink-muted);
}

.breadcrumb__item + .breadcrumb__item::before {
  content: "/";
  margin-right: var(--space-1);
  color: var(--ink-muted);
  opacity: 0.4;
  font-size: var(--text-xs);
}

.breadcrumb__link {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color var(--duration-fast);
}

.breadcrumb__link:hover {
  color: var(--ink-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.breadcrumb__item--current {
  color: var(--ink-secondary);
  font-weight: var(--weight-medium);
}

.breadcrumb__separator {
  color: var(--ink-muted);
  opacity: 0.4;
  margin: 0 2px;
  font-size: var(--text-xs);
  user-select: none;
}

/* Avatar */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: var(--weight-medium);
  font-family: var(--font-body);
  flex-shrink: 0;
  overflow: hidden;
  user-select: none;
}

.avatar--sm {
  width: 28px;
  height: 28px;
  font-size: var(--text-xs);
}

.avatar--md {
  width: 36px;
  height: 36px;
  font-size: var(--text-sm);
}

.avatar--lg {
  width: 48px;
  height: 48px;
  font-size: var(--text-md);
}

.avatar__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Account dropdown */

.account-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  min-width: 220px;
  z-index: var(--z-overlay);
  overflow: hidden;
  animation: scaleIn var(--duration-fast) var(--ease-out);
}

.account-dropdown[hidden] {
  display: none;
}

.account-dropdown__header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.account-dropdown__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink-primary);
}

.account-dropdown__email {
  font-size: var(--text-xs);
  color: var(--ink-muted);
  margin-top: 1px;
}

.account-dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
  text-decoration: none;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
}

.account-dropdown__item:hover {
  background: var(--surface-alt);
  color: var(--ink-primary);
}

.account-dropdown__item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.account-dropdown__item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--ink-muted);
}

.account-dropdown__divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

.account-dropdown__item--danger {
  color: var(--error);
}

.account-dropdown__item--danger:hover {
  background: var(--error-soft);
}

/* Search trigger */

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
  background: var(--surface);
  min-width: 200px;
}

.search-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

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

.search-trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-trigger__text {
  flex-grow: 1;
}

.search-trigger__shortcut {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 2px var(--space-2);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

/* Environment badge */

.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--info-soft);
  color: var(--info);
}

.env-badge--dev {
  background: var(--info-soft);
  color: var(--info);
}

.env-badge--staging {
  background: var(--warning-soft);
  color: var(--warning);
}

.env-badge--prod {
  background: var(--success-soft);
  color: var(--success);
}

/* Connection status */

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

.connection-status__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
}

.connection-status--connected .connection-status__dot {
  background: var(--success);
}

.connection-status--disconnected .connection-status__dot {
  background: var(--error);
}

.connection-status--connecting .connection-status__dot {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

/* Error boundary */

.error-boundary {
  padding: var(--space-8);
  text-align: center;
  background: var(--error-soft);
  border: 1px solid color-mix(in srgb, var(--error) 20%, transparent);
  border-radius: var(--radius-lg);
  margin: var(--space-4);
}

.error-boundary[hidden] {
  display: none;
}

.error-boundary__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--error);
  margin-bottom: var(--space-2);
}

.error-boundary__message {
  font-size: var(--text-base);
  color: var(--ink-secondary);
  margin-bottom: var(--space-6);
}

/* Skip link */

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--surface);
  color: var(--accent);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  z-index: var(--z-tooltip);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  transition: top var(--duration-fast);
}

.skip-link:focus {
  top: var(--space-4);
}

/* Screen reader only */

.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;
}

/* Meta grid */

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

.meta-grid[hidden] {
  display: none;
}

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

.meta-grid__label {
  color: var(--ink-muted);
  font-weight: var(--weight-medium);
}

.meta-grid__value {
  color: var(--ink-primary);
}

.meta-grid__value--mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* ------------------------------------------------------------
   SECTION 27: Animations & Micro-interactions
   ------------------------------------------------------------ */

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast--leaving {
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}

/* ── Offline Banner ── */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  padding: 8px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  /* Status-only surface: never block primary header controls. */
  pointer-events: none;
  transition: transform 300ms var(--ease-out);
}
.offline-banner[hidden] {
  display: block;
  transform: translateY(-100%);
  pointer-events: none;
}
.offline-banner--warning {
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fcd34d;
}
.offline-banner--success {
  background: #d1fae5;
  color: #065f46;
  border-bottom: 1px solid #6ee7b7;
}
[data-theme="dark"] .offline-banner--warning {
  background: #451a03;
  color: #fcd34d;
  border-bottom-color: #92400e;
}
[data-theme="dark"] .offline-banner--success {
  background: #064e3b;
  color: #6ee7b7;
  border-bottom-color: #065f46;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Grain overlay */

.grain-overlay {
  position: relative;
}

.grain-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  background-repeat: repeat;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}

/* Card hover lift */

.card-hover-lift {
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast);
}

.card-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Button press */

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

/* Animate in (staggered) */

.animate-in {
  animation: fadeSlideUp var(--duration-slow) var(--ease-out) both;
}

.animate-in--delay-1 {
  animation-delay: 100ms;
}

.animate-in--delay-2 {
  animation-delay: 200ms;
}

.animate-in--delay-3 {
  animation-delay: 300ms;
}

.animate-in--delay-4 {
  animation-delay: 400ms;
}

.animate-in--delay-5 {
  animation-delay: 500ms;
}

.animate-in--delay-6 {
  animation-delay: 600ms;
}

/* Spinner */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
}

.spinner--sm {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.spinner--lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* Content visibility for off-screen panels */

.content-auto {
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
}

/* ------------------------------------------------------------
   SECTION 28: Accessibility Overrides
   ------------------------------------------------------------ */

/* Reduced motion */

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

  .skeleton::after {
    animation: none;
  }

  .timeline-step__marker--in_progress {
    animation: none;
  }
}

/* High contrast */

@media (prefers-contrast: more) {
  :root {
    --border: #94a3b8;
    --border-strong: #64748b;
    --ink-muted: #334155;
  }

  .action-btn,
  .form-input,
  .form-select,
  .form-textarea {
    border-width: 2px;
  }

  .status-badge,
  .cell-badge,
  .filter-chip {
    border: 1px solid currentColor;
  }

  body {
    font-weight: calc(var(--weight-regular) + 100);
  }
}

/* Forced colors */

@media (forced-colors: active) {
  .action-btn {
    border: 1px solid ButtonText;
  }

  .action-btn--primary {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonText;
  }

  .status-badge,
  .cell-badge {
    border: 1px solid;
  }

  .form-input:focus,
  .form-select:focus,
  .form-textarea:focus {
    outline: 2px solid Highlight;
  }

  .sidebar-nav__item--active {
    border-color: Highlight;
    color: Highlight;
  }

  .surface-tab[aria-selected="true"],
  .workbench-tab[aria-selected="true"] {
    border-color: Highlight;
  }

  .toggle-switch__track {
    border: 1px solid ButtonText;
  }

  .stat-card,
  .card,
  .self-service-card,
  .analytics-card {
    border: 1px solid ButtonText;
  }

  .notification-item--unread::before {
    background: Highlight;
  }

  .progress-bar__fill {
    background: Highlight;
  }

  .skeleton,
  .skeleton::after {
    background: ButtonFace;
    border: 1px solid ButtonText;
  }
}

/* Focus ring (global) */

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Print styles */

@media print {
  .shell-sidebar,
  .shell > .sidebar,
  .shell-header,
  .toast-container,
  .command-palette,
  .notification-drawer,
  .onboarding,
  .progress-bar,
  .error-boundary,
  .action-rail,
  .table-toolbar,
  .table-pagination {
    display: none !important;
  }

  .shell {
    display: block;
  }

  .shell-main {
    padding: 0;
    overflow: visible;
  }

  .data-table-wrapper,
  .data-table-wrap {
    border: 1px solid #000;
    overflow: visible;
  }

  .stat-card,
  .card,
  .analytics-card {
    break-inside: avoid;
  }

  body {
    background: white;
    color: black;
    widows: 2;
    orphans: 2;
  }

  a[href]::after {
    content: none;
  }
}

/* ------------------------------------------------------------
   SECTION 29: Responsive Breakpoints
   ------------------------------------------------------------ */

/* Mobile (max-width: 528px) */

@media (max-width: 528px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }

  .shell-sidebar,
  .shell > .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: var(--z-sidebar);
  }

  .shell--sidebar-open .shell-sidebar,
  .shell--sidebar-open > .sidebar {
    transform: translateX(0);
  }

  .shell-main {
    padding: var(--space-4);
  }

  .header-bar {
    padding: var(--space-2) var(--space-3);
  }

  .header-command-bar {
    margin: 0;
    border-radius: 0;
    flex-direction: column;
    align-items: flex-start;
  }

  .header__row--secondary {
    padding: var(--space-3);
    gap: var(--space-3);
  }

  .header__command-input-wrap {
    min-height: 40px;
  }

  .header__command-kbd {
    display: none;
  }

  .header-snapshot__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-trigger {
    min-width: auto;
  }

  .search-trigger__text,
  .search-trigger__shortcut {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .stat-card {
    padding: var(--space-3);
  }

  .stat-card__value {
    font-size: var(--text-xl);
  }

  .action-rail {
    gap: var(--space-2);
  }

  .action-btn {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .table-search__input {
    width: 100%;
  }

  .data-table-scroll {
    margin: 0 calc(-1 * var(--space-4));
    padding: 0 var(--space-4);
  }

  .detail-panel {
    width: 100%;
  }

  .notification-drawer {
    width: 100%;
  }

  .command-palette__dialog {
    width: calc(100vw - var(--space-6));
    margin-top: var(--space-6);
  }

  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .comparison-cards {
    grid-template-columns: 1fr;
  }

  .self-service-grid {
    grid-template-columns: 1fr;
  }

  .calendar__cell {
    min-height: 60px;
    padding: var(--space-1);
  }

  .calendar__shift {
    font-size: 10px;
    padding: 1px 4px;
  }

  .calendar__grid--week,
  .calendar__grid--day {
    display: none;
  }

  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
  }

  .toast {
    min-width: auto;
    max-width: none;
  }

  .onboarding__dialog {
    width: calc(100vw - var(--space-6));
  }

  .onboarding__content {
    padding: var(--space-4);
  }

  .pipeline-stages {
    overflow-x: auto;
    padding-bottom: var(--space-2);
  }
}

/* Tablet (min-width: 768px) */

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .self-service-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .run-start-form__fields {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop (min-width: 1120px) */

@media (min-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .self-service-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .analytics-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .header-snapshot__grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Wide desktop (min-width: 1440px) */

@media (min-width: 1440px) {
  .shell-main {
    padding: var(--space-8);
  }

  .shell-main__content,
  .shell-main > [role="tabpanel"] {
    max-width: 90rem;
  }
}
