/* Vitasya Voice Agents — light SaaS theme (issue 0017).
   Design tokens keep the original variable NAMES (--accent, --ok, …) because
   stats.js reads them at runtime to color Chart.js — changing values here
   restyles the charts with zero JS changes. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6f8;            /* app canvas */
  --panel: #ffffff;         /* card surface */
  --border: #e8e9ee;
  --text: #191a20;
  --dim: #6f7280;
  --accent: #7c5cfc;        /* the one purple */
  --accent-strong: #6a4aef; /* hover */
  --accent-soft: #f2eefe;   /* active-nav / tint backgrounds */
  --ok: #16a34a;   --ok-soft: #e7f6ec;
  --warn: #d97706; --warn-soft: #fdf3e2;
  --err: #dc2626;  --err-soft: #fdeaea;
  --shadow: 0 1px 2px rgba(25, 26, 32, 0.04), 0 6px 20px rgba(25, 26, 32, 0.05);
  --radius: 14px;           /* cards */
  --radius-sm: 10px;        /* controls */
  --sidebar-w: 232px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex; /* sidebar (injected by nav.js) + main */
}

main { flex: 1; min-width: 0; max-width: 1240px; padding: 24px 28px 48px; }

/* Page header inside main: title + page-level actions. */
header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.2px; }
h1 span { color: var(--accent); }
.badges { display: flex; gap: 8px; flex: 1; }

/* ---------- sidebar (markup injected by nav.js) ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 18px 12px 14px; z-index: 20;
}
.sb-logo {
  display: flex; align-items: center; gap: 10px; padding: 2px 10px 16px;
  font-weight: 700; font-size: 15px; letter-spacing: -0.2px; color: var(--text);
  text-decoration: none;
}
.sb-logo .mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.sb-logo .mark svg { width: 16px; height: 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--dim); font-size: 14px; font-weight: 500; text-decoration: none;
}
.sb-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sb-item:hover { color: var(--text); background: var(--bg); }
.sb-item.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.sb-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.sb-status { display: flex; gap: 12px; padding: 4px 10px 10px; }
.sb-status span { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--dim); }
.sb-status i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex-shrink: 0;
}
.sb-status .on i { background: var(--ok); }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 4px 10px; }
.sb-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.sb-user .who { flex: 1; min-width: 0; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user button { background: none; border: none; color: var(--dim); padding: 6px; cursor: pointer; }
.sb-user button:hover { color: var(--err); }
.sb-user button svg { width: 16px; height: 16px; display: block; }

/* Mobile: sidebar slides in over the content; hamburger injected by nav.js. */
.menu-btn {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 30;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow);
}
.menu-btn svg { width: 18px; height: 18px; }
.sb-scrim { display: none; position: fixed; inset: 0; background: rgba(25, 26, 32, 0.35); z-index: 19; }
@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.2s ease; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sb-scrim { display: block; }
  main { padding: 64px 16px 40px; }
}

/* ---------- badges & pills ---------- */
.badge, .pill {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--bg); color: var(--dim); white-space: nowrap;
}
.badge.ok, .pill.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- buttons ---------- */
button {
  font: inherit; font-size: 14px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--accent); color: #fff; padding: 9px 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
}
button:hover { background: var(--accent-strong); }
button svg, a.ghost svg { width: 15px; height: 15px; flex-shrink: 0; }
button.ghost, a.ghost {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); font-weight: 500;
}
a.ghost {
  display: inline-flex; align-items: center; gap: 7px; border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 14px; text-decoration: none; white-space: nowrap;
}
a.ghost:hover, button.ghost:hover { background: var(--bg); border-color: #d9dbe3; }
button.danger { background: var(--err-soft); color: var(--err); }
button.danger:hover { background: #fbdcdc; }
button:disabled { opacity: 0.5; cursor: default; pointer-events: none; }

.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--warn-soft); border: 1px solid #f3dfba; color: #92610a;
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px;
}
.banner.hidden { display: none; }
.banner a.ghost, .banner button { margin-left: auto; white-space: nowrap; }

/* ---------- live call bar (dashboard) ---------- */
.callbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.call-status { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 260px; }
#callTitle { font-weight: 600; }
.dim { color: var(--dim); font-size: 13px; }

.pulse { width: 12px; height: 12px; border-radius: 50%; background: #d3d5dd; flex-shrink: 0; }
.pulse.live { background: var(--ok); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.35); }
  50% { box-shadow: 0 0 0 9px rgba(22, 163, 74, 0); }
}

#dialForm { display: flex; gap: 8px; }
/* display:flex on the id outranks the generic .hidden — hide explicitly
   (no history.operate permission, issue 0036). */
#dialForm.hidden { display: none; }
#dialForm input { width: 180px; }
#dialForm select { max-width: 150px; }

