:root {
  --navy-deep: #05070d;
  --navy: #0b0f1a;
  --navy-panel: #10182b;
  --navy-border: #232f4d;
  --gold: #d4af6a;
  --gold-bright: #f0c987;
  --white: #f4f2ec;
  --grey: #9aa3b8;
  --red: #e05a5a;
  --green: #4fd67a;
  --amber: #f0b429;
  --font-size-base: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--navy-deep);
  color: var(--white);
  font-family: "Segoe UI", "Georgia", serif;
  font-size: var(--font-size-base);
  overflow: hidden;
}

body.compact { --font-size-base: 15px; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- Header ---------- */
.header {
  background: linear-gradient(180deg, var(--navy-panel), var(--navy));
  border-bottom: 2px solid var(--gold);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-title {
  font-size: 1.5em;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gold-bright);
  margin: 0;
}
.brand-sub {
  margin: 2px 0 0;
  color: var(--grey);
  font-size: 0.75em;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--navy-border);
  background: var(--navy);
  font-size: 0.7em;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--grey); }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.warn { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dot.pulse { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.mode-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-size: 0.7em;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
}

.header-right { display: flex; gap: 10px; align-items: center; }

/* ---------- Main grid ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 24px;
  gap: 14px;
  overflow: hidden;
}

.speaker-row {
  display: flex;
  gap: 14px;
}
.card {
  background: var(--navy-panel);
  border: 1px solid var(--navy-border);
  border-radius: 10px;
  padding: 14px 18px;
}
.label {
  color: var(--gold);
  font-size: 0.65em;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 6px;
  font-weight: 600;
}
.current-speaker { flex: 1; padding: 8px 18px; }
.speaker-name { font-size: 1.1em; font-weight: 700; }
.last-statement { flex: 2; padding: 8px 18px; }
.last-statement p { margin: 0; font-size: 0.95em; line-height: 1.3; font-style: italic; }

.suggestion-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-color: var(--gold);
  border-width: 2px;
  position: relative;
  justify-content: center;
}
.suggestion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.suggestion-type {
  color: var(--gold-bright);
  font-size: 1.1em;
  letter-spacing: 1px;
  font-weight: 700;
  text-transform: uppercase;
}
.confidence { color: var(--grey); font-size: 0.7em; }
/* This is the single most important element on the whole dashboard - it
   must dominate the screen so it's readable at a glance on monitor 2. */
.suggestion-body {
  font-size: clamp(1.6em, 3.4vw, 3.1em);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 14px;
  color: var(--white);
  overflow-y: auto;
}
.suggestion-body.insufficient { color: var(--amber); font-style: italic; }
.followup {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--navy-border);
  color: var(--grey);
  font-size: 1em;
}
.followup .label { display: inline; margin-right: 6px; }

.badge-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.badge {
  font-size: 0.65em;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--navy);
  border: 1px solid var(--navy-border);
  color: var(--grey);
}
.badge.fact { border-color: var(--green); color: var(--green); }
.badge.assumption { border-color: var(--amber); color: var(--amber); }

/* ---------- Action buttons ---------- */
.action-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  background: var(--navy);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9em;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--gold); color: var(--navy-deep); }
.btn:active { transform: scale(0.97); }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: white; }
.btn.ghost { border-color: var(--navy-border); color: var(--grey); }
.btn.ghost:hover { background: var(--navy-border); color: var(--white); }
.btn.small { padding: 6px 12px; font-size: 0.75em; }

select, input[type=text], input[type=number], textarea {
  background: var(--navy);
  border: 1px solid var(--navy-border);
  color: var(--white);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.9em;
  font-family: inherit;
}

/* ---------- Mode selector ---------- */
.mode-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.mode-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--navy-border);
  background: var(--navy);
  color: var(--grey);
  font-size: 0.7em;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}
.mode-btn.active { border-color: var(--gold); color: var(--gold-bright); background: var(--navy-panel); }

