:root {
  --brand: #2563eb;
  --brand-accent: #0ea5e9;
  --brand-soft: rgba(37, 99, 235, 0.1);
  --brand-ring: rgba(37, 99, 235, 0.28);

  --bg: #f6f7f9;
  --bg-elevated: #ffffff;
  --bg-sunken: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --sidebar-bg: #0f1729;
  --sidebar-fg: #94a3b8;
  --sidebar-fg-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);

  --text: #101828;
  --text-muted: #667085;
  --text-subtle: #98a2b3;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;

  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --bad: #d92d20;
  --bad-bg: #fef3f2;
  --info: #175cd3;
  --info-bg: #eff8ff;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.1), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);

  --sidebar-w: 258px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-elevated: #131a2c;
  --bg-sunken: #090d19;
  --surface: #131a2c;
  --surface-2: #182135;
  --sidebar-bg: #080c17;
  --sidebar-fg: #7d8ba4;
  --sidebar-fg-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.05);

  --text: #e6ebf5;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --border: #232c42;
  --border-strong: #2f3a54;

  --ok: #34d399;
  --ok-bg: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 14px 28px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.011em; color: var(--text); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 12px; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(14, 165, 233, 0.1), transparent 55%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
}

/* The brand name carries the sign-in card on its own, so it is sized to read as
   a heading rather than as a label next to an icon. */
.auth-brand strong {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.25;
}

.auth-brand img { max-height: 40px; max-width: 180px; }

.auth-logo-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff; font-weight: 700; font-size: 16px;
  letter-spacing: -0.02em;
}

.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); margin-bottom: 22px; font-size: 13.5px; }
.auth-foot { margin-top: 20px; text-align: center; color: var(--text-subtle); font-size: 12.5px; }
.auth-foot a { color: var(--text-muted); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar-head {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-head img { max-height: 32px; max-width: 150px; }

.sidebar-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff; font-weight: 700; font-size: 13px;
  flex: 0 0 32px;
}

.sidebar-name {
  color: #fff; font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-nav { padding: 12px 10px 20px; flex: 1; }

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #4d5b74;
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-fg);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-item.active { background: var(--brand); color: var(--sidebar-fg-active); }
.nav-item.active .nav-ico { opacity: 1; }
.nav-ico { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.75; }
.nav-badge {
  margin-left: auto;
  background: var(--bad);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11.5px;
  color: #4d5b74;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-spacer { flex: 1; }

.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-ring);
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 500;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: grid; place-items: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.menu { position: relative; }
.menu-trigger {
  display: flex; align-items: center; gap: 9px;
  background: transparent; border: 1px solid transparent;
  padding: 5px 8px; border-radius: 9px; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 13.5px;
}
.menu-trigger:hover { background: var(--surface-2); border-color: var(--border); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff; font-weight: 600; font-size: 12px;
  flex: 0 0 32px;
}

.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  padding: 6px;
  display: none;
  z-index: 60;
}
.menu-panel.open { display: block; }
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  background: none; border: none; cursor: pointer;
  font-family: inherit; text-align: left;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-head { padding: 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head strong { display: block; font-size: 13.5px; }
.menu-head span { color: var(--text-muted); font-size: 12px; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }

.content { padding: 24px; flex: 1; max-width: 1500px; width: 100%; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head .page-sub { color: var(--text-muted); font-size: 13.5px; margin: 0; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-head h3 { margin: 0; }
.card-head .card-sub { color: var(--text-muted); font-size: 12.5px; margin: 2px 0 0; }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; gap: 10px; align-items: center;
}

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* ---------- Stats ---------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.stat-label { color: var(--text-muted); font-size: 12.5px; font-weight: 500; margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.stat-meta { font-size: 12px; color: var(--text-subtle); margin-top: 5px; }
.stat-ico {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand);
  position: absolute; top: 15px; right: 15px;
}
.stat.ok .stat-ico { background: var(--ok-bg); color: var(--ok); }
.stat.bad .stat-ico { background: var(--bad-bg); color: var(--bad); }
.stat.warn .stat-ico { background: var(--warn-bg); color: var(--warn); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

label.lbl, .lbl {
  display: block;
  font-size: 12.8px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.req { color: var(--bad); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="tel"], input[type="date"], input[type="datetime-local"], input[type="time"],
input[type="search"], input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 0.12s, box-shadow 0.12s;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
/* A select inside a table row, where the full-width one would push the
   column out to nothing useful. */
/* A field that lives inside a table row, under the thing it describes. */
.inline-edit { display: flex; gap: 6px; align-items: center; margin-top: 5px; }
.inline-edit input {
  width: auto;
  min-width: 130px;
  padding: 4px 8px;
  font-size: 12.5px;
}

select.sel-sm {
  width: auto;
  min-width: 132px;
  padding: 5px 28px 5px 9px;
  font-size: 12.5px;
  background-position: right 7px center;
}

textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg-sunken);
  color: var(--text-subtle);
  cursor: not-allowed;
}
input.is-error, select.is-error, textarea.is-error { border-color: var(--bad); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] {
  width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 16px; accent-color: var(--brand); cursor: pointer;
}
.check-label { font-size: 13.5px; }
.check-label small { display: block; color: var(--text-muted); font-size: 12px; margin-top: 1px; }

.radio-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.radio-card {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  display: flex; gap: 10px; align-items: flex-start;
  transition: border-color 0.12s, background 0.12s;
  background: var(--surface);
}
.radio-card:hover { border-color: var(--brand); }
.radio-card.selected { border-color: var(--brand); background: var(--brand-soft); }
.radio-card strong { display: block; font-size: 13.5px; }
.radio-card small { color: var(--text-muted); font-size: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn.is-disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(0.93); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(0.93); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; width: 32px; height: 32px; }

.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; border-color: var(--border-strong); }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.2px;
}
table.data th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .t-main { font-weight: 550; }
table.data .t-sub { color: var(--text-muted); font-size: 12px; }
table.data .t-actions { text-align: right; white-space: nowrap; }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-ico {
  width: 46px; height: 46px;
  margin: 0 auto 12px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--text-subtle);
}
.empty h3 { margin-bottom: 5px; }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.8px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }

