/* ═══════════════════════════════════════════════════════════════════════════
   TRACE ANALYZER 2.0 — Modern Industrial Light Mode
   ═══════════════════════════════════════════════════════════════════════════ */

*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}

:root {
  /* ── Surface & Background ── */
  --bg: #f8fafc;
  --bg-alt: #f1f5f9;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: #cbd5e1;

  /* ── Text ── */
  --tx: #0f172a;
  --tx2: #475569;
  --tx3: #94a3b8;
  --tx4: #cbd5e1;

  /* ── Semantic States ── */
  --pass: #10b981;
  --pass-bg: #ecfdf5;
  --pass-border: #a7f3d0;
  --fail: #ef4444;
  --fail-bg: #fef2f2;
  --fail-border: #fecaca;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --ai: #8b5cf6;
  --ai-bg: #f5f3ff;
  --ai-border: #ddd6fe;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;

  /* ── Head Type Colors ── */
  --head-rh20: #3b82f6;
  --head-rh08: #10b981;
  --head-rh02: #f59e0b;
  --head-rh28: #8b5cf6;

  /* ── Layout ── */
  --sb-w: 64px;
  --pn-w: 280px;

  /* ── Typography ── */
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* ── Radius ── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-xl: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
}

html, body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--tx);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
}

/* ═══ LAYOUT ═══ */
.app { display: flex; min-height: 100vh; }

/* ═══ SIDEBAR ═══ */
.sidebar {
  width: var(--sb-w);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center;
  padding: 20px 0 20px;
  gap: 4px;
  z-index: 100;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sb-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.sb-logo svg { width: 18px; height: 18px; }

.nav-i { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.ni {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all .15s ease;
  color: var(--tx3);
  position: relative;
}
.ni:hover { background: var(--bg); color: var(--tx2); }
.ni.act { background: var(--ai-bg); color: var(--ai); }
.ni.act::before {
  content: '';
  position: absolute;
  left: -12px;
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--ai);
}
.ni svg { width: 20px; height: 20px; stroke-width: 1.7; }

.nav-b { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--ai);
  font-family: var(--font);
  margin-top: 8px;
}

/* ═══ MAIN ═══ */
.main { margin-left: var(--sb-w); flex: 1; display: flex; min-height: 100vh; }

/* ═══ PANEL ═══ */
.panel {
  width: var(--pn-w); flex-shrink: 0;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 20px;
  overflow-y: auto; max-height: 100vh;
  position: sticky; top: 0;
  background: var(--surface);
}

.ps h3 {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tx3);
  margin-bottom: 8px;
  padding: 0 8px;
}

.pl { list-style: none; }
.pl li {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .12s ease;
  font-size: 13px;
  color: var(--tx2);
  position: relative;
}
.pl li a {
  color: inherit; text-decoration: none;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pl li:hover { background: var(--bg); }
.pl li.active { background: var(--ai-bg); color: var(--ai); font-weight: 500; }

.badge {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--bg-alt);
  color: var(--tx3);
  font-family: var(--mono);
  white-space: nowrap; flex-shrink: 0;
  border: 1px solid var(--border-light);
}

.del-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}
.del-btn {
  opacity: 0; transition: opacity .12s;
  color: var(--fail);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-family: inherit;
}
.pl li:hover .del-btn { opacity: 1; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-p { background: var(--pass); }
.dot-f { background: var(--fail); }
.dot-n { background: var(--tx4); }

.serial-fails { font-size: 10px; font-weight: 700; color: var(--fail); font-family: var(--mono); }

.type-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  letter-spacing: .02em;
}
.type-badge.type-badge-sm {
  margin-left: 3px;
  font-size: 9px;
}
.rh20 { background: #eff6ff; color: var(--head-rh20); }
.rh08 { background: var(--pass-bg); color: var(--head-rh08); }
.rh02 { background: var(--warn-bg); color: var(--head-rh02); }
.rh28 { background: var(--ai-bg); color: var(--head-rh28); }
.unbekannt { background: var(--bg-alt); color: var(--tx3); }

/* ═══ UPLOAD ═══ */
.uz {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s ease;
}
.uz:hover, .uz.dragover {
  border-color: var(--ai);
  background: var(--ai-bg);
}
.uz h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; color: var(--tx); }
.uz p { font-size: 12px; color: var(--tx3); line-height: 1.4; }
.uz input[type=file] { display: none; }

