/* OHC Communications dashboard — bright, spacious, light theme */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --ink: #16233b;
  --ink-2: #51607a;
  --ink-3: #8a96ad;
  --line: #e4e9f2;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #1a7f37;      --ok-bg: #e6f4ea;
  --warn: #9a6700;    --warn-bg: #fff8e1;
  --bad: #c62828;     --bad-bg: #fdecea;
  --off: #6b7280;     --off-bg: #eef0f3;
  --ring: #b26a00;    --ring-bg: #fff3e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22,35,59,.06), 0 4px 16px rgba(22,35,59,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
}
h1, h2 { font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 14px; }
.muted { color: var(--ink-2); } .small { font-size: .85rem; font-weight: 400; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); display: inline-block; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.conn-badge { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.conn-on  { color: var(--ok); background: var(--ok-bg); }
.conn-off { color: var(--bad); background: var(--bad-bg); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 28px 64px; display: grid; gap: 24px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.tile {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px;
}
.tile-num { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--ink-2); font-size: .85rem; margin-top: 2px; }

.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters select, .filters input {
  font: inherit; font-size: .9rem; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink);
}

.livecalls { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.call-card {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 14px 16px; display: grid; gap: 4px;
}
.call-card.ringing { border-left-color: var(--ring); }
.call-card .cc-head { display: flex; justify-content: space-between; font-size: .8rem; font-weight: 700; letter-spacing: .04em; }
.cc-state { text-transform: uppercase; }
.cc-state.answered { color: var(--ok); } .cc-state.ringing { color: var(--ring); }
.cc-timer { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.cc-num { font-size: 1.15rem; font-weight: 650; }
.cc-sub { color: var(--ink-2); font-size: .9rem; }
.empty { color: var(--ink-3); margin: 4px 0; }

.extgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.ext {
  border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: grid; gap: 6px;
}
.ext-num { font-weight: 700; font-size: 1.1rem; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; width: fit-content; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.st-available { color: var(--ok); background: var(--ok-bg); }
.st-busy      { color: var(--bad); background: var(--bad-bg); }
.st-ringing   { color: var(--ring); background: var(--ring-bg); animation: pulse 1s infinite; }
.st-offline   { color: var(--off); background: var(--off-bg); }
@keyframes pulse { 50% { opacity: .55; } }

table.calls { width: 100%; border-collapse: collapse; font-size: .92rem; margin-top: 8px; }
table.calls th { text-align: left; color: var(--ink-2); font-weight: 600; font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.calls td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.calls tr:hover td { background: #f0f4fa; cursor: pointer; }
.pill { font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.pill.answered { color: var(--ok); background: var(--ok-bg); }
.pill.missed   { color: var(--bad); background: var(--bad-bg); }
.pill.inbound  { color: var(--accent); background: #e8f0fe; }
.pill.outbound { color: #6d28d9; background: #f1eafe; }
.rec-icon { font-size: .9rem; }

.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.health .h-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.h-label { color: var(--ink-2); font-size: .82rem; }
.h-val { font-weight: 700; font-size: 1.1rem; margin-top: 2px; }
meter { width: 100%; height: 10px; }

button { font: inherit; font-weight: 600; border: 0; border-radius: 9px; padding: 9px 18px; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
button:hover { filter: brightness(1.05); }

dialog { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; max-width: 560px; width: 92vw; }
dialog::backdrop { background: rgba(22,35,59,.35); }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 4px 0 4px 14px; font-size: .9rem; }
.timeline .t-time { color: var(--ink-3); font-size: .8rem; margin-right: 8px; font-variant-numeric: tabular-nums; }
audio { width: 100%; margin-top: 12px; }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 40px; width: min(400px, 92vw); }
.login-card h1 { font-size: 1.3rem; margin: 18px 0 14px; }
.login-card label { display: grid; gap: 6px; margin-bottom: 14px; font-size: .9rem; font-weight: 600; color: var(--ink-2); }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; }
.login-card button { width: 100%; margin-top: 6px; }
.form-error { color: var(--bad); font-size: .9rem; }

@media (max-width: 640px) {
  .wrap { padding: 16px 14px 48px; }
  .panel { padding: 16px; }
  table.calls th:nth-child(6), table.calls td:nth-child(6),
  table.calls th:nth-child(7), table.calls td:nth-child(7) { display: none; }
}

/* AI summary + transcript (Stage 10) */
.ai-box { background: #f4f8ff; border: 1px solid #dbe7fb; border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.ai-label { font-weight: 700; font-size: .85rem; margin-bottom: 6px; }
.ai-box p { margin: 6px 0; }
.ai-actions { margin: 6px 0 0; padding-left: 18px; font-size: .9rem; }
details.transcript { margin-top: 12px; }
details.transcript summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
details.transcript p { font-size: .9rem; white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 10px 12px; }
button.mini { font-size: .75rem; padding: 2px 10px; margin-left: 8px; }
.pill.cat-sales      { color: #1f6feb; background: #e8f0fe; }
.pill.cat-repairs    { color: #9a6700; background: #fff8e1; }
.pill.cat-accounts   { color: #1a7f37; background: #e6f4ea; }
.pill.cat-compliance { color: #6d28d9; background: #f1eafe; }
.pill.cat-other      { color: #6b7280; background: #eef0f3; }
.cat-box { display: inline-block; background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe3c8; border-radius: 8px; padding: 4px 12px; font-size: .85rem; margin: 4px 0 2px; }

/* labelled transcript lines */
.tl-wrap { background: var(--bg); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; font-size: .9rem; }
.tl { line-height: 1.45; }
.tl-who { font-weight: 700; font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; border-radius: 5px; padding: 1px 7px; margin-right: 8px; }
.tl-caller .tl-who { color: var(--ink-2); background: #e7ebf2; }
.tl-staff .tl-who { color: var(--accent); background: #e8f0fe; }
.key-box { text-align: center; margin: 14px 0; }
.key-box code { font-size: 1.05rem; letter-spacing: 2px; background: var(--bg); padding: 8px 14px; border-radius: 8px; user-select: all; }
