/* ============================================================
   Relay — compact admin dashboard UI.
   No external CSS framework. Light + dark, one component set.
   ============================================================ */

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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --primary-soft-border: #93c5fd;
  --success: #16a34a;
  --success-soft: #d1fae5;
  --success-soft-text: #065f46;
  --warning: #d97706;
  --warning-soft: #ffedd5;
  --warning-soft-text: #9a3412;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --danger-soft-text: #991b1b;
  --requester-soft: #ede9fe;
  --requester-soft-text: #5b21b6;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --info-soft-text: #075985;
  --muted: #64748b;
  --text-muted: var(--muted);
  --text: #0f172a;
  --text-soft: #334155;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-elevated: #ffffff;
  --shadow: 0 1px 2px rgba(2, 6, 23, 0.05), 0 6px 16px rgba(2, 6, 23, 0.05);
  --shadow-sm: 0 1px 2px rgba(2, 6, 23, 0.04);
  --shadow-lg: 0 12px 32px rgba(2, 6, 23, 0.16);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-pill: 999px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --text-xs: 0.72rem;
  --text-sm: 0.85rem;
  --text-base: 0.9375rem;
  --text-lg: 1.05rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --nav-h: 3rem;
  --focus-ring: 0 0 0 3px var(--primary-soft);
  color-scheme: light;
}

/* GitHub Dark palette: https://primer.style/primitives/colors */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #58a6ff;
    --primary-hover: #79c0ff;
    --primary-soft: rgba(88, 166, 255, 0.15);
    --primary-soft-border: rgba(88, 166, 255, 0.4);
    --success: #3fb950;
    --success-soft: rgba(63, 185, 80, 0.15);
    --success-soft-text: #56d364;
    --warning: #d29922;
    --warning-soft: rgba(210, 153, 34, 0.15);
    --warning-soft-text: #e3b341;
    --danger: #f85149;
    --danger-soft: rgba(248, 81, 73, 0.15);
    --danger-soft-text: #ff7b72;
    --requester-soft: rgba(163, 113, 247, 0.18);
    --requester-soft-text: #d2a8ff;
    --info: #79c0ff;
    --info-soft: rgba(88, 166, 255, 0.15);
    --info-soft-text: #a5d6ff;
    --muted: #8b949e;
    --text-muted: var(--muted);
    --text: #e6edf3;
    --text-soft: #c9d1d9;
    --border: #30363d;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #21262d;
    --surface-elevated: #21262d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --primary: #58a6ff;
  --primary-hover: #79c0ff;
  --primary-soft: rgba(88, 166, 255, 0.15);
  --primary-soft-border: rgba(88, 166, 255, 0.4);
  --success: #3fb950;
  --success-soft: rgba(63, 185, 80, 0.15);
  --success-soft-text: #56d364;
  --warning: #d29922;
  --warning-soft: rgba(210, 153, 34, 0.15);
  --warning-soft-text: #e3b341;
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.15);
  --danger-soft-text: #ff7b72;
  --requester-soft: rgba(163, 113, 247, 0.18);
  --requester-soft-text: #d2a8ff;
  --info: #79c0ff;
  --info-soft: rgba(88, 166, 255, 0.15);
  --info-soft-text: #a5d6ff;
  --muted: #8b949e;
  --text-muted: var(--muted);
  --text: #e6edf3;
  --text-soft: #c9d1d9;
  --border: #30363d;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --surface-elevated: #21262d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------- base elements ---------- */

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  margin: 0 0 var(--space-2);
  letter-spacing: -0.015em;
  font-weight: 700;
  line-height: 1.25;
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
p { margin: 0 0 var(--space-3); }
a { color: var(--primary); }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}
.container.wide { max-width: 1440px; }

/* Layout primitives */
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { gap: var(--space-2); }
.stack-lg { gap: var(--space-6); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); margin-bottom: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

article, .card, .panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

article, .card {
  padding: var(--space-5);
}

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

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: var(--space-4);
}
label[hidden], [hidden] { display: none !important; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.65rem;
  margin-top: 0.2rem;
  min-height: 2.25rem;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

input:focus, select:focus, textarea:focus, .btn:focus-visible, .pill:focus-visible,
.nav-links a:focus-visible, .theme-toggle:focus-visible, .nav-toggle:focus-visible,
.queue-row:focus-visible, summary:focus-visible {
  outline: none;
  border-color: var(--primary-soft-border);
  box-shadow: var(--focus-ring);
}

input:disabled, select:disabled, textarea:disabled,
input[readonly], textarea[readonly] {
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.85;
}

input.is-invalid, select.is-invalid, textarea.is-invalid,
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger-soft) 40%, var(--surface));
}

input[type="checkbox"] { width: auto; min-height: 0; margin-right: 0.4rem; vertical-align: middle; }

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

fieldset { border: 0; margin: 0; padding: 0; }

table { border-collapse: separate; border-spacing: 0; width: 100%; }

table thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.5rem 0.65rem 0;
}

table tbody tr td {
  vertical-align: middle;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0.5rem 0.7rem 0;
}

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

/* Data tables */
.data-table, .dense-table { width: 100%; }
.data-table thead th, .dense-table thead th {
  background: var(--surface-2);
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  /* No position:sticky here — inside .table-responsive (overflow-x:auto) the
     stuck header is painted offset and covers the first body row. */
}
.data-table tbody tr td, .dense-table tbody tr td {
  padding: 0.52rem 0.65rem;
}
.data-table tbody tr:hover td, .dense-table tbody tr:hover td {
  background: color-mix(in srgb, var(--primary-soft) 35%, transparent);
}
.data-table.zebra tbody tr:nth-child(even) td,
.dense-table.zebra tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* Absolute action menus are clipped while overflow-x is auto; lift the
   scrollport only while a panel is open so Approve/Reject forms stay usable. */