/* The dialling row that sits under a waiting campaign on the approvals page:
   part of the row above it, not a record of its own. */
.data tr.sub-row > td { background: var(--surface-2, #f7f8fa); padding-top: 10px; padding-bottom: 10px; }
.data tr.sub-row .lbl { margin-bottom: 4px; }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-wait { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.pill-muted { background: var(--surface-2); color: var(--text-subtle); border-color: var(--border); }
.pill-plain::before { display: none; }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.4px;
  border: 1px solid transparent;
  align-items: flex-start;
}
.alert-ico { flex: 0 0 18px; margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: currentColor; }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: currentColor; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: currentColor; }
.alert a { color: inherit; text-decoration: underline; }
.alert-body { min-width: 0; }

/* ---------- Compose ---------- */
.composer { position: relative; }
.composer textarea { font-size: 14px; min-height: 150px; }
.counter-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-muted);
}
.composer textarea { border-radius: var(--radius-sm) var(--radius-sm) 0 0; margin-bottom: 0; }
.counter-item strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.counter-warn { color: var(--warn); }
.counter-bad { color: var(--bad); }

.preview-phone {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.preview-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 11px 14px;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
  line-height: 1.5;
}
.preview-sender {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Progress ---------- */
.progress {
  height: 7px;
  background: var(--bg-sunken);
  border-radius: 20px;
  overflow: hidden;
}
.progress-bar { height: 100%; background: var(--brand); border-radius: 20px; transition: width 0.3s; }
.progress-bar.ok { background: var(--ok); }
.progress-bar.bad { background: var(--bad); }
.progress-split { display: flex; height: 7px; border-radius: 20px; overflow: hidden; background: var(--bg-sunken); }
.progress-split span { display: block; height: 100%; }

/* ---------- Misc layout ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-end { justify-content: flex-end; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: 12.4px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); }
.text-brand { color: var(--brand); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .lbl { font-size: 11.5px; margin-bottom: 4px; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.pager-btn {
  padding: 6px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  background: var(--surface);
}
.pager-btn:hover { background: var(--surface-2); text-decoration: none; }
.pager-btn.is-disabled { opacity: 0.45; pointer-events: none; }
.pager-info { color: var(--text-muted); font-size: 12.5px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab {
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 16px; font-size: 13.4px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; word-break: break-word; }

.code-block {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.3px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
  line-height: 1.65;
}

.copy-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12.3px;
  word-break: break-all;
}
.copy-row .spacer { flex: 1; }

.qr-box {
  background: #fff;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-block;
  line-height: 0;
}
.qr-box svg { width: 176px; height: 176px; display: block; }

.recovery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-family: var(--mono);
  font-size: 13px;
}
.recovery-grid span {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  letter-spacing: 0.06em;
}

.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  background: var(--surface-2);
}
.drop-zone { position: relative; }
label.drop-zone { display: block; margin: 0; }
.drop-zone:hover, .drop-zone.dragover { border-color: var(--brand); background: var(--brand-soft); }
.drop-zone:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

/* Hidden, but still focusable and still validated - see initDropZone(). */
.drop-zone input[type="file"] {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-ico { display: block; color: var(--text-subtle); margin-bottom: 8px; }
.drop-title { display: block; font-size: 14.5px; color: var(--text); word-break: break-word; }
.drop-sub { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-muted); }
.drop-browse { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.drop-formats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}
.drop-limit { font-size: 11.5px; color: var(--text-subtle); margin-left: 4px; }

/* After a choice: green when the file is usable, red when it is not. */
.drop-zone.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.drop-zone.has-file .drop-ico { color: var(--ok); }
.drop-zone.is-invalid { border-color: var(--bad); background: var(--bad-bg); }
.drop-zone.is-invalid .drop-ico,
.drop-zone.is-invalid .drop-title { color: var(--bad); }

.toast-host {
  position: fixed; bottom: 22px; right: 22px; z-index: 100;
  display: flex; flex-direction: column; gap: 9px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 11px 15px;
  font-size: 13.4px;
  min-width: 240px;
  max-width: 380px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.55);
  display: none;
  place-items: center;
  z-index: 90;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: grid; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); }

