/* ═══════════════════════════════════════════════════════════════
   Sherlock – Teltonika Telematik Parser
   styles.css – Core layout, header, KPI bar, sidebar, tabs
   Design language: Vimcar / IBM Carbon – light, clean, corporate
   ═══════════════════════════════════════════════════════════════ */

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Backgrounds — Vimcar light theme (IBM Carbon Gray scale) */
  --bg-base:     #f4f4f4;   /* Carbon Gray 10 — page background */
  --bg-surface:  #ffffff;   /* White — header, cards, panels */
  --bg-elevated: #f4f4f4;   /* Slightly inset elements */
  --bg-hover:    #e8e8e8;   /* Carbon Gray 20 — hover state */
  --bg-input:    #ffffff;   /* White inputs */

  /* Borders — Carbon Gray */
  --border-subtle:  #e0e0e0;   /* Carbon Gray 20 */
  --border-default: #c6c6c6;   /* Carbon Gray 30 */
  --border-strong:  #8d8d8d;   /* Carbon Gray 40 */

  /* Text — Carbon Gray */
  --text-primary:   #161616;   /* Carbon Gray 100 — main text */
  --text-secondary: #525252;   /* Carbon Gray 60 — secondary */
  --text-muted:     #8d8d8d;   /* Carbon Gray 40 — hints, labels */
  --text-disabled:  #c6c6c6;   /* Carbon Gray 30 — disabled */

  /* Primary — Vimcar IBM Blue */
  --accent:       #0043ce;            /* IBM Blue 60 — exact Vimcar brand */
  --accent-hover: #002d9c;            /* IBM Blue 80 — hover */
  --accent-light: #d0e2ff;            /* IBM Blue 10 — tinted bg */
  --accent-dim:   rgba(0,67,206,.07); /* button glow, focus ring */
  --accent-glow:  rgba(0,67,206,.14);

  /* Severity — unchanged per ARCHITECTURE.md */
  --sev-info:     #6b7280;
  --sev-notice:   #3b82f6;
  --sev-warning:  #f97316;
  --sev-critical: #ef4444;
  --sev-data-gap: #8b5cf6;

  /* Severity backgrounds — lighter tints for light theme */
  --sev-info-bg:     rgba(107,114,128,.08);
  --sev-notice-bg:   rgba(59, 130,246,.08);
  --sev-warning-bg:  rgba(249,115, 22,.08);
  --sev-critical-bg: rgba(239, 68, 68,.08);
  --sev-gap-bg:      rgba(139, 92,246,.08);

  /* Layout */
  --header-h:  52px;
  --input-h:   158px;
  --kpi-h:     70px;
  --sidebar-w: 224px;
  --radius:    4px;
  --radius-lg: 6px;

  /* Typography — Inter for body (Vimcar also uses Inter), system fallback for offline */
  --font-ui:   'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono: 'Cascadia Code', 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, 'Courier New', monospace;

  /* Motion */
  --t-fast: 100ms ease;
  --t-base: 180ms ease;
  --t-slow: 280ms ease;
}

/* ── Base ─────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 1px 4px;
  border-radius: 2px;
}

strong { font-weight: 600; color: var(--text-primary); }

/* ── App Root ─────────────────────────────────────────────────── */
.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */
.app-header {
  flex-shrink: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 100;
}

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-logo {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}

.brand-sep {
  width: 1px;
  height: 16px;
  background: var(--border-default);
  flex-shrink: 0;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.1px;
}

/* Header controls (right) */
.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.control-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%238d8d8d'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 4px 22px 4px 8px;
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.control-select:hover { border-color: var(--border-strong); }
.control-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
  outline: none;
}

.input-toggle-btn {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-family: var(--font-ui);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
}

.input-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.privacy-notice {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-disabled);
}