/* ---------- form controls (shared) ---------- */
input, select, textarea {
  font: inherit; font-size: 13px; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: #a6a8b3; }
textarea { resize: vertical; line-height: 1.4; }

/* ---------- stat cards ---------- */
.stat-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.stat-card .ico {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.stat-card .ico svg { width: 17px; height: 17px; }
.stat-card .body { flex: 1; min-width: 0; }
.stat-card .num { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.stat-card .lbl { font-size: 12px; color: var(--dim); margin-top: 1px; }
.stat-card .sub { font-size: 11px; color: var(--dim); margin-top: 4px; }
/* Clickable variants (dashboard drill-down). */
a.stat-card { text-decoration: none; color: inherit; }
a.stat-card:hover { border-color: var(--accent); }

/* ---------- panels / cards ---------- */
.panels { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 760px) { .panels { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); display: flex; flex-direction: column; min-height: 380px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 15px; font-weight: 600; }
.scroll { padding: 14px 16px; overflow-y: auto; flex: 1; max-height: 56vh; }
.hint { color: var(--dim); font-size: 13px; }

.bubble { margin-bottom: 12px; font-size: 14px; line-height: 1.45; }
.bubble .who {
  display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--dim); margin-bottom: 2px; font-weight: 600;
}
.bubble.agent .who { color: var(--accent); }
.bubble.user .who { color: var(--ok); }

.tool-entry {
  border-left: 2px solid var(--accent); padding: 6px 10px;
  margin-bottom: 10px; font-size: 13px;
}
.tool-entry .tname { font-weight: 600; }
.tool-entry .tmeta { color: var(--dim); font-size: 12px; }
.tool-entry pre {
  margin-top: 6px; font-size: 11px; color: var(--dim);
  white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow-y: auto;
}

/* ---------- data tables (reference look) ---------- */
.table-wrap { overflow-x: auto; flex: 1; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--dim); font-weight: 600; padding: 10px 14px;
  border-bottom: 1px solid var(--border); background: #fafafc; white-space: nowrap;
}
.data-table td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr.click { cursor: pointer; }
.data-table tbody tr.click:hover, .data-table tbody tr.active { background: #fafafc; }
.data-table .t-main { font-weight: 600; color: var(--text); }
.data-table .t-dim { color: var(--dim); font-size: 12px; }
.data-table .t-actions { text-align: right; }
.data-table .t-actions button { padding: 4px 9px; font-size: 12px; }
.data-table input[type="checkbox"] { width: auto; }

/* ---------- call history page ---------- */
.history-panel { min-height: 0; }
.history-panel .table-wrap { max-height: 62vh; overflow-y: auto; }

.filterbar {
  display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px 14px; align-items: end;
  min-height: 0; padding: 14px 16px; margin-bottom: 16px;
}
.filterbar label { display: block; font-size: 12px; color: var(--dim); font-weight: 500; }
.filterbar input, .filterbar select {
  display: block; width: auto; min-width: 120px; margin-top: 4px;
}
.filterbar .tests-check { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; }
.filterbar .tests-check input { width: auto; min-width: 0; margin: 0; }
.filterbar .search-label { flex: 1; min-width: 180px; }
.filterbar .search-label input { width: 100%; }
.load-more-row { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; }
.load-more-row .hidden { display: none; }
.del-call { padding: 3px 9px; margin-left: 10px; font-size: 12px; }

/* Detail view: chronological trace */
.detail-body { padding: 14px 16px; overflow-y: auto; max-height: 74vh; }
.detail-body audio { display: block; width: 100%; max-width: 480px; margin: 8px 0 4px; }
.detail-body > div > a { color: var(--accent); font-size: 12px; }
#detailTimeline { margin-top: 12px; }
.tl-row { display: flex; gap: 12px; padding: 7px 0; font-size: 14px; line-height: 1.45; }
.tl-time { color: var(--dim); font-size: 11px; min-width: 76px; padding-top: 3px; flex-shrink: 0; }
.tl-body { flex: 1; min-width: 0; }
.tl-who {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--dim); margin-bottom: 2px; font-weight: 600;
}
.tl-agent .tl-who { color: var(--accent); }
.tl-caller .tl-who { color: var(--ok); }
.tl-err { color: var(--err); font-size: 13px; }
.tl-body pre {
  margin-top: 4px; font-size: 11px; color: var(--dim);
  white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow-y: auto;
  background: var(--bg); border-radius: 8px; padding: 8px 10px;
}

/* ---------- settings-style rows (num-row: label + control) ---------- */
.num-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.num-row span { font-size: 13px; }
.num-row select { margin-top: 0; }

/* Consent warning for recording-without-announcement (issue 0008) */
.warn-note {
  color: #92610a; font-size: 12px; line-height: 1.45;
  background: var(--warn-soft); border: 1px solid #f3dfba;
  border-radius: 8px; padding: 8px 10px; margin-bottom: 10px;
}

/* ---------- fieldsets (settings/agent/workflow forms) ---------- */
fieldset {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
legend { padding: 0 6px; font-size: 13px; color: var(--text); font-weight: 600; }
fieldset label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
fieldset input, fieldset select, fieldset textarea { display: block; width: 100%; margin-top: 4px; }
.row { display: flex; gap: 8px; }
fieldset .hidden, .hidden { display: none; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
.lang-voice { margin-left: 10px; padding-left: 10px; border-left: 2px solid var(--border); }
/* Advanced voice tuning expander (issue 0028) — matches the label style;
   sliders indent like .lang-voice rows. */
fieldset details { margin-bottom: 10px; }
fieldset details summary { font-size: 13px; color: var(--dim); cursor: pointer; }
fieldset details label { margin: 8px 0 0 10px; padding-left: 10px; border-left: 2px solid var(--border); }
.map-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.map-row span { font-size: 12px; color: var(--dim); }
.map-row select { margin-top: 0; }
fieldset code { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 4px; }
.row input { flex: 1; }
.status { font-size: 12px; margin-top: 8px; color: var(--dim); min-height: 14px; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

/* ---------- login page (no sidebar) ---------- */
.login-main { max-width: 420px; margin: 0 auto; padding-top: 12vh; }
.login-main header { justify-content: center; }
.login-panel { padding-bottom: 4px; min-height: 0; }
.login-form { padding: 16px; }
.login-form label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 12px; }
.login-form input { width: 100%; margin-top: 4px; font-size: 14px; }
.login-form button { width: 100%; margin-top: 4px; }

/* ---------- integrations page (compact accordion) ---------- */
.int-list { display: flex; flex-direction: column; gap: 10px; max-width: 640px; }
.int-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.int-head {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%;
  padding: 13px 16px; background: none; border: none; border-radius: 0;
  cursor: pointer; text-align: left; color: var(--text); font: inherit;
}
.int-head:hover { background: #fafafc; }
/* Status dot: green halo = connected, red = not, grey = unknown. */
.int-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: #d3d6de; box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.int-dot.on { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.int-dot.off { background: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.int-name { font-size: 14px; font-weight: 600; flex-shrink: 0; }
.int-sum {
  flex: 1; min-width: 0; font-size: 12.5px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.int-chev {
  width: 16px; height: 16px; flex-shrink: 0;
  stroke: var(--dim); fill: none; stroke-width: 2;
  transition: transform 0.25s ease;
}
.int-card.open .int-chev { transform: rotate(180deg); }
/* Smooth expand/contract: grid 0fr→1fr animates to the content's own height
   (no max-height guessing); the inner div carries the padding so the closed
   state collapses to a true 0. */
.int-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; }
.int-card.open .int-wrap { grid-template-rows: 1fr; }
.int-wrap > .int-inner { overflow: hidden; min-height: 0; padding: 0 16px; }
.int-inner > :first-child { margin-top: 2px; }
.int-inner > :last-child { margin-bottom: 14px; }
.int-inner label { display: block; font-size: 13px; color: var(--dim); margin: 10px 0; }
.int-inner input { margin-top: 4px; font-size: 14px; }
/* Masked credential fingerprint rows */
.int-details {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center;
  margin: 10px 0 4px; font-size: 12.5px;
}
.int-details code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  color: var(--text); background: var(--bg); border-radius: 6px;
  padding: 3px 8px; justify-self: start;
}
@media (prefers-reduced-motion: reduce) {
  .int-wrap, .int-chev, .int-dot { transition: none; }
}
.int-sub { font-size: 13px; font-weight: 600; margin: 14px 0 8px; }

/* ---------- stats page ---------- */
.stats-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.stats-grid-2 { grid-template-columns: 1fr 1fr; }
.stats-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 760px) { .stats-grid-2, .stats-grid-3 { grid-template-columns: 1fr; } }

.stats-panel { min-height: 0; margin-bottom: 16px; }
.stats-grid .stats-panel { margin-bottom: 0; }
.chart-box { position: relative; padding: 14px 16px; height: 240px; }
.chart-box.chart-wide { height: 260px; }

.time-metrics { padding: 10px 16px 14px; font-size: 13px; }
.time-metrics .tm-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.time-metrics .tm-row:last-child { border-bottom: none; }
.time-metrics .tm-lbl { color: var(--dim); }

.table-box { padding: 6px 16px 14px; overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th {
  text-align: right; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--dim); padding: 8px 10px; cursor: pointer; user-select: none; white-space: nowrap;
}
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table th:hover, .stats-table th.sorted { color: var(--text); }
.stats-table td {
  text-align: right; padding: 7px 10px; border-top: 1px solid var(--border); white-space: nowrap;
}
.stats-table td:first-child { font-weight: 600; }

/* ---------- workflows page ---------- */
.wf-main { max-width: 980px; }
.wf-editor { padding: 16px; }
.wf-editor fieldset { margin-bottom: 14px; box-shadow: none; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.cond-row {
  display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; flex-wrap: wrap;
}
.cond-row select, .cond-row input { flex: 1; min-width: 120px; margin-top: 0; }
.cond-row .del-call { flex: 0; }
.sched-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.wf-sched-label { margin-top: 6px; }
.dow-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.dow-check { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.dow-check input { width: auto; margin: 0; }
.outcome-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px; }
.outcome-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.wf-editor .map-row { grid-template-columns: 1fr 2fr; margin-bottom: 6px; }

/* ---------- workflows v2: flow builder (issue 0021) ---------- */
.wf2-main { max-width: 1160px; }

/* List view: card grid replacing the v1 table. */
.wf2-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.wf2-wfcard {
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 9px;
}
.wf2-wfcard:hover { border-color: var(--accent); }
.wf2-wfcard .top { display: flex; align-items: center; gap: 8px; }
.wf2-wfcard .name {
  font-weight: 600; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wf2-wfcard .last { font-size: 12px; color: var(--dim); }

/* ON/OFF switch on the workflow cards (checkbox under the hood). */
.wf2-switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.wf2-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.wf2-switch i {
  display: block; width: 100%; height: 100%; border-radius: 999px;
  background: #d3d5dd; transition: background 0.15s ease; pointer-events: none;
}
.wf2-switch i::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(25, 26, 32, 0.2);
  transition: left 0.15s ease;
}
.wf2-switch input:checked + i { background: var(--ok); }
.wf2-switch input:checked + i::after { left: 19px; }

/* Editor view: flow column + drawer. The drawer column only exists while open. */
.wf2-editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.wf2-editor.drawer-open { grid-template-columns: minmax(0, 1fr) 400px; }

/* The flow: vertical trunk of step cards joined by connector lines. */
.wf2-flow { max-width: 560px; margin: 0 auto; padding: 4px 0 40px; }
.wf2-card {
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
}
.wf2-card:hover { border-color: #d9dbe3; }
.wf2-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wf2-card .head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.wf2-card .sub { font-size: 12px; color: var(--dim); margin-top: 4px; line-height: 1.45; }
.wf2-line { width: 2px; height: 20px; background: #d9dbe3; margin: 0 auto; }

/* Reply branches (text-first): terminal outcomes fan out in a strip; the
   👍 path resumes the trunk below via the .wf2-resume pill. */
.wf2-fork-label { text-align: center; font-size: 11px; color: var(--dim); margin-bottom: 8px; }
.wf2-branches { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.wf2-card.mini { padding: 9px 10px; }
.wf2-card.mini .head { font-size: 12px; }
.wf2-card.mini .sub { font-size: 11px; margin-top: 3px; }
.wf2-resume {
  text-align: center; margin: 12px 0; font-size: 12px; font-weight: 600; color: var(--ok);
}

/* Chips: conditions as readable sentences on the trigger/conditions cards. */
.wf2-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.wf2-chip {
  font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}

/* Badges on flow cards (e.g. 📼 voicemail on the call card). */
.wf2-badge {
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--bg); color: var(--dim); white-space: nowrap;
}
.wf2-badge.on { background: var(--ok-soft); color: var(--ok); }

/* Drawer: sticky settings panel; field styling mirrors the fieldset forms. */
.wf2-drawer {
  position: sticky; top: 16px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); max-height: calc(100vh - 32px);
}
.wf2-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.wf2-drawer-head h2 { font-size: 15px; font-weight: 600; }
.wf2-drawer-head button { padding: 4px 9px; }
.wf2-drawer-body { padding: 14px 16px; overflow-y: auto; }
.wf2-panel label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
.wf2-panel input, .wf2-panel select, .wf2-panel textarea { display: block; width: 100%; margin-top: 4px; }
.wf2-panel label.check { display: flex; align-items: center; gap: 8px; }
.wf2-panel label.check input { width: auto; margin: 0; }
.wf2-panel code { font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 4px; }
.wf2-panel .cond-row select, .wf2-panel .cond-row input { width: auto; }

/* Searchable board picker (issue 0024): input + filtered dropdown over a
   hidden select. */
.wf2-combo { position: relative; }
/* The wrapped select is the value holder only — .wf2-panel select's
   display:block outranks the generic .hidden, so hide it explicitly. */
.wf2-combo select { display: none; }
.wf2-combo-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 6; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 220px; overflow-y: auto;
}
.wf2-combo-item { padding: 7px 11px; font-size: 13px; cursor: pointer; }
.wf2-combo-item:hover { background: var(--bg); }
.wf2-combo-item.sel { color: var(--accent); font-weight: 600; }
.wf2-combo-empty { padding: 7px 11px; font-size: 12px; color: var(--dim); }

/* Schedule pickers (issue 0022): time rows + chip toggle grids. */
.wf2-time-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.wf2-time-row input { flex: 1; margin-top: 0; width: auto; }
.wf2-time-row .del-call { flex: 0; margin-left: 0; }
.wf2-chipgrid { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.wf2-chipgrid.wf2-grid7 { display: grid; grid-template-columns: repeat(7, 1fr); }
.wf2-chip-toggle { position: relative; margin: 0 !important; }
.wf2-chip-toggle input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; margin: 0; cursor: pointer;
}
.wf2-chip-toggle span {
  display: flex; align-items: center; justify-content: center;
  padding: 5px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--border); background: var(--panel); color: var(--dim);
}
.wf2-chip-toggle input:checked + span {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent); font-weight: 600;
}

@media (max-width: 1000px) {
  /* Drawer drops below the flow instead of beside it. */
  .wf2-editor.drawer-open { grid-template-columns: 1fr; }
  .wf2-drawer { position: static; max-height: none; }
}

/* ---------- agent page (issue 0017) ---------- */
.agent-main { max-width: 860px; }
.profile-card {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.profile-card .avatar {
  width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; text-transform: uppercase;
}
.profile-card .p-info { flex: 1; min-width: 200px; }
.profile-card .p-info input {
  font-size: 17px; font-weight: 700; border-color: transparent; padding: 4px 8px; margin-left: -8px; width: 100%;
}
.profile-card .p-info input:hover { border-color: var(--border); }
.profile-card .p-sub { font-size: 13px; color: var(--dim); margin-top: 2px; }
.profile-card .p-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- responsive tables/cards ---------- */
@media (max-width: 700px) {
  .data-table th, .data-table td { padding: 10px 10px; }
  .callbar, #dialForm { flex-direction: column; align-items: stretch; }
  #dialForm input, #dialForm select { width: 100%; max-width: none; }
  .profile-card .p-actions { width: 100%; }
}

/* ---------- agent cards (issue 0033, hero redesign) ---------- */
.agents-panel { min-height: 0; }
.agents-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px; padding: 16px;
}
.agent-card {
  display: flex; flex-direction: column; text-align: left; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px -14px rgba(16, 24, 40, 0.14);
  transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease;
}
.agent-card:hover {
  border-color: #d6cdfb; transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 18px 40px -14px rgba(109, 92, 245, 0.28);
}

/* Hero: full-bleed photo or gradient placeholder with a large bot glyph. */
.ac-hero {
  position: relative; height: 200px; overflow: hidden;
  background: linear-gradient(160deg, #eef0ff 0%, #f6eeff 100%);
}
.ac-hero .ac-photo {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center top;
}
.ac-hero-ph {
  position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: rgba(255, 255, 255, 0.94);
}
.ac-hero-ph svg { width: 76px; height: 76px; filter: drop-shadow(0 8px 18px rgba(16, 24, 40, 0.22)); }

/* Frosted status pill (top right): Default / Online / No number. */
.ac-status {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--border);
  border-radius: 999px; backdrop-filter: blur(6px);
  font-size: 11px; font-weight: 500; letter-spacing: 0.02em; color: #475467;
}
.ac-status i { width: 7px; height: 7px; border-radius: 50%; background: #98a2b3; }
.ac-status.live i { background: #22c55e; box-shadow: 0 0 6px rgba(34, 197, 94, 0.6); }
.ac-status.default i { background: var(--accent); box-shadow: 0 0 6px rgba(124, 92, 252, 0.6); }

.ac-body { display: flex; flex-direction: column; flex: 1; padding: 16px 18px 20px; }
.ac-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ac-head-row > div:first-child { min-width: 0; }
.ac-name { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }
.ac-role {
  font-size: 12.5px; font-weight: 500; color: var(--accent); margin-top: 3px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ac-model {
  display: inline-flex; align-items: center; padding: 5px 9px; flex-shrink: 0;
  background: #f7f6ff; border: 1px solid #ece9ff; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: #344054; white-space: nowrap;
}
.ac-desc {
  margin-top: 12px; font-size: 13px; color: var(--dim); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 60px;
}
.ac-desc.empty { font-style: italic; color: #a6a8b3; }
.ac-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ac-open {
  width: 100%; margin-top: 16px; padding: 11px; border-radius: 10px;
  font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  box-shadow: 0 8px 20px -8px rgba(124, 92, 252, 0.6);
}

/* Mobile: the card grid collapses into a compact list — thumbnail on the
   left, info on the right, the whole row is the tap target (the Open button
   and the empty-description hint disappear). */
@media (max-width: 700px) {
  .agents-grid { grid-template-columns: 1fr; gap: 10px; padding: 12px; }
  .agent-card { flex-direction: row; border-radius: 14px; }
  .agent-card:hover { transform: none; }
  .ac-hero { width: 100px; flex-shrink: 0; height: auto; min-height: 112px; }
  .ac-hero-ph svg { width: 44px; height: 44px; }
  /* Status pill collapses to its dot, bottom-left of the thumbnail
     (font-size 0 hides the label text; the dot keeps its own size). */
  .ac-status {
    top: auto; right: auto; bottom: 8px; left: 8px;
    font-size: 0; gap: 0; padding: 5px;
  }
  .ac-hero .card-menu { top: 8px; left: 8px; }
  .ac-hero .card-menu .menu-toggle { width: 26px; height: 26px; font-size: 13px; }
  .ac-body { padding: 10px 14px 12px; min-width: 0; }
  .ac-name { font-size: 15px; }
  .ac-role { font-size: 12px; margin-top: 2px; }
  .ac-model { display: none; }
  .ac-desc { -webkit-line-clamp: 2; min-height: 0; margin-top: 6px; font-size: 12.5px; }
  .ac-desc.empty { display: none; }
  .ac-meta { margin-top: 8px; gap: 4px; }
  .ac-meta .chip { font-size: 10px; padding: 2px 8px; }
  .ac-open { display: none; }
}
.chip {
  font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); color: var(--dim); white-space: nowrap;
}

/* Avatar image / gradient placeholder (shared by cards, pickers, profile). */
.a-avatar {
  width: 52px; height: 52px; border-radius: 15px; flex-shrink: 0; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.a-avatar.ph svg { width: 55%; height: 55%; }

/* ⋯ menu on a card */
.card-menu { position: relative; margin-left: auto; }
.card-menu .menu-toggle {
  padding: 2px 9px; font-size: 15px; line-height: 1.4; color: var(--dim); border-radius: 8px;
}
/* On hero cards the menu floats frosted over the image, top left. */
.ac-hero .card-menu { position: absolute; top: 12px; left: 12px; z-index: 2; margin: 0; }
.ac-hero .card-menu .menu-toggle {
  width: 30px; height: 30px; padding: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.85); border: 1px solid var(--border);
  backdrop-filter: blur(6px); color: #475467;
}
.ac-hero .card-menu .menu-pop { left: 0; right: auto; top: 36px; }
.card-menu .menu-pop {
  display: none; position: absolute; right: 0; top: 30px; z-index: 6;
  flex-direction: column; min-width: 150px; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.card-menu.open .menu-pop { display: flex; }
.menu-pop button {
  background: none; border: 0; border-radius: 0; color: var(--text);
  padding: 9px 13px; font-size: 13px; font-weight: 500; text-align: left; justify-content: flex-start;
}
.menu-pop button:hover { background: var(--bg); }
.menu-pop button.danger { color: var(--err); background: none; }
.menu-pop button.danger:hover { background: var(--err-soft); }

/* Profile header: uploadable avatar + description row */
.p-avatar { position: relative; cursor: pointer; border-radius: 15px; flex-shrink: 0; display: inline-flex; }
.p-avatar .a-avatar, .p-avatar img { width: 64px; height: 64px; border-radius: 15px; }
.p-avatar::after {
  content: 'Change'; position: absolute; left: 0; right: 0; bottom: 0;
  background: rgba(20, 18, 30, 0.55); color: #fff; font-size: 10px; font-weight: 600;
  text-align: center; padding: 3px 0; opacity: 0; transition: opacity .15s ease;
  border-radius: 0 0 15px 15px; pointer-events: none;
}
.p-avatar:hover::after { opacity: 1; }
.profile-card .desc-row { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.profile-card .p-info input.p-desc {
  flex: 1; font-size: 13px; font-weight: 400; color: var(--dim); border-color: transparent;
  padding: 3px 8px; margin-left: -8px; width: auto;
}
.profile-card .p-info input.p-desc:hover { border-color: var(--border); }
.profile-card .p-info input.p-desc:focus { color: var(--text); }
.profile-card #genDesc { padding: 4px 10px; font-size: 12px; }

/* Clickable agent pick-cards (scheduling targets) */
.field-label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 6px; }
#schedulingTargetsRow { margin-bottom: 10px; }
.pick-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-card {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); font-size: 13px; font-weight: 500; padding: 5px 14px 5px 6px; cursor: pointer;
}
.pick-card .a-avatar { width: 28px; height: 28px; border-radius: 50%; }
.pick-card .a-avatar.ph svg { width: 60%; height: 60%; }
.pick-card:hover { border-color: #d6cdfb; background: var(--panel); }
.pick-card.sel {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent); font-weight: 600;
}
.pick-card.sel::after { content: '✓'; font-size: 12px; font-weight: 700; }

/* Section title polish: legends render INSIDE the card as real headers
   (float:left takes a legend out of the fieldset-border notch), slightly
   larger, with an icon chip. Applies to every fieldset page-wide. */
legend {
  float: left; width: 100%;
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; letter-spacing: -0.1px;
  padding: 0; margin: 2px 0 14px;
}
fieldset > *:not(legend) { clear: both; }
.leg-ico {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.leg-ico svg { width: 16px; height: 16px; }

/* ---------- AI prompt generator modal (issue 0034) ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 18, 30, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-scrim.hidden { display: none; }
.gen-modal {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(20, 18, 30, 0.3);
  width: 660px; max-width: 100%; max-height: 92vh; overflow-y: auto; padding: 20px;
}
.gen-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.gen-head h2 { font-size: 16px; font-weight: 700; }
.gen-head button { padding: 4px 10px; }
.gen-modal label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
.gen-modal textarea, .gen-modal input { display: block; width: 100%; margin-top: 4px; }
.gen-modal .row { display: flex; gap: 8px; margin: 10px 0; }
.gen-modal .row input { flex: 1; margin-top: 0; width: auto; }
.gen-out {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font: inherit; font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  min-height: 90px; max-height: 260px; overflow-y: auto; margin-bottom: 10px;
}
.gen-greeting {
  font-size: 13px; line-height: 1.5; background: var(--accent-soft);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
}
button.gen-open { color: var(--accent); border-color: #d6cdfb; }
button.gen-open:hover { background: var(--accent-soft); }

/* ---------- saved voice library rows (issue 0035) ---------- */
.voice-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 6px 10px; margin-left: 10px; border-left: 2px solid var(--border);
  font-size: 13px;
}
.voice-row .dim { flex: 1; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.voice-row button { margin-left: 0; }

/* ---------- Agent Performance page (stats redesign) ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } }
.kpi-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 16px 12px;
}
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 12.5px; font-weight: 500; color: var(--dim); }
.kpi-delta { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.kpi-delta.good { color: #067647; background: #ecfdf3; }
.kpi-delta.bad { color: #b42318; background: #fef3f2; }
.kpi-num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 8px; }
.kpi-sub { font-size: 11.5px; color: #98a2b3; margin-top: 1px; min-height: 15px; }
.spark { display: block; width: 100%; height: 34px; margin-top: 8px; }

/* Leaderboard */
.lb-panel { min-height: 0; margin-bottom: 16px; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px 14px; flex-wrap: wrap; }
.lb-head h2 { font-size: 16px; font-weight: 700; }
.lb-head .dim { display: block; margin-top: 2px; font-size: 12.5px; }
.seg { display: flex; gap: 4px; background: #f2f4f7; padding: 3px; border-radius: 9px; }
.seg button {
  font-size: 12.5px; font-weight: 500; color: #475467; background: none;
  padding: 5px 12px; border-radius: 7px; box-shadow: none;
}
.seg button:hover { background: #e9ebf0; color: #344054; }
.seg button.on { color: #fff; background: var(--accent); font-weight: 600; }
.seg button.on:hover { background: var(--accent-strong); }

.lb-grid {
  display: grid; align-items: center; gap: 14px;
  grid-template-columns: 30px 1.7fr 0.7fr 1.4fr 0.8fr 0.7fr 1fr 24px;
}
.lb-cols {
  padding: 8px 22px; background: #fafafb;
  border-top: 1px solid #f0f1f3; border-bottom: 1px solid #f0f1f3;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: #98a2b3;
}
.lb-cols .r, .lb-row .r { text-align: right; }
.lb-block { border-bottom: 1px solid #f4f4f6; }
.lb-block:last-child { border-bottom: none; }
.lb-row { padding: 13px 22px; cursor: pointer; }
.lb-row:hover { background: #fbfaff; }
.lb-rank { font-size: 13px; font-weight: 700; color: #c0c4cd; }
.lb-who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.lb-avatar { width: 34px !important; height: 34px !important; border-radius: 9px !important; }
.lb-avatar.ph svg { width: 60%; height: 60%; }
.lb-id { display: flex; flex-direction: column; min-width: 0; }
.lb-id .n { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-id .r { font-size: 11.5px; color: #98a2b3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.lb-row .num { font-size: 13px; font-variant-numeric: tabular-nums; color: #475467; }
.lb-conn { display: flex; align-items: center; gap: 9px; }
.track { flex: 1; height: 7px; background: #f0f1f3; border-radius: 99px; overflow: hidden; }
.track .fill { height: 100%; border-radius: 99px; }
.lb-conn .pct { font-size: 12.5px; font-weight: 600; color: #475467; width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
.lb-score-box { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.lb-score-box .trend { font-size: 11px; font-weight: 600; }
.lb-score-box .score {
  font-size: 13px; font-weight: 700; color: #fff; padding: 3px 8px;
  border-radius: 7px; font-variant-numeric: tabular-nums;
}
.lb-caret { text-align: right; font-size: 13px; color: #c0c4cd; transition: transform 0.15s ease; }
.lb-caret.open { transform: rotate(180deg); }
.lb-empty { padding: 18px 22px; }

/* Expanded drill-down */
.lb-detail {
  display: grid; grid-template-columns: 230px 1fr 280px; gap: 26px;
  background: #fbfbfc; border-top: 1px solid #f0f1f3; padding: 20px 22px 24px;
}
.lb-sec-title {
  font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: #98a2b3; margin-bottom: 12px;
}
.lb-mix { display: flex; align-items: center; gap: 16px; }
.lb-donut { position: relative; flex-shrink: 0; width: 92px; height: 92px; }
.lb-donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.lb-donut-center .v { font-size: 17px; font-weight: 700; line-height: 1; }
.lb-donut-center .k { font-size: 9.5px; color: #98a2b3; }
.lb-legend { display: flex; flex-direction: column; gap: 7px; min-width: 0; flex: 1; }
.lb-legend-row { display: flex; align-items: center; gap: 7px; }
.lb-legend-row .dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.lb-legend-row .k { font-size: 12px; color: #475467; }
.lb-legend-row .v { font-size: 12px; font-weight: 600; margin-left: auto; padding-left: 8px; }
.lb-vol { display: flex; align-items: flex-end; gap: 5px; height: 90px; }
.lb-vol-slot { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.lb-vol-bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); }
.lb-vol-axis { display: flex; justify-content: space-between; margin-top: 7px; font-size: 10.5px; color: #c0c4cd; }
.lb-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.lb-wf-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.lb-wf-row .k { font-size: 12.5px; color: #344054; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-wf-row .c { font-size: 12px; color: #98a2b3; white-space: nowrap; }
.lb-wf-row .v { font-size: 12px; font-weight: 600; color: var(--ok); width: 38px; text-align: right; }
.lb-link { font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.lb-link:hover { text-decoration: underline; }

/* Bottom panels */
.bt-panel { min-height: 0; padding: 20px 22px; display: block; }
.panel-head2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.panel-head2 h2 { font-size: 15px; font-weight: 700; }
.heatmap { display: flex; flex-direction: column; gap: 6px; }
.hm-row { display: flex; align-items: center; gap: 6px; }
.hm-day { width: 30px; font-size: 11px; color: #98a2b3; flex-shrink: 0; }
.hm-cells { display: flex; gap: 6px; flex: 1; }
.hm-col { flex: 1; text-align: center; font-size: 10.5px; color: #c0c4cd; }
.hm-cell {
  flex: 1; height: 26px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600; color: #5b4bd6;
}
.hm-cell.hot { color: #fff; }
.hm-cell.empty { background: #f6f6f8; color: #d3d5dd; }
.wfp-row {
  display: grid; grid-template-columns: 1.3fr 1.4fr 52px; gap: 12px;
  align-items: center; padding: 11px 0; border-bottom: 1px solid #f4f4f6;
}
.wfp-row:last-child { border-bottom: none; }
.wfp-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wfp-id .n { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wfp-id .m { font-size: 11.5px; color: #98a2b3; }
.wfp-pct { font-size: 13px; font-weight: 600; text-align: right; color: #344054; font-variant-numeric: tabular-nums; }

/* Mobile: leaderboard drops the avg-time/intake columns; detail stacks. */
@media (max-width: 860px) {
  .lb-grid { grid-template-columns: 24px 1.7fr 0.7fr 1.3fr 1fr 20px; gap: 10px; }
  .lb-hide-sm { display: none; }
  .lb-detail { grid-template-columns: 1fr; gap: 20px; }
  .lb-row, .lb-cols { padding-left: 14px; padding-right: 14px; }
  .lb-head { padding: 14px; }
}

/* ---------- monday.com column mapping (agent page redesign) ---------- */
.map-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.map-title { font-size: 13px; font-weight: 600; color: var(--text); }
.map-head .dim { font-size: 12px; }
.map-head button { padding: 5px 11px; font-size: 12.5px; color: var(--accent); border-color: #d6cdfb; }
.map-head button:hover { background: var(--accent-soft); }
.map-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.map-item {
  display: grid; grid-template-columns: 26px 150px 16px 1fr 92px;
  align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px;
  background: var(--panel); transition: border-color .15s ease, background .15s ease;
}
.map-item.mapped { border-color: #d6cdfb; background: #fdfcff; }
.map-ico {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: var(--bg); color: var(--dim);
  display: inline-flex; align-items: center; justify-content: center;
}
.map-item.mapped .map-ico { background: var(--accent-soft); color: var(--accent); }
.map-ico svg { width: 13px; height: 13px; }
.map-lbl { font-size: 13px; font-weight: 500; color: var(--text); }
.map-arrow { color: #c0c4cd; font-size: 13px; text-align: center; }
.map-item select { width: 100%; margin: 0; display: block; }
.map-type {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  color: #98a2b3; background: var(--bg); border-radius: 6px;
  padding: 4px 0; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-type.col { color: var(--accent); background: var(--accent-soft); }
.map-template-label { margin-top: 4px; }
.ph-row { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.ph-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; font-weight: 500; color: var(--accent);
  background: var(--accent-soft); border: none; border-radius: 999px; padding: 4px 10px;
}
.ph-chip:hover { background: #e6defc; color: var(--accent-strong); }
@media (max-width: 700px) {
  .map-item { grid-template-columns: 26px 1fr 82px; row-gap: 6px; }
  .map-arrow { display: none; }
  .map-item select { grid-column: 1 / -1; }
}

/* ---------- settings subpages + roles & permissions (issue 0036) ---------- */
/* Tab strip under the Settings h1: General · Credentials & numbers · Users & roles */
.subtabs { display: flex; gap: 6px; margin: -6px 0 18px; flex-wrap: wrap; }
.subtab {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  color: var(--dim); text-decoration: none;
}
.subtab:hover { background: #f0f0f4; color: var(--text); }
.subtab.active { background: var(--accent-soft); color: var(--accent); }

/* Users/roles tables: selects size to their cell, not the fieldset-wide 100% */
#usersTable select { width: auto; min-width: 120px; margin: 0; }
/* the fieldset-wide `select { width:100% }` would crush the new-role row */
#newRoleFrom { width: auto; flex: 0 0 auto; }
.matrix-title { font-weight: 600; margin: 14px 0 8px; }
#matrixTable td input:not([type=checkbox]) { display: inline-block; width: 240px; margin: 0 0 0 6px; }

/* ---------- mobile pass (issue 0036 follow-up) ----------
   The drawer nav (≤900px) and per-page grid collapses already exist above;
   this block closes the remaining gaps: form rows that overflowed, cramped
   touch targets, and header rows that couldn't wrap. */
/* Fieldsets default to min-width:min-content and refuse to shrink — a wide
   table inside would push the page sideways instead of scrolling in its
   .table-wrap. Applies at every width, matters on phones. */
fieldset { min-width: 0; }

@media (max-width: 700px) {
  .row { flex-wrap: wrap; }
  .row input { min-width: 0; flex: 1 1 160px; }
  .row button, .row select { flex: 0 0 auto; }
  fieldset { padding: 14px; }
  .panel-head, .panel-head2 { flex-wrap: wrap; gap: 8px; }
  /* comfortable tap targets for the small inline actions (✕, Edit, Overrides) */
  button.del-call { padding: 8px 12px; min-height: 36px; }
  button.tri { min-width: 44px; min-height: 36px; }
  .subtab { padding: 9px 13px; }
  /* users table: keep the role picker usable without forcing a wide cell */
  #usersTable select { min-width: 100px; }
  #matrixTable td input:not([type=checkbox]) { width: 140px; }
  .num-row { grid-template-columns: 1fr; gap: 4px; }
  .num-row select { width: 100%; }
}
#matrixTable td, #matrixTable th { text-align: center; }
#matrixTable td:first-child, #matrixTable th:first-child { text-align: left; white-space: nowrap; }
button.tri {
  min-width: 40px; padding: 3px 8px; font-size: 12px; color: var(--dim);
}
button.tri.allow { background: var(--ok-soft); color: var(--ok); }
button.tri.deny { background: var(--err-soft); color: var(--err); }
