/* =============================================================================
   sipnab Analyze Page -- Terminal TUI Style
   ============================================================================= */

:root {
  --bg: #0a0e14;
  --surface: #1f2430;
  --surface-2: #242936;
  --text: #cbccc6;
  /* Lifted from #707a8c to meet WCAG AA (>=4.5:1) on --bg and the surfaces. */
  --text-dim: #96a0b0;
  --accent: #ffcc66;
  --accent-glow: rgba(255, 204, 102, 0.12);
  --link: #73d0ff;
  --good: #bae67e;
  --warn: #ffcc66;
  --bad: #ff6666;
  --border: #2d3640;
  --border-light: #3d4754;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace;

  /* TUI status bar bg (matches native ratatui rgb(48,48,64)) */
  --status-bg: rgb(48, 48, 64);

  /* SIP method colors (matching TUI) */
  --color-invite: #5ccfe6;
  --color-provisional: #ffcc66;
  --color-success: #bae67e;
  --color-redirect: #d4bfff;
  --color-client-err: #ff6666;
  --color-server-err: #f28779;
  --color-bye: #f29e74;
  --color-ack: #95e6cb;
  --color-cancel: #ffa759;
  --color-register: #73d0ff;
  /* Lifted from #707a8c to meet WCAG AA — twin of --text-dim. */
  --color-options: #96a0b0;

  /* TUI semantic colors */
  --tui-cyan: #5fafaf;
  --tui-teal: #5ccfe6;
  --tui-coral: #d75f5f;
  --tui-blue: #5f87d7;
}

/* =============================================================================
   Everything monospace -- terminal app
   ============================================================================= */

.analyze-app,
.analyze-app * {
  font-family: var(--font-mono) !important;
}

/* =============================================================================
   Analyze App Shell
   ============================================================================= */

.analyze-app {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px); /* subtract nav height */
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

/* =============================================================================
   Drop Zone -- terminal style, polished
   ============================================================================= */

.analyze-dropzone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(60% 55% at 50% 38%, rgba(255, 204, 102, 0.05), transparent 70%),
    var(--bg);
}

.dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 520px;
  width: 100%;
}

.dropzone-kicker {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1.1rem;
}

/* The drop target box -- a real (role=button) control */
.dropzone-box {
  position: relative;
  width: 100%;
  padding: 3rem 2rem 2.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent);
  border: 1px dashed var(--border-light);
  border-radius: 14px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.dropzone-box:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(255, 204, 102, 0.05), transparent);
}

.dropzone-box:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-color: var(--accent);
}

.analyze-dropzone.drag-over .dropzone-box {
  border-color: var(--accent);
  border-style: solid;
  background: linear-gradient(180deg, rgba(255, 204, 102, 0.09), transparent);
  transform: translateY(-2px);
  box-shadow: 0 20px 50px -22px rgba(0, 0, 0, 0.75);
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 1.1rem;
  border-radius: 16px;
  color: var(--accent);
  background: rgba(255, 204, 102, 0.1);
  border: 1px solid rgba(255, 204, 102, 0.22);
  transition: transform 0.2s, background 0.2s;
}

.dropzone-icon svg {
  width: 30px;
  height: 30px;
}

.dropzone-box:hover .dropzone-icon,
.analyze-dropzone.drag-over .dropzone-icon {
  transform: translateY(-2px);
  background: rgba(255, 204, 102, 0.16);
}

.dropzone-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 0.35rem;
}

.dropzone-sub {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0 0 1.5rem;
}

.dropzone-browse {
  color: var(--accent);
  border-bottom: 1px solid rgba(255, 204, 102, 0.35);
}

.dropzone-formats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
}

.dropzone-fmt {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.18rem 0.5rem;
}

/* Size ceiling + local-processing reassurance, in the box itself. */
.dropzone-hint {
  margin: 1rem 0 0;
  font-size: 0.74rem;
  color: var(--text-dim);
}

/* Outcome preview: tells you what you get back before you drop anything. */
.dropzone-outcome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.55rem;
  margin-top: 1.4rem;
  font-size: 0.76rem;
  color: var(--text-dim);
}
.dropzone-outcome-label {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.dropzone-outcome-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.16rem 0.5rem;
  color: var(--text);
}

