/* ============================================================================
   Softphone — "Quiet" theme (v1.1)
   Warm off-white canvas, white panels on hairline borders, ink text, and one
   deep evergreen used sparingly for primary actions. No ornament: hierarchy
   comes from type, spacing and alignment.
   ========================================================================== */

   :root {
    /* Canvas */
    --bg: #f6f6f3;
    --shell: transparent;

    /* Surfaces */
    --surface: #ffffff;
    --surface2: #fafaf8;
    --surface3: #f1f1ed;
    --glass: rgba(255, 255, 255, 0.92);

    /* Lines */
    --border: #e6e5e0;
    --border2: #d7d6d0;

    /* Ink */
    --text: #1b1c1e;
    --text2: #62656b;
    --text3: #9c9fa5;

    /* Evergreen — primary action, selection, connected (historically "sage") */
    --sage: #2f6b57;
    --sage-d: #275a49;
    --sage-weak: rgba(47, 107, 87, 0.07);
    --sage-ring: rgba(47, 107, 87, 0.22);

    /* Brick — end call, destructive */
    --coral: #b94a3e;
    --coral-d: #a13f34;
    --coral-weak: rgba(185, 74, 62, 0.06);

    /* Slate — informational */
    --accent: #4a6178;
    --accent2: #5b5f86;
    --accent-weak: #f1f3f6;
    --accent-ring: rgba(74, 97, 120, 0.2);

    /* Semantic */
    --green: #2f7a58;
    --green-weak: rgba(47, 122, 88, 0.09);
    --red: #b94a3e;
    --red-2: #a13f34;
    --red-weak: rgba(185, 74, 62, 0.05);
    --amber: #a8701f;
    --cyan: #3d7a8a;
    --gold: #c9a45c;

    /* Geometry */
    --radius-lg: 12px;
    --radius: 10px;
    --radius-sm: 8px;

    /* Depth — barely there */
    --shadow-sm: 0 1px 1px rgba(27, 28, 30, 0.03);
    --shadow: 0 1px 2px rgba(27, 28, 30, 0.04);
    --shadow-lg: 0 18px 48px rgba(27, 28, 30, 0.14);

    --mono: 'DM Mono', ui-monospace, 'SF Mono', monospace;
    --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --serif: var(--sans);
  }

  /* Dark mode — graphite, same restraint. Toggled from the rail. */
  body.dark {
    --bg: #121315;
    --shell: transparent;
    --surface: #1a1b1e;
    --surface2: #17181a;
    --surface3: #222326;
    --glass: rgba(26, 27, 30, 0.92);
    --border: #2a2b2f;
    --border2: #36373c;
    --text: #ececee;
    --text2: #a3a5ab;
    --text3: #6c6f76;
    --sage: #5f9e86;
    --sage-d: #7fb39f;
    --sage-weak: rgba(95, 158, 134, 0.12);
    --sage-ring: rgba(95, 158, 134, 0.3);
    --coral: #d06a5d;
    --coral-d: #e08376;
    --coral-weak: rgba(208, 106, 93, 0.1);
    --accent: #8ea4bb;
    --accent-weak: rgba(142, 164, 187, 0.1);
    --green: #5f9e86;
    --green-weak: rgba(95, 158, 134, 0.12);
    --red-weak: rgba(208, 106, 93, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  svg.ic {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: block;
  }
  
  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 0.3s ease, color 0.3s ease;
  }
  .payer-row { display: flex; gap: 8px; margin-bottom: 10px; }
.payer-select {
  flex: 1; min-width: 0; padding: 10px 12px;
  background: var(--surface2, #fff); color: inherit;
  border: 1px solid var(--surface3, #ddd); border-radius: 10px;
  font: 500 13px/1.3 'Inter', sans-serif; cursor: pointer;
}
.payer-select:focus { outline: none; border-color: var(--sage, #2f6b57);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage, #2f6b57) 22%, transparent); }
.payer-select option { font-family: 'DM Mono', monospace; }
.btn-payer-refresh {
  flex: 0 0 auto; width: 38px; border: 1px solid var(--surface3, #ddd);
  border-radius: 10px; background: var(--surface2, #fff); color: inherit; cursor: pointer;
  display: grid; place-items: center;
}
.btn-payer-refresh:hover { border-color: var(--sage, #2f6b57); }

/* Line under the payer dropdown: how much work is queued, and a way in to the
   inventory panel. Looks like text, behaves like a link. */
.payer-hint {
  display: none;
  width: 100%;
  margin: -4px 0 10px;
  padding: 0 2px;
  border: none;
  background: none;
  text-align: left;
  font: 500 11px/1.4 var(--sans);
  color: var(--text2);
  cursor: pointer;
}
.payer-hint.show { display: block; }
.payer-hint:hover { color: var(--text); }
.payer-hint u { text-decoration-color: var(--border2); text-underline-offset: 2px; }

/* ── Patient inventory panel ─────────────────────────────────────────────────
   What the agent will dial, and how a tester replaces it with a spreadsheet. */
.inv-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(27, 28, 30, 0.42);
  backdrop-filter: blur(3px);
}
.inv-overlay.show { display: flex; }

.inv-panel {
  width: min(920px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.inv-head { display: flex; align-items: flex-start; gap: 12px; }
.inv-head-text { flex: 1; min-width: 0; }
.inv-title { font: 600 17px/1.2 var(--serif); color: var(--text); }
.inv-sub { margin-top: 3px; font: 500 11.5px/1.4 var(--sans); color: var(--text2); }
.inv-x {
  border: none;
  background: none;
  color: var(--text3);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.inv-x:hover { color: var(--text); }

.inv-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inv-actions .ivr-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  font-size: 11.5px;
}
.inv-actions .ivr-btn svg.ic { width: 13px; height: 13px; }
.inv-actions .ivr-btn.primary { color: #fff; }

.inv-drop {
  padding: 13px 15px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  background: var(--surface2);
  font: 500 11.5px/1.6 var(--sans);
  color: var(--text2);
}
.inv-drop strong { color: var(--text); font-weight: 600; }
.inv-drop.over { border-color: var(--sage); background: var(--sage-weak); color: var(--text); }
.inv-drop.busy { opacity: 0.6; }

.inv-result {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface2);
  font: 500 11.5px/1.6 var(--sans);
  color: var(--text);
}
.inv-result.ok { border-color: rgba(47, 122, 88, 0.4); background: var(--green-weak); }
.inv-result.warn { border-color: rgba(168, 112, 31, 0.42); background: rgba(168, 112, 31, 0.1); }
.inv-result.bad { border-color: rgba(185, 74, 62, 0.4); background: var(--red-weak); }
.inv-result-title { font-weight: 700; margin-bottom: 4px; }
.inv-result ul { margin: 6px 0 0; padding-left: 17px; color: var(--text2); }
.inv-result li { margin-bottom: 3px; }
.inv-result-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; }

.inv-filter { display: flex; gap: 8px; }
.inv-filter select,
.inv-filter input {
  padding: 8px 11px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: 500 12px/1.3 var(--sans);
}
.inv-filter select { flex: 0 0 auto; max-width: 45%; cursor: pointer; }
.inv-filter input { flex: 1; min-width: 0; }
.inv-filter select:focus,
.inv-filter input:focus { outline: none; border-color: var(--sage); }

.inv-table-wrap {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.inv-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.inv-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 11px;
  background: var(--surface3);
  border-bottom: 1px solid var(--border2);
  text-align: left;
  font: 600 10px/1.2 var(--sans);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text2);
  white-space: nowrap;
}
.inv-table td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-table tbody tr:hover td { background: var(--surface2); }
.inv-table .mono { font-family: var(--mono); font-size: 11px; }
.inv-table .dim { color: var(--text3); }
.inv-table .num { color: var(--text3); text-align: right; width: 34px; }
.inv-empty { padding: 26px 14px; text-align: center; color: var(--text3); font-size: 12px; }
.inv-group td {
  background: var(--surface3);
  font: 600 10.5px/1.2 var(--sans);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text2);
}
  
  /* ── App frame ───────────────────────────────────────────────────────────── */
  .app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 14px 18px 18px;
    gap: 12px;
  }
  
  /* ── Top bar ─────────────────────────────────────────────────────────────── */
  .topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    padding: 0 4px;
  }
  
  .tile {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-weak);
    color: var(--accent);
    flex-shrink: 0;
  }
  
  .tile svg.ic {
    width: 20px;
    height: 20px;
  }
  
  .tile.sm {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }
  
  .tile.sage {
    background: var(--sage-weak);
    color: var(--sage-d);
  }
  
  .wordmark {
    font-family: var(--serif);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--text);
  }

  .app-version {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 500;
    color: var(--text3);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 9px;
    white-space: nowrap;
  }
  
  .reg-pill {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    color: var(--text2);
    font-family: var(--sans);
    font-size: 13px;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  
  .reg-pill:hover {
    border-color: var(--border2);
    box-shadow: var(--shadow);
  }
  
  .reg-pill .chev {
    color: var(--text3);
    display: flex;
  }
  
  .reg-pill .chev svg.ic {
    width: 15px;
    height: 15px;
  }
  
  .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
  }
  
  .logs-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text2);
    font-family: var(--sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
  }
  
  .logs-fab:hover {
    color: var(--text);
    border-color: var(--border2);
    box-shadow: var(--shadow);
  }
  
  .logs-fab svg.ic {
    width: 15px;
    height: 15px;
    color: var(--text3);
  }
  
  .logs-fab.active {
    background: var(--accent-weak);
    border-color: var(--accent-ring);
    color: var(--accent);
  }
  
  .logs-fab.active svg.ic {
    color: var(--accent);
  }
  
  .me {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  
  .avatar {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #2c2d30;
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .avatar::after {
    content: '';
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--green);
    border: 2px solid var(--bg);
  }
  
  .me-state {
    font-size: 13px;
    color: var(--text2);
  }
  
  /* ── Body: rail + workspace shell ────────────────────────────────────────── */
  .frame {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 14px;
  }
  
  .rail {
    width: 66px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
    gap: 8px;
  }
  
  .rail-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 13px;
    background: none;
    color: var(--text3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  
  .rail-btn svg.ic {
    width: 20px;
    height: 20px;
  }
  
  .rail-btn:hover {
    background: var(--surface3);
    color: var(--text2);
  }
  
  .rail-btn.active {
    background: var(--accent-weak);
    color: var(--accent);
  }
  
  .rail-btn:focus-visible,
  button:focus-visible,
  a:focus-visible,
  input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  
  .rail-btn { position: relative; }
  
  .tab-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--coral);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    box-sizing: content-box;
  }
  
  .rail-spacer {
    flex: 1;
  }
  
  .rail-btn.ghost {
    background: var(--surface3);
    color: var(--text2);
  }
  
  .rail-btn.ghost:hover {
    color: var(--text);
  }
  
  /* ── Workspace: Dialer | IVR (+ optional Logs) ───────────────────────────── */
  .workspace {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: 400px minmax(320px, 1fr);
    gap: 16px;
    padding: 16px;
    background: var(--shell);
    border: 1px solid var(--border);
    border-radius: 24px;
    align-items: stretch;
    position: relative;
    overflow: hidden;
  }
  
  /* Botanical signature — a single quiet flourish behind the dialer. */
  .decor {
    position: absolute;
    left: -34px;
    bottom: -20px;
    width: 240px;
    pointer-events: none;
    opacity: 0.5;
    z-index: 0;
  }
  
  /* Hidden until the Logs button asks for it. Scoped to .workspace so it outranks
     the generic `.col { display: flex }` below — same specificity would lose on
     source order and the column would never actually hide. */
  .workspace .col-debug {
    display: none;
  }
  
  @media (min-width: 1180px) {
    .workspace.show-logs {
      grid-template-columns: 400px minmax(300px, 1fr) 356px;
    }
  }
  
  @keyframes slideInRight {
    from { opacity: 0; transform: translateX(14px); }
    to { opacity: 1; transform: translateX(0); }
  }
  
  .workspace.show-logs .col-debug {
    display: flex;
    animation: slideInRight 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }
  
  @keyframes colPop {
    0% { transform: scale(0.99); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
  }
  
  .col-pop {
    animation: colPop 0.34s cubic-bezier(0.22, 1, 0.36, 1);
  }
  
  .col {
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
  }
  
  .col-phone {
    overflow-y: auto;
    scrollbar-width: thin;
  }
  
  @media (max-width: 1179px) {
    body { overflow: auto; height: auto; }
    .app { height: auto; min-height: 100vh; }
    .frame { flex-direction: column; }
    .rail {
      width: 100%;
      flex-direction: row;
      justify-content: flex-start;
      padding: 8px 12px;
    }
    .rail-spacer { flex: 1; }
    .workspace {
      grid-template-columns: 1fr;
      height: auto;
    }
    .col-phone { overflow-y: visible; }
    .col-ivr, .col-debug { height: 560px; }
    .workspace.show-logs .col-debug { display: flex; }
    .decor { display: none; }
  }
  
  /* ── Card chrome (shared by all three panels) ────────────────────────────── */
  .card {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
  }
  
  .card-head {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 18px 20px;
    flex-shrink: 0;
  }
  
  .card-head .head-text {
    min-width: 0;
    flex: 1;
  }
  
  .card-title {
    font-family: var(--serif);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.1px;
    line-height: 1.2;
  }
  
  .card-sub {
    font-size: 12px;
    color: var(--text3);
    margin-top: 2px;
  }
  
  /* Status pills in card headers */
  .pill {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text2);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
  }
  
  .pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text3);
  }
  
  /* Registration dot (id=connDot) — also used inside the top bar pill */
  .brand-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text3);
    flex-shrink: 0;
    transition: all 0.3s;
  }
  
  .brand-dot.connected {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-weak);
  }
  
  .brand-dot.connecting {
    background: var(--amber);
    animation: blink 1s infinite;
  }
  
  .reg-badge {
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--text2);
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .reg-badge.ok { color: var(--text); }
  .reg-badge.fail { color: var(--red-2); }
  
  @keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
  }
  
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  @keyframes ringPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
  }
  
  @keyframes timerTick {
    from { opacity: 0.65; }
    to { opacity: 1; }
  }
  
  /* ── SSL trust banner ────────────────────────────────────────────────────── */
  .ssl-banner {
    display: none;
    margin: 0 20px 14px;
    padding: 13px 15px;
    background: rgba(168, 112, 31, 0.08);
    border: 1px solid rgba(168, 112, 31, 0.28);
    border-radius: var(--radius);
  }
  
  .ssl-banner.show {
    display: block;
    animation: slideDown 0.25s ease;
  }
  
  .ssl-banner-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--amber);
    margin-bottom: 5px;
  }
  
  .ssl-banner-text,
  .ssl-banner-steps {
    font-size: 11.5px;
    color: var(--text2);
    margin-bottom: 9px;
    line-height: 1.6;
  }
  
  .ssl-banner-steps {
    padding-left: 12px;
  }
  
  .btn-trust {
    width: 100%;
    padding: 9px;
    background: var(--amber);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    font-family: var(--sans);
    cursor: pointer;
    transition: filter 0.15s;
  }
  
  .btn-trust:hover { filter: brightness(1.06); }
  
  .btn-trust-done {
    width: 100%;
    padding: 8px;
    margin-top: 7px;
    background: none;
    color: var(--sage-d);
    border: 1px solid var(--sage-ring);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    transition: background 0.15s;
  }
  
  .btn-trust-done:hover { background: var(--sage-weak); }
  
  /* ── Panels inside the phone card ────────────────────────────────────────── */
  .tab-panel {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
  }
  
  .tab-panel.active {
    display: flex;
  }
  
  /* ── Dial input ──────────────────────────────────────────────────────────── */
  .dialpad {
    padding: 0 20px 14px;
  }
  
  .dialpad-input-row {
    position: relative;
    margin-bottom: 12px;
  }
  
  .dialpad-input {
    width: 100%;
    padding: 14px 46px 14px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  
  .dialpad-input::placeholder {
    color: var(--text3);
    font-family: var(--sans);
  }
  
  .dialpad-input:focus {
    border-color: var(--sage);
    box-shadow: 0 0 0 3px var(--sage-ring);
  }
  
  .btn-backspace {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  
  .btn-backspace:hover {
    background: var(--surface3);
    color: var(--text);
  }
  
  /* ── Keys ────────────────────────────────────────────────────────────────── */
  .keys {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 9px;
  }
  
  .key {
    aspect-ratio: 2.15;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 600;
    font-family: var(--sans);
    transition: all 0.12s ease;
    user-select: none;
    position: relative;
    overflow: hidden;
  }
  
  .key sub {
    font-size: 8px;
    letter-spacing: 1.4px;
    color: var(--text3);
    font-weight: 500;
    line-height: 1;
    margin-top: 3px;
    font-family: var(--sans);
  }
  
  .key:hover {
    background: var(--surface);
    border-color: var(--sage-ring);
    color: var(--sage-d);
    box-shadow: 0 4px 14px rgba(47, 107, 87, 0.16);
  }
  
  .key:hover sub { color: var(--sage); }
  
  .key:active {
    transform: scale(0.97);
    background: var(--sage-weak);
  }
  
  /* Agent-driven key press */
  @keyframes agentPress {
    0% { transform: scale(1); }
    40% { transform: scale(0.9); }
    100% { transform: scale(1); }
  }
  
  .key.agent-press {
    animation: agentPress 0.24s ease;
    background: var(--sage);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px rgba(39, 90, 73, 0.4);
  }
  
  .key.agent-press sub { color: rgba(255, 255, 255, 0.75); }
  
  /* ── Volume ──────────────────────────────────────────────────────────────── */
  .volume-row {
    padding: 14px 20px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .volume-label,
  .volume-max {
    display: flex;
    align-items: center;
    color: var(--text3);
  }
  
  .volume-label svg.ic,
  .volume-max svg.ic {
    width: 17px;
    height: 17px;
  }
  
  .volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--sage) 0%, var(--surface3) 100%);
    outline: none;
  }
  
  .volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--sage);
    border: 2px solid var(--surface);
    box-shadow: 0 1px 5px rgba(39, 90, 73, 0.5);
    cursor: pointer;
  }
  
  .volume-slider::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--sage);
    border: 2px solid var(--surface);
    cursor: pointer;
  }
  
  /* ── Action buttons ──────────────────────────────────────────────────────── */
  .actions {
    padding: 0 20px 14px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
  
  .action-btn {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 2px;
    transition: all 0.15s;
  }
  
  .action-btn .ico {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .action-btn svg.ic {
    width: 18px;
    height: 18px;
  }
  
  .action-btn span.label {
    font-size: 9.5px;
    font-weight: 600;
    font-family: var(--sans);
    letter-spacing: 0.2px;
    color: var(--text3);
  }
  
  .action-btn:hover:not(:disabled) {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border2);
  }
  
  .action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
  }
  
  .action-btn.active {
    background: var(--sage-weak);
    border-color: var(--sage-ring);
    color: var(--sage-d);
  }
  
  .action-btn.active span.label { color: var(--sage-d); }
  
  .action-btn.danger {
    background: var(--coral-weak);
    border-color: rgba(185, 74, 62, 0.4);
    color: var(--coral-d);
  }
  
  .action-btn.danger span.label { color: var(--coral-d); }
  
  /* ── Call / End ──────────────────────────────────────────────────────────── */
  .call-row {
    padding: 0 20px 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  
  .btn-call {
    padding: 15px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-family: var(--sans);
    font-weight: 700;
    font-size: 15px;
    color: #fff;
  }
  
  .btn-call svg.ic { width: 17px; height: 17px; }
  
  .btn-call:active { transform: scale(0.985); }
  
  .btn-call:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }
  
  .btn-dial {
    background: var(--sage);
    box-shadow: 0 8px 20px rgba(39, 90, 73, 0.24);
  }
  
  .btn-dial:hover:not(:disabled) {
    filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(39, 90, 73, 0.3);
  }
  
  .btn-hangup {
    background: var(--coral);
    box-shadow: 0 8px 20px rgba(161, 63, 52, 0.22);
  }
  
  .btn-hangup:hover:not(:disabled) {
    filter: brightness(1.05);
    box-shadow: 0 10px 24px rgba(161, 63, 52, 0.28);
  }
  
  /* ── Record ──────────────────────────────────────────────────────────────── */
  .record-row {
    padding: 0 20px 16px;
  }
  
  .btn-record {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text2);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition: all 0.15s;
  }
  
  .btn-record:hover:not(:disabled) {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border2);
  }
  
  .btn-record:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  .btn-record.recording {
    background: var(--coral-weak);
    border-color: rgba(185, 74, 62, 0.45);
    color: var(--coral-d);
  }
  
  .rec-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
  }
  
  .btn-record.recording .rec-dot {
    animation: blink 0.8s infinite;
  }
  
  /* ── Live call readout ───────────────────────────────────────────────────── */
  .display {
    padding: 0 20px 4px;
    display: none;
    flex-direction: column;
  }
  
  .display.show { display: flex; }
  
  .number-display {
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 1px;
    min-height: 30px;
    display: flex;
    align-items: center;
  }
  
  .number-display .placeholder {
    color: var(--text3);
    font-size: 14px;
    letter-spacing: 0;
    font-family: var(--sans);
  }
  
  .number-display.agent-keying { color: var(--sage-d); }
  
  .number-display .keying {
    color: var(--sage-d);
    font-weight: 600;
    letter-spacing: 2px;
  }
  
  .number-display .keying::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 0.95em;
    margin-left: 5px;
    background: var(--sage);
    vertical-align: -1px;
    animation: blink 0.9s steps(1) infinite;
  }
  
  .call-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    min-height: 18px;
  }
  
  .call-status-text {
    font-size: 12px;
    color: var(--text2);
  }
  
  .call-timer {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--sage-d);
    display: none;
    animation: timerTick 1s infinite alternate;
  }
  
  .call-direction {
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 700;
    display: none;
  }
  
  .call-direction.outgoing {
    background: var(--accent-weak);
    color: var(--accent);
  }
  
  .call-direction.incoming {
    background: var(--green-weak);
    color: var(--green);
  }
  
  /* ── Card footers ────────────────────────────────────────────────────────── */
  .card-foot {
    margin-top: auto;
    padding: 13px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
  }
  
  .card-foot .foot-ic {
    color: var(--sage);
    display: flex;
    flex-shrink: 0;
  }
  
  .foot-label {
    font-size: 11px;
    color: var(--text3);
    line-height: 1.35;
  }
  
  .status-bar {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 500;
    color: var(--sage-d);
    line-height: 1.35;
    word-break: break-all;
  }
  
  .status-bar.error { color: var(--red-2); }
  .status-bar.success { color: var(--sage-d); }
  .status-bar.info { color: var(--accent); }
  
  .meta-foot {
    padding: 11px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--text3);
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
  }
  
  .meta-foot span {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  
  .meta-foot svg.ic { width: 12px; height: 12px; }
  
  #ivrCount { color: var(--text2); }
  #logCount { color: var(--text2); }
  
  /* ── Settings panel ──────────────────────────────────────────────────────── */
  .config-panel {
    padding: 0 20px 18px;
    overflow-y: auto;
  }
  
  .field {
    margin-bottom: 12px;
  }
  
  .field label {
    display: block;
    font-size: 10px;
    color: var(--text3);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-family: var(--sans);
    font-weight: 600;
  }
  
  .field input {
    width: 100%;
    padding: 11px 13px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: var(--mono);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  
  .field input:focus {
    border-color: var(--sage);
    box-shadow: 0 0 0 3px var(--sage-ring);
  }
  
  .field .check {
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-size: 12.5px;
    color: var(--text2);
    font-weight: 500;
  }
  
  .field .check input {
    width: auto;
    accent-color: var(--sage);
  }
  
  .btn-connect {
    width: 100%;
    padding: 13px;
    background: var(--sage);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    font-family: var(--sans);
    box-shadow: 0 8px 20px rgba(39, 90, 73, 0.24);
    transition: filter 0.15s, transform 0.1s;
  }
  
  .btn-connect:hover { filter: brightness(1.05); }
  .btn-connect:active { transform: scale(0.99); }
  
  /* ── History ─────────────────────────────────────────────────────────────── */
  .history-list,
  .recordings-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 12px 12px;
  }
  
  .history-item {
    padding: 11px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
    animation: slideDown 0.2s ease;
  }
  
  .history-item:hover { background: var(--surface2); }
  
  .history-icon {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .history-icon svg.ic { width: 15px; height: 15px; }
  
  .history-icon.out {
    background: var(--accent-weak);
    color: var(--accent);
  }
  
  .history-icon.in {
    background: var(--sage-weak);
    color: var(--sage-d);
  }
  
  .history-icon.missed {
    background: var(--coral-weak);
    color: var(--coral-d);
  }
  
  .history-info {
    flex: 1;
    min-width: 0;
  }
  
  .history-number {
    font-family: var(--mono);
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .history-meta {
    font-size: 11px;
    color: var(--text3);
    margin-top: 3px;
    display: flex;
    gap: 8px;
  }
  
  .history-recall {
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: var(--text3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
  }
  
  .history-recall svg.ic { width: 14px; height: 14px; }
  
  .history-recall:hover {
    border-color: var(--sage);
    color: var(--sage-d);
    background: var(--sage-weak);
  }
  
  /* ── Recordings ──────────────────────────────────────────────────────────── */
  .rec-item {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    background: var(--surface2);
    animation: slideDown 0.2s ease;
  }
  
  .rec-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }
  
  .rec-number {
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text2);
  }
  
  .rec-number svg.ic { width: 14px; height: 14px; color: var(--text3); }
  
  .rec-meta {
    font-size: 10.5px;
    color: var(--text3);
  }
  
  .rec-item audio {
    width: 100%;
    height: 32px;
    margin-bottom: 8px;
  }
  
  .rec-item-actions { display: flex; gap: 8px; }
  
  .btn-dl {
    flex: 1;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text2);
    text-decoration: none;
    font-size: 11.5px;
    font-weight: 600;
    font-family: var(--sans);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
  }
  
  .btn-dl svg.ic { width: 13px; height: 13px; }
  
  .btn-dl:hover {
    background: var(--sage-weak);
    border-color: var(--sage-ring);
    color: var(--sage-d);
  }
  
  /* ── Empty states (shared) ───────────────────────────────────────────────── */
  .empty {
    margin: auto;
    padding: 24px 28px;
    text-align: center;
    animation: fadeIn 0.3s ease;
  }
  
  .empty-art {
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: var(--surface3);
    color: var(--text3);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .empty-art svg { width: 30px; height: 30px; }
  
  .empty-title {
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 7px;
  }
  
  .empty-text {
    font-size: 12.5px;
    color: var(--text3);
    line-height: 1.65;
    max-width: 260px;
    margin: 0 auto;
  }
  
  .empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--text3);
    font-size: 13px;
  }
  
  /* ── IVR panel ───────────────────────────────────────────────────────────── */
  .ivr-now {
    margin: 0 20px 14px;
    padding: 13px 15px;
    background: var(--accent-weak);
    border-radius: var(--radius);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text2);
    display: flex;
    align-items: center;
    gap: 11px;
    flex-shrink: 0;
  }
  
  .ivr-now .now-ic {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .ivr-now .now-ic svg.ic { width: 13px; height: 13px; }

  #ivrNow { flex: 1; min-width: 0; }

  /* Call ID chip — the id testers quote in bug reports. */
  .call-id {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
    padding: 4px 4px 4px 12px;
    background: var(--surface);
    border: 1.5px solid var(--accent);
    border-radius: 999px;
    color: var(--text2);
    cursor: pointer;
    font: inherit;
  }
  .call-id[hidden] { display: none; }
  .call-id:hover { box-shadow: 0 0 0 3px var(--accent-ring); }
  .call-id-k {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text3);
  }
  .call-id-v {
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--accent);
    user-select: all;
  }
  .call-id-copy {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-family: var(--sans);
    font-size: 11.5px;
    font-weight: 600;
  }
  .call-id svg.ic { width: 13px; height: 13px; }
  .call-id.copied .call-id-copy { background: var(--green); }


  .history-callid {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--accent);
    background: var(--accent-weak);
    border: none;
    border-radius: 6px;
    padding: 1px 6px;
    cursor: pointer;
  }
  
  .ivr-timeline {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
  }
  
  /* Entries read as a two-sided transcript inside the IVR timeline:
     the payer's IVR speaks on the LEFT, our agent answers on the RIGHT, and
     session events (start/stop/handoff/errors) span the full width as dividers.
     Bubbles hug their content and stop at 88% so the two sides stay legible. */
  .ivr-entry {
    border: 1px solid var(--border);
    border-left: 3px solid var(--text3);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    background: var(--surface2);
    animation: slideDown 0.2s ease;
    flex-shrink: 0;
    max-width: 88%;
    align-self: flex-start;
  }
  
  /* ── Agent side (right) ── */
  .ivr-entry.spoke,
  .ivr-entry.dtmf,
  .ivr-entry.wait {
    align-self: flex-end;
    border-left-width: 1px;
    border-left-color: var(--border);
    border-right-width: 3px;
    border-right-style: solid;
  }
  
  /* Role label hugs the outer edge on the agent side. */
  .ivr-entry.spoke .ivr-entry-head,
  .ivr-entry.dtmf .ivr-entry-head,
  .ivr-entry.wait .ivr-entry-head {
    flex-direction: row-reverse;
  }
  
  /* ── Session events (full width) ── */
  .ivr-entry.system,
  .ivr-entry.error,
  .ivr-entry.handoff {
    align-self: stretch;
    max-width: 100%;
  }
  
  .ivr-entry-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
  }
  
  .ivr-role {
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
  }
  
  .ivr-time {
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text3);
    flex-shrink: 0;
  }
  
  .ivr-entry-body {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
    word-break: break-word;
  }
  
  /* IVR — left */
  .ivr-entry.heard { border-left-color: var(--cyan); }
  .ivr-entry.heard .ivr-role { color: var(--cyan); }
  .ivr-entry.heard .ivr-entry-body { color: #2e7285; font-style: italic; }
  
  /* Agent — right */
  .ivr-entry.spoke {
    border-right-color: var(--accent2);
    background: rgba(91, 95, 134, 0.06);
  }
  .ivr-entry.spoke .ivr-role { color: var(--accent2); }
  .ivr-entry.spoke .ivr-entry-body { color: #6b52c4; }
  
  .ivr-entry.dtmf {
    border-right-color: var(--sage);
    background: var(--sage-weak);
  }
  .ivr-entry.dtmf .ivr-role { color: var(--sage-d); }
  .ivr-entry.dtmf .ivr-entry-body { color: var(--sage-d); font-family: var(--mono); }
  
  .ivr-entry.wait {
    border-right-color: var(--amber);
    background: rgba(168, 112, 31, 0.07);
  }
  .ivr-entry.wait .ivr-role { color: var(--amber); }
  .ivr-entry.wait .ivr-entry-body { color: var(--amber); }
  
  /* Session events — full width */
  .ivr-entry.handoff {
    border-left-color: var(--sage);
    background: var(--sage-weak);
  }
  .ivr-entry.handoff .ivr-role { color: var(--sage-d); }
  
  .ivr-entry.system { border-left-color: var(--accent); }
  .ivr-entry.system .ivr-role { color: var(--accent); }
  .ivr-entry.system .ivr-entry-body { color: var(--text2); }
  
  .ivr-entry.error { border-left-color: var(--red); }
  .ivr-entry.error .ivr-role { color: var(--red); }
  .ivr-entry.error .ivr-entry-body { color: var(--red-2); }
  
  .ivr-state {
    font-family: var(--sans);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text3);
    padding: 6px 11px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 999px;
    white-space: nowrap;
  }
  
  .ivr-state.live {
    color: var(--sage-d);
    background: var(--sage-weak);
    border-color: var(--sage-ring);
  }
  
  .ivr-state.done {
    color: var(--accent);
    background: var(--accent-weak);
    border-color: var(--accent-ring);
  }
  
  .ivr-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text3);
    flex-shrink: 0;
    transition: all 0.3s;
  }
  
  .ivr-dot.live {
    background: var(--sage);
    box-shadow: 0 0 0 3px var(--sage-weak);
    animation: blink 1.4s infinite;
  }
  
  .ivr-dot.done {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-weak);
    animation: none;
  }
  
  .ivr-btn,
  .debug-btn {
    padding: 6px 11px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text2);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    transition: all 0.15s;
  }
  
  .ivr-btn:hover,
  .debug-btn:hover {
    background: var(--surface3);
    border-color: var(--border2);
    color: var(--text);
  }
  
  .head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* ── Flagging a problem ──────────────────────────────────────────────────── */
  .ivr-btn.flag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--red-2);
    border-color: rgba(185, 74, 62, 0.28);
    background: var(--red-weak);
  }

  .ivr-btn.flag svg.ic { width: 12px; height: 12px; }

  .ivr-btn.flag:hover {
    background: rgba(185, 74, 62, 0.16);
    border-color: var(--red);
    color: var(--red-2);
  }

  .ivr-btn.flag.active {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
  }

  .ivr-btn.primary {
    background: var(--sage);
    border-color: var(--sage);
    color: #fff;
  }

  .ivr-btn.primary:hover { background: var(--sage-d); border-color: var(--sage-d); color: #fff; }
  .ivr-btn:disabled { opacity: 0.5; cursor: default; }

  .flag-form {
    margin: 0 20px 14px;
    padding: 13px 14px;
    background: var(--red-weak);
    border: 1px solid rgba(185, 74, 62, 0.26);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex-shrink: 0;
  }

  .flag-form-head {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--red-2);
  }

  .flag-x {
    margin-left: auto;
    border: none;
    background: none;
    color: var(--red-2);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
  }

  .flag-selects {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .flag-form select,
  .flag-form textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--sans);
    font-size: 12px;
    padding: 8px 9px;
  }

  .flag-form textarea { resize: vertical; line-height: 1.5; }
  .flag-form select:focus,
  .flag-form textarea:focus { outline: none; border-color: var(--red); }

  .flag-form-foot {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .flag-ctx {
    flex: 1;
    min-width: 0;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* AR call note: full width, reads as a document, not a chat bubble. */
  .ivr-entry.claim-note {
    align-self: stretch;
    max-width: 100%;
    border-left-color: var(--sage);
    background: var(--surface);
  }
  .ivr-entry.claim-note .ivr-role { color: var(--sage-d); }
  .ivr-entry.claim-note .ivr-entry-body {
    color: var(--text);
    user-select: text;
    white-space: pre-wrap;
  }
  .ivr-entry.claim-note.pending { border-left-color: var(--amber); }
  .ivr-entry.claim-note.pending .ivr-entry-body { color: var(--text2); }
  .ivr-entry.claim-note.failed { border-left-color: var(--red); }

  .claim-note-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
  }
  .claim-note-state { font-size: 11px; color: var(--text3); }
  .ivr-entry.claim-note.failed .claim-note-state { color: var(--red-2); }
  .claim-note-copy {
    font-size: 11px;
    font-weight: 600;
    color: var(--sage-d);
    background: var(--sage-weak);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 3px 10px;
    cursor: pointer;
    margin-left: auto;
  }
  .claim-note-copy:hover { border-color: var(--sage); }

  /* Flags live in the timeline alongside what the agent did, full width. */
  .ivr-entry.flag {
    align-self: stretch;
    max-width: 100%;
    border-left-color: var(--red);
    background: var(--red-weak);
  }

  .ivr-entry.flag.warning { border-left-color: var(--amber); background: rgba(168, 112, 31, 0.09); }
  .ivr-entry.flag.note    { border-left-color: var(--accent); background: var(--accent-weak); }

  .ivr-entry.flag .ivr-role { color: var(--red-2); }
  .ivr-entry.flag.warning .ivr-role { color: var(--amber); }
  .ivr-entry.flag.note .ivr-role { color: var(--accent); }
  .ivr-entry.flag .ivr-entry-body { color: var(--text); }

  .flag-tag {
    display: inline-block;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text2);
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 999px;
    padding: 1px 7px;
    margin-bottom: 5px;
  }

  .flag-thread {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .flag-comment {
    font-size: 11.5px;
    color: var(--text2);
    padding-left: 9px;
    border-left: 2px solid var(--border2);
    margin-top: 5px;
  }

  .flag-comment b { color: var(--text); font-weight: 600; margin-right: 5px; }

  .flag-comment-btn {
    align-self: flex-start;
    margin-top: 7px;
    padding: 3px 9px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 999px;
    color: var(--text2);
    font-family: var(--sans);
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
  }

  .flag-comment-btn:hover { color: var(--text); border-color: var(--text3); }
  
  .ivr-entry.flag.closed { opacity: 0.7; }

  /* ── My flags ─────────────────────────────────────────────────────────────── */
  .ivr-btn.my-flags { display: inline-flex; align-items: center; gap: 6px; }
  .mf-badge {
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--sage);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
  }

  .mf-panel { width: min(640px, 100%); height: min(720px, 100%); }

  .mf-filters { display: flex; flex-wrap: wrap; gap: 6px; }
  .mf-chip {
    padding: 5px 11px;
    border: 1px solid var(--border2);
    border-radius: 999px;
    background: var(--surface2);
    color: var(--text2);
    font: 600 11px/1.3 var(--sans);
    cursor: pointer;
  }
  .mf-chip span { margin-left: 3px; color: var(--text3); font-weight: 500; }
  .mf-chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
  .mf-chip.active span { color: inherit; opacity: 0.7; }

  .mf-list {
    flex: 1;
    min-height: 120px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
  }
  .mf-empty { padding: 28px 12px; text-align: center; color: var(--text2); font-size: 12px; line-height: 1.6; }

  .mf-card {
    display: flex;
    flex-direction: column;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--red);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .mf-card.warning { border-left-color: var(--amber); }
  .mf-card.note    { border-left-color: var(--accent); }
  .mf-card.resolved,
  .mf-card.dropped { background: var(--surface2); }
  .mf-card.unseen  { box-shadow: 0 0 0 2px var(--sage-ring); }

  .mf-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 6px; }
  .mf-top .flag-tag { margin-bottom: 0; }
  .mf-num { font-family: var(--mono); font-size: 11px; color: var(--text3); }
  .mf-sev {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--red-2);
  }
  .mf-card.warning .mf-sev { color: var(--amber); }
  .mf-card.note .mf-sev    { color: var(--accent); }
  .mf-new {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--sage-d);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  .mf-status {
    margin-left: auto;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 700;
    border: 1px solid var(--border2);
    color: var(--text2);
    background: var(--surface3);
  }
  .mf-status.open     { color: var(--red-2);  border-color: rgba(185, 74, 62, 0.3); background: var(--red-weak); }
  .mf-status.resolved { color: var(--sage-d); border-color: var(--sage-ring);       background: var(--sage-weak); }
  .mf-c .mf-status    { margin-left: 0; margin-right: 6px; padding: 0 7px; font-size: 9.5px; }

  .mf-note { font-size: 12.5px; line-height: 1.5; color: var(--text); word-break: break-word; }
  .mf-meta { margin-top: 5px; font-size: 11px; color: var(--text3); }
  .mf-outcome { margin-top: 8px; font-size: 11.5px; font-weight: 600; color: var(--text2); }
  .mf-outcome.resolved { color: var(--sage-d); }

  .mf-thread { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
  .mf-c {
    padding-left: 9px;
    border-left: 2px solid var(--border2);
    font-size: 11.5px;
    color: var(--text2);
    word-break: break-word;
  }
  .mf-c.st { border-left-color: var(--sage); }
  .mf-c b { color: var(--text); font-weight: 600; margin-right: 6px; }
  .mf-t { font-family: var(--mono); font-size: 10px; color: var(--text3); }

  @media (max-width: 600px) {
    .inv-overlay { padding: 0; }
    .mf-panel { height: 100%; border-radius: 0; padding: 14px 16px 16px; }
  }

  /* ── Logs panel ──────────────────────────────────────────────────────────── */
  .icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    border-radius: 8px;
    color: var(--text3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
  }
  
  .icon-btn:hover {
    background: var(--surface3);
    color: var(--text);
  }
  
  .log-filters {
    display: flex;
    gap: 6px;
    padding: 0 18px 14px;
    flex-wrap: wrap;
    flex-shrink: 0;
  }
  
  .chip {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text2);
    font-size: 11px;
    font-weight: 600;
    font-family: var(--sans);
    cursor: pointer;
    transition: all 0.15s;
  }
  
  .chip:hover {
    border-color: var(--border2);
    color: var(--text);
  }
  
  .chip.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--surface);
  }
  
  .debug-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 6px 8px;
    display: flex;
    flex-direction: column;
  }
  
  .log-entry {
    padding: 5px 12px;
    font-family: var(--mono);
    font-size: 11px;
    line-height: 1.6;
    display: flex;
    gap: 10px;
    border-left: 2px solid transparent;
    border-radius: 6px;
    animation: fadeIn 0.15s ease;
    flex-shrink: 0;
  }
  
  .log-entry:hover { background: var(--surface2); }
  
  .log-time {
    color: var(--text3);
    flex-shrink: 0;
    font-size: 10px;
    padding-top: 1px;
  }
  
  .log-tag {
    flex-shrink: 0;
    width: 40px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.4px;
    align-self: flex-start;
    margin-top: 2px;
    color: var(--text3);
    font-family: var(--sans);
  }
  
  .log-msg {
    color: var(--text2);
    flex: 1;
    word-break: break-word;
  }
  
  .log-entry.success { border-left-color: var(--sage); }
  .log-entry.success .log-tag { color: var(--sage-d); }
  
  .log-entry.error { border-left-color: var(--red); }
  .log-entry.error .log-tag { color: var(--red); }
  .log-entry.error .log-msg { color: var(--red-2); }
  
  .log-entry.warn { border-left-color: var(--amber); }
  .log-entry.warn .log-tag { color: var(--amber); }
  
  .log-entry.info { border-left-color: var(--accent); }
  .log-entry.info .log-tag { color: var(--accent); }
  
  .log-entry.ws,
  .log-entry.sip,
  .log-entry.ice,
  .log-entry.media { border-left-color: var(--border2); }
  
  .log-entry.dim { opacity: 0.6; }
  
  /* Chip filtering — hide everything the active chip doesn't match. */
  .debug-log[data-filter="info"] .log-entry:not(.info),
  .debug-log[data-filter="success"] .log-entry:not(.success),
  .debug-log[data-filter="sip"] .log-entry:not(.sip),
  .debug-log[data-filter="ws"] .log-entry:not(.ws),
  .debug-log[data-filter="error"] .log-entry:not(.error):not(.warn) {
    display: none;
  }
  
  .tip {
    margin: 0 16px 16px;
    padding: 12px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--text3);
    flex-shrink: 0;
  }
  
  .tip svg.ic {
    width: 14px;
    height: 14px;
    color: var(--gold);
    margin-top: 1px;
  }
  
  .tip b { color: var(--text2); font-weight: 600; }
  
  /* ── Incoming call ───────────────────────────────────────────────────────── */
  .incoming-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27, 28, 30, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
  }
  
  .incoming-overlay.show { display: flex; }
  
  .incoming-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 34px 30px;
    text-align: center;
    width: 312px;
    box-shadow: var(--shadow-lg);
    animation: ringPulse 1.5s infinite;
  }
  
  .incoming-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--sage-weak);
    color: var(--sage-d);
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .incoming-avatar svg { width: 32px; height: 32px; }
  
  .incoming-label {
    font-size: 10.5px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
    margin-bottom: 6px;
  }
  
  .incoming-number {
    font-family: var(--mono);
    font-size: 23px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 26px;
  }
  
  .incoming-actions {
    display: flex;
    gap: 22px;
    justify-content: center;
  }
  
  .btn-answer,
  .btn-reject {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .btn-answer svg.ic,
  .btn-reject svg.ic { width: 22px; height: 22px; }
  
  .btn-answer {
    background: var(--sage);
    box-shadow: 0 8px 20px rgba(39, 90, 73, 0.34);
  }
  
  .btn-reject {
    background: var(--coral);
    box-shadow: 0 8px 20px rgba(161, 63, 52, 0.34);
  }
  
  .btn-answer:hover,
  .btn-reject:hover {
    transform: scale(1.06);
    filter: brightness(1.05);
  }
  
  audio { display: none; }
  .rec-item audio { display: block; }
  
  /* ── Scrollbars ──────────────────────────────────────────────────────────── */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text3); }
  
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  /* ── Sign-in (login.html) ────────────────────────────────────────────────── */
  .login-body { overflow: auto; }

  .login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }

  .login-card {
    width: 100%;
    max-width: 396px;
    padding: 30px 30px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: login-rise 0.32s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  }

  @keyframes login-rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }

  .login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
  }

  .login-title {
    font-family: var(--serif);
    font-size: 25px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin-bottom: 7px;
  }

  .login-sub {
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text2);
    margin-bottom: 22px;
  }

  .login-card .field input { font-family: var(--sans); font-size: 13.5px; }
  .login-card .btn-connect { margin-top: 14px; }
  .login-card .btn-connect:disabled { filter: grayscale(0.4) brightness(0.98); cursor: default; }

  .login-msg {
    margin-top: 14px;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    line-height: 1.5;
    border: 1px solid transparent;
  }

  .login-msg.error {
    background: var(--red-weak);
    border-color: rgba(185, 74, 62, 0.28);
    color: var(--red-2);
  }

  .login-msg.warn {
    background: rgba(168, 112, 31, 0.12);
    border-color: rgba(168, 112, 31, 0.3);
    color: var(--amber);
  }

  .login-msg.ok {
    background: var(--sage-weak);
    border-color: var(--sage-ring);
    color: var(--sage-d);
  }

  .login-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--text3);
  }

  .login-foot svg.ic { width: 14px; height: 14px; }

  /* ── Signed-in strip in Settings ─────────────────────────────────────────── */
  .who-row {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    margin-bottom: 14px;
    background: var(--sage-weak);
    border: 1px solid var(--sage-ring);
    border-radius: var(--radius-sm);
  }

  .who-text { flex: 1; min-width: 0; }

  .who-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-weight: 600;
    color: var(--text3);
  }

  .who-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .btn-signout {
    padding: 7px 12px;
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: 999px;
    color: var(--text2);
    font: 600 12px var(--sans);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
  }

  .btn-signout:hover { color: var(--coral-d); border-color: var(--coral); }

  /* Assigned by the login — shown for reference, not for editing. */
  .field input[readonly] {
    background: var(--surface3);
    color: var(--text2);
    cursor: default;
  }

  .field input[readonly]:focus {
    border-color: var(--border);
    box-shadow: none;
  }

  .field-note {
    margin-top: -6px;
    margin-bottom: 12px;
    font-size: 11px;
    color: var(--text3);
  }