.table-responsive:has(.slide-panel[open]) {
  overflow: visible;
}
.table-actions {
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}
.table-action-group {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}
.table-actions .slide-panel {
  display: inline-block;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  position: relative;
  vertical-align: middle;
}
.table-actions .slide-panel[open] {
  z-index: 30;
}
.table-actions .slide-panel > summary.btn {
  display: inline-flex;
  margin: 0;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  min-height: 2rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  font-weight: 700;
}
.table-actions .slide-panel-body {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  z-index: 31;
  min-width: 16rem;
  max-width: min(22rem, 80vw);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  white-space: normal;
}

details { border-radius: var(--radius-sm); }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 480px;
  width: 90vw;
}
dialog::backdrop { background: rgba(2, 6, 23, 0.5); }
dialog > article { box-shadow: var(--shadow); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-weight: 600;
  font-size: var(--text-sm);
  padding: 0.42rem 0.8rem;
  min-height: 2.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s, opacity 0.15s;
  line-height: 1.2;
}

.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn:active { transform: translateY(1px); }

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

.btn.outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn.outline:hover {
  border-color: var(--primary-soft-border);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn.contrast, .btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.contrast:hover, .btn.danger:hover { filter: brightness(0.92); }

.btn.approve-btn, .btn.success {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.btn.approve-btn:hover, .btn.success:hover { filter: brightness(0.92); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn.ghost:hover { color: var(--primary); background: var(--surface-2); }

.btn-link {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  min-height: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.btn-link:hover { color: var(--primary-hover); background: transparent; }

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

.btn-loading::after {
  content: "";
  width: 0.85em;
  height: 0.85em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 0.35rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-sm { padding: 0.35rem 0.7rem; font-size: var(--text-xs); min-height: 2rem; }
.btn-block { width: 100%; }

a[role="button"] { text-decoration: none; }

/* ---------- badges / chips / pills ---------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  color: var(--text-soft);
  white-space: nowrap;
}

.badge.submitted { background: var(--primary-soft); color: var(--primary-hover); }
.badge.pending_lead_approval { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.lead_approved { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.in_progress { background: var(--primary-soft); color: var(--primary-hover); }
.badge.done { background: var(--success-soft); color: var(--success-soft-text); }
.badge.lead_rejected, .badge.rejected { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.low { background: var(--success-soft); color: var(--success-soft-text); }
.badge.medium { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.high { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.critical { background: var(--danger); color: #fff; }
.badge.production { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.staging { background: var(--primary-soft); color: var(--primary-hover); }
.badge.other { background: var(--surface-2); color: var(--text-soft); }
.badge.normal { background: var(--surface-2); color: var(--text-soft); }
.badge.urgent { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.requester { background: var(--requester-soft); color: var(--requester-soft-text); }
.badge.request-id {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

.badge.pending_approval { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.active { background: var(--success-soft); color: var(--success-soft-text); }
.badge.paused { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.pending_cancellation { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.cancelled { background: var(--surface-2); color: var(--text-soft); }
.badge.expected { background: var(--surface-2); color: var(--text-soft); }
.badge.approved { background: var(--success-soft); color: var(--success-soft-text); }
.badge.missing { background: var(--danger-soft); color: var(--danger-soft-text); }
.badge.extra { background: var(--primary-soft); color: var(--primary-hover); margin-left: 0.35rem; }
.row-extra td:first-child { padding-left: 1.4rem; }
.badge.waived { background: var(--surface-2); color: var(--text-soft); }
.badge.awaiting_submission { background: var(--surface-2); color: var(--text-soft); }
.badge.awaiting_approval { background: var(--primary-soft); color: var(--primary-hover); }
.badge.action_required { background: var(--danger-soft); color: var(--danger-soft-text); }

/* inventory server/service status badges */
.badge.running { background: var(--success-soft); color: var(--success-soft-text); }
.badge.degraded { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.stopped { background: var(--surface-2); color: var(--text-soft); }
.badge.maintenance { background: var(--warning-soft); color: var(--warning-soft-text); }
.badge.decommissioned { background: var(--surface-2); color: var(--text-soft); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  min-height: 2.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  cursor: pointer;
}
.pill:hover { border-color: var(--primary-soft-border); color: var(--primary); }
.pill.active {
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
  color: var(--primary-hover);
}
.pill-row { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: var(--space-3); }

/* One wrapping command bar for subscription status, filters, export, cost, and bulk work. */
.list-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--space-4);
  padding: 0.55rem;
  border-block: 1px solid var(--border);
}
.list-toolbar .pill-row { margin-bottom: 0; }
.payment-report-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: auto;
  margin: 0;
  font-size: var(--text-xs);
}
.payment-report-toolbar select,
.payment-report-toolbar input { width: auto; margin: 0; min-height: 2.1rem; }
.payment-report-metrics { margin-bottom: var(--space-4); }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}
/* Override the global width:100% so the controls sit compactly inline. */
.filter-bar select,
.filter-bar input[type="search"] {
  width: auto;
  margin: 0;
  min-height: 2.1rem;
  padding: 0.25rem 0.55rem;
  font-size: var(--text-sm);
}
.filter-bar .filter-search { width: 11rem; max-width: 40vw; }
.filter-bar select { max-width: 10rem; }
@media (max-width: 640px) {
  .payment-report-toolbar label { width: 100%; justify-content: space-between; }
  .payment-report-toolbar select,
  .payment-report-toolbar input { flex: 1; min-width: 0; }
  .filter-bar { width: 100%; margin-left: 0; }
  .filter-bar .filter-search { flex: 1 1 100%; width: auto; max-width: none; }
}

/* Dense admin view for the subscriptions tables — tighter type & spacing so
   many rows read clearly in one screen. */
.dense-subs .panel-title { font-size: var(--text-xs); }
.workspace-section { margin-bottom: var(--space-4); }
.workspace-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.15rem;
  border-bottom: 1px solid var(--border);
}
.panel-count {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
}
.finance-queue-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  font-size: inherit;
  text-align: left;
  transition: background 0.15s;
}
.finance-queue-toggle:hover { background: var(--surface-3, #eef); }
.finance-queue-toggle:focus-visible { outline: 2px solid var(--accent, #4a6); outline-offset: 1px; }
.finance-queue-toggle-left { display: flex; align-items: center; gap: 0.5rem; }
.finance-queue-toggle-right { color: var(--text-soft); font-size: var(--text-sm); white-space: nowrap; }
.finance-queue-body { padding: 0.75rem 0 0; }
.budget-meter {
  width: 7rem;
  height: 0.38rem;
  margin-bottom: 0.25rem;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}
.budget-meter > span { display: block; height: 100%; background: var(--success); border-radius: inherit; }
.budget-meter.approaching > span { background: var(--warning); }
.budget-meter.over > span { background: var(--danger); }
.extraction-evidence {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.extraction-field {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.extraction-field .row { justify-content: space-between; gap: var(--space-2); }
.toolbar-cost {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.45rem;
  color: var(--text-soft);
  font-size: var(--text-xs);
}
.bulk-action-bar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0 auto;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius);
  background: var(--primary-soft);
  font-size: var(--text-xs);
}
.bulk-action-bar.has-selection { display: flex; }
.bulk-action-bar select {
  width: auto;
  min-width: 12rem;
  min-height: 2rem;
  margin: 0;
  padding: 0.25rem 0.55rem;
  font-size: var(--text-xs);
}
.select-cell {
  width: 2.25rem;
  min-width: 2.25rem;
  text-align: center;
}
.select-cell input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
}
.dense-subs .data-table tbody tr:has(.subscription-select:checked) td {
  background: var(--primary-soft);
}
.table-actions .inline-action-panel > summary.btn {
  width: auto;
  min-width: auto;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
}
.table-actions .inline-action-panel .slide-panel-body {
  min-width: min(22rem, 86vw);
}
.more-actions-stack { display: flex; flex-direction: column; gap: 0.4rem; }
.more-actions-stack > details > summary { margin-bottom: 0.3rem; }
.more-actions-stack > details[open] > summary { border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.dense-subs .data-table { font-size: var(--text-xs); }
.dense-subs .data-table thead th {
  padding: 0.35rem 0.6rem;
  font-size: 0.66rem;
  position: static;
}
.dense-subs .data-table tbody tr td { padding: 0.3rem 0.6rem; }
.dense-subs .data-table .badge { padding: 0.05rem 0.4rem; font-size: 0.64rem; }
.dense-subs .btn-sm { padding: 0.15rem 0.5rem; min-height: 1.55rem; font-size: 0.68rem; }
.dense-subs .table-action-group { gap: 0.2rem; }
.dense-subs .meta-inline { font-size: 0.66rem; }
@media (max-width: 640px) {
  .toolbar-cost { width: 100%; }
  .bulk-action-bar { width: 100%; margin-left: 0; }
  .bulk-action-bar.has-selection {
    position: fixed;
    inset: auto 0.5rem 0.5rem;
    z-index: 30;
    width: auto;
    box-shadow: var(--shadow-lg);
  }
  .bulk-action-bar select { flex: 1 1 10rem; min-width: 0; }
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
}
.pager .pager-info { color: var(--muted); font-size: var(--text-xs); margin: 0 0.3rem; }
.pager [aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.65rem;
  min-height: 1.75rem;
  font-size: var(--text-xs);
  cursor: pointer;
}
.chip-btn:hover { border-color: var(--primary-soft-border); color: var(--primary); background: var(--primary-soft); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: var(--space-3); }

/* ---------- nav ---------- */

.navbar {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--nav-h);
}

.navbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--nav-h);
  gap: var(--space-4);
  position: relative;
}

.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -0.02em;
  z-index: 2;
}