/* Screen-reader-only utility, scoped to the analyzer. */
.analyze-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Inline lock glyph replacing the emoji in the topbar. */
.tui-lock {
  width: 11px;
  height: 11px;
  vertical-align: -1px;
}

.dropzone-privacy {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.4rem;
  font-size: 0.78rem;
  color: var(--good);
  background: rgba(186, 230, 126, 0.06);
  border: 1px solid rgba(186, 230, 126, 0.22);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
}

.dropzone-privacy svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* One-click sample loader for first-time visitors. */
.dropzone-sample {
  display: block;
  margin: 1.2rem auto 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone-sample:hover {
  border-color: var(--accent);
  background: rgba(255, 204, 102, 0.08);
}

/* =============================================================================
   Keyboard focus -- consistent visible ring on every interactive control
   ============================================================================= */
.dropzone-sample:focus-visible,
.topbar-btn:focus-visible,
.panel-tab:focus-visible,
.export-dropdown button:focus-visible,
.help-popup-close:focus-visible,
.flow-legend summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Sortable headers are keyboard-reachable (tabindex=0); ring sits inside. */
.call-list th.sortable:focus-visible,
.call-list th.stream-sortable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Inline error card — replaces native alert() for load failures. */
.dropzone-error {
  margin: 1.2rem auto 0;
  max-width: 34rem;
  color: var(--bad);
  background: rgba(255, 102, 102, 0.07);
  border: 1px solid rgba(255, 102, 102, 0.35);
  border-radius: 10px;
  padding: 0.8rem 1.1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

/* Transient toast for errors after the workspace is up. */
.analyze-toast {
  position: fixed;
  bottom: 3.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  max-width: 36rem;
  color: var(--bad);
  background: var(--surface);
  border: 1px solid rgba(255, 102, 102, 0.45);
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* Informational variant (e.g. "compressed capture decompressed"): same
   placement as the error toast, calmer good-news colors. */
.analyze-toast--info {
  color: var(--good);
  border-color: rgba(186, 230, 126, 0.4);
}

/* Demo-mode banner: fabricated data must be unmistakable. */
.demo-banner {
  background: rgba(255, 167, 89, 0.12);
  border-bottom: 1px solid rgba(255, 167, 89, 0.4);
  color: #ffa759;
  font-size: 0.82rem;
  padding: 0.45rem 1rem;
}

/* Topbar health pills — summary before detail. */
.topbar-health { display: inline-flex; gap: 0.4rem; }
.health-pill {
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.08rem 0.55rem;
  white-space: nowrap;
}
.health-good { color: var(--good); background: rgba(186, 230, 126, 0.1); border: 1px solid rgba(186, 230, 126, 0.3); }
.health-warn { color: #ffa759; background: rgba(255, 167, 89, 0.1); border: 1px solid rgba(255, 167, 89, 0.3); }
.health-bad  { color: var(--bad); background: rgba(255, 102, 102, 0.1); border: 1px solid rgba(255, 102, 102, 0.35); }

/* Empty state for the dialog table (parallel to .stream-empty). */
.dialog-empty {
  padding: 1.6rem 1.2rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}
.dialog-empty code { color: var(--text); }

/* Collapsible ladder legend for first-time readers. */
.flow-legend {
  display: inline-block;
  margin-left: 0.9rem;
  font-weight: 400;
}
.flow-legend summary {
  cursor: pointer;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
  display: inline;
}
.flow-legend summary:hover { color: var(--accent); }
.flow-legend-body {
  position: absolute;
  z-index: 50;
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  padding: 0.75rem 0.95rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  max-width: 30rem;
  white-space: normal;
}
.flow-legend-body i { font-style: normal; font-weight: 600; }
.flow-legend-body .lg-arrow { color: var(--accent); }
.flow-legend-body .lg-good { color: var(--good); }
.flow-legend-body .lg-info { color: var(--text-dim); }
.flow-legend-body .lg-bad { color: var(--bad); }
.flow-legend-body .lg-dim { opacity: 0.55; }

/* =============================================================================
   Workspace Layout
   ============================================================================= */

.analyze-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  overflow: hidden;
  /* Room for the F-key bar at bottom */
  padding-bottom: 25px;
}

/* =============================================================================
   Top Bar -- TUI Status Lines
   ============================================================================= */

.analyze-topbar {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--status-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: auto;
  gap: 0;
}

.topbar-status-line {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: visible;
  min-height: 26px;
}

.topbar-status-line .tui-label {
  color: var(--text-dim);
}

.topbar-status-line .tui-value {
  color: var(--text);
}

.topbar-status-line .tui-accent {
  color: var(--accent);
}

.topbar-status-line .tui-sep {
  color: var(--border-light);
  margin: 0 10px;
}

.topbar-filename {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-stat {
  font-size: 12px;
  color: var(--text-dim);
}

.topbar-stat strong {
  color: var(--text);
  font-weight: 600;
}

/* Second status line: filter */
.topbar-filter-line {
  display: flex;
  align-items: center;
  padding: 5px 10px 7px;
  font-size: 12px;
  min-height: 24px;
  gap: 6px;
  background: var(--status-bg);
}

.topbar-filter-line .tui-label {
  color: var(--text-dim);
  flex-shrink: 0;
}

.topbar-filter {
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 4px 9px;
  flex: 1;
  max-width: 460px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.topbar-filter:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 204, 102, 0.12);
}

.topbar-filter::placeholder {
  color: var(--text-dim);
}

/* Actions in the status bar */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  padding: 3px 11px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.topbar-btn:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface-2);
}

.topbar-btn--clear:hover {
  color: var(--bad);
  border-color: rgba(255, 102, 102, 0.5);
  background: rgba(255, 102, 102, 0.08);
}

.topbar-btn svg {
  width: 12px;
  height: 12px;
}

.topbar-export-wrap {
  position: relative;
}

.export-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 4px;
  overflow: hidden;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7);
  z-index: 50;
  min-width: 128px;
}

