:root {
  --bg: #0e1420;
  --panel: #141b2b;
  --panel-2: #1b2436;
  --border: #263149;
  --text: #e6ebf5;
  --muted: #8a94a8;
  --accent: #3b82f6;
  --danger: #ef4444;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.workflow-section { padding: 18px 0; border-top: 1px solid var(--border); min-width: 0; }
.workflow-section h3 { margin: 0 0 12px; font-size: 16px; }
.workflow-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 12px 0; }
.workflow-toolbar label, .workflow-name { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.workflow-name { max-width: 420px; margin: 12px 0; }
.workflow-toolbar select { width: min(360px, 100%); }
.workflow-table-wrap { overflow-x: auto; max-width: 100%; }
.workflow-steps-table { min-width: 750px; table-layout: fixed; }
.workflow-steps-table th:first-child { width: 55px; }
.workflow-steps-table th:nth-child(2) { width: 205px; }
.workflow-steps-table th:nth-child(3) { width: 100px; }
.workflow-steps-table th:last-child { width: 115px; }
.workflow-steps-table input, .workflow-steps-table select { width: 100%; min-width: 0; }
.workflow-step-actions { display: flex; gap: 4px; }
.workflow-step-actions button, #workflow-add { width: 30px; height: 30px; padding: 0; font-size: 18px; }
.workflow-inline-status { display: block; margin-top: 5px; max-width: 320px; overflow-wrap: anywhere; font-size: 12px; }
#workflow-pools input[type="number"] { width: 85px; }
.workflow-run { border-bottom: 1px solid var(--border); padding: 12px 0; }
.workflow-run summary { cursor: pointer; overflow-wrap: anywhere; line-height: 1.6; font-size: 13px; }
.workflow-task-table { min-width: 600px; margin-top: 12px; }
.workflow-task-table td { overflow-wrap: anywhere; max-width: 320px; }
.workflow-task-steps { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.workflow-events { padding-left: 22px; max-height: 260px; overflow-y: auto; font-size: 12px; }
.workflow-events li { padding: 5px 0; overflow-wrap: anywhere; }
.workflow-dialog { width: min(440px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 8px; background: var(--panel); color: var(--text); padding: 22px; }
.workflow-dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.workflow-dialog label { display: flex; flex-direction: column; gap: 6px; }
.workflow-dialog select { width: 100%; min-width: 0; }
.workflow-dialog p, #workflow-error, #workflow-definition-error { overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .workflow-toolbar label { width: 100%; }
  .workflow-toolbar select { width: 100%; }
  #view-workflows { min-width: 0; }
}

.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  max-width: min(420px, calc(100vw - 32px));
  background: #13251b;
  border: 1px solid rgba(34, 197, 94, 0.45);
  border-radius: 8px;
  color: #86efac;
  padding: 12px 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  font-size: 13px;
}

.toast.error {
  background: #2b1518;
  border-color: rgba(239, 68, 68, 0.55);
  color: #fca5a5;
}

.dashboard-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dashboard-section-label { margin: 14px 0 -8px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin: 16px 0; }
.dashboard-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.dashboard-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.dashboard-card .dashboard-value { display: block; font-size: 25px; font-weight: 700; margin-top: 5px; }
.mini-button { padding: 4px 8px; font-size: 11px; }
.dashboard-card.online .dashboard-value { color: #22c55e; }
.dashboard-card.offline .dashboard-value, .dashboard-card.failed .dashboard-value { color: var(--danger); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dashboard-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin-bottom: 14px; min-width: 0; }
.dashboard-panel h3 { margin: 0 0 12px; font-size: 15px; }
.dashboard-row { border-top: 1px solid var(--border); padding: 9px 0; font-size: 13px; }
.dashboard-row:first-child { border-top: 0; }
.dashboard-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.processing-job { border-top: 1px solid var(--border); padding: 10px 0 4px; }
.processing-job:first-child { border-top: 0; padding-top: 0; }
.processing-job-header, .processing-file { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 12px; }
.processing-file { display: block; margin-top: 8px; }
.processing-file strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-weight: 500; }
.processing-timing, .archive-progress-label { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; margin-top: 8px; }
.processing-timing strong { color: var(--text); font-weight: 500; }
.archive-progress { height: 8px; overflow: hidden; background: #0b101a; border: 1px solid var(--border); border-radius: 4px; margin-top: 12px; }
.archive-progress span { display: block; height: 100%; background: #3b82f6; transition: width 240ms ease; }
.processing-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 6px; margin: 12px 0; }
.processing-summary span { color: var(--muted); font-size: 10px; }
.processing-summary strong { display: block; color: var(--text); font-size: 17px; line-height: 1.2; }
.pipeline-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; }
.pipeline-table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 11px; }
.pipeline-table th, .pipeline-table td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); }
.pipeline-table th:first-child, .pipeline-table td:first-child { text-align: left; }
.pipeline-table tbody tr:last-child td { border-bottom: 0; }
.pipeline-table th { color: var(--muted); font-weight: 600; background: #111827; }
.pipeline-table .working-count { color: #93c5fd; font-weight: 700; }
.pipeline-table .completed-count { color: #86efac; }
.pipeline-table .failed-count:not(:empty) { color: #fca5a5; }
.pipeline-heading { margin: 14px 0 8px; font-size: 12px; text-transform: uppercase; }
.idle-ingestion > p { margin: 0 0 12px; color: var(--muted); font-size: 11px; }
.idle-ingestion code { color: var(--text); }
.legacy-error-note { display: flex; flex-direction: column; gap: 3px; margin: 10px 0; padding: 9px; border-left: 2px solid #f59e0b; background: rgba(245, 158, 11, 0.08); font-size: 11px; }
.legacy-error-note span { color: var(--muted); }
.archive-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.archive-step { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); font-size: 11px; }
.archive-step strong { color: var(--text); }
.archive-step.complete { border-color: rgba(34, 197, 94, 0.35); }
.archive-step.active { border-color: rgba(59, 130, 246, 0.65); background: rgba(59, 130, 246, 0.07); }
.archive-step-marker { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 50%; }
.archive-step.complete .archive-step-marker { border-color: #22c55e; color: #86efac; }
.pipeline-legend, .pipeline-state-line { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.pipeline-legend { justify-content: flex-end; margin: -24px 0 8px; font-size: 10px; }
.pipeline-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 2px; background: currentColor; }
.pipeline-flow { display: grid; gap: 7px; }
.pipeline-flow-row { padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; background: #111827; }
.pipeline-flow-row.active { border-color: rgba(59, 130, 246, 0.75); background: rgba(59, 130, 246, 0.08); box-shadow: inset 3px 0 0 #3b82f6; }
.pipeline-flow-heading { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto auto; align-items: center; gap: 7px; font-size: 11px; }
.step-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.active-pill { padding: 2px 6px; border-radius: 4px; background: rgba(59, 130, 246, 0.18); color: #93c5fd; font-size: 9px; text-transform: uppercase; }
.step-percent { min-width: 34px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.pipeline-segments { display: flex; width: 100%; height: 8px; margin: 7px 0 6px; overflow: hidden; border-radius: 3px; background: #0b101a; }
.pipeline-segments span { display: block; height: 100%; min-width: 0; transition: width 220ms ease; }
.pipeline-segments .waiting { background: #475569; }
.pipeline-segments .working { background: #3b82f6; }
.pipeline-segments .completed { background: #22c55e; }
.pipeline-segments .failed { background: #ef4444; }
.pipeline-segments .skipped { background: #f59e0b; }
.pipeline-state-line { color: var(--muted); font-size: 9px; }
.pipeline-state-line b { color: var(--text); font-size: 10px; font-variant-numeric: tabular-nums; }
.pipeline-state-line .working b { color: #93c5fd; }
.pipeline-state-line .completed b { color: #86efac; }
.pipeline-state-line .failed b { color: #fca5a5; }
.pipeline-state-line .skipped b { color: #fbbf24; }
.pipeline-legend .waiting { color: #64748b; }
.pipeline-legend .working { color: #3b82f6; }
.pipeline-legend .completed { color: #22c55e; }
.pipeline-legend .failed { color: #ef4444; }
.pipeline-legend .skipped { color: #f59e0b; }
.working-list { display: grid; gap: 8px; }
.working-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; padding: 9px 10px; border-left: 3px solid #3b82f6; background: rgba(59, 130, 246, 0.07); }
.working-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.working-item span { grid-column: 1; color: #93c5fd; font-size: 10px; }
.working-item small { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); }
.ingestion-error-row { padding: 10px 0; border-top: 1px solid var(--border); font-size: 11px; }
.ingestion-error-row:first-child { border-top: 0; padding-top: 0; }
.ingestion-error-row p { margin: 4px 0 8px; color: var(--muted); }
.error-recording-link { border: 0; padding: 0; background: transparent; color: var(--text); font-weight: 700; text-align: left; }
.error-recording-link:hover { color: #93c5fd; background: transparent; }
.error-row-actions { display: flex; gap: 6px; }
.error-row-actions button { padding: 4px 8px; font-size: 10px; }
.ingestion-error-card { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.error-drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.error-drawer-header h3 { margin: 4px 0 16px; }
.eyebrow { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.icon-button { width: 32px; height: 32px; padding: 0; font-size: 20px; }
.error-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.error-detail-grid div { min-width: 0; }
.error-detail-grid span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.error-detail-grid strong { display: block; margin-top: 3px; overflow-wrap: anywhere; font-size: 12px; }
.error-technical { margin: 18px 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.error-technical h4 { margin: 4px 0; }
.error-technical p { overflow-wrap: anywhere; }
.recommended-action { color: #fbbf24; }
.error-technical pre { max-height: 220px; overflow: auto; padding: 10px; background: #0b101a; color: #cbd5e1; white-space: pre-wrap; }
.step-history { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 16px; padding: 0; list-style: none; font-size: 11px; }
.step-history li { color: var(--muted); }
.step-history li span { display: inline-block; width: 18px; }
.step-history li.completed { color: #86efac; }
.step-history li.failed { color: #fca5a5; font-weight: 700; }
.error-actions { position: sticky; bottom: 0; padding-top: 12px; background: var(--panel); }
.dashboard-history { overflow-x: auto; }
.settings-panel { max-width: 760px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 18px; margin-top: 18px; }
.settings-panel h3 { margin-top: 0; }
.settings-panel label { display: block; margin: 12px 0; }
.settings-panel input[type="text"] { width: 100%; margin-top: 6px; }
.checkbox-label { display: flex !important; gap: 8px; align-items: center; }
.checkbox-label input { width: auto !important; }
.transfer-settings-section { max-width: 960px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.transfer-settings-section h3 { margin-top: 0; font-size: 17px; }
.transfer-settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
.transfer-settings-grid h4 { grid-column: 1 / -1; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.transfer-settings-grid label, .transfer-form label { display: flex; flex-direction: column; gap: 7px; min-width: 0; font-size: 13px; }
.transfer-settings-grid .checkbox-label { grid-column: 1 / -1; flex-direction: row; }
.transfer-settings-grid input, .transfer-form input { width: 100%; min-width: 0; }
.transfer-settings-actions, .transfer-form-actions, .transfer-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.transfer-settings-actions { margin-top: 22px; }
.transfer-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.transfer-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; padding: 18px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.transfer-drop-zone { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 10px 14px; border: 1px dashed var(--border); border-radius: 4px; color: var(--text); }
.transfer-drop-zone.drag-over { border-color: var(--accent); background: var(--panel-2); }
.transfer-drop-zone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.transfer-hash, .transfer-form-actions { grid-column: 1 / -1; }
.transfer-hash input { font-family: ui-monospace, monospace; font-size: 13px; }
.transfer-hash-progress { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 24px; }
.transfer-hash-progress progress { flex: 0 1 240px; width: 240px; max-width: 100%; height: 8px; accent-color: var(--accent); }
.transfer-hash-progress [role="status"] { min-height: 20px; overflow-wrap: anywhere; font-size: 13px; }
.transfer-table-wrap { overflow-x: auto; }
.transfer-table { min-width: 720px; table-layout: fixed; }
.transfer-table th:first-child { width: 25%; }
.transfer-table th:last-child { width: 22%; }
.transfer-table td { overflow-wrap: anywhere; vertical-align: top; }
.transfer-table td strong, .transfer-table td small { display: block; }
.transfer-table td small { margin-top: 5px; color: var(--muted); }
.transfer-table td details { max-width: 100%; margin-top: 6px; }
.transfer-table td details summary { cursor: pointer; color: var(--accent); overflow-wrap: anywhere; }
.transfer-table td details ul { max-height: 220px; overflow-y: auto; overflow-x: hidden; margin: 6px 0; padding: 0 8px 0 22px; overscroll-behavior: contain; }
.transfer-table td details li { overflow-wrap: anywhere; margin: 3px 0; }
.transfer-table td .transfer-archive-warning { max-height: 4.5em; overflow-y: auto; }
.transfer-table progress { width: 100%; height: 8px; margin-top: 8px; accent-color: var(--accent); }
.transfer-row-actions button { padding: 5px 8px; font-size: 12px; }
#transfer-error, #transfer-settings-error, #transfer-selection { overflow-wrap: anywhere; }
@media (max-width: 800px) { .transfer-settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .transfer-settings-grid, .transfer-form { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 800px) { .dashboard-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .processing-summary { grid-template-columns: repeat(3, minmax(70px, 1fr)); }
  .error-detail-grid, .step-history { grid-template-columns: 1fr; }
  .error-actions { flex-wrap: wrap; }
}

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

input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="date"], input[type="datetime-local"], select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  color-scheme: dark;
}

input:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

select option { background: var(--panel-2); color: var(--text); }

button {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); }
button.danger { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger); color: var(--text); }

/* Login & Password Reset */
.login-view {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 { font-size: 18px; margin: 0 0 8px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 4px 0 0; }

.auth-card-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-top: 2px;
}

.auth-card-links a {
  color: var(--accent);
  text-decoration: none;
}

.auth-card-links a:hover {
  text-decoration: underline;
}

.notice {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.4;
  margin: 6px 0 0;
}

.success-notice {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

/* App shell */
.app-view { display: flex; height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 6px;
}

.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.brand { font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.icon-button { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-icon { display: none; width: 22px; text-align: center; font-size: 16px; }
.nav-label { display: inline; }

.nav-item.active, .nav-item:hover { background: var(--panel-2); }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.app-version { color: var(--muted); font-size: 10px; letter-spacing: 0.4px; }

.sidebar-collapsed .sidebar { width: 72px; }
.sidebar-collapsed .brand, .sidebar-collapsed .sidebar-panel, .sidebar-collapsed .sidebar-footer { overflow: hidden; white-space: nowrap; }
.sidebar-collapsed .brand { width: 0; }
.sidebar-collapsed .brand-row { justify-content: center; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; }
.sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .nav-icon { display: inline-block; }
.sidebar-collapsed .sidebar-panel { display: none; }
.sidebar-collapsed .sidebar-footer span { display: none; }
.sidebar-collapsed #logout-btn { padding: 8px 0; font-size: 0; }
.sidebar-collapsed #logout-btn::before { content: "⇥"; font-size: 16px; }

.content { flex: 1; padding: 20px 28px; overflow-y: auto; }

.view h2 { margin-top: 0; }

.search-command { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; margin-bottom: 16px; }
.search-command input { font-size: 16px; padding: 12px 14px; }

.search-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) minmax(180px, 1.2fr);
  gap: 10px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}
.search-filters label, .saved-search-block { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); min-width: 0; }
.search-filters input, .search-filters select { width: 100%; }
.saved-search-block > span { font-weight: 700; }
.saved-searches { display: flex; flex-direction: column; gap: 6px; }
.saved-search-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.saved-search-row button { padding: 5px 7px; font-size: 12px; text-align: left; }

.search-body { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(320px, 0.45fr); gap: 18px; align-items: start; }

.results-panel { min-width: 0; }
.results-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
#results-summary { margin-left: 10px; }
.map-panel { height: 180px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; position: relative; overflow: hidden; background: #111827; }
.map-grid { position: absolute; inset: 0; background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px); background-size: 28px 28px; opacity: 0.5; }
.map-copy { position: absolute; left: 16px; bottom: 14px; right: 16px; color: var(--muted); font-size: 13px; }
.detail-panel { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; min-width: 280px; }

.results-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.results-table th, .results-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.results-table th[data-sort] { cursor: pointer; user-select: none; }
.results-table th[data-sort]:hover { color: var(--accent); }
.results-table tr:hover { background: var(--panel-2); cursor: pointer; }

.placeholder { color: var(--muted); }
.muted { color: var(--muted); }
.storage-location { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.storage-path { min-width: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab-btn { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 4px; }
.tab-btn.active { border-bottom-color: var(--accent); color: var(--accent); }

.detail-field { font-size: 13px; margin-bottom: 6px; }
.detail-field .label { color: var(--muted); margin-right: 6px; }
.detail-field { overflow-wrap: anywhere; word-break: break-word; }
.detail-actions { display: flex; gap: 8px; justify-content: flex-end; margin: -4px 0 10px; }
.preservation-panel { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.preservation-panel h4 { margin: 8px 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }

.file-row { font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); }

video { width: 100%; border-radius: 6px; margin-bottom: 12px; background: #000; }

/* ---------- Evidence Player ---------- */

.player-picker { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 14px 0; }
.player-picker label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.player-picker select, .player-picker input { min-width: 190px; }

.player-stage { border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow: hidden; }

.player-header { display: flex; flex-wrap: wrap; gap: 26px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.player-header-item { display: flex; flex-direction: column; gap: 2px; }
.player-header-item .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.player-header-item strong { font-size: 13px; }
.player-header-item { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }

.player-screen { position: relative; background: #000; aspect-ratio: 16 / 9; width: 100%; }
.player-timezone-caption { position: absolute; bottom: 12px; left: 12px; right: 12px; width: fit-content; max-width: calc(100% - 24px); padding: 5px 8px; background: rgba(0, 0, 0, 0.78); color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; pointer-events: none; z-index: 1; }
.player-screen:fullscreen { aspect-ratio: auto; height: 100%; }
.segment-timezone { display: block; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.player-video { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border-radius: 0; opacity: 0; pointer-events: none; }
/* Only the active buffer is visible; the other is preloading the next recording. */
.player-video.active { opacity: 1; pointer-events: auto; }
.player-gap-notice { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 16px; border-radius: 6px; background: rgba(0, 0, 0, 0.78); color: #fbbf24; font-size: 13px; border: 1px solid rgba(251, 191, 36, 0.5); }

.player-transport { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.transport-btn { min-width: 34px; height: 30px; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--panel); color: var(--text); cursor: pointer; font-size: 13px; }
.transport-btn:hover { border-color: var(--accent); }
.transport-btn.play { min-width: 42px; font-size: 15px; }
.transport-speed { height: 30px; }
.transport-clock { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-left: 10px; min-width: 0; }
.transport-clock #player-clock-timezone { flex-basis: 100%; overflow-wrap: anywhere; }
.transport-clock strong { font-size: 16px; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.transport-clock span { font-size: 11px; font-variant-numeric: tabular-nums; }
.transport-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.transport-right input[type="range"] { width: 90px; accent-color: var(--accent); }

.timeline-block { padding: 12px 16px 6px; }
.timeline-ruler { position: relative; height: 14px; margin-bottom: 2px; }
.timeline-tick { position: absolute; transform: translateX(-50%); font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

.timeline-track { position: relative; height: 46px; border-radius: 5px; background: repeating-linear-gradient(90deg, #1b1f27 0 6px, #171b22 6px 12px); border: 1px solid var(--border); cursor: pointer; overflow: hidden; }
.timeline-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.timeline-segments, .timeline-events { position: absolute; inset: 0; }
.timeline-segment { position: absolute; top: 12px; height: 22px; padding: 0; border: 0; border-radius: 3px; background: #2f7d5a; cursor: pointer; }
.timeline-segment:hover { background: #3a9c70; }
.timeline-segment.playing { background: var(--accent); }

.timeline-event { position: absolute; top: 4px; width: 3px; height: 38px; padding: 0; border: 0; border-radius: 2px; transform: translateX(-50%); background: #fbbf24; cursor: pointer; }
.timeline-event.trigger { background: #ef4444; }
.timeline-event:hover, .timeline-event:focus-visible { background: #fff; }

.timeline-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; box-shadow: 0 0 5px rgba(255, 255, 255, 0.75); }
.timeline-selection { position: absolute; top: 0; bottom: 0; background: rgba(96, 165, 250, 0.22); border-left: 2px solid #60a5fa; border-right: 2px solid #60a5fa; pointer-events: none; }
.timeline-handle { position: absolute; top: 0; bottom: 0; width: 11px; transform: translateX(-50%); background: #60a5fa; border-radius: 3px; cursor: ew-resize; opacity: 0.85; }
.timeline-handle:hover { opacity: 1; }

.timeline-legend { display: flex; gap: 16px; margin-top: 7px; font-size: 10px; color: var(--muted); }
.timeline-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.timeline-legend .swatch.recorded { background: #2f7d5a; }
.timeline-legend .swatch.gap { background: #1b1f27; border: 1px solid var(--border); }
.timeline-legend .swatch.alarm { background: #fbbf24; }

.player-selection { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel-2); }
.selection-summary { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.selection-summary .label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.selection-summary strong { font-variant-numeric: tabular-nums; }
.selection-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.selection-status { padding: 10px 16px; font-size: 12px; border-top: 1px solid var(--border); background: var(--panel); line-height: 1.6; word-break: break-all; }

.player-meta { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.player-meta h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.player-segment-list { max-height: 210px; overflow-y: auto; }
.player-segment-row { display: grid; grid-template-columns: 170px 1fr auto auto; gap: 12px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 12px; }
.player-segment-row.playing { background: rgba(96, 165, 250, 0.1); border-radius: 4px; }
.player-segment-row .seg-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.player-segment-row .seg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-segment-row .seg-dur { font-variant-numeric: tabular-nums; }
.seg-jump { padding: 3px 9px; font-size: 11px; }

@media (max-width: 860px) {
  .player-segment-row { grid-template-columns: 1fr auto; }
  .player-segment-row .seg-time { grid-column: 1 / -1; }
  .player-transport { flex-wrap: wrap; }
}

.selected-tray {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.selected-summary { font-weight: 600; margin-bottom: 8px; }
.selected-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.selected-chip { background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; padding: 4px 10px; font-size: 12px; }
.selected-actions { display: flex; gap: 10px; }

.inline-form { display: flex; gap: 10px; margin-bottom: 16px; }

#collection-detail { margin-top: 16px; font-size: 13px; }

/* Sidebar status panels */
.sidebar-panel { margin-top: 18px; font-size: 12px; }
.sidebar-panel-title { font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px; }
.status-list { display: flex; flex-direction: column; gap: 4px; }
.status-row { display: flex; justify-content: space-between; gap: 8px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-dot.available, .status-dot.online { background: #22c55e; }
.status-dot.preview_available { background: var(--accent); }
.status-dot.retrieving { background: #f59e0b; }
.status-dot.offline_required, .status-dot.offline { background: var(--danger); }
.status-dot.not_in_orain, .status-dot.unknown, .status-dot.not_configured { background: var(--muted); }

/* Results table additions */
.thumb-placeholder {
  width: 56px;
  height: 32px;
  border-radius: 4px;
  background: linear-gradient(135deg, #263149, #1b2436);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.thumb-placeholder .video-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.thumb-placeholder.video { color: #93c5fd; }
.thumb-placeholder.image { color: #86efac; }
.thumb-placeholder.audio { color: #fbbf24; }
.thumb-placeholder.document, .thumb-placeholder.file { color: #cbd5e1; }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge.available { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.status-badge.preview_available { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.status-badge.retrieving { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.status-badge.offline_required { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.status-badge.not_in_orain, .status-badge.unknown { background: rgba(138, 148, 168, 0.15); color: var(--muted); }
.status-badge.detected { background: rgba(138, 148, 168, 0.15); color: var(--muted); }
.status-badge.processing { background: rgba(59, 130, 246, 0.15); color: var(--accent); }
.status-badge.completed { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.status-badge.failed { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  min-width: 340px;
}
.package-card { width: min(560px, calc(100vw - 32px)); }
.package-review-card { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; display: flex; flex-direction: column; }
.package-review-list { max-height: 420px; overflow-y: auto; margin: 14px 0; }
.package-manifest-list { max-height: 160px; overflow-y: auto; margin: 8px 0 14px; padding: 8px; border: 1px solid var(--border); background: var(--panel-2); font-size: 11px; }
.package-review-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.package-review-item h4 { margin: 0 0 8px; font-size: 13px; }
.package-file-option { margin: 5px 0 !important; font-size: 12px; }
.package-file-option { flex-direction: row !important; justify-content: flex-start; text-align: left; }
.package-review-subheading { margin: 10px 0 5px; color: var(--text); font-size: 12px; font-weight: 700; }
.package-player-heading { margin-top: 16px; }
.package-file-empty { margin: 5px 0; font-size: 12px; }
.package-summary { margin-bottom: 12px; color: var(--muted); }
.package-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; margin-bottom: 12px; }
.package-progress { border: 1px solid var(--border); border-radius: 8px; padding: 14px; margin: 12px 0; background: var(--panel-2); }
.package-progress-title { font-weight: 700; margin-bottom: 10px; }
.progress-track { height: 10px; border-radius: 999px; background: #0f172a; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, var(--accent)); transition: width 180ms ease; }
.progress-percent { font-size: 22px; font-weight: 700; margin: 8px 0; }
.package-step { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.package-progress-filename { margin-top: 10px; font-weight: 700; }
.package-review-card > .modal-actions { position: sticky; bottom: -20px; margin: 12px -20px -20px; padding: 12px 20px 20px; background: var(--panel); border-top: 1px solid var(--border); }
.modal-card label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.modal-card input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.collection-items-table { width: 100%; margin-top: 12px; }
.collection-items-table th, .collection-items-table td { text-align: left; padding: 6px 8px; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
  font-size: 12px;
  flex-wrap: wrap;
}
.rows-per-page { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.rows-per-page select { padding: 4px 6px; }
.page-jump { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.page-jump input { width: 62px; padding: 4px 6px; }
.results-total { margin-left: auto; min-width: 160px; text-align: right; }
#first-page-btn, #prev-page-btn, #next-page-btn, #last-page-btn { padding: 5px 10px; }

@media (max-width: 1180px) {
  .search-filters { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .search-body { grid-template-columns: minmax(0, 1fr); }
  .detail-panel { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .app-view { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar, .sidebar-collapsed .sidebar { width: 100%; min-height: auto; }
  .sidebar-collapsed .sidebar { padding: 10px 12px; }
  .sidebar-collapsed .brand-row { justify-content: space-between; margin: 0; }
  .sidebar-collapsed .brand { display: block; width: auto; }
  .sidebar-collapsed .nav-item, .sidebar-collapsed .sidebar-panel, .sidebar-collapsed .sidebar-footer { display: none; }
  .content { padding: 16px; }
  .search-command { grid-template-columns: 1fr; }
  .search-filters { grid-template-columns: 1fr; }
  .search-body { grid-template-columns: 1fr; }
  .results-total { margin-left: 0; width: 100%; text-align: left; }
  .package-options { grid-template-columns: 1fr; }
  .ingestion-pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
