/* Palette taken from the Sénalia logo itself: orange #f08b00, navy #003f7c. Light only —
   the logo's wordmark is dark navy on transparent and becomes unreadable on a dark surface. */
:root {
  color-scheme: light;
  --orange: #f08b00;
  --orange-soft: #fff4e3;
  --navy: #003f7c;
  --navy-soft: #eaf1f8;
  --ink: #16202c;
  --muted: #6b7785;
  --line: #e1e7ef;
  --bg: #f5f7fa;
  --panel: #fff;
  --red: #c0392b;
  --green: #1f8a52;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1 { font-size: 20px; margin: 0 0 2px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 8px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--orange); font-weight: 600; }
.error { color: var(--red); }

button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); padding: 7px 12px; color: var(--ink); }
button:hover { border-color: var(--navy); }
button.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
button.primary:hover { background: #d97d00; }
button.primary:disabled { background: var(--line); border-color: var(--line); color: var(--muted); cursor: not-allowed; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--navy); border-color: var(--line); }

input, textarea, select { font: inherit; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--ink); width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; }

/* --- login ------------------------------------------------------------------------- */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--navy-soft); }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px; width: 340px; text-align: center; box-shadow: 0 10px 30px rgba(0, 63, 124, .08); }
.login-logo { height: 120px; margin-bottom: 8px; }
.login-card form { display: grid; gap: 12px; margin-top: 18px; text-align: left; }
.login-card label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }

/* --- shell ------------------------------------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.brand img { height: 30px; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.topbar .search { flex: 1; max-width: 560px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-actions .user { font-size: 12px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 56px); }
aside { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.detail { overflow-y: auto; padding: 20px 24px 60px; }
.empty { padding: 32px; text-align: center; }

/* --- video list -------------------------------------------------------------------- */
.videos { list-style: none; margin: 0; padding: 0; }
.video { display: grid; grid-template-columns: 76px 1fr 10px; gap: 10px; align-items: center;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.video:hover { background: var(--navy-soft); }
.video.selected { background: var(--orange-soft); box-shadow: inset 3px 0 0 var(--orange); }
.thumb { width: 76px; height: 44px; object-fit: cover; border-radius: 4px; background: var(--line); }
.video-meta { min-width: 0; display: grid; gap: 1px; }
.video-meta .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.video-meta .sub, .video-meta .tags { font-size: 11px; color: var(--muted); }
.video-meta .tags { color: var(--navy); }
.hit { font-size: 11px; color: var(--muted); font-style: italic; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.hit em { color: var(--orange); font-style: normal; }

.status { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.status.never { background: var(--line); }
.status.queued { background: var(--muted); }
.status.running { background: var(--orange); animation: pulse 1.2s ease-in-out infinite; }
.status.done { background: var(--green); }
.status.gated { background: var(--orange); }
.status.failed { background: var(--red); }
@keyframes pulse { 50% { opacity: .25; } }

/* --- detail ------------------------------------------------------------------------ */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(220px, 1fr);
  gap: 20px; margin-top: 16px; }
.player-col video { width: 100%; max-height: 340px; background: #000; border-radius: var(--radius); }
.runs { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.run { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center;
  padding: 7px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.run-lines { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.run-metrics { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.run:hover { background: var(--navy-soft); }
.run.selected { background: var(--orange-soft); }
.run-id { font-family: ui-monospace, Menlo, monospace; }
.run-status { color: var(--muted); }
.badge { background: var(--orange); color: #fff; border-radius: 10px; padding: 1px 8px; font-size: 11px; }

.run-metrics-bar { display: flex; gap: 28px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding: 10px 14px; background: var(--navy-soft); border-radius: var(--radius); }
.run-metrics-bar .metric { display: flex; flex-direction: column; gap: 2px; }
.run-metrics-bar .label { font-size: 11px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .04em; }
.run-metrics-bar .value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }

.log pre, .error-block { background: #101a26; color: #d7e2ee; padding: 12px; border-radius: var(--radius);
  font-size: 12px; max-height: 260px; overflow: auto; white-space: pre-wrap; }
.error-block { background: #fdeceb; color: var(--red); }

.tabs { display: flex; gap: 4px; margin: 28px 0 16px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 8px 12px; color: var(--muted);
  border-bottom: 2px solid transparent; border-radius: 0; }
.tabs button.active { color: var(--navy); border-bottom-color: var(--orange); font-weight: 600; }

/* --- transcript -------------------------------------------------------------------- */
.gate { background: var(--navy-soft); padding: 8px 12px; border-radius: var(--radius); font-size: 13px; }
.gate.warn { background: var(--orange-soft); color: var(--ink); }
.segments { list-style: none; margin: 12px 0 0; padding: 0; }
.segment { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 8px 10px;
  border-left: 3px solid transparent; border-radius: 4px; }
.segment:nth-child(odd) { background: var(--panel); }
.segment.review { border-left-color: var(--orange); background: var(--orange-soft); }
.segment.excluded { opacity: .55; }
.segment .ts { font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding: 2px 6px;
  color: var(--navy); background: var(--navy-soft); border-color: transparent; }
.segment .text p { margin: 0; }
.segment .original { font-size: 12px; color: var(--muted); margin-top: 2px; }
.segment .tag-line { font-size: 12px; color: var(--orange); margin-top: 3px; }
.alternatives { margin: 4px 0 0 16px; padding: 0; font-size: 12px; color: var(--navy); }

/* --- procedure ----------------------------------------------------------------------- */
.procedure-title { margin-top: 12px; }
.procedure-title h2 { margin: 0 0 8px; font-size: 18px; }
.procedure-title .review-free-edit { max-width: 480px; }
.procedure-title .review-free-edit input { flex: 1; font: inherit; font-size: 13px;
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; }
.procedure-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 16px; }
.procedure-step { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  background: var(--panel); }
.procedure-step h3 { margin: 0 0 8px; font-size: 14px; }
.procedure-step p { margin: 0 0 6px; }
.procedure-image { max-width: 100%; max-height: 320px; border-radius: 4px; margin: 0 0 10px;
  display: block; }
.procedure-step .tag-line { font-size: 12px; color: var(--orange); margin-top: 3px; }
.procedure-check-field { font-size: 13px; }
.procedure-check-field strong { font-weight: 600; margin-right: 4px; }
.diagnostics-note {
  margin-top: 20px; padding: 14px 18px; border-left: 3px solid var(--orange);
  background: var(--panel); border-radius: 0 var(--radius) var(--radius) 0;
}
.diagnostics-note-intro { font-weight: 600; font-size: 13px; margin: 0 0 10px; }
.diagnostics-note .procedure-steps { margin-top: 0; }
.procedure-diagnostics .procedure-step p { white-space: pre-line; }
.procedure-step .review { margin-top: 8px; font-size: 12px; }
.procedure-step .review summary { cursor: pointer; color: var(--orange); font-weight: 600; }
.tag-edited { font-size: 11px; font-weight: 600; color: var(--green); border: 1px solid var(--green);
  border-radius: 3px; padding: 1px 5px; vertical-align: middle; }
.review-options { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.review-options form { margin: 0; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 5px 12px; font-size: 12px; color: var(--ink); cursor: pointer; text-align: left; }
.chip:hover { border-color: var(--orange); color: var(--orange); }
.review-free-edit { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; }
.review-free-edit textarea { flex: 1; font: inherit; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 4px; resize: vertical; }
.revert-form { display: inline; margin-left: 6px; }
.link-button { background: none; border: none; padding: 0; font-size: 11px; color: var(--muted);
  text-decoration: underline; cursor: pointer; }
.link-button:hover { color: var(--orange); }
.tag-saved { font-size: 11px; font-weight: 600; color: var(--green); margin-left: 6px;
  animation: fade-out 3s ease-in 1.5s forwards; }
.just-saved { animation: flash-bg 2s ease-out; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes flash-bg { from { background: var(--orange-soft); } to { background: var(--panel); } }

/* --- forms ------------------------------------------------------------------------- */
.params fieldset { border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin: 0 0 14px; background: var(--panel);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.params legend { grid-column: 1 / -1; font-size: 12px; font-weight: 600;
  color: var(--navy); text-transform: uppercase; letter-spacing: .05em; padding: 0 4px; }
.params label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.params label.wide { grid-column: 1 / -1; }
.params label.check { display: flex; align-items: center; gap: 8px; }
.params label.check input { width: auto; }
.params > p { margin-top: 0; }
.meta { margin-top: 16px; }
.meta dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 12px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

/* --- trace --------------------------------------------------------------------------- */
table.trace { width: 100%; border-collapse: collapse; font-size: 13px; }
table.trace th, table.trace td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.trace th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
table.trace tfoot td { font-weight: 600; border-top: 2px solid var(--line); border-bottom: none; }

/* --- comments ---------------------------------------------------------------------- */
.comments { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.comments li { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.comments .author { font-weight: 600; }
.comments .when { color: var(--muted); font-size: 11px; margin-left: 8px; }
.comments p { margin: 4px 0 0; white-space: pre-wrap; }
.comment-form { display: grid; gap: 8px; max-width: 620px; }
.comment-form button { justify-self: start; }