.brand-logo {
  color: var(--primary);
  flex-shrink: 0;
  transition: transform 0.25s ease, color 0.15s ease;
}

.brand-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 55%, #06b6d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.04em;
  text-transform: lowercase;
  transition: filter 0.15s ease, letter-spacing 0.25s ease;
}

.navbar-brand:hover .brand-logo {
  transform: translateX(2px) scale(1.05);
  color: var(--primary-hover);
}
.navbar-brand:hover .brand-text {
  filter: brightness(1.08);
  letter-spacing: -0.01em;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  z-index: 2;
}
.nav-toggle-icon {
  display: block;
  width: 1.1rem;
  height: 2px;
  background: currentColor;
  position: relative;
  border-radius: 1px;
}
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.nav-toggle-icon::before { top: -5px; }
.nav-toggle-icon::after { top: 5px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav-links a,
.nav-link-btn {
  text-decoration: none;
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  min-height: 2.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  background: none;
  cursor: pointer;
  font: inherit;
}

.nav-links a:hover,
.nav-link-btn:hover { color: var(--primary); background: var(--primary-soft); }

.nav-links a.active {
  color: var(--primary-hover);
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
}

.nav-links .badge { margin-left: 0.25rem; }

.nav-dropdown { position: relative; }
.nav-dropdown > summary {
  list-style: none;
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  min-height: 2.25rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.nav-dropdown > summary::-webkit-details-marker { display: none; }
.nav-dropdown > summary:hover,
.nav-dropdown[open] > summary {
  color: var(--primary);
  background: var(--primary-soft);
}
.nav-dropdown > summary.active {
  color: var(--primary-hover);
  background: var(--primary-soft);
  border-color: var(--primary-soft-border);
}
.nav-dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 10rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  z-index: 40;
}
.nav-dropdown-menu a {
  border-radius: var(--radius-sm);
  width: 100%;
}

.billing-subnav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
  margin-bottom: var(--space-3);
  padding: var(--space-1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  scrollbar-width: thin;
  overscroll-behavior-inline: contain;
}

.billing-subnav a {
  text-decoration: none;
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: 600;
  flex: 0 0 auto;
  padding: 0.32rem 0.65rem;
  min-height: 2rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.billing-subnav a:hover { color: var(--primary); background: var(--surface); }
.billing-subnav a.active {
  color: var(--primary-hover);
  background: var(--surface);
  border-color: var(--primary-soft-border);
  box-shadow: var(--shadow-sm);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: var(--radius-pill);
  width: auto;
  min-width: 2.25rem;
  padding: 0 0.6rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--primary-soft-border); }

main.container { padding-top: var(--space-3); padding-bottom: var(--space-6); }

/* ---------- page header / actions ---------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-3);
}

.page-title { font-size: var(--text-xl); line-height: 1.2; margin: 0; }
.page-subtitle { margin: var(--space-2) 0 0; color: var(--muted); font-size: var(--text-sm); }
.compact-header .page-title { font-size: var(--text-lg); }
.compact-header .page-subtitle { margin-top: var(--space-1); }
.period-nav { margin: calc(-1 * var(--space-1)) 0 var(--space-3); }

.detail-header .page-title { font-size: var(--text-lg); }
.detail-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
}
.detail-header-meta span { display: inline-flex; align-items: center; gap: 0.25rem; }

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

/* ---------- panels ---------- */

.panel {
  padding: 0;
  margin-bottom: var(--space-4);
}

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

.panel-title { margin: 0; font-size: var(--text-sm); font-weight: 700; }
.panel-body { padding: var(--space-3) var(--space-4); }
.panel-body.flush { padding: 0; }
.panel-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

.card-meta { color: var(--muted); font-size: var(--text-sm); margin-bottom: var(--space-3); }
.meta-inline { color: var(--muted); font-size: var(--text-xs); }

.entity-title { font-size: var(--text-sm); font-weight: 600; color: var(--text); text-decoration: none; }
.entity-title:hover { color: var(--primary); }

.empty-state { text-align: center; padding: var(--space-8) var(--space-4); color: var(--muted); }
.empty-state .btn { margin-top: var(--space-4); }

/* ---------- stat cards ---------- */

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  overflow: hidden;
}

