/* ADM Test Portal - design tokens.
   Reporting/Dashboard screens: clean corporate, aligned to MBR Insights
   Dashboard's palette for visual consistency across the tool suite.
   Operational screens (Log Execution, live session, Retest Queue) layer a
   distinct "command center" treatment via [data-mode="ops"] -- dark by
   default, monospace timing readouts, LED-style status dots -- because
   testers use those screens live in a dark MCR room, not in a review. */

:root {
  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface2: #f7f9fc;
  --border: #d1d9e6;
  --text: #1e293b;
  --muted: #6b7280;
  --faint: #94a3b8;

  --accent: #4f8ef7;
  --accent-tint: #dbeafe;
  --amber: #f59e0b;
  --amber-tint: #fef3c7;
  --cyan: #06b6d4;
  --green: #22c55e;
  --green-tint: rgba(34,197,94,.12);
  --red: #ef4444;
  --red-tint: rgba(239,68,68,.12);

  --radius: 10px;
  --shadow: 0 1px 2px rgba(30,41,59,.05), 0 6px 16px rgba(30,41,59,.06);

  --font-display: -apple-system, "Segoe UI Semibold", "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #20232f;
  --border: #2e3250;
  --text: #e8eaf6;
  --muted: #8890a8;
  --faint: #64748b;

  --accent: #4f8ef7;
  --accent-tint: rgba(79,142,247,.15);
  --amber: #f59e0b;
  --amber-tint: rgba(245,158,11,.15);
  --cyan: #06b6d4;
  --green: #22c55e;
  --green-tint: rgba(34,197,94,.15);
  --red: #ef4444;
  --red-tint: rgba(239,68,68,.15);

  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
}

/* --- Operational / command-center mode: always dark, regardless of the
   user's light/dark preference. Applied via <body data-mode="ops"> on the
   Log Execution / live session / Retest Queue pages. --- */
[data-mode="ops"] {
  --bg: #0a0c12;
  --surface: #12141c;
  --surface2: #171a24;
  --border: #262a3a;
  --text: #e8eaf6;
  --muted: #8890a8;
  --faint: #5b6478;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar (dark always, both modes) --- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #12141f;
  color: #b7c0da;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  border-right: 1px solid #22263a;
}
.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: #fff;
  padding: 0 10px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}