/* ============================================================================
   Quiet layer (v1.1)
   Structure for the theme above: an unadorned header, panels sitting straight
   on the canvas, and controls that only take colour when they mean something.
   ========================================================================== */

/* ── Header ────────────────────────────────────────────────────────────────── */
.app { padding: 12px 20px 20px; gap: 14px; }
.topbar { padding: 0; gap: 12px; min-height: 44px; }

.topbar .tile {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--surface);
}
.topbar .tile svg.ic { width: 16px; height: 16px; }
.wordmark { font-family: var(--sans); font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }

.app-version {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text3);
  border: none;
  border-left: 1px solid var(--border2);
  border-radius: 0;
  padding: 1px 0 1px 12px;
}

.reg-pill {
  margin-left: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  box-shadow: none;
}
.reg-pill:hover { box-shadow: none; }
.reg-badge { font-family: var(--sans); font-size: 12.5px; }

.logs-fab { padding: 7px 12px; border-radius: var(--radius-sm); box-shadow: none; font-weight: 500; }
.logs-fab:hover { box-shadow: none; }
.logs-fab.active { background: var(--surface3); color: var(--text); border-color: var(--border2); }

.avatar { width: 30px; height: 30px; font-size: 11.5px; background: #2c2d30; }
body.dark .avatar { background: #3a3b40; }

/* ── Frame ─────────────────────────────────────────────────────────────────── */
.frame { gap: 14px; }
.rail { box-shadow: none; border-radius: var(--radius-lg); padding: 10px 0; gap: 4px; }
.rail-btn { width: 38px; height: 38px; border-radius: var(--radius-sm); }
.rail-btn.active { background: var(--surface3); color: var(--text); }
.rail-btn.ghost { background: none; }
.rail-btn.ghost:hover { background: var(--surface3); }

.workspace { padding: 0; gap: 14px; background: none; border: none; border-radius: 0; overflow: visible; }
.decor { display: none; }

.card { box-shadow: var(--shadow); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { font-size: 12px; color: var(--text3); margin-top: 1px; }
.card-head .tile { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--surface3); color: var(--text2); }

.pill { border-radius: 6px; padding: 4px 9px; font-size: 11px; font-weight: 500; box-shadow: none; }

/* ── Controls ──────────────────────────────────────────────────────────────── */
.key { background: var(--surface); }
.key:hover { background: var(--surface2); border-color: var(--border2); color: var(--text); box-shadow: none; }
.key:hover sub { color: var(--text2); }
.key:active { background: var(--surface3); }
.key.agent-press { box-shadow: none; }

.btn-call { padding: 13px; font-weight: 600; font-size: 14px; }
.btn-dial, .btn-hangup,
.btn-dial:hover:not(:disabled), .btn-hangup:hover:not(:disabled) { box-shadow: none; filter: none; }
.btn-dial:hover:not(:disabled) { background: var(--sage-d); }
.btn-hangup:hover:not(:disabled) { background: var(--coral-d); }

.btn-connect { font-weight: 600; box-shadow: none; }
.btn-connect:hover:not(:disabled) { filter: none; background: var(--sage-d); }

.volume-slider { background: var(--surface3); }
.volume-slider::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--border2); background: var(--surface); }

