:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2f5bd3;
  --riya: #eef2fd;
  --riya-border: #cdd8f7;
  --shopper: #eaf6ee;
  --shopper-border: #c4e6cf;
  --sys: #8a93a3;
  --ok: #1f7a3d;
  --ok-bg: #e5f4ea;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --demo: #7a2bb5;
  --demo-bg: #f3e8fd;
  --playing: #ffd666;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b2029;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --border: #2c3340;
    --accent: #8aa8ff;
    --riya: #1f2a44;
    --riya-border: #2f3f66;
    --shopper: #1c3326;
    --shopper-border: #2b4d38;
    --sys: #8a93a3;
    --ok: #6fd28f;
    --ok-bg: #173323;
    --bad: #ff8a80;
    --bad-bg: #3a1c1a;
    --warn: #ffcf66;
    --warn-bg: #3a2e12;
    --demo: #d4a6ff;
    --demo-bg: #2e1d40;
    --playing: #8a6d00;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
}
a { color: var(--accent); }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 0 0 12px; }
h2 { font-size: 1rem; margin: 0 0 8px; }
h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; text-decoration: none; color: var(--text); }
button {
  font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; cursor: pointer;
}
button.link { background: none; border: none; color: var(--accent); padding: 4px; }
.banner { margin: 0; padding: 8px 16px; background: var(--warn-bg); color: var(--warn); font-size: .9rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.empty { text-align: center; color: var(--muted); }

.login { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 10px; }
.login input { font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.error { color: var(--bad); margin: 0; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 8px; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 4px; }
.filters select, .filters input {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-width: 140px;
}
.filter-actions { display: flex; gap: 12px; align-items: center; }

/* call history table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
table.calls { border-collapse: collapse; width: 100%; font-size: .88rem; }
.calls th, .calls td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.calls th { font-size: .78rem; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface); }
.calls tbody tr.clickable { cursor: pointer; }
.calls tbody tr:hover { background: var(--bg); }
.calls td:first-child a { font-weight: 600; text-decoration: none; white-space: nowrap; }
.calls .phone { white-space: nowrap; }
a.sort { color: inherit; text-decoration: none; }
a.sort.active { color: var(--accent); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8rem; white-space: nowrap; background: var(--bg); border: 1px solid var(--border); }
.status-connected { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.status-no-answer, .status-busy, .status-interrupted, .status-in-progress { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.status-failed, .status-refused-by-pre-call-checks { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.tag { display: inline-block; padding: 1px 7px; margin: 0 4px 3px 0; border-radius: 6px; font-size: .78rem; background: var(--riya); border: 1px solid var(--riya-border); white-space: nowrap; }
.tag.quiet { background: none; color: var(--muted); border-color: var(--border); }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tag.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.tag.demo { background: var(--demo-bg); color: var(--demo); border-color: transparent; }

/* single call */
.header-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.header-title h1 { margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; margin: 8px 0 12px; }
.facts dt, .mini dt { font-size: .75rem; color: var(--muted); }
.facts dd, .mini dd { margin: 0; overflow-wrap: anywhere; }
.checks, .relaxations { margin-top: 12px; }
.check-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.check-list li { font-size: .8rem; padding: 2px 8px; border-radius: 6px; background: var(--ok-bg); color: var(--ok); }
.check-list li.bad { background: var(--bad-bg); color: var(--bad); }
.check-list li.quiet { background: var(--bg); color: var(--muted); }
.relaxations { background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px; }
.relaxations ul { margin: 4px 0; padding-left: 18px; }
.relaxations .muted { color: inherit; opacity: .8; }

.call-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; margin-top: 16px; align-items: start; }
.player { position: sticky; top: 0; z-index: 2; margin-bottom: 12px; padding: 10px 14px; }
.player audio { width: 100%; }
.player p { margin: 4px 0 0; }
.no-recording { margin: 0; color: var(--muted); font-style: italic; }

.chat { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; border: 1px solid; }
.bubble p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.riya { align-self: flex-start; background: var(--riya); border-color: var(--riya-border); border-top-left-radius: 4px; }
.bubble.shopper { align-self: flex-end; background: var(--shopper); border-color: var(--shopper-border); border-top-right-radius: 4px; }
.bubble .meta { font-size: .74rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bubble .lang { text-transform: uppercase; font-weight: 600; }
.bubble .kind { padding: 0 6px; border-radius: 5px; border: 1px solid var(--riya-border); }
.bubble.kind-fixed .kind, .kind-chip.kind-fixed { background: #dfe7fb; color: #1d3f9a; }
.bubble.kind-model .kind, .kind-chip.kind-model { background: #e9e3fb; color: #4b2a9a; }
.bubble.kind-filler .kind, .kind-chip.kind-filler { background: #f1f1f1; color: #555; }
.bubble.kind-action .kind, .kind-chip.kind-action { background: #fff0d1; color: #7a4f00; }
.bubble.kind-filler p { font-style: italic; opacity: .85; }
.kind-chip { padding: 0 6px; border-radius: 5px; font-size: .78rem; }
.timing { margin-top: 4px; font-size: .76rem; color: var(--muted); }
.timing summary { cursor: pointer; }
.sys { align-self: center; font-size: .78rem; color: var(--sys); text-align: center; max-width: 90%; }
.sys.sys-guard { color: var(--warn); }
.sys.sys-recorded, .sys.sys-identity { color: var(--ok); }
.sys.sys-decision { color: #1d3f9a; }
.sys.failed { color: var(--bad); }
.clock { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .74rem; color: var(--muted); }
.seekable { cursor: pointer; }
.playing { outline: 3px solid var(--playing); outline-offset: 2px; }
.legend { margin-top: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.summary h2 { margin-bottom: 0; }
.mini { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 0; }
.plain { padding-left: 18px; margin: 0; }
.sent { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.sent li { border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.sent .meta { font-size: .78rem; color: var(--muted); }
.sent .body { margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .88rem; }
.sent .link { overflow-wrap: anywhere; color: var(--accent); }

/* phones: the table becomes cards, the summary goes under the chat */
@media (max-width: 760px) {
  main { padding: 12px 16px; }
  .filters label { flex: 1 1 40%; min-width: 0; }
  .filters select, .filters input { min-width: 0; width: 100%; }
  .filter-actions { flex: 1 1 100%; }
  .table-wrap { background: none; border: none; overflow: visible; }
  table.calls, .calls tbody, .calls tr, .calls td { display: block; width: 100%; }
  .calls thead { display: none; }
  .calls tr { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 0; }
  .calls td { border: none; padding: 3px 12px; display: flex; flex-wrap: wrap; gap: 4px 10px; min-width: 0; overflow-wrap: anywhere; }
  .calls .tag { white-space: normal; }
  .calls td::before { content: attr(data-label); flex: 0 0 110px; color: var(--muted); font-size: .76rem; }
  .calls td[data-label=""]::before { content: none; }
  .call-layout { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
}

/* Call me */
.nav { display: flex; gap: 14px; margin-right: auto; margin-left: 18px; font-size: .9rem; }
.call-me { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
.call-me label { display: flex; flex-direction: column; gap: 4px; }
.call-me label.choice { flex-direction: row; align-items: flex-start; gap: 8px; }
.call-me fieldset { border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.call-me input[type=text], .call-me input:not([type]), .call-me input[type=tel] { padding: 8px; font-size: 1rem; }
.call-me button { padding: 10px; font-size: 1rem; }
.banner.bad { background: #fde8e8; color: #8a1c1c; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; flex-wrap: wrap; }
.steps li { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.steps li.done { background: #e3f4e8; color: #1c6b34; border-color: #b9e2c5; }
.steps li.final.ok { background: #e3f4e8; color: #1c6b34; border-color: #b9e2c5; font-weight: 600; }
.steps li.final.bad { background: #fde8e8; color: #8a1c1c; border-color: #f2c4c4; font-weight: 600; }

/* 2026-10-05: logins, allowed numbers, client view */
.topbar form .who { margin-right: 0.4rem; }
button.link.danger { color: var(--bad, #b42318); }
table.numbers { width: 100%; border-collapse: collapse; }
table.numbers th, table.numbers td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid rgba(127, 127, 127, 0.2); }
.bubble .who-said { font-weight: 600; margin-right: 0.35rem; }
