:root {
  /* Layout */
  --sidebar-width: 220px;

  /* Backgrounds */
  --color-bg:           #0d1117;
  --color-sidebar-bg:   #080c14;
  --color-surface:      #161b27;
  --color-surface-2:    #1e2535;
  --color-border:       #2d3748;

  /* Text */
  --color-text:         #e2e8f0;
  --color-text-muted:   #94a3b8;
  --color-text-dim:     #64748b;

  /* Accent */
  --color-accent:       #3b82f6;
  --color-accent-dim:   rgba(59, 130, 246, 0.12);

  /* Status */
  --color-status-active:      #2e7d32;
  --color-status-pending:     #92400e;
  --color-status-investigate: #6d28d9;
  --color-status-hold:        #c2410c;
  --color-status-discarded:   #475569;
  --color-status-clean:       #0f766e;

  /* Stat cards */
  --color-stat-navy:   #1e3a5f;
  --color-stat-teal:   #0f766e;
  --color-stat-amber:  #92400e;
  --color-stat-slate:  #334155;
  --color-stat-purple: #5b21b6;
}

/* ── Base ──────────────────────────────────────────────────────────────────── */
body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
}

code, .font-monospace, .phys-label {
  font-family: 'IBM Plex Mono', monospace;
}

/* ── App layout ────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  z-index: 100;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 1.5rem 2rem;
  min-width: 0;
}

/* ── Sidebar components ────────────────────────────────────────────────────── */
.sidebar-brand {
  font-family: 'IBM Plex Mono', monospace;
  padding: 1.25rem 1rem;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-search input {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
  font-size: 0.8rem;
}

.sidebar-search input::placeholder {
  color: var(--color-text-dim);
}

.sidebar-search input:focus {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-text);
  box-shadow: 0 0 0 0.2rem var(--color-accent-dim);
}

.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.sidebar-section-label {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.sidebar-link {
  display: block;
  padding: 0.4rem 1rem;
  font-size: 0.825rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
}

.sidebar-link:hover {
  color: var(--color-text);
  background: var(--color-accent-dim);
}

.sidebar-link.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: var(--color-accent-dim);
}

.sidebar-link.sub {
  padding-left: 1.75rem;
  font-size: 0.8rem;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}

.sidebar-toggle:hover { color: var(--color-text); }

.sidebar-toggle .chevron {
  font-style: normal;
  transition: transform 0.15s ease;
  font-size: 0.75rem;
  line-height: 1;
}

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

.sidebar-section-content.collapsed { display: none; }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

/* ── Activity timeline ─────────────────────────────────────────────────────── */
.activity-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-timeline li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.825rem;
}

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

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.activity-label {
  color: var(--color-text);
}