.status-bar { font-family: var(--sans); font-size: 12.5px; word-break: normal; overflow-wrap: anywhere; }

.inv-title { font-family: var(--sans); font-weight: 600; font-size: 16px; }
.inv-overlay { background: rgba(27, 28, 30, 0.38); backdrop-filter: none; }

/* ── Sign-in ───────────────────────────────────────────────────────────────── */
.login-card { max-width: 400px; padding: 30px 30px 22px; border-radius: 14px; box-shadow: 0 1px 2px rgba(27, 28, 30, 0.04), 0 12px 32px rgba(27, 28, 30, 0.06); }
.login-brand .tile { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--text); color: var(--surface); }
.login-brand .tile svg.ic { width: 16px; height: 16px; }
.login-brand .app-version { margin-left: auto; }
.login-title { font-family: var(--sans); font-size: 21px; font-weight: 600; letter-spacing: -0.015em; }

@media (max-width: 600px) {
  .app { padding: 10px 12px 16px; }
  .app-version { display: none; }
}

/* ============================================================================
   IVR card — compact header, transcript-only timeline, router test marks
   ========================================================================== */

/* ── Header: one row ───────────────────────────────────────────────────────── */
.ivr-head { gap: 10px; padding: 10px 14px; margin-bottom: 10px; }
.ivr-head .head-text { flex: 0 0 auto; }
.ivr-head .card-title { white-space: nowrap; }
.ivr-head .head-actions { margin-left: auto; min-width: 0; gap: 7px; }
.ivr-head .ivr-btn { white-space: nowrap; flex-shrink: 0; }
.ivr-head .ivr-state {
  min-width: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 5px 10px;
}