.export-dropdown.open {
  display: block;
}

.export-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.export-dropdown button:hover {
  background: var(--accent-glow);
  color: var(--text);
}

/* =============================================================================
   Panels
   ============================================================================= */

.analyze-panels {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.panel-left {
  width: 45%;
  min-width: 280px;
}

.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 320px;
}

.panel-right-top {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100px;
}

.panel-right-bottom {
  height: 30%;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--border);
}

.panel-header {
  display: flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  background: var(--surface);
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-header::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 8px;
  background: var(--tui-teal);
}

#panel-raw-header::before {
  background: var(--accent);
}

/* Resize handles -- thin visible seam, wide invisible grab area */
.panel-resize {
  flex-shrink: 0;
  position: relative;
  background: var(--border);
  transition: background 0.15s;
  z-index: 10;
}

.panel-resize::after {
  content: "";
  position: absolute;
  inset: 0;
}

.panel-resize[data-direction="horizontal"] {
  width: 1px;
  cursor: col-resize;
}

.panel-resize[data-direction="horizontal"]::after {
  left: -4px;
  right: -4px;
}

.panel-resize[data-direction="vertical"] {
  height: 1px;
  cursor: row-resize;
}

.panel-resize[data-direction="vertical"]::after {
  top: -4px;
  bottom: -4px;
}

.panel-resize:hover,
.panel-resize.active {
  background: var(--accent);
}

/* =============================================================================
   Call List Table -- dense monospace like native TUI
   ============================================================================= */

.call-list-wrap {
  flex: 1;
  overflow: auto;
}