.sidebar .brand small { display: block; font-weight: 400; font-size: 11px; color: #6f7ba0; letter-spacing: 0.06em; margin-top: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #b7c0da; text-decoration: none; font-size: 13.5px; margin-bottom: 2px; }
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar .nav-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: #565f80; margin: 16px 10px 6px; }
.sidebar .spacer { flex: 1; }
.sidebar .user-card { border-top: 1px solid rgba(255,255,255,0.08); padding: 14px 10px 4px; font-size: 12.5px; }
.sidebar .user-card .name { color: #fff; font-weight: 600; }
.sidebar .user-card .role-badge { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 20px; background: rgba(245,158,11,.15); color: var(--amber); font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; }
.sidebar .mode-flag { margin-top: 10px; font-size: 10.5px; padding: 4px 8px; border-radius: 6px; background: rgba(239,68,68,.15); color: #f27d8f; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; display: inline-block; }

/* --- Main --- */
.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; row-gap: 10px; }
.topbar > div:first-child { flex: 1 1 260px; min-width: 200px; }
.topbar h1 { font-family: var(--font-display); font-size: 19px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.theme-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 20px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.theme-toggle:hover { border-color: var(--accent); }
.org-select { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }

.content { padding: 24px 28px 40px; }

/* --- KPI cards (Dashboard / reporting) --- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 980px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi-card .kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-label small { display: block; font-size: 10px; color: var(--faint); text-transform: none; letter-spacing: 0; margin-top: 1px; }
.kpi-card .kpi-value { font-family: var(--font-mono); font-size: 28px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-card .kpi-value.accent { color: var(--accent); }
.kpi-card .kpi-value.green { color: var(--green); }
.kpi-card .kpi-value.red { color: var(--red); }
.kpi-card .kpi-value.amber { color: var(--amber); }
.kpi-card .kpi-delta { font-size: 11px; color: var(--faint); margin-top: 4px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-header { padding: 16px 20px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: baseline; justify-content: space-between; }
.panel-header h2 { font-family: var(--font-display); font-size: 14.5px; font-weight: 700; margin: 0; }
.panel-header .hint { font-size: 11.5px; color: var(--faint); }
.panel-body { padding: 18px 20px; }

.grid-2-1 { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 980px) { .grid-2-1 { grid-template-columns: 1fr; } }

.wbr-list { display: flex; flex-direction: column; }
.wbr-item { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.wbr-item:last-child { border-bottom: none; }
.wbr-item .label { font-size: 12.5px; color: var(--muted); }
.wbr-item .label small { display: block; font-size: 10.5px; color: var(--faint); margin-top: 1px; }
.wbr-item .value { font-family: var(--font-mono); font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wbr-item .value.warn { color: var(--red); }
.wbr-item .value.ok { color: var(--green); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.badge.pass { background: var(--green-tint); color: var(--green); }
.badge.fail { background: var(--red-tint); color: var(--red); }
.badge.na { background: rgba(148,163,184,.15); color: var(--faint); }
.badge.pending { background: var(--amber-tint); color: var(--amber); border: 1px solid rgba(245,158,11,.35); font-weight: 800; }
.badge.tier-critical { background: var(--red-tint); color: var(--red); }
.badge.tier-major { background: var(--amber-tint); color: var(--amber); }
.badge.tier-wider-field { background: rgba(148,163,184,.15); color: var(--faint); }

table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--faint); border-bottom: 1px solid var(--border); padding: 8px 10px; }
table.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--surface2); }
/* short hyphenated codes like A-01 are soft-wrap points to the browser by
   default -- pin them to one line so a narrow column doesn't split them */
table.data-table td.ref-cell, table.data-table th.ref-col { white-space: nowrap; }

/* --- All Tests: selection + drag-and-drop-to-session tray --- */
table.data-table td.select-cell, table.data-table th.select-col { width: 30px; }
table.data-table tbody tr.selectable { cursor: grab; }
table.data-table tbody tr.selectable.dragging { opacity: .4; }
table.data-table tbody tr.row-selected { background: var(--accent-tint); }
table.data-table tr.group-header td { background: var(--surface2); font-weight: 700; font-size: 12px; letter-spacing: 0.02em; cursor: pointer; user-select: none; padding: 8px 10px; }
table.data-table tr.group-header:hover td { background: var(--accent-tint); }
table.data-table tr.group-header .chevron { display: inline-block; width: 14px; transition: transform .15s ease; }
table.data-table tr.group-header .group-select-cb { margin-right: 8px; vertical-align: middle; cursor: pointer; }
table.data-table tr.group-header.collapsed .chevron { transform: rotate(-90deg); }
table.data-table tr.subgroup-header td { background: var(--surface); font-weight: 600; font-size: 11.5px; color: var(--faint); cursor: pointer; user-select: none; padding: 6px 10px 6px 26px; }
table.data-table tr.subgroup-header:hover td { color: var(--text); }
table.data-table tr.subgroup-header .chevron { display: inline-block; width: 14px; transition: transform .15s ease; }
table.data-table tr.subgroup-header.collapsed .chevron { transform: rotate(-90deg); }
table.data-table tr.group-row.hidden-row { display: none; }

.session-tray {
  position: sticky; bottom: 0; margin-top: 14px;
  background: var(--surface); border: 2px dashed var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  transition: border-color .15s, background .15s;
}
.session-tray.drop-hover { border-color: var(--accent); background: var(--accent-tint); }
.session-tray .tray-label { font-size: 12.5px; font-weight: 700; color: var(--faint); }
.session-tray .tray-count { font-size: 13px; font-weight: 700; color: var(--accent); }
.session-tray .tray-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.session-tray .chip { background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px 3px 12px; font-size: 11.5px; display: flex; align-items: center; gap: 6px; }
.session-tray .chip button { border: none; background: none; color: var(--faint); cursor: pointer; font-size: 13px; line-height: 1; padding: 0; }
.session-tray .tray-empty { font-size: 12px; color: var(--faint); }
.tab-strip { display: flex; gap: 4px; margin-bottom: 14px; }
.tab-strip button { border: 1px solid var(--border); background: var(--surface); color: var(--faint); font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.tab-strip button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; padding: 12px; background: var(--surface2); border-radius: 8px; }
.inline-form input, .inline-form select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12.5px; }
.map-editor-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.map-editor-row .tc-checks { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.map-editor-row .map-editor-scenario { display: flex; flex-direction: column; gap: 2px; width: 260px; flex-shrink: 0; font-size: 12px; }
.map-editor-row .map-editor-scenario .badge { align-self: flex-start; }
.map-editor-row .map-editor-scenario .area { color: var(--faint); font-size: 11px; }
.map-editor-row .map-editor-scenario .desc { color: var(--text); line-height: 1.3; }
.map-editor-row label.tc-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; cursor: pointer; }
.map-editor-row label.tc-chip.checked { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }

.section-gap { margin-top: 18px; }

.pop-details { margin-top: 8px; padding: 10px; background: var(--surface2); border-radius: 8px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; background: var(--accent); color: #fff; }
.btn:hover { filter: brightness(0.92); }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-wrap { max-width: 420px; width: 100%; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 32px 28px; }
.login-wrap h1 { font-family: var(--font-display); font-size: 18px; margin: 0 0 4px; }
.login-wrap p { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.login-wrap select, .login-wrap button { width: 100%; padding: 10px 12px; margin-bottom: 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; background: var(--surface); color: var(--text); }
.login-logo { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 24px; }
.login-logo img { width: 44px; height: 44px; border-radius: 10px; margin-bottom: 10px; box-shadow: var(--shadow); }
.login-logo .login-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -0.01em; }
.login-logo .login-tagline { font-size: 10.5px; color: var(--faint); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 2px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.login-btn { display: block; text-align: center; text-decoration: none; padding: 11px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; transition: filter .12s, background .12s; }
.login-btn.primary { background: var(--accent); color: #fff; }
.login-btn.primary:hover { filter: brightness(0.93); }
.login-btn.secondary { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.login-btn.secondary:hover { background: var(--surface2); }
.login-hint { color: var(--faint); font-size: 11px; margin: 6px 0 0; line-height: 1.4; }

/* --- Command-center components (ops mode only) --- */
.led { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 0 3px transparent; }
.led.idle { background: var(--faint); }
.led.live { background: var(--red); box-shadow: 0 0 0 3px var(--red-tint); animation: pulse 1.4s infinite; }
.led.pass { background: var(--green); box-shadow: 0 0 0 3px var(--green-tint); }
.led.fail { background: var(--red); box-shadow: 0 0 0 3px var(--red-tint); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.ops-timer { font-family: var(--font-mono); font-size: 44px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ops-timer.armed { color: var(--faint); }
.ops-timer.running { color: var(--amber); }
.ops-timer.pass { color: var(--green); }
.ops-timer.fail { color: var(--red); }

.result-select { display: flex; gap: 8px; }
.result-btn { flex: 1; padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--muted); font-weight: 700; font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; text-align: center; }
.result-btn.pass.selected { background: var(--green-tint); color: var(--green); border-color: var(--green); }
.result-btn.fail.selected { background: var(--red-tint); color: var(--red); border-color: var(--red); }
.result-btn.na.selected { background: rgba(148,163,184,.15); color: var(--faint); border-color: var(--faint); }

/* --- Backlog #6: site-wide scrolling news ticker --- */
.ticker-bar { background: var(--surface2); border-bottom: 1px solid var(--border); overflow: hidden; white-space: nowrap; position: relative; height: 30px; display: flex; align-items: center; }
.ticker-track { display: inline-flex; gap: 48px; padding-left: 100%; animation: ticker-scroll 45s linear infinite; }
.ticker-track:hover { animation-play-state: paused; }
.ticker-item { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ticker-item.joint { color: var(--accent); font-weight: 600; }
.ticker-bar.size-small .ticker-item { font-size: 10.5px; }
.ticker-bar.size-medium .ticker-item { font-size: 12px; }
.ticker-bar.size-large .ticker-item { font-size: 14.5px; }
.ticker-bar.size-small { height: 24px; }
.ticker-bar.size-medium { height: 30px; }
.ticker-bar.size-large { height: 36px; }
@keyframes ticker-scroll { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* Brief highlight flash for a just-created/updated table row. */
tr.row-highlight { animation: row-highlight-fade 2.5s ease-out; }
@keyframes row-highlight-fade {
  0% { background: var(--green-tint); }
  100% { background: transparent; }
}