.privacy-notice svg {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   INPUT SECTION
   ═══════════════════════════════════════════════════════════════ */
.input-section {
  flex-shrink: 0;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  max-height: var(--input-h);
  overflow: hidden;
  transition: max-height var(--t-slow) cubic-bezier(0.4, 0, 0.2, 1);
}

.input-section.collapsed {
  max-height: 0;
}

.input-inner {
  display: flex;
  gap: 10px;
  padding: 10px 20px;
  height: var(--input-h);
}

#raw-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  resize: none;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

#raw-input::placeholder {
  color: var(--text-disabled);
  font-style: italic;
}

#raw-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

/* Input actions column */
.input-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 148px;
  padding-top: 1px;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: center;
  user-select: none;
  line-height: 1;
}

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

.btn-secondary input[type='file'] { display: none; }

.file-name {
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 14px;
}

.input-spacer { flex: 1; }

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast), transform 80ms ease;
  line-height: 1;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:active { transform: translateY(1px); }

/* ═══════════════════════════════════════════════════════════════
   KPI BAR
   ═══════════════════════════════════════════════════════════════ */
.kpi-bar {
  flex-shrink: 0;
  height: var(--kpi-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  overflow-y: hidden;
}

.kpi-bar::-webkit-scrollbar { height: 0; }

.kpi-card {
  flex: 1;
  min-width: 108px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8px 18px;
  border-right: 1px solid var(--border-subtle);
  transition: background var(--t-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card:last-child { border-right: none; }
.kpi-card:hover { background: var(--bg-elevated); }

/* Severity accent bar on left edge */
.kpi-card[data-severity]::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; height: 60%;
  width: 3px;
  border-radius: 0 2px 2px 0;
}

.kpi-card[data-severity='warning']::before  { background: var(--sev-warning); }
.kpi-card[data-severity='critical']::before { background: var(--sev-critical); }
.kpi-card[data-severity='notice']::before   { background: var(--sev-notice); }

.kpi-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 3px;
  white-space: nowrap;
  font-weight: 500;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
  transition: color var(--t-base);
}

.kpi-value.empty { color: var(--text-disabled); }

.kpi-card[data-severity='warning']  .kpi-value { color: var(--sev-warning); }
.kpi-card[data-severity='critical'] .kpi-value { color: var(--sev-critical); }
.kpi-card[data-severity='notice']   .kpi-value { color: var(--sev-notice); }

.kpi-sub {
  font-size: 9.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════════════════════
   APP BODY
   ═══════════════════════════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ─── Filter Sidebar ─────────────────────────────────────────── */
.filter-sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  flex-shrink: 0;
  padding: 9px 16px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-elevated);
}

/* Filter groups */
.filter-group {
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.filter-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  cursor: pointer;
  user-select: none;
  transition: background var(--t-fast);
}

.filter-group-header:hover { background: var(--bg-hover); }

.filter-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.filter-group-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-disabled);
  flex-shrink: 0;
}

.filter-group[data-group='time']        .filter-group-dot { background: var(--sev-info); }
.filter-group[data-group='record-type'] .filter-group-dot { background: var(--sev-notice); }
.filter-group[data-group='drive-state'] .filter-group-dot { background: var(--sev-warning); }
.filter-group[data-group='quality']     .filter-group-dot { background: var(--sev-warning); }
.filter-group[data-group='special']     .filter-group-dot { background: var(--sev-critical); }

.filter-group-chevron {
  width: 11px;
  height: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--t-base);
}

.filter-group.collapsed .filter-group-chevron { transform: rotate(-90deg); }

.filter-group-body {
  padding: 4px 16px 10px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-subtle);
}

.filter-group.collapsed .filter-group-body { display: none; }

.filter-empty {
  font-size: 11px;
  color: var(--text-disabled);
  font-style: italic;
  padding: 4px 0;
}

/* ─── Sidebar header with reset button ──────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-reset-btn {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--font-ui);
  padding: 2px 7px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
  line-height: 1.4;
}

.filter-reset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Active filter indicator on sidebar border */
.filter-sidebar.filters-active {
  border-right-color: var(--accent);
}