a.stat-card { text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
a.stat-card:hover, a.stat-card.active {
  border-color: var(--primary-soft-border);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.stat-value { font-size: var(--text-lg); font-weight: 800; color: var(--primary); line-height: 1; flex-shrink: 0; }
.stat-label { color: var(--muted); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
}
.kpi-label { color: var(--muted); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 var(--space-2); }
.kpi-value { font-size: var(--text-xl); font-weight: 800; margin: 0; line-height: 1.2; }

/* ---------- toolbar / search ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: var(--space-4); }
.toolbar-search { flex: 1; min-width: 180px; margin: 0; }
.toolbar-search input { margin: 0; }

.ai-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-4);
}
.ai-toolbar form { display: inline; margin: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* ---------- kv / people ---------- */

.kv { display: grid; grid-template-columns: 100px 1fr; gap: var(--space-2) var(--space-3); font-size: var(--text-sm); margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- comments ---------- */

.comment {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}
.comment-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: 0.25rem;
}
.comment-author { font-weight: 700; font-size: var(--text-sm); }
.comment-time { color: var(--muted); font-size: var(--text-xs); }
.comment p { margin: 0.3rem 0 0; font-size: var(--text-sm); }
.comment-ai-text { white-space: pre-wrap; }

/* ---------- alerts / toasts ---------- */

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-bottom: var(--space-4); font-size: var(--text-sm); border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger-soft-text); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success-soft-text); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info-soft-text); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning-soft-text); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }

.toast-region {
  position: fixed;
  top: calc(var(--nav-h) + 0.75rem);
  right: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
}

.toast {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  background: var(--success-soft);
  color: var(--success-soft-text);
  border: 1px solid transparent;
  animation: toast-in 0.15s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- status stepper ---------- */

.status-current { margin: 0 0 var(--space-4); color: var(--text-soft); font-size: var(--text-sm); }

.note-callout {
  border-left: 3px solid var(--warning);
  background: var(--warning-soft);
  color: var(--warning-soft-text);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

/* ---------- AI assistant ---------- */

.ai-reco {
  border: 1px solid var(--primary);
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}
.ai-reco-head { font-size: var(--text-sm); margin-bottom: 0.25rem; }
.ai-reco-reason { margin: 0.25rem 0 0.5rem; opacity: 0.9; }
.ai-reco-hint { margin: 0.35rem 0 0; font-size: var(--text-xs); opacity: 0.85; }
.ai-reco-foot { margin: 0.5rem 0 0; font-size: var(--text-xs); opacity: 0.7; }
.ai-reco form { margin: 0.4rem 0 0; }
.ai-reco-pending { border-style: dashed; opacity: 0.9; }
.ai-reco-error {
  border-color: var(--danger);
  border-left-color: var(--danger);
  background: var(--danger-soft);
}
.comment-ai { border-left: 3px solid var(--primary); padding-left: 0.6rem; }
.badge.ai-badge { background: var(--primary); color: #fff; margin-left: 0.35rem; }

.workflow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
}

.workflow-steps li {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.7rem;
  background: var(--surface-2);
  position: relative;
}

.workflow-steps li.done {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success-soft-text);
}
.workflow-steps li.current {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-soft);
  color: var(--primary-hover);
}
.workflow-steps li.rejected {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger-soft-text);
}
.workflow-steps li.skipped { opacity: 0.45; }

.step-label { display: block; font-weight: 700; font-size: var(--text-xs); }
.step-hint { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.7rem; line-height: 1.3; }

/* ---------- history timeline ---------- */

.history-list { list-style: none; margin: 0; padding: 0 0 0 0.35rem; font-size: var(--text-sm); }
.history-list li {
  position: relative;
  border-left: 2px solid var(--primary-soft-border);
  padding: 0 0 var(--space-4) var(--space-4);
  margin: 0;
}
.history-list li:last-child { padding-bottom: 0; }
.history-list li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.history-actor { font-weight: 700; display: block; }
.history-action { color: var(--text-soft); display: block; margin-top: 0.1rem; }
.history-time { color: var(--muted); font-size: var(--text-xs); display: block; margin-top: 0.15rem; }

