/* ══════════════════════════════════════════════════════════════════════
   FORTCALL — California Pizza order desk.

   The palette is California Pizza's own, lifted from its storefront theme
   record: red #ED1C24, the deeper red #CC2E2E, the menu green #478A2B, the
   price green #278B36, the savings yellow #FFD400, and the #F5F5F5 canvas the
   site sets its menu on.

   All three of those hues at full strength would look like a traffic light, so
   the console rations them. Red appears in exactly three places: the wordmark,
   a live call, and the gate failing. Green appears in two: a price, and a
   clearance passing. Yellow appears in one: a warning worth reading. Everything
   else is ink, paper and hairlines — so when the rail turns red it is the only
   red on the screen and it is impossible to miss.
   ══════════════════════════════════════════════════════════════════════ */

:root {
  --red: #ED1C24;
  --red-deep: #CC2E2E;
  --red-wash: #FFF1F1;
  --green: #278B36;
  --green-deep: #218C34;
  --green-menu: #478A2B;
  --green-wash: #EEF6EC;
  --yellow: #FFD400;
  --yellow-wash: #FFF9DE;

  --ink: #171210;
  --ink-2: #453D39;
  --muted: #77706C;
  --paper: #F5F5F5;
  --card: #FFFFFF;
  /* The canvas is the brand's own #F5F5F5 pulled a couple of points warm, so
     the whole console sits in the same light as the menu it is selling from. */
  --canvas: #F2EFED;
  --hairline: #E4E1DE;
  --hairline-2: #D6D2CE;

  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(23,18,16,.05), 0 1px 3px rgba(23,18,16,.04);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/* Must beat every display rule below it — the hidden attribute is how whole
   views and panels are switched off. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ─────────── wordmark ─────────── */

.wordmark {
  font-weight: 800;
  letter-spacing: .14em;
  font-size: 13px;
  color: var(--ink);
  text-transform: uppercase;
}
.wordmark span { color: var(--red); }
.wordmark--lg { font-size: 22px; letter-spacing: .18em; display: block; }

/* ─────────── login ─────────── */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(90% 60% at 50% 0%, #FFF5F5 0%, transparent 70%),
    var(--canvas);
}
.login__card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  text-align: left;
}
.login__sub {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.login__err {
  margin: 12px 0 0;
  color: var(--red-deep);
  font-size: 13px;
}

/* ─────────── shell ─────────── */

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

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: var(--card);
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.topbar__client {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  border: 0;
  background: transparent;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
}
.tab:hover { background: var(--paper); color: var(--ink); }
.tab.is-active { background: var(--ink); color: #fff; }

.view { display: none; flex: 1; min-height: 0; }
.view.is-active { display: block; }

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 22rem) minmax(0, 1fr) minmax(280px, 24rem);
  gap: 14px;
  padding: 14px;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.col--live { position: sticky; top: 62px; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ─────────── panels ─────────── */

.panel {
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel__h {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel__h .count { color: var(--hairline-2); font-weight: 600; }
.panel__h .btn { margin-left: auto; }
.panel--gate { border-left: 3px solid var(--red); }
.panel--basis { background: var(--yellow-wash); border-color: #EFDFA4; }

.muted { color: var(--muted); }
.hint { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.basis {
  margin: -4px 0 12px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  border-left: 2px solid var(--hairline-2);
  padding-left: 9px;
}

/* ─────────── form ─────────── */

.field { display: block; margin-bottom: 12px; }
.field__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea, .searchbar input, .whisper input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm);
  background: var(--card);
  font-size: 13.5px;
}
.field textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

.btn {
  border: 1px solid var(--hairline-2);
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover:not(:disabled) { background: var(--paper); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 11px; font-size: 12px; }
.btn--ghost { background: transparent; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover:not(:disabled) { background: #000; }
/* Red is spent here deliberately: ending a live call is destructive. */
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--red-deep); }

.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }
.searchbar input { flex: 1; }

/* ─────────── the book ─────────── */

.book { display: flex; flex-direction: column; gap: 6px; max-height: 380px; overflow-y: auto; }
.cust {
  text-align: left;
  width: 100%;
  border: 1px solid var(--hairline);
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.cust:hover { background: var(--paper); }
.cust.is-sel { border-color: var(--ink); background: var(--paper); }
.cust__top { display: flex; align-items: baseline; gap: 8px; }
.cust__name { font-weight: 650; font-size: 13.5px; }
.cust__city { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.cust__meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cust__flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* ─────────── tags ─────────── */

.tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-2);
  border: 1px solid var(--hairline);
}
.tag--stop { background: var(--red-wash); color: var(--red-deep); border-color: #F5C9C9; }
.tag--warn { background: var(--yellow-wash); color: #7A5C00; border-color: #EFDFA4; }
.tag--good { background: var(--green-wash); color: var(--green-deep); border-color: #CBE3C4; }

/* ─────────── live panel ─────────── */

.panel--live { display: flex; flex-direction: column; gap: 14px; }
.live__head { display: flex; align-items: flex-start; gap: 14px; }
.live__state {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
/* A call in progress is the one thing on this screen allowed to pulse. */
.live__state.is-live { color: var(--red); }
.live__state.is-live::before {
  content: "";
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 7px;
  vertical-align: middle;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.live__who { font-size: 15px; font-weight: 650; margin-top: 3px; }
.live__meters { margin-left: auto; text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.timer { font-family: var(--mono); font-size: 17px; font-variant-numeric: tabular-nums; }
.level { width: 84px; height: 4px; background: var(--hairline); border-radius: 3px; overflow: hidden; }
.level i { display: block; height: 100%; width: 0; background: var(--green-menu); transition: width .08s linear; }

/* ─────────── THE RAIL — the signature element ───────────
   Four stages. They fill in California Pizza's own green as the desk earns
   them, and the fourth one — the right to sell — cannot light until the third
   does. When screening fails, stage three turns the brand's red and stage four
   locks with a strike through it: the brand's own colour becomes, literally,
   the thing you cannot have until the basket clears. */

.rail {
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 12px;
  background: var(--paper);
}
.rail__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 11px;
}
.rail__verdict { margin-left: auto; letter-spacing: .04em; }
.rail.is-passed { border-color: #CBE3C4; background: var(--green-wash); }
.rail.is-passed .rail__verdict { color: var(--green-deep); }
.rail.is-failed { border-color: var(--red); background: var(--red-wash); }
.rail.is-failed .rail__verdict { color: var(--red); }

.rail__stages { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; }
.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-2);
  background: var(--card);
  font-size: 11.5px;
  color: var(--muted);
  transition: background .18s, border-color .18s, color .18s;
}
.stage b {
  flex: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--hairline);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.stage span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage.is-done {
  border-color: var(--green-menu);
  background: var(--green-wash);
  color: var(--green-deep);
  font-weight: 650;
}
.stage.is-done b { background: var(--green-menu); color: #fff; }
.stage.is-active { border-color: var(--ink); color: var(--ink); font-weight: 650; }
.stage.is-active b { background: var(--ink); color: #fff; }
.stage.is-failed {
  border-color: var(--red);
  background: #fff;
  color: var(--red);
  font-weight: 700;
}
.stage.is-failed b { background: var(--red); color: #fff; }
/* The locked stage is the whole point: the sale is visibly out of reach. */
.stage.is-locked { opacity: .55; border-style: dashed; }
.stage.is-locked span { text-decoration: line-through; }

.rail__note { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.rail.is-failed .rail__note { color: var(--red-deep); font-weight: 600; }

/* ─────────── transcript ─────────── */

.transcript {
  flex: 1;
  min-height: 260px;
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--r);
  padding: 12px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.transcript__empty { margin: auto; font-size: 13px; }
.line { display: flex; flex-direction: column; gap: 2px; max-width: 88%; }
.line--agent { align-self: flex-start; }
.line--caller { align-self: flex-end; align-items: flex-end; }
.line__who {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}
.line__text {
  padding: 8px 11px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  line-height: 1.5;
  background: var(--paper);
  border: 1px solid var(--hairline);
}
.line--caller .line__text { background: var(--ink); color: #fff; border-color: var(--ink); }
.line--sys { align-self: center; max-width: 100%; }
.line--sys .line__text {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 2px 0;
}
.line--block .line__text {
  background: var(--red-wash);
  border-color: #F5C9C9;
  color: var(--red-deep);
  font-weight: 600;
}

.whisper { display: flex; gap: 8px; }
.whisper input { flex: 1; }

/* ─────────── tools ─────────── */

.tools { display: flex; flex-direction: column; gap: 5px; max-height: 320px; overflow-y: auto; }
.tool {
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 7px 9px;
  font-size: 12px;
  background: var(--card);
}
.tool__name { font-family: var(--mono); font-size: 11.5px; font-weight: 600; }
.tool__detail { color: var(--muted); margin-top: 2px; font-size: 11.5px; line-height: 1.45; }
.tool.is-run { border-style: dashed; color: var(--muted); }
.tool.is-ok { border-left: 2px solid var(--green-menu); }
.tool.is-block { border-left: 2px solid var(--red); background: var(--red-wash); }
.tool.is-fail { border-left: 2px solid var(--yellow); background: var(--yellow-wash); }

/* ─────────── stats / kpi ─────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.stat {
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  background: var(--card);
}
.stat__k {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat__v { font-family: var(--mono); font-size: 17px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat--good .stat__v { color: var(--green); }
.stat--bad .stat__v { color: var(--red); }

.kv { display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--hairline); font-size: 12.5px; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--muted); flex: none; min-width: 116px; }
.kv__v { min-width: 0; word-break: break-word; }

.score { margin-top: 12px; }
.bar { height: 5px; background: var(--hairline); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--green-menu); }
.bar.is-low i { background: var(--red); }

/* ─────────── lists, cards, chips, tables ─────────── */

.calltypes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.calltypes li { border-left: 2px solid var(--green-menu); padding-left: 9px; }
.calltypes b { display: block; font-size: 13px; }
.calltypes span { font-size: 11.5px; color: var(--muted); line-height: 1.45; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.cardlet { border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 11px; }
.cardlet h4 { margin: 0 0 4px; font-size: 13.5px; }
.cardlet p { margin: 0 0 6px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11.5px;
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 3px 10px;
  background: var(--paper);
}
.chip code { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

.chunks { display: flex; flex-direction: column; gap: 8px; max-height: 620px; overflow-y: auto; }
.chunk { border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 10px 11px; }
.chunk h4 { margin: 0 0 3px; font-size: 13px; }
.chunk p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.chunk__meta { margin-top: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); }

.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td { text-align: left; padding: 6px 9px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.table th {
  font-size: 10px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--card);
}
.table td.num { font-family: var(--mono); text-align: right; }
/* Prices are set in California Pizza's own price green. */
.table td.price { font-family: var(--mono); text-align: right; color: var(--green); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }

.finding {
  display: flex;
  gap: 9px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 12.5px;
}
.finding:last-child { border-bottom: 0; }
.finding__state {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 84px;
  text-align: center;
}
.finding__state[data-s="cleared"] { background: var(--green-wash); color: var(--green-deep); }
.finding__state[data-s="contains"] { background: var(--red-wash); color: var(--red-deep); }
.finding__state[data-s="unverified"] { background: var(--yellow-wash); color: #7A5C00; }

/* ─────────── responsive ─────────── */

@media (max-width: 1180px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .col--live { grid-column: 1 / -1; order: -1; position: static; }
}
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); padding: 10px; gap: 10px; }
  .wrap { padding: 10px; gap: 10px; }
  .topbar { gap: 10px; padding: 9px 12px; }
  .topbar__client { display: none; }
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .rail__stages { flex-wrap: wrap; }
  .stage { flex: 1 1 44%; }
  .row2 { grid-template-columns: 1fr; }
  .line { max-width: 96%; }
  .kv { flex-direction: column; gap: 1px; }
  .kv__k { min-width: 0; }
}