.call-list {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.call-list thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

.call-list th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: var(--surface);
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.call-list th.sortable {
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.call-list th.sortable:hover {
  color: var(--text);
  background: var(--surface-2);
}

.call-list th.sort-active {
  color: var(--accent);
}

.call-list th.sort-active::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.call-list th.sort-active.sort-asc::after {
  border-bottom: 5px solid var(--accent);
}

.call-list th.sort-active.sort-desc::after {
  border-top: 5px solid var(--accent);
}

.call-list td {
  padding: 4px 8px;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(45, 54, 64, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

/* Accent rail anchored on the first cell for the selected row */
.call-list td:first-child {
  box-shadow: inset 2px 0 0 transparent;
}

.call-list tbody tr {
  cursor: pointer;
  transition: background 0.08s;
}

.call-list tbody tr:hover {
  background: var(--surface);
}

.call-list tbody tr.selected {
  background: var(--accent-glow);
}

.call-list tbody tr.selected td {
  color: var(--text);
}

.call-list tbody tr.selected td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}

/* Method cell coloring */
.call-list .cell-method { font-weight: 600; font-size: 12px; }
.call-list .method-invite { color: var(--tui-teal); }
.call-list .method-subscribe { color: var(--tui-teal); }
.call-list .method-register { color: var(--tui-blue); }
.call-list .method-options { color: var(--color-options); }
.call-list .method-bye { color: var(--tui-coral); }
.call-list .method-cancel { color: var(--color-cancel); }
.call-list .method-ack { color: var(--text-dim); }
.call-list .method-prack { color: var(--text-dim); }

/* State cell coloring -- matching native TUI */
.call-list .state-incall,
.call-list .state-registered,
.call-list .state-completed,
.call-list .state-confirmed,
.call-list .state-active { color: var(--good); }

.call-list .state-trying,
.call-list .state-ringing,
.call-list .state-early { color: var(--warn); }

.call-list .state-failed,
.call-list .state-cancelled { color: var(--bad); }

.call-list .state-terminated { color: var(--text-dim); }

/* PDD cell */
.call-list .cell-pdd {
  font-size: 12px;
}

/* =============================================================================
   Call Flow Diagram
   ============================================================================= */

.flow-placeholder,
.raw-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 1.5rem;
  opacity: 0.8;
}

.flow-container {
  flex: 1;
  overflow: auto;
  padding: 0.25rem 0;
  background: var(--bg);
}

/* Endpoint headers */
.flow-endpoints {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 0;
  min-height: 26px;
}

.flow-endpoint {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--link);
  white-space: nowrap;
  position: relative;
}

.flow-endpoint::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 1px;
  height: 4px;
  background: var(--border);
}

/* Endpoint vertical lines (swim lanes) */
.flow-messages {
  position: relative;
  font-size: 12px;
  padding: 4px 0;
}

/* Individual message row */
.flow-msg {
  display: flex;
  align-items: center;
  padding: 2px 8px;
  cursor: pointer;
  transition: background 0.05s;
  position: relative;
  min-height: 24px;
}

.flow-msg:hover {
  background: var(--surface);
}

.flow-msg.selected {
  background: var(--accent-glow);
  box-shadow: inset 2px 0 0 var(--accent);
}

.flow-msg.retransmission {
  opacity: 0.45;
}

/* Timestamp */
.flow-time {
  flex-shrink: 0;
  width: 72px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  padding-right: 8px;
}

/* Arrow area */
.flow-arrow-area {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  min-height: 22px;
}

/* Arrow drawing */
.flow-arrow {
  position: absolute;
  display: flex;
  align-items: center;
  height: 1px;
}

.flow-arrow.request .flow-line {
  background: var(--color-invite);
}

.flow-arrow.response .flow-line {
  background: repeating-linear-gradient(
    to right,
    var(--text-dim) 0px,
    var(--text-dim) 4px,
    transparent 4px,
    transparent 8px
  );
}

.flow-line {
  flex: 1;
  height: 1px;
}