/* ---------- request details (category render_detail) ---------- */

.detail-list, .detail-kv {
  display: grid;
  grid-template-columns: minmax(7rem, 10rem) 1fr;
  gap: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  align-items: start;
}

.detail-item, .detail-kv .row {
  display: contents;
}

.detail-label, .detail-kv .row > strong, .detail-kv .block > strong {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-top: 0.15rem;
}

.detail-value, .detail-kv .row > :not(strong) {
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  word-break: break-word;
}

.detail-block, .detail-kv .block {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.detail-block .detail-label,
.detail-kv .block > strong {
  display: block;
  margin-bottom: 0;
  padding-top: 0;
}

.detail-block p, .detail-kv .block p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
}

.detail-code, .detail-block pre, .detail-kv .block pre {
  margin: 0;
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.45;
}

.detail-section {
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.detail-section:last-child { margin-bottom: 0; }
.detail-section-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 700;
}

.detail-highlight {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--primary-hover);
}
.detail-highlight .badge { font-weight: 700; }

.detail-list a, .detail-kv a { color: var(--primary); }

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
.form-grid > label,
.form-row > label { margin-bottom: 0; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid fieldset.full { margin: 0; padding: 0; }

.form-section {
  grid-column: 1 / -1;
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.form-section:last-child { margin-bottom: 0; }
.form-section-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-sm);
  font-weight: 700;
}
.form-section-desc {
  margin: 0 0 var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}
.form-section .form-grid { margin: 0; }

.panel-body > form > .form-section {
  margin: 0;
  padding: var(--space-3) 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.panel-body > form > .form-section:first-of-type { border-top: 0; padding-top: 0; }

.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  grid-column: 1 / -1;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }

.line-item-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 5.5rem 5.5rem 1.2fr auto;
  gap: var(--space-2) var(--space-3);
  align-items: end;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.line-item-row label { margin: 0; }
.line-item-row .remove-line-item {
  align-self: end;
  min-width: 2rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 400;
}
.field-error {
  display: block;
  margin-top: 0.35rem;
  color: var(--danger-soft-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
  align-items: center;
  padding: var(--space-3) 0;
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  bottom: 0;
  z-index: 5;
}

.progressive-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.85rem;
  background: var(--surface-2);
}
.card-ledger-panel > summary { list-style: none; cursor: pointer; }
.card-ledger-panel > summary::-webkit-details-marker { display: none; }
.card-ledger-panel > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--muted);
  font-size: var(--text-lg);
}
.card-ledger-panel[open] > summary::after { content: "-"; }
.advanced-form-block { margin-top: var(--space-3); }
.advanced-form-content { padding-top: var(--space-2); }
.advanced-form-content .form-section {
  margin: 0;
  padding: var(--space-3) 0;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
}
.progressive-section summary { color: var(--text-soft); font-weight: 700; padding: 0.45rem 0; }
.progressive-section summary.btn { text-align: center; display: inline-flex; }
.progressive-content { margin-top: 0.35rem; display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4); }
.progressive-content .full { grid-column: 1 / -1; }

.slide-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
}
.slide-panel summary {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--text-soft);
  padding: 0.25rem 0;
}
.slide-panel-body { margin-top: var(--space-3); }

.yes-no-field legend {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  padding: 0;
}

.required-mark { color: var(--danger); }

.yes-no-options {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.yes-no-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  color: var(--text-soft);
  margin: 0;
  min-height: 2.5rem;
}

.help-panel {
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  padding: 0.55rem 0.9rem;
  margin-bottom: var(--space-4);
}
.help-panel summary { font-weight: 700; color: var(--primary-hover); }
.help-list { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--text-soft); font-size: var(--text-sm); }
.help-list li { margin-bottom: 0.3rem; }

.dialog-footer { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: var(--space-3); }

/* ---------- action panel (dense admin) ---------- */

.action-panel { display: flex; flex-direction: column; gap: var(--space-3); }
.action-primary { width: 100%; }
.action-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.action-secondary .btn { flex: 1 1 auto; }
.action-danger {
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ---------- merge panel (GitLab one-click merge) ---------- */

.merge-panel {
  border: 1px solid var(--primary-soft-border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--surface) 55%);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .merge-panel {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 16%, var(--surface)) 0%, var(--surface) 60%);
  }
}
:root[data-theme="dark"] .merge-panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 16%, var(--surface)) 0%, var(--surface) 60%);
}
.merge-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.merge-panel-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--text);
  font-size: var(--text-base);
}
.merge-panel-link {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.merge-panel-link:hover { text-decoration: underline; }
.merge-status-box { min-height: 1.6rem; margin-bottom: var(--space-3); }
.merge-status-box .spinner-row { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: var(--text-sm); }
.merge-refresh {
  background: none;
  border: none;
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
}
.merge-refresh:hover { text-decoration: underline; }
.badge-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.merge-cta-row { display: flex; flex-direction: column; gap: var(--space-2); }
.merge-cta {
  width: 100%;
  font-size: var(--text-base);
  padding: 0.75rem 1rem;
  min-height: 2.9rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.merge-ack {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: var(--text-sm);
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
}
.merge-ack input { margin-top: 0.2rem; }
.merge-disabled-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  font-size: var(--text-sm);
}
.merge-hint { margin: var(--space-2) 0 0; font-size: var(--text-xs); color: var(--muted); text-align: center; }
.action-meta { color: var(--muted); font-size: var(--text-sm); margin: 0; }

/* ---------- master–detail split layout ---------- */

.split {
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  gap: var(--space-4);
  align-items: start;
}

.queue-col { min-width: 0; }
.queue-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: calc(100vh - var(--nav-h) - 9rem); overflow-y: auto; padding-right: 0.15rem; }