/* ─── Filter count badge ─────────────────────────────────────── */
.filter-count {
  flex-shrink: 0;
  padding: 4px 16px;
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
  letter-spacing: 0.1px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ─── Preset buttons ─────────────────────────────────────────── */
.filter-presets {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-presets-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1px;
}

.preset-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-ui);
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
  line-height: 1.4;
}

.preset-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.preset-btn:active { opacity: 0.8; }

/* ─── Filter fields ──────────────────────────────────────────── */
.filter-field {
  margin-top: 8px;
}

.filter-field:first-child { margin-top: 2px; }

.filter-label {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 500;
}

/* Radio group (stacked) */
.filter-radio-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

/* Radio row (horizontal: Alle / ON / OFF) */
.filter-radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.filter-radio-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  line-height: 1.3;
}

.filter-radio-label input[type='radio'] {
  accent-color: var(--accent);
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Checkbox */
.filter-check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  line-height: 1.3;
}

.filter-check-label input[type='checkbox'] {
  accent-color: var(--accent);
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Number / datetime inputs */
.filter-input-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.filter-input {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 6px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  min-width: 0;
}

.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.filter-number {
  width: 72px;
}

.filter-datetime {
  width: 100%;
  font-family: var(--font-ui);
}

.filter-unit {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ─── Tab Navigation ─────────────────────────────────────────── */
.tab-nav {
  flex-shrink: 0;
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
  overflow-y: hidden;
}

.tab-nav::-webkit-scrollbar { height: 0; }

.tab-btn {
  flex-shrink: 0;
  height: 40px;
  padding: 0 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-family: var(--font-ui);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ─── Tab Panels ─────────────────────────────────────────────── */
.tab-panels {
  flex: 1;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.tab-panel {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 24px;
}

.tab-panel.active { display: block; }

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  height: 100%;
  max-height: calc(100vh - 320px);
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  color: var(--border-strong);
  flex-shrink: 0;
}

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.1px;
}

.empty-state-text {
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.65;
}

.empty-state-text code {
  background: var(--accent-light);
  color: var(--accent-hover);
  border: none;
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 0.9em;
}

/* ═══════════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-info     { background: var(--sev-info-bg);  color: var(--sev-info); }
.badge-notice   { background: var(--sev-notice-bg); color: var(--sev-notice); }
.badge-warning  { background: var(--sev-warning-bg); color: var(--sev-warning); }
.badge-critical { background: var(--sev-critical-bg); color: var(--sev-critical); }
.badge-data-gap { background: var(--sev-gap-bg);    color: var(--sev-data-gap); }

/* Row severity highlights (Records table) */
.sev-info     { background: var(--sev-info-bg); }
.sev-notice   { background: var(--sev-notice-bg); }
.sev-warning  { background: var(--sev-warning-bg); }
.sev-critical { background: var(--sev-critical-bg); }
.sev-data-gap { background: var(--sev-gap-bg); }

/* ═══════════════════════════════════════════════════════════════
   RECORDS TABLE
   ═══════════════════════════════════════════════════════════════ */
#tab-records {
  padding: 0;
}

.records-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.records-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11.5px;
}

.records-count {
  font-weight: 600;
  color: var(--text-secondary);
}