/* ---------- Transcript panel ---------- */
.transcript-panel {
  border-top: 1px solid var(--navy-border);
  background: var(--navy-panel);
  transition: max-height 0.2s ease;
  overflow: hidden;
  max-height: 260px;
  display: flex;
  flex-direction: column;
}
.transcript-panel.collapsed { max-height: 42px; }
.transcript-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  cursor: pointer;
  border-bottom: 1px solid var(--navy-border);
}
.transcript-body {
  overflow-y: auto;
  padding: 10px 18px;
  font-size: 0.9em;
}
.t-line { margin-bottom: 10px; }
.t-meta { color: var(--gold); font-size: 0.75em; letter-spacing: 1px; }
.t-text { color: var(--white); }
.t-line.speaker-KNOX .t-meta { color: var(--green); }
.t-line.speaker-MICROPHONE .t-meta { color: var(--green); }

/* ---------- Audio meters ---------- */
.meters { display: flex; gap: 18px; }
.meter { flex: 1; }
.meter-label { font-size: 0.7em; color: var(--grey); letter-spacing: 1px; margin-bottom: 4px; }
.meter-track { height: 10px; background: var(--navy); border-radius: 5px; overflow: hidden; border: 1px solid var(--navy-border); }
.meter-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); width: 0%; transition: width 0.08s linear; }

/* ---------- Utility ---------- */
.flex-1 { flex: 1; }
.scroll { overflow-y: auto; }
.muted { color: var(--grey); }
.hidden { display: none !important; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--navy-panel);
  border: 1px solid var(--red);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85em;
  max-width: 320px;
}
.toast.warn { border-color: var(--amber); }
.toast.info { border-color: var(--navy-border); }

/* ---------- Settings / Cases pages ---------- */
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px;
  overflow-y: auto;
  height: 100vh;
}
.section {
  background: var(--navy-panel);
  border: 1px solid var(--navy-border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 20px;
}
.section h2 {
  color: var(--gold-bright);
  font-size: 1em;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 0;
}
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.form-row label { color: var(--grey); font-size: 0.9em; flex: 1; }
.form-row .control { flex: 1; }
.form-row .control select, .form-row .control input { width: 100%; }
nav.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
nav.tabs a {
  color: var(--grey);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--navy-border);
  font-size: 0.85em;
}
nav.tabs a.active { color: var(--gold-bright); border-color: var(--gold); }
.case-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--navy-border);
  border-radius: 8px;
  margin-bottom: 8px;
}
.case-list-item.active { border-color: var(--gold); }
textarea { width: 100%; min-height: 70px; resize: vertical; }

/* ---------- Case memory strip (main dashboard) ---------- */
.memory-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 18px;
  font-size: 0.85em;
}
.mem-item { color: var(--white); white-space: nowrap; }
.memory-strip .btn { margin-left: auto; }
.memory-strip .btn.ghost { margin-left: 0; }

/* ---------- Live contradiction alert banner ---------- */
.contradiction-alert {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-panel);
  border: 2px solid var(--red);
  border-radius: 10px;
  padding: 16px 20px;
  width: 520px;
  max-width: 90vw;
  z-index: 997;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
.contradiction-alert-header {
  color: var(--red);
  font-weight: 700;
  letter-spacing: 1px;
  font-size: 0.9em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.contradiction-alert-header.medium { color: var(--amber); }
.contradiction-alert-body { font-size: 1em; line-height: 1.4; margin-bottom: 12px; }
.contradiction-alert-actions { display: flex; gap: 8px; }
/* Production authentication */
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at top, #172033 0, #080b12 55%); }
.auth-card { width: min(420px, 100%); display: grid; gap: 1rem; padding: 2rem; border: 1px solid #33405a; border-radius: 14px; background: #101621; box-shadow: 0 24px 80px rgba(0,0,0,.45); }
.auth-card label { display: grid; gap: .4rem; color: #cbd5e1; }
.auth-card input { padding: .8rem; border: 1px solid #475569; border-radius: 7px; color: #f8fafc; background: #080b12; }
.auth-card button { padding: .85rem; border: 0; border-radius: 7px; font-weight: 700; cursor: pointer; }
.auth-card [role="alert"] { min-height: 1.25rem; color: #fca5a5; }
