/* Centaur design system — shared tokens + components for index.html,
   dashboard.html, portal.html. Dark by default (demo + console); the portal
   opts into the light palette via <html data-theme="light">. Nothing in here
   changes behavior — it is pure presentation, layered under each page's own
   (much smaller) layout-specific <style> block. */

:root {
  --bg:#0B1416; --surface:#101C1F; --surface-2:#152528; --border:#1F3237;
  --text:#E8EDEE; --text-2:#8FA3A6;
  --accent:#12A594; --accent-hover:#0E8377; --accent-soft:rgba(18,165,148,.12);
  --ok:#22C55E; --warn:#F59E0B; --neutral:#64748B; --danger:#EF4444;
  --card-shadow: none;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg:#F7FAF9; --surface:#FFFFFF; --surface-2:#F0F5F4; --border:#E2ECEA;
  --text:#0F1F1D; --text-2:#5B6B69;
  --accent:#0F766E; --accent-hover:#115E59; --accent-soft:rgba(15,118,110,.08);
  --ok:#15803D; --warn:#B45309; --neutral:#64748B; --danger:#B91C1C;
  --card-shadow: 0 1px 2px rgba(15,31,29,.06);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: var(--font-ui);
  font-size: 13px;
}

.mono, .mono * {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- eyebrows */
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* ---------------------------------------------------------------- page titles */
.page-title-block { margin-bottom: 16px; }
.page-title, h2.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-transform: none;
  margin: 0 0 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-2);
}

/* ---------------------------------------------------------------- header */
.app-header {
  height: 56px;
  min-height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg);
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.app-header .brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.app-header h1 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .navlink {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  margin-left: auto;
}
.app-header .navlink:hover { color: var(--accent-hover); }

.status-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-pulse 2.4s ease-in-out infinite;
}
.status-dot.down { background: var(--neutral); animation: none; opacity: 1; }
@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot { animation: none; opacity: 1; }
}

/* .chip is rendered as either a plain <span> (inert, e.g. index.html's mode
   chip) or a clickable <button> (the portal's desk-filter chips) -- `height`
   is reset to auto so it stays a compact pill rather than inheriting the
   generic button {} rule's fixed 32px, same "reset the box model, keep the
   free hover/focus affordances" idiom as .metric below. */
.chip {
  display: inline-flex;
  align-items: center;
  height: auto;
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--surface);
  white-space: nowrap;
}
input.chip-input {
  font-size: 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--surface);
  flex: 0 1 260px;
  min-width: 0;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
input.chip-input:last-child { margin-left: auto; }