.mobile-only { display: none; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; }
  .content { padding: 16px; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 35; display: none;
  }
  .sidebar-scrim.open { display: block; }
}

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4, .field-row, .field-row-3 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dt { margin-top: 8px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .hide-sm { display: none !important; }
  .auth-card { padding: 24px; }
  .recovery-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .page-head-actions, .filters, .pager { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ddd; }
}

/* ---- Template composer: locked wording, one field per blank ---- */
.tpl-lock { margin-bottom: 16px; }

.tpl-lock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

/* The registered wording. Deliberately not an input: there is nothing here to
   type into, and it should not look as though there were. */
.tpl-body {
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* Each blank, showing whatever has been typed into it so far. */
.tpl-slot {
  display: inline;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--info) 22%, transparent);
  font-weight: 600;
  word-break: break-all;
}

.tpl-slot-empty {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--border);
  border-color: color-mix(in srgb, var(--warn) 24%, transparent);
  font-weight: 500;
  font-style: italic;
}

.tpl-vars-head {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 18px 0 10px;
}

.tpl-var { margin-bottom: 12px; }

.tpl-var-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tpl-var-row input { flex: 1; min-width: 0; }
.tpl-var-row input[readonly] { background: var(--bg-sunken); color: var(--text-muted); }

/* A field that exists to be read, not typed in: an agent's code after they
   have been created, where everything about them is already filed under it. */
input.is-locked,
input[readonly] { background: var(--bg-sunken); color: var(--text-muted); cursor: default; }

.tpl-var-src {
  flex: 0 0 auto;
  width: auto;
  max-width: 44%;
  font-size: 12.5px;
}

.tpl-var-count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-subtle);
  min-width: 48px;
  text-align: right;
}

.tpl-var-count.over { color: var(--bad); font-weight: 650; }

@media (max-width: 560px) {
  .tpl-var-row { flex-wrap: wrap; }
  .tpl-var-src { max-width: 100%; width: 100%; }
  .tpl-var-row input { flex: 1 1 60%; }
}

/* Shown while no template has been chosen, in place of the message box. */
.tpl-prompt {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--info) 20%, transparent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