/* Which agent mode is on. The sentence that used to sit under the title is its tooltip. */
.mode-chip {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface3);
  color: var(--text2);
  font-size: 10.5px;
  font-weight: 600;
  cursor: help;
}
.mode-chip.test { color: var(--amber); border-color: rgba(168, 112, 31, 0.3); background: rgba(168, 112, 31, 0.08); }

/* ── "More" menu ───────────────────────────────────────────────────────────── */
.more-wrap { position: relative; flex-shrink: 0; }
.ivr-btn.more { display: inline-flex; align-items: center; gap: 5px; }
.ivr-btn.more svg.ic { width: 11px; height: 11px; }
.ivr-btn.more[aria-expanded="true"] { background: var(--surface3); color: var(--text); border-color: var(--border2); }

.more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 250px;
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.more-menu[hidden] { display: none; }

.more-menu > button,
.more-check {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text);
  font: 500 12.5px/1.3 var(--sans);
  text-align: left;
  cursor: pointer;
}
.more-menu > button[hidden] { display: none; }
.more-menu > button:hover,
.more-menu > button:focus-visible,
.more-check:hover { background: var(--surface3); outline: none; }
.more-hint { margin-left: auto; color: var(--text3); font-size: 10.5px; font-weight: 400; }
.more-menu .mf-badge { margin-left: auto; }
.more-check { margin-top: 4px; padding-top: 9px; border-top: 1px solid var(--border); border-radius: 0 0 6px 6px; }
.more-check input { accent-color: var(--sage); }

