/* Data Viewer — two-column layout: session list + detail */

.dv-shell {
  display: grid;
  grid-template-columns: minmax(210px, 248px) minmax(0, 1fr);
  gap: 10px;
  min-height: 560px;
  align-items: start;
}

/* ── Sessions column ─────────────────────────────────────── */

.dv-sessions-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.dv-toolbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.dv-toolbar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px;
  min-width: 0;
}

.dv-toolbar-row--search {
  grid-template-columns: minmax(0, 1fr) auto;
}

.dv-filter-driver {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.dv-clear-btn {
  padding: 0 10px;
  font-size: 11px;
  white-space: nowrap;
}

.dv-toolbar .input-ctl,
.dv-toolbar .select-ctl {
  font-size: 10px;
  padding: 4px 6px;
  min-height: 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.dv-session-count {
  font-size: 11px;
  color: var(--text-dim, #9aa0a8);
  text-align: right;
}

.dv-list-wrap {
  border: 1px solid var(--border, #2a3040);
  border-radius: 4px;
  background: var(--bg, #12151a);
  max-height: 520px;
  overflow-y: auto;
}

.dv-list-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim, #9aa0a8);
}

/* Session rows — uniform height */
.dv-session-row {
  height: 50px;
  min-height: 50px;
  max-height: 50px;
  box-sizing: border-box;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border, #2a3040);
  cursor: pointer;
  transition: background 0.1s;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}
.dv-session-row:last-child { border-bottom: none; }
.dv-session-row:hover   { background: rgba(10, 158, 142, 0.07); }
.dv-session-row.selected {
  background: rgba(10, 158, 142, 0.16);
  border-left: 3px solid var(--cyan, #0a9e8e);
  padding-left: 8px;
}

.dv-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 17px;
  flex: 0 0 17px;
  margin-bottom: 2px;
  min-width: 0;
}

.dv-row-summary {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #e4e8f0);
  line-height: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.dv-row-key {
  display: block;
  height: 14px;
  flex: 0 0 14px;
  line-height: 14px;
  font-size: 10px;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--text-dim, #6a7080);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Type badges ─────────────────────────────────────────── */

.dv-badges {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  overflow: hidden;
  max-width: 40%;
}

.dv-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid;
  white-space: nowrap;
}
.dv-badge--setup    { color: #0a9e8e; border-color: #0a9e8e; }
.dv-badge--prerace  { color: #e8952a; border-color: #e8952a; }
.dv-badge--run      { color: #7eb6ff; border-color: #7eb6ff; }
.dv-badge--ds       { color: #a87ef0; border-color: #a87ef0; }
.dv-badge--checklist { color: #e8c44a; border-color: #e8c44a; }
.dv-badge--other    { color: #9aa0a8; border-color: #9aa0a8; }

/* ── Detail column ───────────────────────────────────────── */

.dv-detail-col {
  display: flex;
  flex-direction: column;
  background: var(--panel, #1a1d24);
  border: 1px solid var(--border, #2a3040);
  border-radius: 4px;
  padding: 16px;
  gap: 14px;
  min-height: 480px;
}

/* View tabs: detail vs compare */
.dv-view-tabs {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.dv-view-tab {
  background: transparent;
  border: 1px solid var(--border, #2a3040);
  color: var(--text-dim, #9aa0a8);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.dv-view-tab--active {
  background: rgba(10, 158, 142, 0.14);
  border-color: var(--cyan, #0a9e8e);
  color: var(--text, #e4e8f0);
  font-weight: 600;
}

/* Empty state */
.dv-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  color: var(--text-dim, #9aa0a8);
  gap: 10px;
  padding: 32px 0;
}
.dv-empty-icon { font-size: 36px; }
.dv-detail-empty p { margin: 0; font-size: 13px; text-align: center; }

/* Loaded state */
.dv-detail-loaded { display: flex; flex-direction: column; gap: 14px; }

/* Header: key name + badges */
.dv-detail-header {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border, #2a3040);
}
.dv-detail-key {
  font-size: 14px;
  font-weight: 700;
  color: var(--text, #e4e8f0);
  word-break: break-all;
  flex: 1 1 auto;
}

/* Section stack — full-width tables instead of cramped card grid */
.dv-section-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dv-section-card {
  background: var(--bg, #12151a);
  border: 1px solid var(--border, #2a3040);
  border-radius: 4px;
  padding: 0;
  overflow: hidden;
}

.dv-card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan, #0a9e8e);
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border, #2a3040);
  margin: 0;
}

.dv-card-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dv-card-table th,
.dv-card-table td {
  padding: 7px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border, #2a3040);
}
.dv-card-table tr:last-child th,
.dv-card-table tr:last-child td {
  border-bottom: none;
}
.dv-card-table th {
  color: var(--text-dim, #9aa0a8);
  font-weight: 500;
  white-space: nowrap;
  width: 34%;
  background: rgba(0, 0, 0, 0.15);
}
.dv-card-table td {
  color: var(--text, #e4e8f0);
  font-weight: 500;
  word-break: break-word;
}

/* Compare panel */
.dv-compare-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
}

.dv-compare-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim, #9aa0a8);
}

.dv-compare-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 160px auto;
  gap: 8px;
  align-items: end;
}

.dv-compare-pick {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim, #9aa0a8);
}

.dv-compare-summary {
  font-size: 12px;
  color: var(--text-dim, #9aa0a8);
}

.dv-compare-table-wrap {
  border: 1px solid var(--border, #2a3040);
  border-radius: 4px;
  overflow: auto;
  max-height: 520px;
  background: var(--bg, #12151a);
}

.dv-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dv-compare-table th,
.dv-compare-table td {
  padding: 7px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border, #2a3040);
  vertical-align: top;
}

.dv-compare-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel, #1a1d24);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim, #9aa0a8);
  z-index: 1;
}

.dv-compare-table tbody th[scope="row"] {
  color: var(--text-dim, #9aa0a8);
  font-weight: 500;
  width: 28%;
  background: rgba(0, 0, 0, 0.12);
}

.dv-compare-table tbody td {
  color: var(--text, #e4e8f0);
  width: 36%;
  word-break: break-word;
}

.dv-compare-table tr.dv-compare-changed td {
  background: rgba(232, 149, 42, 0.10);
}

.dv-compare-table tr.dv-compare-changed th[scope="row"] {
  color: var(--warning, #ffb300);
}

.dv-compare-empty {
  text-align: center;
  color: var(--text-dim, #9aa0a8);
  padding: 24px;
}

/* Legacy alias kept for mobile rules */
.dv-section-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dv-no-data {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim, #9aa0a8);
  grid-column: 1 / -1;
}

/* Stints table */
.dv-stints-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dv-section-card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan, #0a9e8e);
}
.dv-stints-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--bg, #12151a);
  border: 1px solid var(--border, #2a3040);
  border-radius: 4px;
}
.dv-stints-table th,
.dv-stints-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border, #2a3040);
}
.dv-stints-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim, #9aa0a8);
  background: var(--panel, #1a1d24);
}
.dv-stints-table td { color: var(--text, #e4e8f0); }
.dv-stints-table tbody tr:last-child td { border-bottom: none; }
.dv-stints-table tbody tr:hover { background: rgba(10, 158, 142, 0.06); }

/* Checklist detail in Data tab */
.dv-checklist-card .dv-checklist-meta {
  margin-bottom: 12px;
}

.dv-chk-steps-wrap {
  margin-top: 4px;
}

.dv-chk-steps-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim, #9aa0a8);
  margin-bottom: 8px;
}

.dv-checklist-steps {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.dv-checklist-steps th,
.dv-checklist-steps td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border, #2a3040);
  vertical-align: top;
}

.dv-checklist-steps th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, #9aa0a8);
  background: var(--panel, #1a1d24);
}

.dv-chk-status {
  width: 72px;
  font-weight: 700;
  white-space: nowrap;
}

.dv-chk-status--done { color: var(--cyan, #0a9e8e); }
.dv-chk-status--miss { color: #e07070; }

.dv-chk-flags {
  width: 56px;
  color: var(--text-dim, #9aa0a8);
  white-space: nowrap;
}

.dv-chk-text {
  color: var(--text, #e4e8f0);
  line-height: 1.4;
}

.dv-chk-group {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cyan, #0a9e8e);
  margin-bottom: 2px;
}

.dv-chk-row--miss td {
  background: rgba(224, 112, 112, 0.06);
}

.dv-chk-row--done td {
  background: rgba(10, 158, 142, 0.04);
}

/* Actions bar */
.dv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border, #2a3040);
  flex: 0 0 auto;
}

button.dv-danger {
  background: transparent;
  border: 1px solid #d03030;
  color: #d03030;
  border-radius: 3px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
button.dv-danger:hover { background: rgba(208, 48, 48, 0.12); }

/* Raw JSON editor */
.dv-raw-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--bg, #12151a);
  border: 1px solid var(--border, #2a3040);
  border-radius: 4px;
}
.dv-raw-sections { display: flex; flex-direction: column; gap: 8px; }
.dv-preview-section { display: flex; flex-direction: column; gap: 4px; }
.dv-preview-section label {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan, #0a9e8e);
}
.dv-preview-section textarea {
  height: 110px;
  resize: vertical;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10px;
  line-height: 1.4;
}
.dv-raw-actions { display: flex; gap: 8px; }

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .dv-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .dv-sessions-col { position: static; }
  .dv-list-wrap    { max-height: 260px; }
  .dv-compare-controls {
    grid-template-columns: 1fr 1fr;
  }
  .dv-compare-controls button { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .dv-compare-controls { grid-template-columns: 1fr; }
}