.tpl-prompt strong { display: block; margin-bottom: 2px; }
.tpl-prompt-ico { flex: 0 0 auto; margin-top: 1px; color: var(--info); }

/* ---- Template import card ---- */
.import-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 16px;
}

.import-notes {
  list-style: none;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px 24px;
}

.import-notes li {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.import-notes li svg { flex: 0 0 auto; margin-top: 2px; }
.import-notes strong { color: var(--text); font-weight: 600; }

/* A long single-line sample, such as a GET URL, wraps instead of scrolling. */
.code-block.code-wrap { white-space: pre-wrap; word-break: break-all; }

/* Two-step marker beside a login on the accounts list. */
.mfa-tag {
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10.5px;
  vertical-align: 1px;
  gap: 3px;
}

/* What the uploaded file filled in, above the blanks. */
.tpl-vars-note {
  margin: -4px 0 12px;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  line-height: 1.55;
}

/* ---------- Voice additions ---------- */

/* The sidebar channel badge is normally a warning colour. Free capacity is
   good news, so it turns green rather than shouting in red. */
.nav-badge-ok { background: var(--ok); }

/* Channel meter: one segment per state so the split between IVR reservation,
   live IVR calls and live OBD calls is readable at a glance. */
.meter {
  display: flex;
  height: 10px;
  border-radius: 20px;
  overflow: hidden;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.meter span { display: block; height: 100%; transition: width 0.3s; }
.meter .seg-obd { background: var(--brand); }
.meter .seg-ivr { background: var(--ok); }
.meter .seg-reserved { background: repeating-linear-gradient(45deg, var(--ok) 0 4px, transparent 4px 8px); opacity: 0.55; }
.meter .seg-spare { background: var(--text-subtle); opacity: 0.35; }

.meter-key { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 9px; font-size: 12px; color: var(--text-muted); }
.meter-key i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: middle; }
.meter-key .k-obd { background: var(--brand); }
.meter-key .k-ivr { background: var(--ok); }
.meter-key .k-reserved { background: repeating-linear-gradient(45deg, var(--ok) 0 3px, transparent 3px 6px); }
.meter-key .k-spare { background: var(--text-subtle); opacity: 0.4; }
.meter-key .k-free { background: var(--bg-sunken); border: 1px solid var(--border-strong); }

/* Per-call-type credit buckets. A customer holds several balances at once, so
   they get a grid rather than the single figure an SMS panel shows. */
.credit-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.credit-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 15px;
  background: var(--surface);
}
.credit-card.is-empty { border-style: dashed; }
.credit-card.is-off { opacity: 0.55; }
.credit-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.credit-value { font-size: 21px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.credit-meta { font-size: 11.5px; color: var(--text-subtle); margin-top: 3px; }
.credit-card.is-low .credit-value { color: var(--bad); }

/* Recording player, inline in a report row. */
.audio-row { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.audio-row audio { height: 32px; max-width: 260px; flex: 1; }
.audio-missing { color: var(--text-subtle); font-size: 12px; }

/* Agent presence. */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 8px; background: var(--text-subtle); }
.dot-online { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot-busy { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.dot-offline { background: var(--text-subtle); }
.agent-name { display: flex; align-items: center; gap: 8px; }

/* Number picker used when an IVR customer chooses their DID. */
.number-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.number-tile {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.number-tile:hover { border-color: var(--brand); background: var(--brand-soft); }
.number-tile.selected { border-color: var(--brand); background: var(--brand-soft); }
.number-tile .num { font-size: 17px; font-weight: 650; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.number-tile .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* A dialled digit in an IVR report. */
.dtmf {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--mono);
  font-weight: 600;
  text-align: center;
}

/* The window banner on the compose page: promotional calling is time-boxed and
   the customer needs to know before they build a list, not after. */
.window-note {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.window-note.is-open { background: var(--ok-bg); border-color: currentColor; color: var(--ok); }
.window-note.is-closed { background: var(--warn-bg); border-color: currentColor; color: var(--warn); }
/* display:flex above beat the hidden attribute, so every call type's note
   showed at once instead of only the chosen one's. */
.window-note[hidden] { display: none; }

/* ---------- Session 2: approvals, TTS templates, IVR designer ---------- */

/* An audio player inside a table cell, under the file's name. */
.audio-inline { display: block; height: 32px; width: 100%; max-width: 280px; margin-top: 6px; }

/* A TTS template's wording, with its blanks picked out. */
.tts-body {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  font-size: 13.4px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.tts-body mark {
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 4px;
  padding: 0 3px;
  font-family: var(--mono);
  font-size: 12.4px;
}
.tts-body mark sup { font-size: 9px; margin-left: 1px; }

/* Reject with a reason, inline in the approvals table. */
.reject-form { display: inline-flex; gap: 6px; margin-top: 6px; }
.reject-form input { width: 200px; padding: 6px 9px; font-size: 12.5px; }

/* Admin team: the permission ticks, two columns where there is room. */
.perm-grid { display: grid; gap: 0 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 6px; }

/* IVR designer: the three numbered steps a call goes through. */
.ivr-step { display: flex; gap: 14px; padding: 16px 0; border-top: 1px dashed var(--border); }
.ivr-step:first-of-type { border-top: 0; }
.ivr-step-no {
  flex: 0 0 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); font-weight: 650; font-size: 13px;
}
.ivr-step-body { flex: 1; min-width: 0; }
.ivr-key { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.ivr-key-no {
  flex: 0 0 36px; height: 36px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-strong); background: var(--surface);
  font-family: var(--mono); font-weight: 650; font-size: 15px;
}
.ivr-key-body { flex: 1; min-width: 0; }
.ivr-agents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ivr-sub { margin-top: 8px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; }
.ivr-sub > summary { cursor: pointer; color: var(--text-muted); }
.ivr-subkey .ivr-key-no { min-width: 34px; font-size: 12px; }

/* A tickable chip, for picking several agents without a clumsy multi-select. */
/* An agent on a menu key, with where they come in that key's queue. */
.pick-order { display: inline-flex; align-items: center; gap: 4px; margin: 0 8px 6px 0; }
.pick-order .pick { margin: 0; }
.pick-pos {
  width: 42px; padding: 4px 6px; text-align: center; font-size: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
}

.pick { display: inline-flex; cursor: pointer; position: relative; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick span {
  padding: 4px 10px; border-radius: 20px; font-size: 12.5px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.pick input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 550; }
.pick input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-ring); }

details > summary::-webkit-details-marker { display: none; }

@media (max-width: 640px) {
  .reject-form { display: flex; flex-wrap: wrap; }
  .reject-form input { width: 100%; }
  .ivr-step { gap: 10px; }
}

/* ---------------------------------------------------------------------------
   The agent's screen.

   Built to fit. An agent glances at this between calls, so everything is on
   one screen: a thin header, then three panels sharing the height that is
   left. Only the call list scrolls, and only when it has to.
   --------------------------------------------------------------------------- */
.agent-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-sunken);
}

.agent-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.agent-top-brand { display: flex; align-items: center; margin-right: auto; }
.agent-top-brand img { max-height: 30px; max-width: 150px; }
.agent-top-brand strong { font-size: 16px; letter-spacing: -0.01em; }
.agent-top-form { margin: 0; }

.agent-who { display: flex; flex-direction: column; line-height: 1.25; }
.agent-name { font-weight: 600; font-size: 14px; }
.agent-sub { font-size: 12px; color: var(--text-muted); }

/* Whether the phone will ring, said in a colour before it is said in words. */
.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 550;
  border: 1px solid var(--border);
}
.agent-state .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.agent-state-live { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.agent-state-paused { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.agent-state-offhours { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.agent-main { flex: 1; padding: 16px 20px; min-height: 0; }

.agent-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: stretch;
  height: 100%;
}
.agent-panel { display: flex; flex-direction: column; min-height: 0; margin: 0; }
.agent-panel .card-body { min-height: 0; }
/* The one thing allowed to scroll, because a busy agent has a long list. */
.agent-scroll { overflow-y: auto; }

/* The dialpad. Bigger targets than a form field, because this gets used with
   one hand while the other holds a phone. */
.dial-display {
  width: 100%;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 10px;
  font-family: var(--mono, monospace);
  margin-bottom: 12px;
}
.dialpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.dial-key {
  padding: 12px 0;
  font-size: 17px;
  font-weight: 550;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.dial-key:hover { background: var(--surface-2); border-color: var(--brand); }
.dial-key:active { background: var(--brand-soft); }
.dial-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.dial-actions .btn-primary { margin-left: auto; }

/* TeleSales agent page (/sales): the leads list in the middle gets the room. */
.sales-grid { grid-template-columns: 300px minmax(0, 1fr) 340px; }
.sales-col { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.sales-today { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); }
.sales-today strong { color: var(--text); font-weight: 600; }
.sales-live { border-color: var(--ok); }
.sales-live-number { font-size: 22px; font-weight: 600; margin: 4px 0; letter-spacing: 0.02em; }
.sales-live-state { display: inline-flex; align-items: center; gap: 7px; color: var(--ok); font-weight: 550; }
.sales-live-state .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: sales-pulse 1.2s ease-in-out infinite; }
@keyframes sales-pulse { 50% { opacity: 0.3; } }
.sales-rate { border-color: var(--brand); }
.sales-outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sales-outcome { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.sales-outcome:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.sales-filters { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.sales-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.sales-filter-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.sales-filter-form select, .sales-filter-form input { width: auto; min-width: 0; flex: 1 1 130px; }
.sales-filter-form .btn { flex: 0 0 auto; }
.sales-pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; }
.sales-calls { list-style: none; margin: 0; padding: 0; }
.sales-calls li { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.sales-calls li:last-child { border-bottom: 0; }
.sales-call-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sales-call-outcome summary { cursor: pointer; margin-top: 4px; list-style: none; }
.sales-call-outcome summary::-webkit-details-marker { display: none; }

/* A narrow laptop, or a phone: one column, and scrolling is fine there. */
@media (max-width: 1100px) {
  .agent-grid, .sales-grid { grid-template-columns: 1fr; height: auto; }
  .agent-scroll { max-height: 420px; }
}

/* The filter box above a long dropdown. Sits tight to the select it filters,
   so the two read as one control rather than two fields. */
.select-search {
  margin-bottom: 6px;
  font-size: 13.5px;
}

/* A customer's IVR, read rather than edited. */
.ivr-read h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); margin: 20px 0 8px; font-weight: 600;
}
.ivr-read h4:first-child { margin-top: 0; }
.ivr-read > p { margin: 0 0 4px; }

/* What the caller is actually told, set apart from our description of it. */
.ivr-said {
  background: var(--surface-2); border-left: 3px solid var(--brand);
  padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 0; white-space: pre-wrap; line-height: 1.5; font-size: 14px;
}

/* Key, what it is for, who it rings. The key is one character and should not
   be given a fifth of the width for it. */
.ivr-menu th:first-child, .ivr-menu td:first-child { width: 48px; }
.ivr-menu th:nth-child(2), .ivr-menu td:nth-child(2) { width: 26%; }

.ivr-facts {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 20px; margin: 14px 0 0; font-size: 13.5px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.ivr-facts dt { color: var(--text-muted); }
.ivr-facts dd { margin: 0; font-weight: 500; }

@media (max-width: 640px) {
  /* Two columns of nothing each. Stacked, with the label above its value. */
  .ivr-facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ivr-facts dt { margin-top: 10px; font-size: 12px; }
}
/* One step of a designed message: a recording, or a blank. */
.step-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.step-row:last-child { border-bottom: 0; }
.step-n {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--text-muted);
  font-size: 12px; font-weight: 600;
}
.step-row audio { grid-column: 2 / -1; height: 32px; width: 100%; }
.step-row .t-sub { grid-column: 2 / -1; }
/* A blank has nothing to type, so it says what it is instead. */
.step-blank { color: var(--text-muted); font-size: 13px; font-style: italic; }

@media (max-width: 760px) {
  /* Five columns on a phone gives each of them none. */
  .step-row { grid-template-columns: 28px minmax(0, 1fr) auto; }
  .step-row input[type=file] { grid-column: 2 / -1; }
}
/* Why a call ended.

   On a span inside the cell, never on the cell itself: -webkit-box on a <td>
   stops it being a table cell, and the row loses its borders and its
   alignment along with it. That is what broke the call report - the text was
   clamped correctly and the table fell apart around it.

   Two lines, then the browser adds the ellipsis. The whole reason is in the
   cell's title, so hovering still shows all of it. */
.t-reason {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 34ch;
  white-space: normal;
}

@media (min-width: 1200px) {
  /* Room for most of them outright on a wide screen. */
  .t-reason { max-width: 52ch; }
}

/* The header on a phone.

   Five things in one wrapping row put the logo, the name, the state and Pause
   across the top and dropped Sign out onto a line of its own on the left,
   which reads as a mistake rather than a menu. Two deliberate rows instead:
   who this is up top with the way out, and below it the two things an agent
   actually touches between calls - whether the phone rings, and the button
   that changes it. Placed by name rather than by source order, so the markup
   stays in the order it reads in. */
@media (max-width: 640px) {
  .agent-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      'brand app   signout'
      'who   state pause';
    align-items: center;
    gap: 10px 8px;
    padding: 10px 14px;
  }
  .agent-top-brand { grid-area: brand; margin-right: 0; }
  .agent-who { grid-area: who; min-width: 0; }
  .agent-state { grid-area: state; justify-self: end; }
  .agent-top-pause { grid-area: pause; justify-self: end; }
  .agent-top-signout { grid-area: signout; justify-self: end; }
  .agent-top-app { grid-area: app; justify-self: end; }

  /* A long customer name must shorten rather than push Pause off the screen. */
  .agent-name, .agent-sub {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Narrower still: the state pill is the one thing that can go, because the
   button beside it already says which state you are in - it reads Pause only
   when calls are coming through. */
@media (max-width: 380px) {
  .agent-top {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'brand signout'
      'who   pause';
  }
  .agent-state { display: none; }
}

/* ---------------------------------------------------------------------------
   The day, hour by hour.

   Bars rather than a chart library: twenty-four numbers do not need three
   hundred kilobytes of JavaScript, and this renders before the page settles.
   The darker part of each bar is the share that was answered, so a busy hour
   the team could not cover is visible as a bar that is mostly pale.
   --------------------------------------------------------------------------- */
.hourly {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
}
.hourly-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.hourly-bar {
  position: relative;
  background: var(--brand-soft);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.hourly-answered { background: var(--ok); border-radius: 3px 3px 0 0; width: 100%; }
.hourly-label {
  font-size: 10px;
  color: var(--text-subtle);
  text-align: center;
  margin-top: 4px;
  height: 12px;
}

/* ---------------------------------------------------------------------------
   The same board, on a screen on the wall.

   Read from across a room by people who will not walk over and navigate it, so
   the chrome goes and the numbers grow.
   --------------------------------------------------------------------------- */
.tv-body { background: var(--bg-sunken); min-height: 100vh; }
.tv-top {
  display: flex;
  align-items: center;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tv-top img { max-height: 34px; max-width: 180px; }
.tv-top strong { font-size: 18px; }
.tv-main { padding: 20px 28px; }
.tv-body .stat-value { font-size: 38px; }
.tv-body .stat-label { font-size: 13px; }
.tv-body h1 { font-size: 26px; }
.tv-body .hourly { height: 160px; }

/* A dropdown of tick boxes, for a filter that takes several values at once
   (campaign statuses, account services). Looks like the selects beside it. */
.multi { position: relative; }
.multi > summary {
  list-style: none; cursor: pointer; user-select: none;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 10px center;
  font-size: 13.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.multi[open] > summary { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.multi-panel {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 100%; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.multi-panel label { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.multi-panel label input { width: auto; margin: 0; }

/* Survey and feedback answers on Call reports: one chip per question. */
.answers-cell { max-width: 360px; }
.answer-chip { display: inline-flex; align-items: center; gap: 4px; margin: 2px 6px 2px 0; font-size: 12px; white-space: nowrap; }
.answer-chip .answer-q { color: var(--text-muted); }
.answers-questions > summary { min-width: 170px; max-width: 240px; }
.answers-questions .multi-panel { max-height: 320px; overflow-y: auto; }