/* ── Test-mode toolbar (only while an integrated test call is live) ────────── */
.gw-testbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
  margin: 0 14px 10px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
}
.gw-testbar[hidden] { display: none; }
.gw-testbar-k {
  margin-right: 2px;
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.ivr-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text2);
  font-size: 11.5px;
  cursor: pointer;
}
.ivr-check input { accent-color: var(--sage); }

/* ── Status strip ──────────────────────────────────────────────────────────── */
.ivr-now { margin: 0 14px 10px; padding: 8px 12px; }
.ivr-now.error { background: var(--red-weak); color: var(--red-2); }
.ivr-now.error .now-ic { background: var(--red); }

.call-review {
  flex-shrink: 0;
  padding: 5px 11px;
  border: 1.5px solid var(--border2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text2);
  font: 600 11.5px/1.2 var(--sans);
  cursor: pointer;
}
.call-review[hidden] { display: none; }
.call-review:hover { border-color: var(--accent); color: var(--accent); }

/* ── Report panel: tighter, and it can shrink to its title row ─────────────── */
.flag-form { margin: 0 14px 10px; padding: 9px 11px; gap: 7px; }
.flag-form-head { gap: 8px; }
.flag-form textarea { min-height: 44px; }
.flag-x { margin-left: 0; }
.flag-collapse {
  margin-left: auto;
  display: grid;
  place-items: center;
  padding: 2px;
  border: none;
  border-radius: 5px;
  background: none;
  color: var(--red-2);
  cursor: pointer;
}
.flag-collapse:hover { background: rgba(185, 74, 62, 0.12); }
.flag-collapse svg.ic { width: 14px; height: 14px; transition: transform 0.15s; }
.flag-draft { color: var(--text3); font-size: 10.5px; font-weight: 500; }
.flag-draft[hidden] { display: none; }