/* ═══ CONTENT ═══ */
.content {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bg);
}

/* ═══ MESSAGES ═══ */
.msg {
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.msg::before { font-size: 14px; }
.msg.success { background: var(--pass-bg); border: 1px solid var(--pass-border); color: #065f46; }
.msg.success::before { content: '✓'; }
.msg.error { background: var(--fail-bg); border: 1px solid var(--fail-border); color: #991b1b; }
.msg.error::before { content: '✗'; }
.msg.warning { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #92400e; }
.msg.warning::before { content: '⚠'; }

/* ═══ HEADER ═══ */
.hdr { display: flex; justify-content: space-between; align-items: flex-start; }
.hdr h1 {
  font-size: 22px; font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin-bottom: 6px;
  color: var(--tx);
}
.hdr p { font-size: 13px; color: var(--tx2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hdr-sub { color: var(--tx2); }

.file-type-tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  font-family: var(--mono);
  background: var(--ai-bg);
  color: var(--ai);
  border: 1px solid var(--ai-border);
}
.serial-tag { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.run-tag { background: var(--pass-bg); color: #065f46; border-color: var(--pass-border); }

/* ═══ AI PREDICTIVE WIDGET ═══ */
.ai-widget {
  background: var(--surface);
  border: 1px solid var(--ai-border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: visible;
}
.ai-widget::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ai), #a78bfa, #c4b5fd);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  pointer-events: none;
}
.ai-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.ai-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--ai-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--ai);
  flex-shrink: 0;
}
.ai-icon svg { width: 16px; height: 16px; }
.ai-title { font-size: 13px; font-weight: 700; color: var(--ai); text-transform: uppercase; letter-spacing: .06em; }
.ai-subtitle { font-size: 11px; color: var(--tx3); }

.ai-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ai-card {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex; gap: 12px;
  transition: all .15s ease;
}
.ai-card:hover { border-color: var(--ai-border); box-shadow: var(--shadow-sm); }
.ai-card-icon {
  width: 28px; height: 28px; min-width: 28px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.ai-card-icon.critical { background: var(--fail-bg); color: var(--fail); }
.ai-card-icon.warning { background: var(--warn-bg); color: var(--warn); }
.ai-card-icon.trend { background: var(--ai-bg); color: var(--ai); }
.ai-card-title { font-size: 12px; font-weight: 600; color: var(--tx); margin-bottom: 3px; }
.ai-card-text { font-size: 11px; color: var(--tx2); line-height: 1.5; }
.ai-card-action {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600;
  color: var(--ai);
  margin-top: 6px; cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ai-card-action::after { content: '→'; }

/* ═══ KPI CARDS ═══ */
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media(max-width: 1100px) { .kpi-row { grid-template-columns: 1fr; } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
  transition: all .2s ease;
  animation: kpiIn .5s cubic-bezier(.22,1,.36,1) backwards;
}
.kpi:nth-child(1) { animation-delay: .05s; }
.kpi:nth-child(2) { animation-delay: .1s; }
.kpi:nth-child(3) { animation-delay: .15s; }
@keyframes kpiIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.kpi:hover { box-shadow: var(--shadow-lg); border-color: var(--border-focus); }

.kpi-ic {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.kpi-ic svg { width: 18px; height: 18px; stroke-width: 1.8; }
.kpi-ic.ic-records { background: #eff6ff; color: var(--info); }
.kpi-ic.ic-pass { background: var(--pass-bg); color: var(--pass); }
.kpi-ic.ic-fail { background: var(--fail-bg); color: var(--fail); }

.kpi-lb {
  font-size: 11px; color: var(--tx3);
  font-weight: 600;
  letter-spacing: .05em;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.kpi-val {
  font-family: var(--mono);
  font-size: 28px; font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-bottom: 8px;
  color: var(--tx);
}
.kpi-val.val-pass { color: var(--pass); }
.kpi-val.val-fail { color: var(--fail); }
.kpi-val.val-warn { color: var(--warn); }

.kpi-chg {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  font-family: var(--mono);
}
.kpi-chg.up { color: #065f46; background: var(--pass-bg); }
.kpi-chg.down { color: #991b1b; background: var(--fail-bg); }
.kpi-chg.neutral { color: #92400e; background: var(--warn-bg); }

.kpi-sub { font-size: 11px; color: var(--tx3); margin-top: 6px; }

.kpi-prog {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-alt);
  margin-top: 8px;
  overflow: hidden;
}
.kpi-prog .fill { height: 100%; border-radius: 2px; transition: width .8s ease; }
.kpi-prog .fill.p { background: var(--pass); }
.kpi-prog .fill.w { background: var(--warn); }
.kpi-prog .fill.f { background: var(--fail); }

/* ── Sparkline SVG inside KPI ── */
.kpi-spark {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  opacity: .08;
  pointer-events: none;
}

.kpi-sep {
  color: var(--tx4);
  font-size: 18px;
  font-weight: 400;
}

/* ═══ FILTERS ═══ */
.flt {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.flt-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}
.flt select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--tx);
  font-family: var(--font);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  outline: none; cursor: pointer;
  min-width: 180px;
  transition: border-color .15s;
}
.flt select:focus { border-color: var(--ai); box-shadow: 0 0 0 2px rgba(139,92,246,0.12); }
.flt label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--tx2); cursor: pointer;
}
.flt input[type=checkbox] { accent-color: var(--ai); width: 15px; height: 15px; }
.flt-cnt { font-size: 11px; color: var(--tx3); font-family: var(--mono); margin-left: auto; }

/* ═══ TEST RUNS ═══ */
.runs-c {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
}
.runs-hdr {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.runs-hdr h2 { font-size: 15px; font-weight: 700; color: var(--tx); }
.runs-hdr-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tog-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--tx2);
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}
.tog-btn:hover { background: var(--ai); color: #fff; border-color: var(--ai); }

.runs-sum { display: flex; gap: 10px; flex-wrap: wrap; }

.rc {
  flex: 1; min-width: 110px;
  text-align: center;
  padding: 12px 10px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--tx4);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: block;
  color: inherit;
}
.rc:hover { border-top-color: var(--ai); background: var(--ai-bg); }
.rc.rc-act {
  border-top-color: var(--ai);
  background: var(--ai-bg);
  border-color: var(--ai-border);
  box-shadow: 0 0 0 2px rgba(139,92,246,0.08);
}
.rc-reset {
  font-size: 11px; color: var(--ai); text-decoration: none;
  padding: 4px 10px; border-radius: 5px;
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  transition: all .12s; white-space: nowrap;
  font-weight: 500;
}
.rc-reset:hover { background: var(--ai); color: #fff; }
.rc-n { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ai); margin-bottom: 2px; }
.rc-d { font-family: var(--mono); font-size: 10px; color: var(--tx3); margin-bottom: 4px; }
.rc-r { font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1.2; }
.rc-ct { font-family: var(--mono); font-size: 11px; margin-top: 2px; }
.rc-rw { font-size: 10px; color: var(--tx3); margin-top: 2px; }

.runs-detail { margin-top: 14px; }
.runs-detail-scroll { max-height: 55vh; overflow: auto; }

/* ═══ RUNS COMPACT TABLE ═══ */
.rtb { border-collapse: separate; border-spacing: 0; width: 100%; }
.rtb th, .rtb td { padding: 7px 10px; text-align: left; font-size: 12px; }
.rtb thead th {
  background: var(--bg);
  font-size: 10px; font-weight: 600;
  color: var(--tx3); text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.rtb .nz-c { width: 50px; position: sticky; left: 0; z-index: 3; background: var(--surface); }
.rtb .run-c { text-align: center; border-left: 2px solid var(--ai-border) !important; min-width: 160px; }
.rcl { font-size: 11px; font-weight: 700; color: var(--ai); }
.rcd { font-family: var(--mono); font-size: 9px; color: var(--tx3); margin-top: 1px; }
.rtb .nz-cell { font-weight: 700; font-size: 13px; position: sticky; left: 0; z-index: 2; background: var(--surface); }
.rtb .rrc { border-left: 2px solid var(--ai-border) !important; padding: 5px 8px !important; }
.rrc.rok { background: var(--pass-bg); }
.rrc.rfail { background: var(--fail-bg); }
.r-ok { color: var(--pass); font-weight: 600; font-size: 12px; }
.r-fc {
  display: inline-block;
  background: var(--fail-bg); border: 1px solid var(--fail-border);
  color: var(--fail); font-weight: 700; font-size: 10px;
  padding: 2px 7px; border-radius: 4px; margin-right: 4px;
}
.r-ft { font-family: var(--mono); font-size: 9px; color: var(--tx3); }
.tr-c { width: 45px; text-align: center; }
.trc { font-size: 13px; font-weight: 700; text-align: center; }
.tr-ok { color: var(--pass); }
.tr-bad { color: var(--fail); }
.tr-worse { color: var(--fail); }
.tr-better { color: var(--pass); }
.tr-same { color: var(--tx3); }

/* ═══ DATA TABLE ═══ */
.tc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.tw { max-height: 65vh; overflow: auto; border-radius: var(--r-lg); }

.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
.dt thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  padding: 10px 14px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--tx3);
  border-bottom: 2px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.dt tbody td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--mono);
  font-size: 12px;
  white-space: nowrap;
  color: var(--tx2);
}
.dt tbody tr { transition: background .1s; }
.dt tbody tr:hover { background: var(--bg); }
.dt tbody tr:last-child td { border-bottom: none; }

.cell-pass {
  color: var(--pass); font-weight: 700;
}
.cell-fail {
  color: var(--fail); font-weight: 700;
}
.cell-skip { color: var(--tx4); }
.cell-serial { color: var(--info); font-weight: 500; }
.cell-datetime { color: var(--tx3); font-size: 11px; }
.cell-center { text-align: center; }
.error-code { color: var(--warn); font-weight: 600; }

.row-fail { background: var(--fail-bg) !important; }
.row-fail:hover { background: #fee2e2 !important; }

/* ── Pass/Fail Indicator Dots ── */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.status-dot.pass { background: var(--pass); }
.status-dot.fail { background: var(--fail); }

/* ── Inline Sparkline ── */
.sparkline-cell {
  display: inline-flex; align-items: center; gap: 6px;
}
.sparkline-cell svg {
  width: 48px; height: 16px;
  vertical-align: middle;
}

/* ═══ FlowPressResult Groups ═══ */
.gh {
  text-align: center !important;
  background: var(--ai-bg) !important;
  border-left: 2px solid var(--ai-border) !important;
  color: var(--ai) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
}
.shr th {
  font-size: 9px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--tx3) !important;
  padding: 4px 8px !important;
  text-align: center !important;
}
.sh { border-right: 1px solid var(--border-light); }

.xc-col { width: 32px; }
.xc {
  text-align: center; cursor: pointer;
  color: var(--tx3); font-size: 11px;
  user-select: none; transition: color .12s;
}
.xc:hover { color: var(--ai); }
.fp-row { cursor: pointer; }
.fp-row.expanded .xc { color: var(--ai); }

.detail-row td {
  padding: 0 !important;
  background: var(--bg) !important;
  border-bottom: 2px solid var(--border) !important;
}
.dg {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  padding: 14px 16px;
}
.dgr {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.dgt {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ai);
  padding: 6px 10px;
  background: var(--ai-bg);
  border-bottom: 1px solid var(--border);
}
.dtb { width: 100%; border-collapse: collapse; }
.dtb tr:not(:last-child) td { border-bottom: 1px solid var(--border-light); }
.dl { font-family: var(--font); font-size: 11px; color: var(--tx3); padding: 4px 8px; white-space: nowrap; }
.dv {
  font-family: var(--mono); font-size: 11px;
  padding: 4px 8px; text-align: right; font-weight: 500;
  color: var(--tx);
}
.dv.cell-pass { color: var(--pass); font-weight: 700; }
.dv.cell-fail { color: var(--fail); font-weight: 700; }

/* ═══ EMPTY STATE ═══ */
.es {
  text-align: center;
  padding: 48px 24px;
  color: var(--tx3);
}
.es-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.es-center-lg { min-height: 60vh; }
.es-center-md { min-height: 40vh; }
.es .icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.es h1, .es h3 { font-size: 18px; font-weight: 700; color: var(--tx); margin-bottom: 6px; }
.es p { font-size: 13px; color: var(--tx2); max-width: 400px; margin: 0 auto; line-height: 1.6; }

/* ═══ PANEL HELPERS ═══ */
.panel-empty { padding: 8px 10px; font-size: 12px; color: var(--tx3); }
.panel-back { font-size: 11px; color: var(--ai); text-decoration: none; font-weight: 500; }
.panel-back-wrap { padding: 0 8px 6px; }

/* ═══ UTILITY ═══ */
.text-pass { color: var(--pass); }
.text-fail { color: var(--fail); }
.text-warn { color: var(--warn); }
.text-info { color: var(--info); }
.hidden { display: none !important; }

/* ═══ MULTIMODAL TOOLBAR ═══ */
.toolbar {
  display: flex; gap: 6px; align-items: center;
}
.toolbar-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--tx3);
  cursor: pointer;
  transition: all .15s;
}
.toolbar-btn:hover { color: var(--ai); border-color: var(--ai-border); background: var(--ai-bg); }
.toolbar-btn svg { width: 16px; height: 16px; stroke-width: 1.8; }

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--tx4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--tx3); }