.records-hint {
  color: var(--text-muted);
  font-style: italic;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

.records-table .col-nr    { width: 48px; }
.records-table .col-ts    { width: 152px; }
.records-table .col-delay { width: 74px; }
.records-table .col-imei  { width: 68px; }
.records-table .col-coord { width: 82px; }
.records-table .col-sat   { width: 44px; }
.records-table .col-spd   { width: 52px; }
.records-table .col-score { width: 54px; text-align: center; }
.records-table .col-flags { width: auto; }

/* Score pill — records table */
.score-pill {
  display: inline-block;
  min-width: 32px;
  padding: 1px 5px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.02em;
}
.score-pill.score-good { background: rgba(34,197, 94,.15); color: #15803d; }
.score-pill.score-warn { background: rgba(249,115, 22,.15); color: #c2410c; }
.score-pill.score-bad  { background: rgba(239, 68, 68,.15); color: #b91c1c; }

.records-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border-default);
  padding: 7px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
}

.records-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: filter var(--t-fast);
}

.records-table tbody tr:hover {
  filter: brightness(0.96);
}

.records-table tbody tr.raw-row {
  cursor: default;
}

.records-table tbody tr.raw-row:hover {
  filter: none;
}

.records-table td {
  padding: 5px 10px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.records-table td.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.records-table td.neg-delay {
  color: var(--sev-critical);
  font-weight: 600;
}

.records-table td.parse-error-cell {
  color: var(--sev-warning);
  font-style: italic;
  font-size: 11px;
}

.records-table td.imei-cell {
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.records-table td.col-flags {
  white-space: normal;
  overflow: visible;
  line-height: 1.8;
}

.no-flags {
  color: var(--text-disabled);
  font-size: 11px;
}

/* Raw row */
.raw-row { display: none; }
.raw-row:not(.hidden) { display: table-row; }

.raw-cell {
  background: var(--bg-elevated) !important;
  padding: 6px 16px 8px !important;
  border-left: 3px solid var(--border-default);
}

.raw-cell code {
  display: block;
  font-size: 10.5px;
  color: var(--text-secondary);
  background: none;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

/* ── Raw-detail layout (property-dictionary expansion) ── */
.raw-detail {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.raw-line-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: -4px;
}

.raw-line {
  display: block;
  font-size: 10.5px;
  color: var(--text-secondary);
  background: none;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
}

/* Properties table inside raw expansion */
.props-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  margin-top: 4px;
}

.props-table thead tr {
  background: transparent;
}

.props-table th {
  padding: 3px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
}

.props-table td {
  padding: 2px 8px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.04));
  vertical-align: middle;
}

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

.props-table tr.props-row-unknown td {
  opacity: 0.55;
}

.props-col-key   { width: 22%; }
.props-col-label { width: 26%; color: var(--text-primary); }
.props-col-value { width: 28%; font-weight: 500; }
.props-col-raw   { width: 24%; color: var(--text-muted); font-size: 10.5px; }

.props-unit {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 2px;
}

.props-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin: 4px 0 0;
  padding: 0;
}

/* ═══════════════════════════════════════════════════════════════
   TRIPS TAB
   ═══════════════════════════════════════════════════════════════ */
.trips-wrap {
  display: flex;
  flex-direction: column;
}

.trips-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 8px 0 16px;
  font-size: 11.5px;
}

.trips-count {
  font-weight: 600;
  color: var(--text-secondary);
}

.trips-section {
  margin-bottom: 28px;
}

.trips-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.trips-section-title--missed { color: var(--sev-warning); }

.trip-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Trip card ───────────────────────────────────────────── */
.trip-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: box-shadow var(--t-fast);
}

.trip-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.trip-card--missed { opacity: 0.82; }

/* Left accent bar for missed-trip candidates */
.trip-card--candidate {
  border-left: 3px solid var(--sev-warning);
  opacity: 1;
}

/* ── Card header ─────────────────────────────────────────── */
.trip-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.trip-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  margin-right: 2px;
}

/* Quality score — right-aligned via margin-left: auto */
.trip-quality {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.trip-quality.quality-good { color: #22c55e; }
.trip-quality.quality-warn { color: var(--sev-warning); }
.trip-quality.quality-bad  { color: var(--sev-critical); }

/* ── Time range row ──────────────────────────────────────── */
.trip-timerange {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.trip-arrow { color: var(--text-muted); }

.trip-duration {
  color: var(--text-muted);
  font-size: 11px;
}

/* ── Stats grid ──────────────────────────────────────────── */
.trip-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px 14px;
}

.trip-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.trip-stat-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 500;
}

.trip-stat-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════════
   RECORD DETAIL PANEL
   ═══════════════════════════════════════════════════════════════ */
.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-base);
}

.detail-panel.open {
  pointer-events: auto;
  opacity: 1;
}

.detail-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
}

.detail-panel-drawer {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0,0,0,.10);
}

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

.detail-panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-elevated);
}

.detail-panel-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.detail-nav-btn {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--t-fast);
  line-height: 1;
}