.flag-form.collapsed { padding: 6px 11px; cursor: pointer; }
.flag-form.collapsed > :not(.flag-form-head) { display: none; }
.flag-form.collapsed .flag-collapse svg.ic { transform: rotate(180deg); }

/* ── Transcript only ───────────────────────────────────────────────────────── */
.ivr-timeline { padding: 0 14px 14px; }
.ivr-timeline.transcript-only .ivr-entry:not(.t-line) { display: none; }

/* ── Router test: one row per utterance — label, tick / cross ──────────────── */
.ivr-entry.utt { max-width: 92%; min-width: 230px; }
.utt .ivr-entry-head { justify-content: flex-start; gap: 8px; }
.utt .ivr-time { margin-left: auto; }

/* Which engine answered the line: IVR = the IVR agent, REP = Nuval. */
.rt-chip {
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  font: 700 10px/1 var(--sans);
  letter-spacing: 0.6px;
  white-space: nowrap;
}
.rt-chip.ivr { color: var(--amber); background: rgba(168, 112, 31, 0.1); border-color: rgba(168, 112, 31, 0.28); }
.rt-chip.rep { color: var(--sage-d); background: var(--sage-weak); border-color: var(--sage-ring); }
.rt-chip.none { color: var(--text2); background: var(--surface3); border-color: var(--border2); }
.rt-chip.pending { color: var(--text3); background: none; border: 1px dashed var(--border2); }