.queue-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2);
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  align-items: start;
}
.queue-row:hover { border-color: var(--primary-soft-border); background: color-mix(in srgb, var(--primary-soft) 25%, var(--surface)); }
.queue-row.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.queue-select {
  width: 1rem;
  flex-shrink: 0;
  /* reserved for future batch selection */
}
.queue-row-body { min-width: 0; }
.queue-row-title { font-weight: 700; font-size: var(--text-sm); color: var(--text); margin-bottom: 0.25rem; }
.queue-row-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; color: var(--muted); font-size: var(--text-xs); }
.queue-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: var(--space-2);
}
.queue-row-actions .btn { pointer-events: auto; }

.detail-col { min-width: 0; }
.detail-pane { min-height: 200px; }

.detail-placeholder {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--muted);
  background: var(--surface);
}

.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-4); align-items: start; }

.aside-stack .panel { margin-bottom: var(--space-4); }
.aside-stack article { margin-bottom: var(--space-4); }
.sticky-aside { position: sticky; top: calc(var(--nav-h) + var(--space-4)); }

.htmx-request .queue-row.active { opacity: 0.85; }
.htmx-request.htmx-swapping { opacity: 0.6; transition: opacity 0.1s; }

/* ---------- users/reports two-col ---------- */

.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-5); align-items: start; }

/* ---------- period tabs / report bars ---------- */

.report-bars { margin-bottom: var(--space-5); }
.report-bar-row { display: grid; grid-template-columns: 140px 1fr 48px; gap: var(--space-3); align-items: center; margin-bottom: 0.5rem; }
.report-bar-label a { font-size: var(--text-sm); font-weight: 600; text-decoration: none; color: var(--text); }
.report-bar-label a:hover { color: var(--primary); }
.report-bar-track { height: 9px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.report-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-hover)); border-radius: var(--radius-pill); min-width: 4px; }
.report-bar-value { text-align: right; font-weight: 700; font-size: var(--text-sm); }

.report-matrix td, .report-matrix th { text-align: center; }
.report-matrix td:first-child, .report-matrix th:first-child { text-align: left; }
.report-matrix .report-totals { background: var(--surface-2); font-weight: 700; }
.report-matrix .row-highlight { background: var(--primary-soft); }

.bar-chart { display: flex; flex-direction: column; gap: var(--space-2); }
.bar-chart-row { display: grid; grid-template-columns: 4rem 1fr 5rem; gap: var(--space-3); align-items: center; font-size: var(--text-sm); }
.bar-chart-track { height: 10px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.bar-chart-fill { height: 100%; background: var(--primary); border-radius: var(--radius-pill); min-width: 2px; }
.bar-chart-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.progress-meter {
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: var(--space-2);
}
.progress-meter > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-pill);
}
.progress-meter.over > span { background: var(--danger); }
.progress-meter.warn > span { background: var(--warning); }

.delta-up { color: var(--danger-soft-text); font-weight: 600; }
.delta-down { color: var(--success-soft-text); font-weight: 600; }
.delta-flat { color: var(--muted); }

.aging-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
.aging-cell {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
}
.aging-cell .stat-value { display: block; margin-bottom: var(--space-1); }

/* ---------- login ---------- */

.login-shell {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, color-mix(in srgb, var(--primary-soft) 70%, transparent), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-7) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card .page-title {
  font-size: var(--text-2xl);
  text-align: center;
  margin-bottom: var(--space-2);
}
.login-card .page-subtitle {
  text-align: center;
  margin-bottom: var(--space-5);
}

/* ---------- invoice viewer / upload ---------- */

.invoice-viewer-panel { min-height: 70vh; }
.invoice-viewer-body {
  padding: 0;
  background: var(--surface-2);
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.invoice-viewer-frame {
  width: 100%;
  min-height: 70vh;
  border: 0;
  background: var(--surface);
}
.invoice-viewer-image {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  display: block;
  margin: var(--space-4) auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.invoice-upload-panel {
  min-width: 18rem;
  max-width: min(24rem, 90vw);
}
.invoice-upload-form label { margin-bottom: var(--space-3); }
.invoice-upload-form .form-row { margin-bottom: var(--space-3); }

/* ---------- pagination ---------- */

.pagination { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-4); }

/* ---------- reduced motion ---------- */

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

/* ---------- responsive ---------- */

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-3);
    margin-top: var(--space-2);
    z-index: 40;
  }
  .navbar-inner.nav-open .nav-links { display: flex; }
  .nav-links a, .nav-link-btn, .nav-dropdown > summary {
    width: 100%;
    border-radius: var(--radius-sm);
    justify-content: flex-start;
  }
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 0 var(--space-3);
    background: transparent;
  }

  .split { grid-template-columns: 1fr; }
  .queue-list { max-height: none; overflow: visible; }
  .detail-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .sticky-aside { position: static; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .line-item-row { grid-template-columns: 1fr 1fr; }
  .line-item-row .remove-line-item { justify-self: start; }
  .aging-grid { grid-template-columns: 1fr; }
  .pill-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .pill-row > * { flex: 0 0 auto; }
  .list-toolbar .filter-bar { flex: 1 1 100%; }
}