.activity-subject {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.activity-meta {
  color: var(--color-text-dim);
  font-size: 0.75rem;
  margin-top: 0.1rem;
}

/* ── Lineage chain ─────────────────────────────────────────────────────────── */
.lineage-chain {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  align-items: center;
  padding: 0.5rem 0;
}

.lineage-node {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.825rem;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: border-color 0.15s;
}

.lineage-node:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.lineage-node.current {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  color: var(--color-accent);
  font-weight: 600;
}

.lineage-chain .arrow {
  color: var(--color-text-dim);
  margin: 0 0.4rem;
  font-size: 0.9rem;
}

/* ── Status badges ─────────────────────────────────────────────────────────── */
.badge-active      { background-color: var(--color-status-active); }
.badge-pending     { background-color: var(--color-status-pending); }
.badge-investigate { background-color: var(--color-status-investigate); }
.badge-hold        { background-color: var(--color-status-hold); }
.badge-discarded   { background-color: var(--color-status-discarded); }
.badge-defective   { background-color: var(--color-status-discarded); }
.badge-clean       { background-color: var(--color-status-clean); }
.badge-storage     { background: #334155; color: #e2e8f0; }

/* Neutral meta badge — for secondary info labels (type, procedure, etc.) */
.badge-meta {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* ── Data completeness mini-bars ───────────────────────────────────────────── */
.completeness-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
}

.completeness-bar .fill {
  height: 100%;
  border-radius: 3px;
  background: #198754;
}

/* ── Compact table ─────────────────────────────────────────────────────────── */
.table-compact td, .table-compact th {
  padding: 0.3rem 0.5rem;
  font-size: 0.875rem;
}

/* ── Investigations table ──────────────────────────────────────────────────── */
.inv-shim-row td { background: var(--color-surface-2); border-top: 2px solid var(--color-border) !important; }
.inv-table { table-layout: fixed; }
.inv-table .col-entity  { width: 36%; }
.inv-table .col-context { }
.inv-table .col-actions { width: 215px; }

/* ── Press batch list ──────────────────────────────────────────────────────── */
.batch-list-table { table-layout: fixed; }
.batch-list-table .col-box    { width: 115px; }
.batch-list-table .col-pos    { width: 42px; }
.batch-list-table .col-batch  { width: 90px; }
.batch-list-table .col-shim   { width: 90px; }
.batch-list-table .col-status { width: 175px; }
.batch-list-table td:last-child, .batch-list-table th:last-child { text-align: end; }
.batch-toggle { background: none; border: none; width: 100%; }
.batch-chevron { transition: transform 0.2s; opacity: 0.5; }
.batch-toggle[aria-expanded="true"] .batch-chevron { transform: rotate(180deg); }

/* ── Replica inbox tables ───────────────────────────────────────────────────── */
.inbox-shim-table   { table-layout: fixed; }
.inbox-detail-table { table-layout: fixed; }
.col-inbox-shim         { width: 130px; }
.col-inbox-storage      { width: 115px; }
.col-inbox-status       { width: 140px; }
.col-inbox-count        { width: 80px; }
.col-inbox-action        { width: 55px; }
.col-inbox-detail-action { width: 210px; }
.col-inbox-pos           { width: 42px; }
.col-inbox-badge-status  { width: 80px; }

/* ── Quick action strip ────────────────────────────────────────────────────── */
.action-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Dashboard stat cards ──────────────────────────────────────────────────── */
.stat-card { border: none; color: #fff; text-decoration: none; display: block; }
.stat-card:hover { filter: brightness(1.1); color: #fff; }
.stat-card-navy   { background-color: var(--color-stat-navy); }
.stat-card-teal   { background-color: var(--color-stat-teal); }
.stat-card-amber  { background-color: var(--color-stat-amber); }
.stat-card-slate  { background-color: var(--color-stat-slate); }
.stat-card-purple { background-color: var(--color-stat-purple); }

/* ── Physical label display ────────────────────────────────────────────────── */
code.phys-label {
  font-size: 0.82rem;
  letter-spacing: 0.01em;
  user-select: all;
}

/* ── Label grid (press run) ────────────────────────────────────────────────── */
.label-grid-cell {
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.6rem 0.75rem;
  min-height: 4rem;
  background: var(--color-surface);
}

.label-grid-cell.filled {
  background: var(--color-accent-dim);
  border-color: #93c5fd;
}

.label-grid-pos {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text-dim);
  margin-bottom: 0.2rem;
}

.label-grid-id {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  color: var(--color-text);
  word-break: break-all;
}

/* ── Dark table header override ─────────────────────────────────────────────── */
[data-bs-theme="dark"] .table-light {
  --bs-table-bg: var(--color-surface-2);
  --bs-table-color: var(--color-text-muted);
  --bs-table-border-color: var(--color-border);
  --bs-table-striped-bg: var(--color-surface-2);
  --bs-table-hover-bg: var(--color-surface-2);
}

/* ── Sidebar palette trigger ────────────────────────────────────────────────── */
.palette-trigger {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.375rem;
  padding: 0.35rem 0.625rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--color-text-dim);
  font-size: 0.8rem;
  text-align: left;
  transition: border-color 0.15s;
}

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

.palette-trigger span { flex: 1; }

/* ── Command palette ────────────────────────────────────────────────────────── */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 1055;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.palette-overlay.open { display: flex; }

.palette-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.625rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
  width: 100%;
  max-width: 600px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 1rem;
}

.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.palette-input-wrap svg { color: var(--color-text-dim); flex-shrink: 0; }

.palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 1rem;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

.palette-input::placeholder { color: var(--color-text-dim); }

.palette-results { overflow-y: auto; flex: 1; }

.palette-section-label {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-dim);
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.875rem;
  transition: background 0.1s;
}

.palette-item:hover,
.palette-item.pal-selected {
  background: var(--color-accent-dim);
  color: var(--color-text);
}

.palette-type-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.67rem;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  flex-shrink: 0;
  min-width: 2.8rem;
  text-align: center;
}

.palette-empty {
  padding: 2rem;
  text-align: center;
  color: var(--color-text-dim);
  font-size: 0.875rem;
}

.palette-footer {
  padding: 0.4rem 1rem;
  font-size: 0.72rem;
  color: var(--color-text-dim);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 1.25rem;
  flex-shrink: 0;
}

kbd {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-size: 0.68rem;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--color-text-muted);
}

/* ── Needs-attention panel ──────────────────────────────────────────────────── */
.attention-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.attention-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.875rem;
  transition: background 0.1s;
}

.attention-item:last-child { border-bottom: none; }

.attention-item:hover { background: var(--color-accent-dim); color: var(--color-text); }

.attention-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.attention-dot-warning { background: #f59e0b; }
.attention-dot-danger  { background: #ef4444; }
.attention-dot-info    { background: var(--color-accent); }

.attention-title { font-weight: 500; }
.attention-sub   { font-size: 0.78rem; color: var(--color-text-muted); }

/* ── Shim card grid ─────────────────────────────────────────────────────────── */
.shim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
}

.shim-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: 0.875rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: border-color 0.15s;
}

.shim-card:hover {
  border-color: var(--color-accent);
  color: inherit;
}

.shim-card-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.shim-card-meta {
  font-size: 0.77rem;
  color: var(--color-text-muted);
}

.shim-card-footer {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.77rem;
  color: var(--color-text-dim);
}

/* ── Changelog / feedback type badges ──────────────────────────────────────── */
.cl-badge-bug         { background: #7f1d1d; color: #fecaca; }
.cl-badge-feature     { background: #1e3a5f; color: #93c5fd; }
.cl-badge-improvement { background: #14532d; color: #86efac; }
.cl-badge-idea        { background: #334155; color: #cbd5e1; }

.cl-dot-bug         { background: #ef4444; }
.cl-dot-feature     { background: var(--color-accent); }
.cl-dot-improvement { background: #22c55e; }
.cl-dot-idea        { background: #94a3b8; }

/* ── Inbox-specific overrides ───────────────────────────────────────────────── */
.row-qc-primary {
  background-color: rgba(59, 130, 246, 0.07) !important;
}

.inbox-batch-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  padding: 0.15rem 0.45rem;
  border-radius: 0.25rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  text-decoration: none;
  display: inline-block;
}

.inbox-batch-badge:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}