.mk-group { display: inline-flex; gap: 4px; }
.mk {
  width: 24px;
  height: 24px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text3);
  cursor: pointer;
  transition: all 0.12s;
}
.mk svg { width: 13px; height: 13px; display: block; }
.mk.ok:hover:not(:disabled) { color: var(--green); border-color: var(--green); }
.mk.bad:hover:not(:disabled) { color: var(--red); border-color: var(--red); }
.mk.ok.on { background: var(--green); border-color: var(--green); color: #fff; }
.mk.bad.on { background: var(--red); border-color: var(--red); color: #fff; }
.mk:disabled { opacity: 0.4; cursor: default; }
.mk:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 1px; }

.ivr-entry.utt.marked-correct { border-left-color: var(--green); }
.ivr-entry.utt.marked-wrong { border-left-color: var(--red); background: var(--red-weak); }

.utt-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  color: var(--text2);
  font-size: 11px;
  font-style: normal;
}
.utt-foot[hidden] { display: none; }
.utt-foot.err { color: var(--red-2); }
.utt-foot button {
  padding: 2px 9px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text2);
  font: 600 10.5px/1.4 var(--sans);
  cursor: pointer;
}
.utt-foot button:hover { color: var(--text); border-color: var(--text3); }

/* Marked so far, in the card footer. */
.meta-foot { align-items: center; gap: 12px; }
.meta-foot span[hidden] { display: none; }
.mark-stats { gap: 10px; color: var(--text2); }
.mark-rest {
  padding: 2px 9px;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: var(--sage-weak);
  color: var(--sage-d);
  font: 600 10.5px/1.4 var(--sans);
  cursor: pointer;
}
.mark-rest:hover { border-color: var(--sage); }
.mark-rest:disabled { opacity: 0.5; cursor: default; }