.flow-label {
  position: absolute;
  top: -13px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

/* Both directions center the label the same way. */
.flow-arrow .flow-label {
  left: 50%;
  transform: translateX(-50%);
}

/* Arrow head -- Unicode triangles.
 *
 * 14px, not the 8px this shipped with. The head was SMALLER than the 11px
 * label it belongs to, which reads as a hairline with a dot on the end rather
 * than an arrow: on a ladder the direction IS the information, and at 8px a
 * reader has to infer it from the label's position instead of seeing it. The
 * row is 22px, so there is room.
 *
 * The negative margin closes the seam between the 1px line and the glyph's own
 * side bearing, and it scales with the glyph -- at 14px a -2px pull leaves a
 * visible gap. */
.flow-head {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}

.flow-arrow.right .flow-head {
  margin-left: -4px;
}

.flow-arrow.left .flow-head {
  margin-right: -4px;
}

/* Method/status colors for labels */
.flow-label-invite { color: var(--color-invite); }
.flow-label-ack { color: var(--color-ack); }
.flow-label-bye { color: var(--color-bye); }
.flow-label-cancel { color: var(--color-cancel); }
.flow-label-register { color: var(--color-register); }
.flow-label-options { color: var(--color-options); }
.flow-label-subscribe { color: var(--color-invite); }
.flow-label-notify { color: var(--color-invite); }

.flow-label-1xx { color: var(--color-provisional); }
.flow-label-2xx { color: var(--color-success); }
.flow-label-3xx { color: var(--color-redirect); }
.flow-label-4xx { color: var(--color-client-err); }
.flow-label-5xx { color: var(--color-server-err); }
.flow-label-6xx { color: var(--color-server-err); }

/* Swim lane lines */
.flow-lane {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  pointer-events: none;
}

/* =============================================================================
   Raw Message -- terminal style
   ============================================================================= */

.raw-message {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: none;
  border-radius: 0;
}

/* Syntax highlighting for raw SIP */
.raw-message .sip-method { color: var(--color-invite); font-weight: 600; }
.raw-message .sip-uri { color: var(--accent); }
.raw-message .sip-version { color: var(--text-dim); }
.raw-message .sip-header-name { color: var(--link); }
.raw-message .sip-header-sep { color: var(--text-dim); }
.raw-message .sip-status-code { color: var(--good); font-weight: 600; }
.raw-message .sip-status-reason { color: var(--text-dim); }
.raw-message .sip-body { color: var(--text-dim); font-style: italic; }
.raw-message .sip-body-key { color: var(--color-provisional); font-style: italic; }
.raw-message .sip-request-line { font-weight: 600; }
.raw-message .sip-status-line { font-weight: 600; }

/* =============================================================================
   F-key Bar -- fixed at bottom, matches native TUI
   ============================================================================= */

/* Keyboard hints are noise on touch-only devices — hide the bar there. */
@media (hover: none) and (pointer: coarse) {
  .fkey-bar { display: none; }
  /* No f-key bar here, so drop the strip reserved for it. */
  .analyze-workspace { padding-bottom: 0; }
}

.fkey-bar {
  background: var(--status-bg);
  border-top: 1px solid var(--border);
  padding: 0 10px;
  font-size: 11px;
  color: var(--text-dim);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 14px;
  min-height: 24px;
}

.fkey-bar .fkey {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.fkey-bar .fkey b {
  display: inline-block;
  color: var(--text);
  font-weight: 600;
  font-size: 10.5px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 16px;
  margin-right: 0;
}

/* =============================================================================
   Loading overlay
   ============================================================================= */

.analyze-loading {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 14, 20, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}

.analyze-loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.analyze-loading-text {
  font-size: 12px;
  color: var(--text-dim);
}

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

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 900px) {
  .analyze-panels {
    flex-direction: column;
  }

  .panel-left {
    width: 100%;
    height: 40%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .panel-right {
    min-width: unset;
  }

  .panel-resize[data-direction="horizontal"] {
    width: 100%;
    height: 1px;
    cursor: row-resize;
  }

  .panel-resize[data-direction="horizontal"]::after {
    left: 0;
    right: 0;
    top: -4px;
    bottom: -4px;
  }

  .topbar-filter {
    max-width: 260px;
  }
}

@media (max-width: 600px) {
  .topbar-status-line {
    flex-wrap: wrap;
    gap: 2px 6px;
    min-height: auto;
  }

  .topbar-status-line .tui-sep {
    margin: 0 6px;
  }

  .topbar-actions {
    width: 100%;
    margin-left: 0;
    margin-top: 4px;
  }

  .topbar-filter-line {
    flex-wrap: wrap;
  }

  .topbar-filter {
    max-width: 100%;
  }

  .dropzone-box {
    padding: 2rem 1.25rem 1.75rem;
  }

  .dropzone-title {
    font-size: 1.02rem;
  }

  .dropzone-icon {
    width: 54px;
    height: 54px;
  }

  .dropzone-icon svg {
    width: 26px;
    height: 26px;
  }

  /* Give the (now horizontally-scrolling) list more vertical room. */
  .panel-left {
    height: 50%;
  }

  /* Drop low-priority columns so the essentials fit without h-scroll. */
  #call-list th:nth-child(5),
  #call-list th:nth-child(6),
  #call-list th:nth-child(8),
  #call-list th:nth-child(9),
  #call-list td:nth-child(5),
  #call-list td:nth-child(6),
  #call-list td:nth-child(8),
  #call-list td:nth-child(9),
  #stream-list th:nth-child(3),
  #stream-list th:nth-child(4),
  #stream-list th:nth-child(5),
  #stream-list th:nth-child(9),
  #stream-list td:nth-child(3),
  #stream-list td:nth-child(4),
  #stream-list td:nth-child(5),
  #stream-list td:nth-child(9) {
    display: none;
  }
}

/* Help popup */
.help-popup {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: helpFade 0.15s ease both;
}

.help-popup-inner {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 22px 26px;
  max-width: 540px;
  width: 100%;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 28px 70px -20px rgba(0, 0, 0, 0.85);
  animation: helpPop 0.2s cubic-bezier(0.2, 0.8, 0.3, 1.1) both;
}

.help-popup-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.help-popup-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.help-popup-close:hover { color: var(--text); background: var(--surface-2); }

.help-popup-table {
  width: 100%;
  border-collapse: collapse;
}

.help-popup-table th {
  text-align: left;
  padding: 12px 0 5px;
  color: var(--tui-cyan);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}

.help-popup-table tr:first-child th {
  padding-top: 0;
}

.help-popup-table td {
  padding: 5px 0;
  vertical-align: top;
  color: var(--text-dim);
}

.help-popup-table td:first-child {
  width: 150px;
  white-space: nowrap;
}

.help-popup-table kbd {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text);
}