/* ---------------------------------------------------------------- buttons */
button {
  font-family: var(--font-ui);
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary, button.act.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover:not(:disabled), button.act.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.act { height: 32px; padding: 0 12px; }

/* ---------------------------------------------------------------- inputs & selects */
select, input {
  font-family: var(--font-ui);
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238FA3A6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
input::placeholder { color: var(--text-2); }
input.note { cursor: text; }

/* consistent, visible keyboard focus everywhere */
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* ---------------------------------------------------------------- pills */
.pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill.qualified, .pill.booked {
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok);
}
.pill.escalated {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
}
.pill.in_progress, .pill.claimed {
  background: var(--accent-soft);
  color: var(--accent);
}
.pill.high {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
}
.pill.urgent {
  background: var(--danger);
  color: #fff;
}
.pill.not_qualified, .pill.none, .pill.normal, .pill.open, .pill.upheld, .pill.withdrawn,
.pill.active {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}
/* A dispute in "open" status is actively under review and needs the
   client's/operator's attention — unlike an idle unclaimed queue item
   (also class "open"), which is just a neutral fact until someone acts.
   Scoped by ancestor so both meanings of the shared class name can coexist. */
.outcomerow .pill.open {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border-color: transparent;
  color: var(--warn);
}

/* ---------------------------------------------------------------- status rail */
/* Signature component: a 3px left rail on every list row / status panel,
   colored by the status pill nested inside it. Pure CSS (:has), so it reacts
   to unchanged, JS-generated markup with no script edits required. */
.row, .outcomerow { border-left: 3px solid var(--border); }
.row:has(.pill.qualified), .outcomerow:has(.pill.upheld) { border-left-color: var(--ok); }
.row:has(.pill.escalated) { border-left-color: var(--warn); }
.row:has(.pill.not_qualified) { border-left-color: var(--neutral); }
.row:has(.pill.in_progress), .row:has(.pill.claimed) { border-left-color: var(--accent); }
.row:has(.pill.urgent) { border-left-color: var(--danger); }
.outcomerow:has(.pill.open) { border-left-color: var(--warn); }
.outcomerow:has(.pill.withdrawn), .outcomerow:has(.pill.none) { border-left-color: var(--neutral); }
/* Qualification pane's signature rail is softened relative to list-row rails
   (2px + 70% opacity vs. the 3px full-saturation row rails above) -- it's a
   whole-panel accent, not a per-item marker, so it reads as ambient framing
   rather than competing with row rails and pill colors for attention. */
.side { border-left: 2px solid var(--border); }
.side:has(#status.qualified) { border-left-color: color-mix(in srgb, var(--ok) 70%, transparent); }
.side:has(#status.escalated) { border-left-color: color-mix(in srgb, var(--warn) 70%, transparent); }
.side:has(#status.not_qualified) { border-left-color: color-mix(in srgb, var(--neutral) 70%, transparent); }
.side:has(#status.in_progress) { border-left-color: color-mix(in srgb, var(--accent) 70%, transparent); }

/* ---------------------------------------------------------------- cards / stat tiles */
/* .metric is rendered as either a plain <div> (inert: escalation rate,
   engine) or a real <button> (clickable: sessions, open queue, SLA
   breached) -- these resets neutralize the generic `button {}` rule's
   height/padding/text-align/weight so both tags render identically except
   for the cursor/hover/focus affordances a <button> gets for free. */
.metric {
  height: auto;
  text-align: left;
  font-weight: normal;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-2);
  box-shadow: var(--card-shadow);
}
.metric b {
  display: block;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.metric.alert b { color: var(--danger); }

/* ---------------------------------------------------------------- queue filter pill */
.filterpill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.filterclear {
  cursor: pointer;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.filterclear:hover { color: var(--text); border-color: var(--accent); }

/* ---------------------------------------------------------------- kv / field rows */
.kv, .field {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--surface);
  font-size: 13px;
}
.kv .k, .field .k { color: var(--text-2); }
.field.captured { border-color: var(--ok); }
.field.captured .v { color: var(--ok); }

/* ---------------------------------------------------------------- rows (lists) */
.row {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.row:hover, .row.active { background: var(--surface-2); }
.row .v { font-weight: 600; font-size: 13px; }
.row .t { color: var(--text-2); font-size: 12px; }

/* ---------------------------------------------------------------- chat bubbles */
.msg {
  padding: 11px 15px;
  border-radius: 10px;
  white-space: pre-wrap;
  font-size: 15px;
  max-width: 68ch;
}
.msg .who {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 4px;
}
.msg.agent, .msg.assistant {
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.msg.caller, .msg.user {
  background: var(--accent-soft);
  color: var(--text);
  align-self: flex-end;
  border-bottom-right-radius: 2px;
  margin-left: auto;
}

/* ---------------------------------------------------------------- empty states / misc */
.muted, .text-2 { color: var(--text-2); }
.empty, .empty-state {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-2);
}
.banner403 { padding: 20px; color: var(--text-2); font-size: 13px; }
.audit { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-2); padding: 4px 0; border-bottom: 1px dashed var(--border); }
.audit b { color: var(--text); }
.audit .escb { color: var(--danger); }

/* ---------------------------------------------------------------- notices */
/* Dismissible inline banners -- replaces native alert(). One stable anchor
   (#noticebar) per page, right under the nav so it's visible regardless of
   tab. Status rail on the left carries the meaning (see DESIGN.md): warn
   (amber) for failures needing operator attention, neutral (slate) for
   informational messages, danger (red) reserved for urgent/destructive --
   never used for a routine failure. */
#noticebar { display: flex; flex-direction: column; gap: 8px; }
#noticebar:empty { display: none; }
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 20px 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--neutral);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text);
}
.notice.warn { border-left-color: var(--warn); }
.notice.danger { border-left-color: var(--danger); }
.notice-msg { flex: 1; }
.notice-close {
  background: none;
  border: none;
  height: auto;
  width: 20px;
  padding: 0;
  color: var(--text-2);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.notice-close:hover { color: var(--text); }

/* ------------------------------------------------------- field validation */
/* Empty-required-field feedback is not a dialog: danger border + a helper
   line under the field, cleared as soon as the operator types. */
input.field-invalid, select.field-invalid { border-color: var(--danger); }
.field-help {
  display: none;
  font-size: 12px;
  color: var(--danger);
  margin: 4px 0 2px;
}
.field-help.show { display: block; }

/* ------------------------------------------------------- destructive action */
/* Reserved for the confirming half of an inline confirm (e.g. "Confirm
   retire?", "Confirm close") -- danger is earned here because the action
   really is destructive/irreversible, per DESIGN.md's "urgent only" rule. */
button.danger, .act.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
button.danger:hover:not(:disabled), .act.danger:hover:not(:disabled) {
  filter: brightness(0.92);
}

h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin: 18px 0 8px;
  font-weight: 600;
}
h2:first-child { margin-top: 0; }
h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin: 14px 0 6px;
  font-weight: 600;
}

/* ---------------------------------------------------------------- responsive (down to 390px) */
@media (max-width: 780px) {
  .app-header { height: auto; padding: 10px 14px; }
  .app-header .navlink { margin-left: 0; }
  main, .convmain { flex-direction: column; }
  .chat-col { border-right: none !important; border-bottom: 1px solid var(--border); }
  .list, .detail, .side { flex: none !important; width: 100%; }
  .list { max-height: 40vh; border-right: none !important; border-bottom: 1px solid var(--border); }
  .metrics { flex-wrap: wrap; }
  .metric { flex: 1 1 45%; }
}