@media (max-width: 640px) {
  .container { padding: 0 var(--space-3); }
  .form-grid, .progressive-content { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .page-header > .actions { width: 100%; justify-content: flex-start; }
  .report-bar-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .report-bar-value { text-align: left; }
  .report-matrix { display: block; overflow-x: auto; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4, .stats-grid { grid-template-columns: 1fr; }
  .detail-list, .detail-kv { grid-template-columns: 1fr; gap: var(--space-1) 0; }
  .extraction-evidence { grid-template-columns: 1fr; }
  .detail-label, .detail-kv .row > strong { padding-top: 0; margin-top: var(--space-2); }
  .action-secondary { flex-direction: column; }
  .action-secondary .btn { width: 100%; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .form-actions .btn { width: 100%; }
  .queue-row-actions { flex-direction: column; }
  .queue-row-actions .btn { width: 100%; }
  input, select, textarea, .btn { min-height: 2.5rem; }
}

@media (max-width: 480px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- inventory dependency graph ---------- */
.inventory-graph-wrap {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-4);
}
.inventory-cy {
  height: 70vh;
  min-height: 460px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.inventory-node-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: var(--space-3) var(--space-4);
  overflow-y: auto;
  max-height: 70vh;
}
.inventory-node-title { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.inventory-node-label {
  margin: var(--space-3) 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.inventory-endpoint-list {
  margin: 0 0 var(--space-3);
  padding-left: 1.1rem;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-soft);
}
.inventory-endpoint-list li { margin-bottom: 0.2rem; }

@media (max-width: 720px) {
  .inventory-graph-wrap { grid-template-columns: 1fr; }
  .inventory-node-panel { max-height: none; }
}

/* ---------- inventory table (compact, Excel-like, centered) ---------- */
.inventory-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-xs);
  width: 100%;
}
.inventory-table thead th {
  white-space: nowrap;
  padding: 0.4rem 0.45rem;
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  vertical-align: middle;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  position: sticky;
  top: 0;
  z-index: 2;
}
.inventory-table thead th:last-child { border-right: none; }
.inventory-table tbody tr td {
  padding: 0.35rem 0.45rem;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
}
.inventory-table tbody tr td:last-child { border-right: none; }
.inventory-table tbody tr:hover td {
  background: color-mix(in srgb, var(--primary-soft) 20%, transparent);
}
.inventory-table tbody tr:hover td:nth-child(1) {
  background: color-mix(in srgb, var(--primary-soft) 28%, var(--surface));
}

.inventory-table th:nth-child(1),
.inventory-table td:nth-child(1) {
  width: 14%;
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
  border-right: 1px solid var(--border);
}
.inventory-table th:nth-child(1) { z-index: 4; background: var(--surface-2); }
.inv-server-group:nth-child(even) td:nth-child(1) {
  background: color-mix(in srgb, var(--surface-2) 30%, var(--surface));
}
.inv-server-group.editing td:nth-child(1) {
  background: color-mix(in srgb, var(--primary-soft) 22%, var(--surface));
}
.inventory-table th:nth-child(2),
.inventory-table td:nth-child(2) { width: 9%; }
.inventory-table th:nth-child(3),
.inventory-table td:nth-child(3) { width: 14%; }
.inventory-table th:nth-child(4),
.inventory-table td:nth-child(4) { width: 15%; }
.inventory-table th:nth-child(5),
.inventory-table td:nth-child(5) { width: 23%; }
.inventory-table th:nth-child(6),
.inventory-table td:nth-child(6) { width: 20%; }
.inventory-table th:nth-child(7),
.inventory-table td:nth-child(7) { width: 5rem; }

.inv-server-group:nth-child(odd) { background: var(--surface); }
.inv-server-group:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 25%, var(--surface)); }
.inv-server-group.editing { background: color-mix(in srgb, var(--primary-soft) 18%, var(--surface)); }
.inv-server-group.inv-highlight { animation: inv-flash 2s ease; }
@keyframes inv-flash {
  0%, 100% { background: transparent; }
  15%, 50% { background: color-mix(in srgb, var(--primary) 18%, transparent); }
}

.inv-server-line,
.inv-service-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  position: relative;
}
.inv-server-name {
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-right: 4.3rem;
}
.inv-service-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-right: 3rem;
}
.inv-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  margin-top: 0.15rem;
  font-size: 0.65rem;
}
.inv-meta .badge {
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
}
.inv-row-meta {
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}
.inv-port-cell .inv-port {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}
.inv-port-cell .badge.normal {
  padding: 0.05rem 0.3rem;
  font-size: 0.65rem;
}

.inv-server-cell,
.inv-service-cell {
  position: relative;
  padding-top: 1.45rem;
}
.inv-actions-row {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 1;
}
.inv-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 0;
  opacity: 1;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--surface-2) 70%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.inv-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: none;
  border-right: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}
.inv-actions-inline .inv-btn-icon:last-child { border-right: none; }
.inv-btn-icon:hover {
  background: var(--surface);
  color: var(--primary);
}
.inv-btn-icon.primary:hover { color: var(--primary); }
.inv-btn-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }
.inv-deps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}
.dep-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}
.dep-chip-server { color: var(--muted); font-weight: 500; font-size: 0.65rem; }
.dep-chip-flag { color: var(--danger); font-weight: 700; }
.dep-chip form { display: inline; }
.dep-chip-remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 0.1rem;
}
.dep-chip-remove:hover { color: var(--danger); }
.dep-add-form { display: inline-flex; align-items: center; }
.dep-add-select {
  font-size: 0.7rem;
  padding: 0.1rem 0.25rem;
  min-height: 1.3rem;
  width: 2.2rem;
  max-width: 2.2rem;
  cursor: pointer;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  transition: width 0.15s, max-width 0.15s;
  text-align: center;
}
.dep-add-select:focus,
.dep-add-select:active {
  width: 10rem;
  max-width: 10rem;
  color: var(--text);
}

.inv-actions-cell {
  white-space: nowrap;
  text-align: center;
}

.inv-error-row td { padding: 0; }
.inv-error-row .alert { margin: 0.35rem; padding: 0.5rem 0.75rem; font-size: var(--text-sm); }

.inv-edit-cell { padding: var(--space-3); background: var(--surface-2); text-align: left; }
.inv-edit-block { max-width: 900px; margin: 0 auto; }
.inv-edit-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
  color: var(--text);
  text-align: center;
}
.inv-edit-preview {
  background: color-mix(in srgb, var(--surface-2) 50%, var(--surface));
}
.inv-edit-preview td {
  padding: 0.35rem 0.5rem;
  color: var(--text-soft);
  text-align: center;
}