.help-popup-table code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--good);
  font-size: 11px;
}

.help-popup-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  text-align: center;
}

@keyframes helpFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes helpPop {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* =============================================================================
   Panel Tabs (Dialogs / RTP Streams)
   ============================================================================= */

.panel-tabs {
  display: flex;
  background: var(--status-bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-tab {
  flex: 1;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.panel-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--accent-glow);
}

.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.tab-content.active {
  display: flex;
}

/* =============================================================================
   RTP Stream List
   ============================================================================= */

.stream-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* MOS color classes */
.mos-good { color: var(--good); }
.mos-fair { color: var(--warn); }
.mos-poor { color: var(--bad); }
/* A MOS with no published impairment value behind it. Deliberately OUTSIDE the
   three-band scale rather than a fourth colour on it: the number is not a bad
   score, it is not a score at all, and giving it a band would put "unknown"
   somewhere on a good-to-poor axis it does not belong on. Dimmed and italic,
   so a row reads as "not measured" at a glance. */
.mos-ungrounded {
  color: var(--text-dim);
  font-style: italic;
}

/* Stream sort headers reuse same pattern as dialog sort */
.stream-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}

.stream-sortable:hover {
  color: var(--text);
  background: var(--surface-2);
}

.stream-sortable.sort-active {
  color: var(--accent);
}

.stream-sortable::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 5px;
  vertical-align: middle;
}

.stream-sortable.sort-active.sort-asc::after {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 4px solid var(--accent);
}

.stream-sortable.sort-active.sort-desc::after {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid var(--accent);
}

/* =============================================================================
   Stream Detail View
   ============================================================================= */

.stream-detail {
  padding: 12px;
  overflow-y: auto;
}

.stream-detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.stream-detail-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 9px 11px;
  border-radius: 7px;
}

.stream-detail-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.stream-detail-card .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.stream-detail-intervals {
  overflow-x: auto;
}

.stream-detail-intervals table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stream-detail-intervals th {
  text-align: left;
  padding: 4px 8px;
  color: var(--text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.stream-detail-intervals td {
  padding: 3px 8px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

/* Stream burst/gap detail in bottom pane */
.stream-burst-gap {
  padding: 12px;
  font-size: 12px;
  overflow-y: auto;
}

.burst-gap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.burst-gap-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 7px 9px;
  border-radius: 7px;
}

.burst-gap-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.burst-gap-card .value {
  font-size: 13px;
  font-weight: 600;
}