/* ═══ HOVER TOOLTIP ═══ */
.cell-tooltip {
  position: relative;
}
.cell-tooltip .tt {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--tx);
  color: #fff;
  font-size: 11px;
  font-family: var(--mono);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
}
.cell-tooltip .tt::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--tx);
}
.cell-tooltip:hover .tt { display: block; }

/* ═══ BORDERLINE STATUS ═══ */
.status-dot.borderline-pass {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.status-dot.borderline-fail {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
.cell-borderline-pass {
  color: #d97706;
  background: rgba(245, 158, 11, 0.06);
}
.cell-borderline-fail {
  color: #d97706;
  background: rgba(245, 158, 11, 0.1);
}
.kpi-chg.borderline {
  color: #d97706;
  background: rgba(245, 158, 11, 0.1);
}

/* ═══ MARGIN BADGES ═══ */
.margin-badge {
  display: inline-block;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}
.margin-badge.ok    { background: rgba(16, 185, 129, 0.12); color: #059669; }
.margin-badge.watch { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.margin-badge.close { background: rgba(245, 158, 11, 0.2);  color: #b45309; }
.margin-badge.over  { background: rgba(239, 68, 68, 0.15);  color: #dc2626; }

/* ═══ MARGIN INDICATOR BAR ═══ */
.margin-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.margin-bar {
  width: 48px;
  height: 5px;
  background: var(--bg3, #e5e7eb);
  border-radius: 3px;
  overflow: hidden;
}
.margin-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.2s ease;
}
.margin-fill.healthy { background: var(--pass, #10b981); }
.margin-fill.close   { background: #f59e0b; }
.margin-fill.over    { background: var(--fail, #ef4444); width: 100% !important; }
.margin-pct {
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--tx3, #9ca3af);
  white-space: nowrap;
}

/* ═══ DRIFT ANALYSIS ═══ */
.drift-section {
  background: var(--card, #fff);
  border: 0.5px solid var(--brd, rgba(0,0,0,0.08));
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}
.drift-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--brd, rgba(0,0,0,0.08));
}
.drift-header h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}
.drift-counts {
  display: flex;
  gap: 6px;
  align-items: center;
}
.drift-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
}
.drift-badge-crit  { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.drift-badge-warn  { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.drift-badge-total { background: var(--bg2, #f3f4f6); color: var(--tx3, #9ca3af); }

.drift-table-wrap { overflow-x: auto; }
.drift-table { margin: 0; }
.drift-table thead th {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tx3, #9ca3af);
  padding: 8px 12px;
}
.drift-table tbody td { padding: 8px 12px; }
.drift-row.drift-critical { background: rgba(239, 68, 68, 0.04); }
.drift-row.drift-warning  { background: rgba(245, 158, 11, 0.04); }

.drift-spark {
  width: 80px;
  height: 24px;
  display: block;
}
.drift-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
}
.drift-status-critical { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.drift-status-warning  { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.drift-status-watch    { background: var(--bg2, #f3f4f6); color: var(--tx3, #9ca3af); }

.cell-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.cell-muted { color: var(--tx4, #d1d5db); }

/* ═══ ORG PRESSURE ═══ */
.orgp-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
}
.orgp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.orgp-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--tx);
}
.orgp-count {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--tx3);
}
.orgp-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.orgp-card {
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg);
}
.orgp-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tx3);
  margin-bottom: 6px;
}
.orgp-val {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--tx);
  margin-bottom: 8px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.orgp-change {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.orgp-change.up {
  color: #065f46;
  background: var(--pass-bg);
}
.orgp-change.down {
  color: #991b1b;
  background: var(--fail-bg);
}
.orgp-spark {
  display: block;
  width: 100%;
  height: 28px;
  margin-bottom: 6px;
}
.orgp-range {
  font-size: 10px;
  font-family: var(--mono);
  color: var(--tx3);
}

/* ═══ CLEANING EFFECTIVENESS ═══ */
.clean-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.clean-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.clean-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--tx);
}
.clean-count {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--tx3);
}
.clean-table-wrap {
  overflow-x: auto;
}
.clean-table {
  margin: 0;
}
.clean-improved {
  background: rgba(16, 185, 129, 0.03);
}
.clean-worsened {
  background: rgba(239, 68, 68, 0.03);
}
.clean-change {
  display: inline-flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.clean-change.positive {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
}
.clean-change.negative {
  color: #dc2626;
  background: rgba(239, 68, 68, 0.12);
}
.clean-nozzles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.clean-nz-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  white-space: nowrap;
}
.clean-nz-tag.improved {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}
.clean-nz-tag.stayed {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}
.clean-nz-tag.worsened {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

/* ═══ CROSS-FILE CORRELATION ═══ */
.xfile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
}
.xfile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.xfile-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--tx);
}
.xfile-serial {
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 5px;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info-border);
}
.xfile-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.xfile-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  background: var(--bg);
  transition: all 0.15s ease;
}
.xfile-card:hover {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-sm);
}
.xfile-card.xfile-has-fails {
  border-left: 3px solid var(--fail);
}
.xfile-card.xfile-ok {
  border-left: 3px solid var(--pass);
}
.xfile-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.xfile-type-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--ai-bg);
  color: var(--ai);
  font-family: var(--mono);
  white-space: nowrap;
}
.xfile-file {
  font-size: 11px;
  color: var(--tx2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.xfile-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}
.xfile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.xfile-stat-val {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--tx);
  line-height: 1.2;
}
.xfile-stat-lbl {
  font-size: 10px;
  color: var(--tx3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.xfile-errors {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.xfile-error-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 11px;
}
.xfile-err-code {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--fail);
  font-size: 11px;
}
.xfile-err-dt {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--tx3);
}
.xfile-more {
  font-size: 10px;
  color: var(--tx3);
  padding-top: 4px;
}

/* ═══ RESPONSIVE ═══ */
@media(max-width: 900px) {
  .sidebar { width: 50px; }
  .main { margin-left: 50px; }
  .panel { width: 220px; padding: 14px 10px; }
  .content { padding: 16px 14px; }
}