.detail-nav-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

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

.detail-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 4px;
  transition: all var(--t-fast);
  line-height: 1;
}

.detail-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.detail-section { margin-bottom: 20px; }
.detail-section:last-child { margin-bottom: 0; }

.detail-section-title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Fields table */
.detail-fields-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.detail-fields-table tr:hover td { background: var(--bg-elevated); }

.detail-fields-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.detail-fields-table .field-label {
  color: var(--text-muted);
  width: 118px;
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-fields-table .field-value {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
  word-break: break-all;
}

/* Flags */
.detail-flags-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.detail-flag-item {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 8px 10px;
  border-left: 3px solid var(--border-default);
}

.detail-flag-item.sev-critical { border-left-color: var(--sev-critical); background: var(--sev-critical-bg); }
.detail-flag-item.sev-warning  { border-left-color: var(--sev-warning);  background: var(--sev-warning-bg); }
.detail-flag-item.sev-notice   { border-left-color: var(--sev-notice);   background: var(--sev-notice-bg); }
.detail-flag-item.sev-data-gap { border-left-color: var(--sev-data-gap); background: var(--sev-gap-bg); }

.detail-flag-type   { margin-bottom: 4px; }
.detail-flag-desc   { font-size: 11.5px; color: var(--text-secondary); line-height: 1.5; }
.detail-flag-evidence {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  word-break: break-all;
}

/* Context records (prev / next) */
.detail-context {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-context-record {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 7px 10px;
  cursor: pointer;
  transition: all var(--t-fast);
  min-width: 0;
}

.detail-context-record:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.detail-context-record--empty {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.detail-context-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 3px;
}

.detail-context-ts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-context-badges {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.detail-context-badges .badge {
  font-size: 9px;
  padding: 1px 4px;
}

/* Raw line */
.detail-raw-line {
  display: block;
  white-space: pre-wrap;
  word-break: break-all;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.55;
  max-height: 200px;
  overflow-y: auto;
}

.detail-copy-btn {
  margin-top: 6px;
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-ui);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
}

.detail-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ═══════════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════════ */
.app-footer {
  flex-shrink: 0;
  height: 34px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 11px;
  color: var(--text-muted);
  gap: 16px;
}

.footer-privacy-opt {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.footer-privacy-opt input[type='checkbox'] {
  accent-color: var(--accent);
  cursor: pointer;
}

.footer-privacy-info {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-disabled);
  font-size: 10.5px;
  white-space: nowrap;
}

.footer-privacy-info svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   THRESHOLD EDITOR (Tab: Einstellungen)
   ═══════════════════════════════════════════════════════════════ */
.thresh-editor {
  padding: 20px 24px 32px;
  max-width: 760px;
}

.thresh-editor-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.thresh-editor-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.thresh-editor-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.thresh-modified-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sev-warning);
  background: rgba(249,115,22,.1);
  border: 1px solid rgba(249,115,22,.25);
  border-radius: 10px;
  padding: 2px 8px;
}

.thresh-editor-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.55;
}

.thresh-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-family: var(--font-ui);
  padding: 5px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--t-fast);
}

.thresh-reset-btn:hover {
  border-color: var(--sev-warning);
  color: var(--sev-warning);
  background: rgba(249,115,22,.06);
}

/* Sections */
.thresh-section {
  margin-bottom: 28px;
}

.thresh-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.thresh-section-hint {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-disabled);
}

/* Grid of rows */
.thresh-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.thresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  background: var(--bg-surface);
  transition: background var(--t-fast);
}

.thresh-row:hover {
  background: var(--bg-elevated);
}

.thresh-label {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}

.thresh-input-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.thresh-input {
  width: 72px;
  height: 26px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 0 6px;
  text-align: right;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -moz-appearance: textfield;
}

.thresh-input::-webkit-inner-spin-button,
.thresh-input::-webkit-outer-spin-button {
  opacity: 1;
}

.thresh-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}

.thresh-unit {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 26px;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBARS
   ═══════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-elevated); }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