.inv-server-group.htmx-request {
  opacity: 0.55;
  pointer-events: none;
}

@media (max-width: 960px) {
  .inventory-table th:nth-child(7),
  .inventory-table td:nth-child(7) { width: 4rem; }
  .inv-actions-inline { opacity: 1; background: transparent; }
}

/* --- Inventory v2: toolbar, collapse, dep chips, server deps, graph controls --- */

/* Table toolbar (search + filters + collapse-all) */
.inv-toolbar { flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.inv-toolbar-search { display: flex; align-items: center; gap: var(--space-3); flex: 1 1 260px; }
.inv-search-input {
  flex: 1 1 200px; max-width: 360px;
  padding: 0.4rem 0.6rem; font-size: var(--text-sm);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.inv-search-input:focus { outline: none; box-shadow: var(--focus-ring); border-color: var(--primary); }
.inv-toolbar-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.inv-filter-group .pill { text-transform: capitalize; }
.inv-toolbar-collapse { display: flex; gap: var(--space-1); }

/* Group visibility / collapse */
.inv-server-group.inv-hidden { display: none; }
.inv-summary-row { display: none; }
.inv-server-group.inv-collapsed .inv-detail-row { display: none; }
.inv-server-group.inv-collapsed .inv-summary-row { display: table-row; }
.inv-summary {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 0.35rem 0.5rem; flex-wrap: wrap;
}
.inv-summary .inv-server-name { font-weight: 600; }
.inv-collapse-toggle {
  border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 0.9rem; line-height: 1;
  padding: 0 0.25rem; border-radius: var(--radius-sm);
}
.inv-collapse-toggle:hover { color: var(--text); background: var(--surface-2); }
.inv-server-line { display: flex; align-items: center; gap: 0.25rem; }

/* Dependency chips: kind dot, optional tag, popover editor */
.dep-kind-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 0.3rem; vertical-align: middle; background: var(--muted);
}
.dep-kind-dot.sync { background: var(--muted); }
.dep-kind-dot.async { background: var(--info); }
.dep-kind-dot.data { background: var(--warning); }
.dep-chip.optional { opacity: 0.72; border-style: dashed; }
.dep-opt-tag {
  margin-left: 0.3rem; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.03em; color: var(--muted);
}
.dep-chip-in { background: var(--surface-2); }
.dep-chip-srv { border-color: var(--primary-soft-border); }

.dep-chip-pop { display: inline-block; position: relative; }
.dep-chip-pop > summary {
  list-style: none; cursor: pointer;
}
.dep-chip-pop > summary::-webkit-details-marker { display: none; }
.dep-add-chip {
  font-weight: 700; color: var(--primary);
  border: 1px dashed var(--primary-soft-border); background: var(--primary-soft);
}
.dep-chip-body {
  position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 0.25rem;
  min-width: 200px; padding: var(--space-2);
  display: flex; flex-direction: column; gap: var(--space-2);
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.dep-chip-body form { display: flex; flex-direction: column; gap: var(--space-1); margin: 0; }
.dep-meta-select, .dep-target-select {
  padding: 0.3rem 0.4rem; font-size: var(--text-sm);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}

/* Server-level dependencies block inside the server cell */
.inv-server-deps {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem;
  margin-top: 0.4rem; padding-top: 0.4rem; border-top: 1px dashed var(--border);
}
.inv-deps-label {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); margin-right: 0.15rem;
}
.inv-rdeps-cell .dep-chip { cursor: default; }

/* Graph controls: filters, layout actions, legend */
.inventory-controls {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
  gap: var(--space-3); margin-bottom: var(--space-3);
}
.inv-graph-filters { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.inv-filter-set {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem 0.5rem; margin: 0;
}
.inv-filter-set legend {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--muted); padding: 0 0.25rem;
}
.inv-check {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-size: var(--text-sm); text-transform: capitalize; margin-right: 0.5rem;
  cursor: pointer;
}
.inv-graph-actions { display: flex; align-items: center; gap: var(--space-2); }
.inv-layout-label { display: inline-flex; align-items: center; gap: 0.35rem; font-size: var(--text-sm); color: var(--text-soft); }

.inventory-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3);
  margin-top: var(--space-3); padding: var(--space-2) var(--space-3);
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: var(--text-xs); color: var(--text-soft);
}
.inv-legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.inv-legend-sep { width: 1px; height: 1rem; background: var(--border); }
.inv-legend-dim { opacity: 0.6; font-style: italic; }
.inv-legend-node {
  display: inline-block; width: 14px; height: 10px; border-radius: 3px;
  border: 2px solid var(--border); background: var(--surface-2);
}
.inv-legend-node.prod { border-color: var(--danger); background: var(--danger-soft); }
.inv-legend-node.staging { border-color: var(--primary); background: var(--primary-soft); }
.inv-legend-node.svc { border-color: var(--primary); background: var(--surface); }
.inv-legend-node.cycle { border-color: var(--warning); border-style: double; border-width: 3px; }
.inv-legend-edge { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--muted); }
.inv-legend-edge.sync { border-top-style: solid; }
.inv-legend-edge.async { border-top-style: dashed; }
.inv-legend-edge.data { border-top-style: dotted; }
.inv-legend-edge.server { border-top-width: 4px; border-top-color: var(--text-soft); }
.inv-legend-edge.crossenv { border-top-color: var(--danger); }
.inv-legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 2px solid; }
.inv-legend-swatch.dependent { border-color: var(--danger); }
.inv-legend-swatch.dependency { border-color: var(--info); }

/* Graph side-panel blast-radius summary */
.inv-impact-summary { display: flex; flex-direction: column; gap: 0.25rem; margin: var(--space-2) 0; }
.inv-impact-metric { font-size: var(--text-sm); color: var(--text-soft); }
.inv-impact-metric.impact strong { color: var(--danger); }
.inv-impact-metric.needs strong { color: var(--info); }
