/* ============================================================
   aireal.admin · unified design tokens
   Clean light neutral · single orange accent
   ============================================================ */
:root {
  /* Neutrals — warm-leaning, oklch */
  --bg:          oklch(0.985 0.003 70);      /* page */
  --surface:     oklch(1     0     0);       /* cards */
  --surface-2:   oklch(0.97  0.003 70);      /* subtler surface */
  --surface-3:   oklch(0.945 0.004 70);      /* hover */
  --border:      oklch(0.91  0.004 70);
  --border-strong: oklch(0.84 0.005 70);
  --ink:         oklch(0.22  0.006 70);
  --ink-2:       oklch(0.42  0.006 70);
  --ink-3:       oklch(0.60  0.006 70);
  --ink-4:       oklch(0.76  0.005 70);

  /* Accent — warm orange, single accent across app */
  --accent:       oklch(0.65 0.18 45);
  --accent-hover: oklch(0.60 0.18 45);
  --accent-soft:  oklch(0.65 0.18 45 / 0.12);
  --accent-ink:   #ffffff;

  /* Status — muted, same chroma family */
  --ok:      oklch(0.62 0.13 155);
  --ok-soft: oklch(0.62 0.13 155 / 0.14);
  --warn:    oklch(0.70 0.15 75);
  --warn-soft: oklch(0.70 0.15 75 / 0.16);
  --err:     oklch(0.60 0.19 25);
  --err-soft: oklch(0.60 0.19 25 / 0.14);
  --info:    oklch(0.62 0.13 240);
  --info-soft: oklch(0.62 0.13 240 / 0.14);

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Layout */
  --sidebar-w:     232px;
  --sidebar-w-min: 60px;
  --header-h:      52px;
  --radius:        6px;
  --radius-sm:     4px;
  --shadow-sm: 0 1px 2px oklch(0.2 0.01 70 / 0.04), 0 1px 1px oklch(0.2 0.01 70 / 0.03);
  --shadow-md: 0 4px 12px oklch(0.2 0.01 70 / 0.08), 0 1px 3px oklch(0.2 0.01 70 / 0.04);
  --shadow-lg: 0 16px 40px oklch(0.2 0.01 70 / 0.14), 0 4px 12px oklch(0.2 0.01 70 / 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   Shell
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    'sidebar header'
    'sidebar main';
  height: 100vh;
  transition: grid-template-columns 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.app.collapsed { grid-template-columns: var(--sidebar-w-min) 1fr; }

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: var(--header-h);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px;
  white-space: nowrap;
}
.sidebar-brand .brand-mark {
  width: 24px; height: 24px; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.sidebar-brand .brand-env {
  font-family: var(--font-mono); font-size: 10px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-left: auto; padding: 2px 6px;
  background: var(--surface-3); border-radius: 3px;
}
.sidebar-brand .brand-env-prod { color: #166534; background: #dcfce7; }
.sidebar-brand .brand-env-dev  { color: #9a3412; background: #fed7aa; }
.app.collapsed .sidebar-brand .brand-text,
.app.collapsed .sidebar-brand .brand-env { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-group { margin-bottom: 14px; }
.nav-group-label {
  font-size: 10.5px; font-weight: 600;
  color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em;
  padding: 4px 10px 6px; white-space: nowrap;
}
.app.collapsed .nav-group-label { opacity: 0; height: 8px; padding: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-size: 13.5px; font-weight: 450;
  cursor: pointer; white-space: nowrap;
  margin: 1px 0;
  transition: background 0.08s, color 0.08s;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active {
  background: var(--accent); color: var(--accent-ink); font-weight: 500;
}
.nav-item.active .nav-icon { color: var(--accent-ink); }
.nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3);
}
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { color: inherit; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-family: var(--font-mono);
  background: var(--surface-3); color: var(--ink-3);
  padding: 1px 6px; border-radius: 10px;
}
.nav-item.active .nav-badge { background: oklch(1 0 0 / 0.2); color: var(--accent-ink); }
.app.collapsed .nav-label, .app.collapsed .nav-badge { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 8px; }
.app.collapsed .nav-item { position: relative; }
.app.collapsed .nav-item:hover::after {
  content: attr(data-label);
  position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%);
  background: var(--ink); color: var(--surface);
  padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap;
  z-index: 100; pointer-events: none;
  box-shadow: var(--shadow-md);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex-shrink: 0;
  border: 1px solid var(--border);
}
.sidebar-footer .u-name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.sidebar-footer .u-role { font-size: 11px; color: var(--ink-3); line-height: 1.2; }
.app.collapsed .sidebar-footer .u-meta { display: none; }
.app.collapsed .sidebar-footer { justify-content: center; }

.collapse-btn {
  background: transparent; border: none;
  color: var(--ink-3); padding: 4px;
  border-radius: 3px; margin-left: auto;
  display: flex; align-items: center; justify-content: center;
}
.collapse-btn:hover { background: var(--surface-3); color: var(--ink); }

/* ---------- Header ---------- */
.header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 14px;
  position: relative;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; flex: 1; min-width: 0; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .muted { color: var(--ink-3); }
.crumbs .current { font-weight: 500; color: var(--ink); }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: var(--radius-sm);
  width: 260px; color: var(--ink-3); font-size: 13px;
  cursor: pointer;
}
.search:hover { border-color: var(--border-strong); }
.search .k {
  margin-left: auto; font-family: var(--font-mono); font-size: 11px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 3px; color: var(--ink-3);
}

.header-status { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- Main ---------- */
.main {
  grid-area: main;
  overflow: auto;
  padding: 20px 28px 40px;
}

/* ============================================================
   Primitives
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border);
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  transition: background 0.08s, border-color 0.08s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 500;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill-ok    { background: var(--ok-soft);    color: var(--ok);     border-color: transparent; }
.pill-warn  { background: var(--warn-soft);  color: var(--warn);   border-color: transparent; }
.pill-err   { background: var(--err-soft);   color: var(--err);    border-color: transparent; }
.pill-info  { background: var(--info-soft);  color: var(--info);   border-color: transparent; }
.pill-dot::before {
  content: '●'; font-size: 8px; display: inline-block;
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.card-head .muted { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }

.page-head {
  display: flex; align-items: flex-end; gap: 14px;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.page-head .sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.kpi-label { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.kpi-val { font-size: 26px; font-weight: 600; line-height: 1.1; margin-top: 6px; letter-spacing: -0.01em; }
.kpi-delta { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--err); }

/* Table */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
table.data tbody td {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }

/* Pipeline flow chips (mirrors current pipeline_debug) */
.flow { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px 0; }
.flow-chip {
  display: flex; flex-direction: column; align-items: center;
  min-width: 86px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.flow-chip .n { font-size: 20px; font-weight: 600; line-height: 1; }
.flow-chip .l { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.flow-chip.proc { background: var(--info-soft); border-color: transparent; }
.flow-chip.proc .n { color: var(--info); }
.flow-chip.done { background: var(--ok-soft); border-color: transparent; }
.flow-chip.done .n { color: var(--ok); }
.flow-chip.warn .n { color: var(--warn); }
.flow-chip.err .n { color: var(--err); }
.flow-sep { color: var(--ink-4); font-size: 16px; padding: 0 2px; }
.flow-sep::before { content: '→'; }

/* Worker panel */
.worker-panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }

/* Progress bar */
.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.3s; }
.progress.ok > div { background: var(--ok); }
.progress.warn > div { background: var(--warn); }
.progress.err > div { background: var(--err); }

/* Form / drawer */
.field { margin-bottom: 14px; }
.field-label {
  display: block; font-size: 11.5px; font-weight: 600;
  color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.field-input, .field-select {
  width: 100%; padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--ink);
  transition: border-color 0.08s, box-shadow 0.08s;
}
.field-input:focus, .field-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field-help { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }

/* Segmented */
.segmented {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px; gap: 0;
}
.segmented > button {
  background: transparent; border: none;
  padding: 4px 12px; font-size: 12.5px; font-weight: 500;
  color: var(--ink-2); border-radius: 3px;
}
.segmented > button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* Checkbox (custom, square) */
.check {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink); cursor: pointer;
  padding: 4px 2px;
}
.check input { display: none; }
.check .box {
  width: 16px; height: 16px; border: 1.5px solid var(--border-strong); border-radius: 3px;
  background: var(--surface); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: transparent; font-size: 12px;
}
.check input:checked ~ .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.check input:checked ~ .box::before { content: '✓'; color: #fff; line-height: 1; }

/* Drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: oklch(0.2 0.01 70 / 0.4);
  z-index: 50; opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.drawer-backdrop.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 51;
  transform: translateX(100%); transition: transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
  display: flex; flex-direction: column;
}
.drawer.on { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.drawer-head .close { margin-left: auto; background: transparent; border: none; color: var(--ink-3); padding: 4px 8px; border-radius: 3px; font-size: 18px; }
.drawer-head .close:hover { background: var(--surface-2); color: var(--ink); }
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
.drawer-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; background: var(--surface-2);
}

/* Icon SVG defaults */
.ico { width: 16px; height: 16px; stroke-width: 1.6; vertical-align: -3px; }

/* Empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); font-size: 13px; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 30;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); width: 280px;
  font-size: 13px;
  display: none;
}
.tweaks-panel.on { display: block; }
.tweaks-panel h4 { margin: 0; padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.tweaks-panel h4 .close { margin-left: auto; cursor: pointer; color: var(--ink-3); background: none; border: none; font-size: 18px; line-height: 1; padding: 0; }
.tweaks-panel .tweak { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.tweaks-panel .tweak:last-child { border-bottom: none; }
.tweaks-panel .tweak .lbl { flex: 1; color: var(--ink-2); }

/* Hide page sections by default */
.page { display: none; }
.page.on { display: block; }

/* Dark mode stub (turn on via Tweaks) */
body.dark {
  --bg: oklch(0.22 0.006 70);
  --surface: oklch(0.265 0.006 70);
  --surface-2: oklch(0.24 0.006 70);
  --surface-3: oklch(0.30 0.006 70);
  --border: oklch(0.34 0.006 70);
  --border-strong: oklch(0.42 0.006 70);
  --ink: oklch(0.96 0.003 70);
  --ink-2: oklch(0.82 0.005 70);
  --ink-3: oklch(0.64 0.005 70);
  --ink-4: oklch(0.46 0.005 70);
}

/* Compact density */
body.compact {
  --header-h: 44px;
}
body.compact .nav-item { padding: 5px 10px; font-size: 13px; }
body.compact .main { padding: 14px 20px 28px; }
body.compact .card-body { padding: 10px 14px; }
body.compact .card-head { padding: 9px 14px; }
body.compact table.data thead th,
body.compact table.data tbody td { padding: 6px 10px; }
body.compact .kpi { padding: 10px 12px; }
body.compact .kpi-val { font-size: 22px; }

/* listings pipeline view */
.card-debug {
  border-left: 3px solid var(--info);
  background: oklch(0.62 0.13 240 / 0.04);
}

/* worker detail modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 960px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.modal-body {
  flex: 1; overflow-y: auto;
}
.modal-section {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-section:last-child {
  border-bottom: none;
}
.spark {
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.pre-debug {
  font-family: var(--font-mono);
  font-size: 11.5px;
  max-height: 240px;
  overflow: auto;
  background: var(--surface-2);
  padding: 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}
.pill-toggle {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-3);
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  user-select: none;
  white-space: nowrap;
}
.pill-toggle:hover { background: var(--surface-2); color: var(--ink-2); }
.pill-toggle.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.pipeline-timeline { list-style: none; margin: 0; padding: 0; }
.pipeline-timeline li {
  display: flex; gap: 8px; align-items: baseline;
  padding: 3px 0; font-size: 12.5px; color: var(--ink-2);
  border-bottom: 1px solid var(--border);
}
.pipeline-timeline li:last-child { border-bottom: none; }
.pipeline-timeline .ts-label { min-width: 120px; color: var(--ink-3); font-size: 12px; }
.pipeline-timeline .ts-val { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.pipeline-timeline .ts-dur { margin-left: auto; font-size: 11.5px; color: var(--info); font-family: var(--font-mono); }

/* ============================================================
   Source filter dropdown (header)
   ============================================================ */
.source-filter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.08s;
}
.source-filter:hover { border-color: var(--border-strong); }
.source-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================================
   Worker grid
   ============================================================ */
.worker-grid-sections { display: flex; flex-direction: column; gap: 20px; }
.worker-phase-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--ink-3);
  margin-bottom: 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.worker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* Worker card */
.worker-card { transition: box-shadow 0.1s, border-color 0.1s; }
.worker-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.worker-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.worker-name {
  font-size: 13px; font-weight: 600; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.worker-card-body {
  padding: 10px 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.worker-stat-label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.worker-stat-val { font-size: 13px; font-weight: 500; color: var(--ink); margin-top: 1px; }
.worker-stat-err { color: var(--err); }

/* Status dots */
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.dot-running  { background: var(--ok); }
.dot-idle     { background: var(--ink-4); }
.dot-degraded { background: var(--warn); }
.dot-dead     { background: var(--err); }
.dot-unknown  { background: var(--ink-4); opacity: 0.5; }

/* Flow chip — clickable variant */
.flow-chip-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.08s, border-color 0.08s, box-shadow 0.08s;
}
.flow-chip-btn:hover { background: var(--surface-3); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.flow-chip-btn.proc { background: var(--info-soft); border-color: transparent; }
.flow-chip-btn.proc:hover { background: oklch(0.62 0.13 240 / 0.22); }
.flow-chip-btn.done { background: var(--ok-soft); border-color: transparent; }
.flow-chip-btn.done:hover { background: oklch(0.62 0.13 155 / 0.22); }

/* ============================================================
   worker grid v2 + drawer
   ============================================================ */

/* Flat 3-column grid (no phase groupings) */
.worker-grid-flat {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 960px) {
  .worker-grid-flat { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .worker-grid-flat { grid-template-columns: 1fr; }
}

/* Worker card v2 */
.worker-card-v2 {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);   /* overridden inline by status */
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px 12px;
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s, background 0.08s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.worker-card-v2:hover {
  box-shadow: var(--shadow-md);
  background: var(--surface-2);
}

/* Card header row */
.wc2-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
}
.wc2-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wc2-name {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}

/* Big processed_today number */
.wc2-big {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.05;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.wc2-big-sub {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* Chips row */
.wc2-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.wc2-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-3);
  white-space: nowrap;
}
.wc2-chip-tp.active {
  background: var(--info-soft);
  color: var(--info);
  border-color: transparent;
}
.wc2-chip-err.has-errors {
  background: var(--err-soft);
  color: var(--err);
  border-color: transparent;
}
.wc2-chip-err:not(.has-errors) {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}

/* Separator + footer */
.wc2-sep {
  height: 1px;
  background: var(--border);
  margin: 0 -4px 8px;
}
.wc2-footer {
  font-size: 11.5px;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Right-side drawer ---- */

/* Very subtle backdrop — main page stays visible (alpha 0.08) */
.modal-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.2 0.01 70 / 0.08);
  z-index: 49;
}

/* Drawer panel */
.modal-drawer-right {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 520px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.16);
  transform: translateX(100%);
  transition: transform 200ms ease-out;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-drawer-right.open {
  transform: translateX(0);
}
@media (max-width: 640px) {
  .modal-drawer-right { width: 100vw; }
}

/* Drawer header: tab strip + close button */
.drawer-tab-strip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

/* Worker tab row */
.worker-tabs {
  display: flex;
  gap: 5px;
  padding-bottom: 8px;
  flex: 1;
}

/* Individual worker tab button (round monogram) */
.worker-tab {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.08s, color 0.08s, border-color 0.08s;
  flex-shrink: 0;
}
.worker-tab:hover {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--border-strong);
}
.worker-tab.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Close button — right-aligned in the tab strip */
.drawer-close-btn {
  margin-left: auto;
  margin-bottom: 8px;
  font-size: 14px;
  flex-shrink: 0;
}
