:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ok: #0f8a5f;
  --warn: #b4530a;
  --danger: #b42318;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* header */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand:hover { opacity: .85; }
.brand-img { height: 30px; width: auto; max-width: 150px; display: block; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 14px; letter-spacing: -0.01em; }
.brand-txt small { font-size: 11px; color: var(--muted); }
/* Shown only when no logo file is present - matches the QA portal's monogram. */
.logo {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 6px 12px; border-radius: 7px; text-decoration: none;
  color: var(--muted); font-weight: 500;
}
.topbar nav a:hover { background: var(--bg); color: var(--ink); }
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); }
.health { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: #f0f1f3; color: var(--muted); border: 1px solid var(--line);
}
.pill.ok { background: #e7f6ef; color: var(--ok); border-color: #c9ebdb; }
.pill.warn { background: #fdf0e6; color: var(--warn); border-color: #f6ddc6; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }
.grid { display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.panel h2 { margin: 0 0 4px; font-size: 15px; }
.panel > .muted:first-of-type { margin-bottom: 12px; }

label { display: block; font-weight: 500; margin: 10px 0 4px; font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 500;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* project list */
.plist { list-style: none; margin: 0; padding: 0; }
.plist li { border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.plist a {
  display: block; padding: 9px 8px; text-decoration: none; color: var(--ink); border-radius: 7px;
}
.plist a:hover { background: var(--bg); }
.plist a.on { background: var(--accent-soft); }

.status { font-size: 11px; padding: 2px 7px; border-radius: 999px; background: #f0f1f3; color: var(--muted); }
.status.ready { background: #e7f6ef; color: var(--ok); }
.status.rendering, .status.queued { background: #fff6e0; color: var(--warn); }
.status.failed { background: #fdeceb; color: var(--danger); }
.status.partial { background: #fdf0e6; color: var(--warn); }

/* plan table - the main event */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #fafbfc; }

.emo { font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: #f0f1f3; color: var(--muted); }
.emo.disclosure { background: #eef0fb; color: #3d4bad; }
.emo.apologetic, .emo.empathetic { background: #fdf0f4; color: #a63a64; }
.emo.friendly, .emo.reassuring { background: #e7f6ef; color: var(--ok); }
.emo.questioning { background: #fff6e0; color: var(--warn); }
.emo.urgent { background: #fdeceb; color: var(--danger); }
.emo.brief { background: #f0f1f3; color: var(--muted); }

.gapbar { height: 4px; background: var(--accent); border-radius: 2px; min-width: 2px; opacity: .55; }
.brk { color: var(--accent); font-weight: 600; background: var(--accent-soft); border-radius: 4px; padding: 0 3px; }
.spoken { font-size: 12.5px; line-height: 1.65; }

.render { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.render audio { width: 100%; margin-top: 8px; }
.notice { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.notice.warn { background: #fdf0e6; color: var(--warn); border: 1px solid #f6ddc6; }
.notice.err { background: #fdeceb; color: var(--danger); border: 1px solid #f7d4d1; }
.notice.info { background: var(--accent-soft); color: #3d4bad; border: 1px solid #dfe3fb; }
.hide { display: none !important; }

/* two-column script editor */
table.lines { table-layout: fixed; }
table.lines td { vertical-align: top; padding: 7px 8px; }
table.lines tr.edited { background: #fffaf2; }
table.lines tr.edited td.orig { color: var(--muted); text-decoration: line-through; text-decoration-color: #d9b38c; }
td.orig { font-size: 12.5px; line-height: 1.55; }
.tight { padding: 5px 7px; font-size: 12.5px; }
textarea.tight { min-height: 0; resize: vertical; font-family: inherit; }
table.lines tr.edited textarea.tight { border-color: #e0a866; background: #fffdf9; }

/* ---- dashboard ---- */
.tiles {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  border-left: 3px solid var(--line);
}
.tile-v { font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.tile-l { font-weight: 500; margin-top: 2px; }
.tile-n { margin-top: 1px; }
/* status carries a word in the label too - never colour alone */
.tile.good { border-left-color: var(--ok); }
.tile.busy { border-left-color: var(--accent); }
.tile.warn { border-left-color: var(--warn); }
.tile.bad  { border-left-color: var(--danger); }

.drop {
  margin-top: 12px; padding: 26px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--bg);
  display: flex; flex-direction: column; gap: 4px;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.linkbtn {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline;
}
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 999px; margin-left: 6px;
  background: #f0f1f3; color: var(--muted); border: 1px solid var(--line);
}
.tag.warn { background: #fdf0e6; color: var(--warn); border-color: #f6ddc6; }
.tag.bad { background: #fdeceb; color: var(--danger); border-color: #f7d4d1; }
#callTable td { vertical-align: middle; }
#callTable a { color: var(--ink); text-decoration: none; }
#callTable a:hover { color: var(--accent); text-decoration: underline; }
.status.transcribing, .status.draft { background: #eef0fb; color: #3d4bad; }

/* ---- call page: a bar that says where you are ---- */
.callbar {
  position: sticky; top: 53px; z-index: 9;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 14px;
}
.callbar .row:last-child { margin-left: auto; }
.steps { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.step .dot-n {
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 600; background: #f0f1f3; color: var(--muted);
  border: 1px solid var(--line);
}
.step.done { color: var(--ink); }
.step.done .dot-n { background: #e7f6ef; color: var(--ok); border-color: #c9ebdb; }
.step.busy { color: var(--accent); font-weight: 500; }
.step.busy .dot-n { background: var(--accent-soft); color: var(--accent); border-color: #dfe3fb; }
.step.warn .dot-n { background: #fdf0e6; color: var(--warn); border-color: #f6ddc6; }
.step.off { opacity: .45; }
.step-sep { color: var(--line); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tab {
  padding: 7px 14px; border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab.on { background: var(--accent-soft); color: var(--accent); border-color: #dfe3fb; }

/* the script table scrolls inside itself, so the page does not run away */
#lines { max-height: 62vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
#lines table.lines thead th {
  position: sticky; top: 0; background: var(--panel); z-index: 1;
  box-shadow: inset 0 -1px 0 var(--line);
}
.callbar .status { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- listen strip ---- */
.ab { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
@media (max-width: 800px) { .ab { grid-template-columns: 1fr; } }
.ab audio { width: 100%; margin-top: 4px; }

/* ---- compliance findings ---- */
td.sugg { font-size: 12.5px; }
.finding { border-left: 3px solid var(--line); padding: 4px 0 4px 8px; margin-bottom: 7px; }
.finding.critical { border-left-color: var(--danger); }
.finding.major { border-left-color: var(--warn); }
.finding.minor, .finding.info { border-left-color: var(--muted); }
.sev {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
  padding: 1px 6px; border-radius: 999px; background: #f0f1f3; color: var(--muted);
}
.sev.critical { background: #fdeceb; color: var(--danger); }
.sev.major { background: #fdf0e6; color: var(--warn); }
.finding q { font-style: italic; }
.approved { color: var(--ok); }

/* ---- waveform editor ---- */
.wavewrap { position: relative; cursor: crosshair; user-select: none; background: #fafbfc;
            border-bottom: 1px solid var(--line); }
.wavewrap canvas { display: block; width: 100%; }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger);
            pointer-events: none; box-shadow: 0 0 4px rgba(180,35,24,.4); }
.transport { display: flex; align-items: center; gap: 8px; padding: 10px 14px; flex-wrap: wrap; }

.linelist { max-height: 340px; overflow-y: auto; margin-top: 10px;
            border: 1px solid var(--line); border-radius: 8px; }
.lrow { display: flex; align-items: baseline; gap: 9px; padding: 6px 10px; cursor: pointer;
        border-bottom: 1px solid var(--line); }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--bg); }
.lrow.on { background: var(--accent-soft); }
.lrow .ltext { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.cust { background: #e7f6ef; color: var(--ok); border-color: #c9ebdb; }

.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 7px; }
.keys div { display: flex; align-items: center; gap: 8px; }
kbd {
  font: 11px ui-monospace, Menlo, monospace; padding: 2px 7px; border-radius: 5px;
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; min-width: 62px;
  text-align: center;
}

/* ---- job queue ---- */
.panel.queue { padding: 12px 16px; }
.qrow { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; }
.qpos {
  width: 19px; height: 19px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; background: #f0f1f3; border: 1px solid var(--line);
}
.spin {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- progress ---- */
.pb-panel { padding: 12px 16px; margin-bottom: 14px; }
.pb { height: 6px; border-radius: 999px; background: #eceef1; overflow: hidden; margin: 8px 0 5px; }
.pb.mini { height: 4px; width: 110px; margin: 0 0 0 auto; flex: none; }
.pb-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .35s ease; }
.pb-fill.idle { width: 100%; background: #d7dae0; }
/* An indeterminate bar must not look like a percentage - it sweeps instead. */
.pb-fill.indet { width: 35%; animation: sweep 1.5s ease-in-out infinite; }
@keyframes sweep {
  0% { margin-left: -35%; } 100% { margin-left: 100%; }
}

/* ---- editor toolbar ---- */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
           padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 9px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .18s ease; z-index: 50;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); }

/* ---- login ---- */
.loginpage { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.loginbox {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px; width: 340px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.loginbox label { margin-top: 12px; }
