:root {
  --bg-0: #f3f6fb;
  --bg-1: #e7edf7;
  --bg-2: #dbe5f6;
  --bg-3: #cfdcf3;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-border: rgba(44, 79, 132, 0.18);
  --ink: #0f203e;
  --ink-soft: #2a3f67;
  --muted: #5f7498;
  --line: rgba(33, 68, 120, 0.18);
  --line-soft: rgba(33, 68, 120, 0.1);
  --primary: #2359c7;
  --primary-strong: #1b49a9;
  --primary-soft: #dbe7ff;
  --danger: #bf4242;
  --danger-soft: #fce9e9;
  --ok: #187a56;
  --ok-soft: #e8f7ef;
  --warn: #976d19;
  --warn-soft: #fff5da;
  --content-max: 1440px;
  --radius-card: 18px;
  --radius-input: 12px;
  --radius-button: 12px;
  --focus-ring: 0 0 0 3px rgba(35, 89, 199, 0.18);
  --shadow-soft: 0 14px 40px rgba(18, 40, 80, 0.08);
  --shadow-hover: 0 20px 55px rgba(16, 33, 68, 0.14);

  --icon-default: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMjQ0NzhmJyBzdHJva2Utd2lkdGg9JzInIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCc+PGNpcmNsZSBjeD0nMTInIGN5PScxMicgcj0nNycvPjwvc3ZnPg==");
  --icon-calls: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxNiAxNicgZmlsbD0nIzI0NDc4Zic+PHBhdGggZD0nTTMuNjU0IDEuMzI4YS42NzguNjc4IDAgMCAxIC43MzctLjE0MWwyLjUyMiAxLjAxYS42NzguNjc4IDAgMCAxIC4zNy40ODJsLjI5MSAyLjA4YS42NzguNjc4IDAgMCAxLS4xOTQuNTkzTDUuNiA3LjEzM2ExMS43NDUgMTEuNzQ1IDAgMCAwIDUuMjY3IDUuMjY3bDEuNzgxLTEuNzgxYS42NzguNjc4IDAgMCAxIC41OTMtLjE5NGwyLjA4LjI5MWEuNjc4LjY3OCAwIDAgMSAuNDgyLjM3bDEuMDEgMi41MjJhLjY3OC42NzggMCAwIDEtLjE0MS43MzdsLTEuMiAxLjJhMS43NDUgMS43NDUgMCAwIDEtMS44Ni40MzRjLTEuNS0uNS0zLjIxLTEuNDUtNC45My0zLjE3QzYuOTYgMTEuMDkgNi4wMSA5LjM4IDUuNTEgNy44OGExLjc0NSAxLjc0NSAwIDAgMSAuNDM0LTEuODZsMS4yLTEuMnonLz48L3N2Zz4=");
  --icon-ivr: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMjQ0NzhmJyBzdHJva2Utd2lkdGg9JzEuOScgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBzdHJva2UtbGluZWpvaW49J3JvdW5kJz48cmVjdCB4PSc1JyB5PSczJyB3aWR0aD0nMTQnIGhlaWdodD0nMTgnIHJ4PScyJy8+PGNpcmNsZSBjeD0nOScgY3k9JzgnIHI9JzEnLz48Y2lyY2xlIGN4PScxMicgY3k9JzgnIHI9JzEnLz48Y2lyY2xlIGN4PScxNScgY3k9JzgnIHI9JzEnLz48Y2lyY2xlIGN4PSc5JyBjeT0nMTInIHI9JzEnLz48Y2lyY2xlIGN4PScxMicgY3k9JzEyJyByPScxJy8+PGNpcmNsZSBjeD0nMTUnIGN5PScxMicgcj0nMScvPjxwYXRoIGQ9J00xMC41IDE2aDMnLz48L3N2Zz4=");
  --icon-automation: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMjQ0NzhmJyBzdHJva2Utd2lkdGg9JzEuOScgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBzdHJva2UtbGluZWpvaW49J3JvdW5kJz48Y2lyY2xlIGN4PSc2JyBjeT0nNicgcj0nMicvPjxjaXJjbGUgY3g9JzE4JyBjeT0nNicgcj0nMicvPjxjaXJjbGUgY3g9JzEyJyBjeT0nMTgnIHI9JzInLz48cGF0aCBkPSdNOCA2aDgnLz48cGF0aCBkPSdNNy40IDcuNWwzLjIgNy4yJy8+PHBhdGggZD0nTTE2LjYgNy41bC0zLjIgNy4yJy8+PC9zdmc+");
  --icon-api: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMjQ0NzhmJyBzdHJva2Utd2lkdGg9JzInIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCc+PHBhdGggZD0nTTggNSAzIDEybDUgNycvPjxwYXRoIGQ9J00xNiA1IDIxIDEybC01IDcnLz48cGF0aCBkPSdNMTMgMyAxMSAyMScvPjwvc3ZnPg==");
  --icon-ai: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMjQ0NzhmJyBzdHJva2Utd2lkdGg9JzEuOCcgc3Ryb2tlLWxpbmVjYXA9J3JvdW5kJyBzdHJva2UtbGluZWpvaW49J3JvdW5kJz48cGF0aCBkPSdNOSA0YTQgNCAwIDAgMC00IDR2M2E0IDQgMCAwIDAgMiAzLjQ2VjE4YTIgMiAwIDAgMCAyIDJoNmEyIDIgMCAwIDAgMi0ydi0zLjU0QTQgNCAwIDAgMCAxOSAxMVY4YTQgNCAwIDAgMC00LTR6Jy8+PHBhdGggZD0nTTkgMTJoNicvPjxwYXRoIGQ9J00xMCA4aDQnLz48L3N2Zz4=");
  --icon-notif: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyNCAyNCcgZmlsbD0nbm9uZScgc3Ryb2tlPScjMjQ0NzhmJyBzdHJva2Utd2lkdGg9JzEnIHN0cm9rZS1saW5lY2FwPSdyb3VuZCcgc3Ryb2tlLWxpbmVqb2luPSdyb3VuZCc+PHBhdGggZD0nTTE4IDhBNiA2IDAgMCAwIDYgOHY0YzAgMS4yLS44IDIuMy0yIDNsLTEgMWgxOGwtMS0xYy0xLjItLjctMi0xLjgtMi0zVjhaJy8+PHBhdGggZD0nTTEwIDE4YTIgMiAwIDAgMCA0IDAnLz48L3N2Zz4=");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

::selection {
  background: rgba(35, 89, 199, 0.24);
  color: #0a1b37;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", "Trebuchet MS", sans-serif;
  font-size: 15.5px;
  line-height: 1.45;
  background:
    radial-gradient(circle at -8% -22%, #c9dcfd 0%, transparent 43%),
    radial-gradient(circle at 102% -6%, #d0d7ff 0%, transparent 35%),
    linear-gradient(165deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 80%, var(--bg-3) 100%);
  overflow-x: clip;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0, rgba(255, 255, 255, 0.22) 50%, transparent 100%);
  opacity: 0.28;
  z-index: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-strong);
}

code {
  display: inline-block;
  padding: 0.08rem 0.38rem;
  border-radius: 7px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.65);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.9em;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8rem;
  padding: 0.82rem clamp(0.9rem, 2.4vw, 1.4rem);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 250, 255, 0.76);
  backdrop-filter: blur(12px) saturate(160%);
  box-shadow: 0 8px 28px rgba(26, 44, 88, 0.08);
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: 0.02em;
  color: #112c58;
  text-transform: uppercase;
}

.topbar .brand::before {
  content: "";
  width: 0.66rem;
  height: 0.66rem;
  border-radius: 999px;
  background: radial-gradient(circle at 36% 34%, #8dc3ff 0%, #2a74dd 70%);
  box-shadow: 0 0 0 2px rgba(45, 90, 160, 0.14);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-live-banner {
  border-color: rgba(151, 109, 25, 0.34);
  background: linear-gradient(145deg, rgba(255, 248, 224, 0.94), rgba(255, 242, 200, 0.92));
  color: #6a450e;
}

.top-live-banner.is-active {
  border-color: rgba(24, 122, 86, 0.34);
  background: linear-gradient(145deg, rgba(226, 248, 238, 0.94), rgba(214, 244, 229, 0.92));
  color: #0f5f3e;
}

.top-live-banner.is-ringing {
  border-color: rgba(191, 66, 66, 0.38);
  background: linear-gradient(145deg, rgba(255, 238, 238, 0.96), rgba(255, 226, 226, 0.94));
  color: #8d2a2a;
  animation: live-top-blink 1s ease-in-out infinite;
}

.topbar nav a,
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.74rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.65);
  color: #1d3970;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition:
    transform 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.topbar nav a:hover,
.nav-link:hover,
.topbar nav a.is-active,
.nav-link.is-active {
  border-color: rgba(42, 95, 190, 0.36);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.95), rgba(240, 248, 255, 0.92));
  color: var(--primary-strong);
  box-shadow: 0 7px 18px rgba(26, 67, 144, 0.12);
  transform: translateY(-1px);
}

.topbar nav a:focus-visible,
.nav-link:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.nav-icon {
  width: 0.93rem;
  height: 0.93rem;
  border-radius: 999px;
  flex: 0 0 0.93rem;
  background: center / contain no-repeat var(--icon-default);
}

.nav-calls .nav-icon {
  background-image: var(--icon-calls);
}

.nav-ivr .nav-icon {
  background-image: var(--icon-ivr);
}

.nav-automation .nav-icon {
  background-image: var(--icon-automation);
}

.nav-api .nav-icon {
  background-image: var(--icon-api);
}

.nav-ai .nav-icon {
  background-image: var(--icon-ai);
}

.nav-riva .nav-icon {
  background-image: var(--icon-api);
}

.notif-toggle .nav-icon {
  background-image: var(--icon-notif);
}

.notif-count {
  min-width: 1.45rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(191, 66, 66, 0.16);
  border: 1px solid rgba(191, 66, 66, 0.28);
  color: #7f2020;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.page {
  position: relative;
  z-index: 1;
  width: min(var(--content-max), calc(100% - 1.1rem));
  margin: 1rem auto 2.2rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.page > * {
  min-width: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  min-width: 0;
}

@media (min-width: 760px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Edit toggle button placed next to inputs */
.edit-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  padding: 0.28rem 0.46rem;
  border-radius: 8px;
  border: 1px solid rgba(33,68,120,0.08);
  background: rgba(255,255,255,0.9);
  cursor: pointer;
  font-size: 0.86rem;
}

.edit-toggle[aria-pressed="true"] {
  border-color: rgba(35,89,199,0.18);
  box-shadow: var(--focus-ring);
  background: linear-gradient(120deg, rgba(235,243,255,0.9), rgba(255,255,255,0.96));
}

.field-with-edit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Top marquee for urgent broadcasts */
.top-marquee {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  color: #122033;
  background: var(--warn-soft);
}
.top-marquee.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}
.top-marquee.is-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.top-marquee.is-live {
  animation: live-marquee-blink 1s ease-in-out infinite;
}
.top-marquee .marquee-text {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-marquee .marquee-action {
  margin-left: 12px;
  color: var(--primary-strong);
  text-decoration: underline;
}
.top-marquee .marquee-close {
  background: transparent;
  border: 0;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  color: inherit;
}

@keyframes live-top-blink {
  0% { box-shadow: 0 0 0 0 rgba(191, 66, 66, 0.00); transform: translateY(0); }
  50% { box-shadow: 0 0 0.75rem 0.08rem rgba(191, 66, 66, 0.26); transform: translateY(-1px); }
  100% { box-shadow: 0 0 0 0 rgba(191, 66, 66, 0.00); transform: translateY(0); }
}

@keyframes live-marquee-blink {
  0% { box-shadow: inset 0 0 0 rgba(0,0,0,0); }
  50% { box-shadow: inset 0 0 0.8rem rgba(191, 66, 66, 0.14); }
  100% { box-shadow: inset 0 0 0 rgba(0,0,0,0); }
}

.notif-center {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.9rem;
  background: rgba(8, 16, 32, 0.34);
  backdrop-filter: blur(3px);
}

.notif-center-card {
  width: min(760px, 100%);
  max-height: min(72vh, 640px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 16px;
  border: 1px solid rgba(43, 79, 130, 0.26);
  background: rgba(248, 252, 255, 0.96);
  box-shadow: 0 20px 48px rgba(12, 28, 58, 0.2);
  overflow: hidden;
}

.notif-center-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--line-soft);
}

.notif-center-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.notif-center-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.notif-list {
  overflow: auto;
  padding: 0.25rem 0.35rem;
}

.notif-item {
  border: 1px solid rgba(45, 77, 128, 0.18);
  border-radius: 12px;
  padding: 0.56rem 0.62rem;
  margin: 0.5rem;
  background: rgba(255, 255, 255, 0.88);
}

.notif-item.is-error {
  border-color: rgba(191, 66, 66, 0.33);
  background: rgba(252, 236, 236, 0.92);
}

.notif-item.is-warn {
  border-color: rgba(151, 109, 25, 0.33);
  background: rgba(255, 245, 218, 0.92);
}

.notif-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.46rem;
  color: var(--muted);
  font-size: 0.81rem;
  margin-bottom: 0.24rem;
}

.notif-item-message {
  color: var(--ink);
  line-height: 1.42;
}

.notif-item-link {
  display: inline-block;
  margin-top: 0.32rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.notif-empty {
  padding: 1rem;
  color: var(--muted);
}

.notif-center-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.62rem 0.9rem;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 0.86rem;
}

.card {
  position: relative;
  overflow: clip;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-card);
  padding: 1rem;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.89) 0%,
    rgba(251, 254, 255, 0.78) 100%
  );
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  transition:
    transform 0.28s ease,
    box-shadow 0.28s ease,
    border-color 0.28s ease;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

@media (hover: hover) {
  .card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: rgba(45, 84, 145, 0.25);
  }
}

h1,
h2,
h3 {
  margin-top: 0;
  color: #142f5d;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

h2 {
  margin-bottom: 0.9rem;
  font-size: clamp(1.1rem, 1.3vw, 1.34rem);
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 0.68rem;
}

.card h2::after {
  content: "";
  height: 2px;
  flex: 1 1 auto;
  min-width: 24px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(50, 94, 177, 0.34), rgba(50, 94, 177, 0));
}

/* Terminal form compact row */
.terminal-form-row {
  display: flex;
  gap: 0.9rem;
  align-items: flex-end;
}
.terminal-form-row .terminal-cmd-input {
  flex: 1 1 60%;
}
.terminal-form-row .terminal-cmd-select {
  flex: 0 0 320px;
}
.terminal-form-row select,
.terminal-form-row input[type="text"] {
  width: 100%;
}
.terminal-cmd-desc {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 6px;
}

/* Port description small text used on Dashboard */
.port-desc {
  display: inline-block;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 76%;
  text-align: right;
}

.repair-output pre {
  margin: 0;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.88rem;
  color: #10203a;
}

h3 {
  margin-bottom: 0.65rem;
  font-size: clamp(1rem, 1.15vw, 1.14rem);
}

p {
  margin-top: 0;
  color: var(--ink-soft);
}

.status-list {
  display: grid;
  gap: 0.5rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed rgba(33, 68, 120, 0.15);
}

.status-row span:first-child {
  color: #213f74;
  font-weight: 600;
}

.status-row span:last-child {
  max-width: 62%;
  text-align: right;
  color: #1d386a;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 0.24rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: #1a3563;
  font-size: 0.81rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill.is-good {
  border-color: rgba(29, 129, 86, 0.36);
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.is-bad {
  border-color: rgba(191, 66, 66, 0.38);
  background: var(--danger-soft);
  color: var(--danger);
}

.pill.is-warn {
  border-color: rgba(151, 109, 25, 0.4);
  background: var(--warn-soft);
  color: var(--warn);
}

/* Distinct pill styles for different ports */
.pill-at1 {
  border-color: rgba(24, 122, 86, 0.36);
  background: linear-gradient(180deg, rgba(225, 249, 235, 0.9), rgba(236, 253, 242, 0.9));
  color: #0f5f3e;
}
.pill-at2 {
  border-color: rgba(35, 89, 199, 0.36);
  background: linear-gradient(180deg, rgba(219, 231, 255, 0.9), rgba(235, 242, 255, 0.9));
  color: var(--primary-strong);
}
.pill-pcm {
  border-color: rgba(120, 80, 140, 0.28);
  background: linear-gradient(180deg, rgba(247, 240, 255, 0.95), rgba(252, 246, 255, 0.95));
  color: #5b3a84;
}

.stack {
  display: grid;
  gap: 0.8rem;
  min-width: 0;
}

.max-600 {
  max-width: 600px;
}

label {
  display: grid;
  gap: 0.38rem;
  color: #1e396a;
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  padding: 0.62rem 0.76rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(36, 89, 199, 0.55);
  box-shadow: var(--focus-ring);
  background: #fff;
}

input[disabled],
select[disabled],
textarea[disabled] {
  opacity: 0.8;
  cursor: not-allowed;
}

.checkbox-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-weight: 600;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.button-row.wrap {
  flex-wrap: wrap;
}

.ivr-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.ivr-toolbar-actions {
  justify-content: flex-end;
}

.ivr-actions-cell {
  min-width: 220px;
}

.ivr-empty {
  margin-bottom: 0;
}

.ivr-pagination {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.ivr-form-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: #173563;
  list-style: none;
}

.ivr-form-panel summary::-webkit-details-marker {
  display: none;
}

.ivr-form-panel summary::before {
  content: "+";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  margin-right: 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(32, 76, 152, 0.3);
  color: #1b4cb5;
  font-weight: 700;
  background: rgba(240, 247, 255, 0.9);
}

.ivr-form-panel[open] summary::before {
  content: "–";
}

.ivr-form-body {
  margin-top: 1rem;
}

.big-controls .btn {
  padding: 0.67rem 0.98rem;
}

.btn {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-button);
  cursor: pointer;
  padding: 0.5rem 0.86rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.23), rgba(255, 255, 255, 0));
  transition: opacity 0.22s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(24, 56, 116, 0.14);
}

.btn:hover::after {
  opacity: 1;
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-small {
  padding: 0.33rem 0.58rem;
  font-size: 0.82rem;
  border-radius: 10px;
}

.btn-primary {
  color: #fff;
  border-color: rgba(20, 62, 152, 0.45);
  background: linear-gradient(135deg, #2f6ee4 0%, #255bcf 58%, #214cb7 100%);
  box-shadow: 0 8px 18px rgba(35, 89, 199, 0.25);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-secondary {
  color: #163a74;
  border-color: rgba(34, 76, 141, 0.28);
  background: rgba(243, 248, 255, 0.95);
}

.btn-secondary:hover {
  background: rgba(229, 239, 255, 0.98);
}

.btn-danger {
  color: #fff;
  border-color: rgba(156, 44, 44, 0.35);
  background: linear-gradient(135deg, #ce4e4e 0%, #b74040 100%);
  box-shadow: 0 7px 18px rgba(180, 64, 64, 0.2);
}

.hint {
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.45;
}

.log-box {
  border: 1px solid rgba(117, 150, 201, 0.3);
  border-radius: 14px;
  background:
    linear-gradient(160deg, #101a2b 0%, #13233a 65%, #173057 100%);
  color: #d7edff;
  min-height: 300px;
  max-height: 430px;
  overflow-y: auto;
  padding: 0.8rem 0.86rem;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.38;
}

.flash-wrap {
  display: grid;
  gap: 0.5rem;
}

.flash {
  position: relative;
  border-radius: 12px;
  padding: 0.62rem 0.78rem;
  border: 1px solid transparent;
  font-weight: 600;
  overflow: hidden;
}

.flash::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: 999px;
  background: rgba(31, 77, 165, 0.5);
}

.flash-ok {
  background: var(--ok-soft);
  border-color: rgba(29, 129, 86, 0.36);
  color: #165f43;
}

.flash-error {
  background: var(--danger-soft);
  border-color: rgba(191, 66, 66, 0.35);
  color: #8f2f2f;
}

.flash-error::before {
  background: rgba(176, 45, 45, 0.58);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
}

.table-bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 0.4rem 0 0.45rem 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(242, 248, 255, 0.92);
}

.table-bulk-summary {
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 600;
}

.table-bulk-buttons {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.table-select-col {
  width: 2.2rem;
  min-width: 2.2rem;
  text-align: center;
}

.table-select-col input[type="checkbox"] {
  width: 0.96rem;
  height: 0.96rem;
  accent-color: #1f5aa6;
  cursor: pointer;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(250, 253, 255, 0.86);
}

.table-pagination-summary {
  color: var(--muted);
  font-size: 0.84rem;
}

.table-pagination-primary {
  display: inline-flex;
  min-width: min(100%, 28rem);
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.table-pagination-search {
  display: inline-flex;
  min-width: min(100%, 18rem);
  align-items: center;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-pagination-search input {
  width: min(18rem, 56vw);
  min-width: 10rem;
  padding: 0.34rem 0.55rem;
  border-radius: 9px;
  font-size: 0.82rem;
}

.table-pagination-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.44rem;
}

.table-pagination-actions label {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.table-pagination-actions select {
  width: auto;
  min-width: 4.5rem;
  padding: 0.24rem 1.7rem 0.24rem 0.46rem;
  border-radius: 9px;
  font-size: 0.82rem;
}

.table-pagination-page {
  color: var(--ink-soft);
  font-size: 0.84rem;
  min-width: 5.8rem;
  text-align: center;
}

@media (max-width: 760px) {
  .table-pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.52rem;
  }

  .table-pagination-summary {
    text-align: center;
    font-size: 0.82rem;
  }

  .table-pagination-actions {
    width: 100%;
    justify-content: center;
    gap: 0.35rem;
  }

  .table-pagination-actions label {
    width: 100%;
    justify-content: center;
  }

  .table-pagination-actions select {
    min-width: 5.5rem;
  }

  .table-pagination-page {
    min-width: 0;
    width: 100%;
    text-align: center;
  }
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid rgba(40, 74, 128, 0.12);
  text-align: left;
  padding: 0.58rem 0.54rem;
  vertical-align: top;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

th {
  color: #1a3a72;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(236, 245, 255, 0.95);
}

tbody tr {
  transition: background-color 0.2s ease;
}

tbody tr:hover {
  background: rgba(239, 246, 255, 0.72);
}

tbody tr.table-row-selected {
  background: rgba(221, 235, 255, 0.95);
}

.tts-model-row {
  cursor: pointer;
}

.tts-model-row:hover {
  background: rgba(225, 239, 255, 0.88);
}

.tts-model-row-selected {
  background: rgba(214, 237, 255, 0.95);
}

.tts-model-selected-cell {
  font-weight: 700;
  color: var(--ok);
}

.inline {
  display: inline-flex;
  margin: 0;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-field select {
  width: auto;
}

.terminal-box {
  white-space: pre-wrap;
  min-height: 320px;
}

/* Blink animation used to indicate a best-effort hangup was sent when no
   active call was reported by the server. Applied to the hangup button. */
.blink {
  animation: sim-blink 1.2s ease-in-out 0s 1;
}

@keyframes sim-blink {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); transform: translateY(0); }
  30% { box-shadow: 0 0 0.6rem 0.08rem rgba(255, 80, 80, 0.24); transform: translateY(-2px); }
  60% { box-shadow: 0 0 0.4rem 0.04rem rgba(255, 80, 80, 0.14); transform: translateY(0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); transform: translateY(0); }
}

#terminal-command {
  font-family: "IBM Plex Mono", Consolas, monospace;
}

.terminal-quick-wrap {
  margin-top: 0.8rem;
}

.terminal-ports-block {
  margin-bottom: 1rem;
}

.terminal-usb-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.66rem 0.74rem;
  background: rgba(251, 254, 255, 0.95);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.4;
  max-height: 210px;
  overflow-y: auto;
}

.terminal-port-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
}

.terminal-port-label {
  margin: 0;
}

#terminal-page {
  grid-template-columns: 1fr;
}

.reveal-section {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.55s ease, transform 0.55s ease;
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal-section.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 760px) {
  body {
    font-size: 16px;
  }

  .page {
    width: min(var(--content-max), calc(100% - 2rem));
    margin-top: 1.2rem;
    gap: 1.1rem;
  }

  .card {
    padding: 1.1rem 1.12rem;
  }

  .topbar nav a,
  .nav-link {
    font-size: 0.85rem;
  }
}

@media (min-width: 1040px) {
  .topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.88rem clamp(1.2rem, 2.2vw, 2rem);
  }

  .topbar nav {
    justify-content: flex-end;
    flex: 1 1 auto;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .grid-2 {
    grid-template-columns: 1fr 1.35fr;
    gap: 1.15rem;
  }

  #terminal-page {
    grid-template-columns: 1.2fr 0.8fr;
  }
}

@media (min-width: 1320px) {
  .page {
    gap: 1.25rem;
  }

  .card {
    padding: 1.18rem 1.2rem;
  }
}

@media (min-width: 1660px) {
  .topbar {
    padding-inline: max(2rem, calc((100vw - var(--content-max)) / 2));
  }
}

@media (max-width: 520px) {
  .topbar .brand {
    font-size: 0.96rem;
  }

  .topbar nav a,
  .nav-link {
    padding: 0.38rem 0.62rem;
    font-size: 0.8rem;
  }

  .page {
    width: calc(100% - 0.8rem);
    margin-top: 0.8rem;
  }

  .card {
    padding: 0.9rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .reveal-section {
    opacity: 1;
    transform: none;
  }
}

/* Classic admin overrides */
:root {
  --bg-0: #f8fafc;
  --bg-1: #f8fafc;
  --bg-2: #f8fafc;
  --bg-3: #f8fafc;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-border: #e2e8f0;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #cbd5e1;
  --line-soft: #e2e8f0;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --content-max: 1280px;
}

body {
  background: #f8fafc;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
}

body::before {
  display: none;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.page {
  width: min(80rem, calc(100% - 2rem));
  margin: 1.2rem auto 2rem;
}

.card {
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.card::after {
  display: none;
}

.card:hover {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.card h2::after {
  display: none;
}

.btn {
  box-shadow: none;
}

.btn:hover {
  transform: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
}

.btn-primary {
  background: #2563eb;
  border-color: #1d4ed8;
}

.btn-danger {
  background: #dc2626;
  border-color: #b91c1c;
}

.btn-secondary {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.log-box {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
}

.compact-status-list .status-row {
  padding: 0.34rem 0;
}

.live-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.live-left,
.live-right {
  display: grid;
  gap: 1rem;
}

#live-quick-core-controls .btn {
  flex: 1 1 9rem;
}

.live-level-meter {
  width: min(100%, 260px);
  height: 0.55rem;
  accent-color: #2563eb;
}

#live-card-talk .status-row span:last-child {
  max-width: 72%;
}

.dtmf-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin: 0.5rem 0;
}

#live-transcript-console {
  min-height: 180px;
  max-height: 320px;
}

.sticky-live-actions {
  position: sticky;
  bottom: 0;
  background: #ffffff;
  padding: 0.45rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  z-index: 8;
}

@media (min-width: 1024px) {
  .live-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
  }

  .sticky-live-actions {
    position: static;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
}

@media (max-width: 760px) {
  .page {
    width: calc(100% - 1rem);
  }
}

.quick-tag.is-active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.compact-ui .card {
  padding: 0.75rem 0.85rem;
}

.compact-ui .status-row {
  padding: 0.26rem 0;
}

.topbar nav a,
.nav-link {
  background: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: none;
}

.topbar nav a:hover,
.nav-link:hover,
.topbar nav a.is-active,
.nav-link.is-active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  transform: none;
  box-shadow: none;
}

h1,
h2,
h3 {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: #0f172a;
}

.ai-split-layout {
  align-items: start;
}

.ai-model-select-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ai-model-select-row select {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 180px;
}

.ai-model-catalog {
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fbff;
  max-height: 260px;
  overflow: auto;
}

.ai-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #e6edf7;
  cursor: pointer;
}

.ai-model-item:last-child {
  border-bottom: 0;
}

.ai-model-item:hover {
  background: #eef4ff;
}

.ai-model-item-id {
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.86rem;
  color: #0f2f67;
}

.ai-tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.ai-tier-badge.free {
  background: #e8f7ef;
  border-color: #b7e4c7;
  color: #136845;
}

.ai-tier-badge.paid {
  background: #fff5da;
  border-color: #f4db9a;
  color: #8f670f;
}

.ai-chat-shell {
  border: 1px solid #dbe4f0;
  border-radius: 16px;
  background: #f8fbff;
  display: flex;
  flex-direction: column;
  min-height: 640px;
  min-width: 0;
}

.ai-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.48rem 0.65rem;
  border-bottom: 1px solid #e5edf8;
  background: #eff5ff;
  border-radius: 16px 16px 0 0;
}

.ai-chat-head-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  min-width: 0;
}

.ai-chat-head-tools > * {
  min-width: 0;
}

.ai-model-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.46rem;
  border-radius: 999px;
  border: 1px solid #c9d8f2;
  background: #ffffff;
  color: #17427e;
  font-size: 0.74rem;
  max-width: 155px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-chat-log {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 380px;
  scrollbar-gutter: stable;
}

.ai-chat-empty {
  color: #5b6d8f;
  font-size: 0.88rem;
}

.ai-msg {
  display: flex;
}

.ai-msg-user {
  justify-content: flex-end;
}

.ai-msg-assistant {
  justify-content: flex-start;
}

.ai-bubble {
  max-width: 82%;
  border-radius: 14px;
  border: 1px solid #d7e2f3;
  background: #ffffff;
  padding: 0.45rem 0.62rem;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

.ai-msg-user .ai-bubble {
  background: #eafaf1;
  border-color: #bfe8ce;
}

.ai-bubble-role {
  font-size: 0.72rem;
  font-weight: 700;
  color: #4d628a;
  margin-bottom: 0.14rem;
}

.ai-bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.ai-chat-compose {
  border-top: 1px solid #e5edf8;
  padding: 0.7rem;
  display: grid;
  gap: 0.5rem;
}

.ai-chat-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ai-chat-model-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.ai-chat-model-wrap span {
  font-size: 0.72rem;
  color: #4d628a;
  white-space: nowrap;
}

.ai-chat-session-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
}

.ai-chat-session-wrap span {
  font-size: 0.72rem;
  color: #4d628a;
  white-space: nowrap;
}

.ai-chat-session-wrap select {
  min-width: 120px;
  max-width: 160px;
}

#ai-model-select,
#ai-chat-model,
#floating-ai-model {
  min-width: 0;
  max-width: 160px;
}

.ai-chat-input {
  min-height: 86px;
  resize: vertical;
}

.ai-chat-input.is-expanded {
  min-height: 180px;
  max-height: 42vh;
}

.ai-chat-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ai-ivr-config-wrap {
  margin-top: 0.35rem;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.65rem;
  display: grid;
  gap: 0.5rem;
}

.ai-ivr-config-wrap h3 {
  margin: 0;
  font-size: 0.96rem;
}

.ai-ivr-config-wrap table th,
.ai-ivr-config-wrap table td {
  font-size: 0.84rem;
  padding: 0.4rem 0.42rem;
}

.ai-ivr-config-wrap .button-row {
  margin: 0;
}

.ai-ivr-toolbar {
  justify-content: space-between;
}

.ai-ivr-enabled-count {
  margin-left: auto;
  font-weight: 600;
}

.ai-ivr-digit-row.is-disabled {
  opacity: 0.7;
}

.ai-ivr-profile-digit-row.is-disabled {
  opacity: 0.7;
}

.ai-ivr-digit-row.is-disabled td {
  background: #f4f6fb;
}

.ai-ivr-profile-digit-row.is-disabled td {
  background: #f4f6fb;
}

.ai-ivr-remove {
  white-space: nowrap;
}

.ai-ivr-profile-remove {
  white-space: nowrap;
}

.ai-chat-inline-audio {
  margin-left: auto;
  width: clamp(180px, 30vw, 320px);
  min-width: 180px;
  max-width: 100%;
}

.ai-chat-status {
  min-width: 80px;
  text-align: right;
}

.ai-chat-stream-now {
  margin-top: 0.1rem;
}

.ai-history-card {
  margin-top: 0.75rem;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.55rem;
}

.ai-history-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #38527f;
  margin-bottom: 0.42rem;
}

.ai-history-list {
  max-height: 170px;
  overflow: auto;
  display: grid;
  gap: 0.34rem;
  scrollbar-gutter: stable;
}

.ai-history-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid #d4e0f2;
  border-radius: 10px;
  background: #ffffff;
  padding: 0.42rem 0.52rem;
  color: #173566;
  cursor: pointer;
}

.ai-history-item:hover {
  background: #eef4ff;
}

.ai-history-item.is-active {
  border-color: #aac3ea;
  background: #e8f1ff;
}

.ai-history-item .meta {
  display: block;
  font-size: 0.74rem;
  color: #60779d;
  margin-top: 0.18rem;
}

@media (min-width: 1040px) {
  .ai-split-layout {
    align-items: stretch;
  }

  .ai-settings-card {
    height: auto;
    max-height: none;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .ai-chat-card {
    height: calc(100vh - 7.5rem);
    max-height: calc(100vh - 7.5rem);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: auto;
    scrollbar-gutter: stable;
  }

  .ai-settings-card .stack {
    flex: 0 0 auto;
    overflow: visible;
    padding-right: 0;
  }

  .ai-chat-shell {
    flex: 1 1 auto;
    min-height: 340px;
  }

  .ai-chat-log {
    min-height: 260px;
  }

  .ai-chat-input {
    min-height: 80px;
    max-height: 130px;
  }

  .ai-chat-input.is-expanded {
    min-height: 210px;
    max-height: 46vh;
  }

  .ai-history-list {
    max-height: 110px;
  }

  .ai-chat-toolbar {
    gap: 0.35rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-gutter: stable;
  }

  .ai-chat-actions {
    gap: 0.35rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-gutter: stable;
  }

  .ai-chat-actions .btn {
    padding: 0.38rem 0.68rem;
  }

  .ai-chat-inline-audio {
    width: clamp(170px, 24vw, 280px);
    min-width: 170px;
  }
}

.floating-ai-root {
  position: fixed !important;
  inset: auto 1rem 1rem auto !important;
  z-index: 14500;
}

.floating-log-root {
  position: fixed !important;
  inset: auto auto 1rem 1rem !important;
  z-index: 14500;
}

.floating-log-toggle {
  border: 1px solid rgba(24, 59, 106, 0.3);
  border-radius: 999px;
  padding: 0.56rem 0.86rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #1f4f95 0%, #1a427b 58%, #173863 100%);
  box-shadow: 0 10px 25px rgba(21, 54, 101, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
}

.floating-log-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  background: #ffffff;
  color: #16345f;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0 0.28rem;
}

.floating-log-panel {
  position: fixed !important;
  left: 1rem !important;
  bottom: 4.2rem !important;
  width: min(520px, calc(100vw - 1rem));
  border: 1px solid #d5e1f2;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(19, 37, 71, 0.25);
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem;
}

.floating-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.floating-log-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.floating-log-box {
  min-height: 300px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.52rem;
  display: grid;
  gap: 0.2rem;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.4;
}

.floating-log-line {
  border-bottom: 1px dashed #d5e0f2;
  padding-bottom: 0.18rem;
}

.floating-log-line:last-child {
  border-bottom: 0;
}

.floating-log-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.floating-ai-toggle {
  border: 1px solid rgba(34, 76, 141, 0.28);
  border-radius: 999px;
  padding: 0.56rem 0.86rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #2f6ee4 0%, #255bcf 58%, #214cb7 100%);
  box-shadow: 0 10px 25px rgba(35, 89, 199, 0.35);
  cursor: pointer;
}

.floating-ai-panel {
  position: fixed !important;
  right: 1rem !important;
  bottom: 4.2rem !important;
  width: min(440px, calc(100vw - 1rem));
  border: 1px solid #d5e1f2;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(19, 37, 71, 0.25);
  display: grid;
  gap: 0.5rem;
  padding: 0.6rem;
}

.floating-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.floating-ai-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.42rem;
  align-items: end;
}

.floating-ai-log {
  min-height: 300px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid #dbe4f0;
  border-radius: 12px;
  background: #f8fbff;
  padding: 0.52rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.floating-ai-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.floating-ai-history-wrap {
  border-top: 1px solid #e2eaf6;
  padding-top: 0.44rem;
}

.floating-ai-history-title {
  font-size: 0.79rem;
  color: #4f6590;
  font-weight: 700;
}

.floating-ai-history-list {
  margin-top: 0.36rem;
  max-height: 120px;
  overflow: auto;
  display: grid;
  gap: 0.32rem;
}

@media (max-width: 900px) {
  .ai-chat-shell {
    min-height: 460px;
  }

  .ai-bubble {
    max-width: 92%;
  }

  .floating-ai-root {
    inset: auto 0.6rem 0.6rem auto !important;
  }

  .floating-log-root {
    inset: auto auto 0.6rem 0.6rem !important;
  }

  .floating-ai-panel {
    right: 0.6rem !important;
    bottom: 3.8rem !important;
    width: min(96vw, 420px);
  }

  .floating-log-panel {
    left: 0.6rem !important;
    bottom: 3.8rem !important;
    width: min(96vw, 420px);
  }

  .floating-ai-toolbar {
    grid-template-columns: 1fr;
  }
}

.call-events-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, 0.42);
  z-index: 11980;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.call-events-modal-card {
  width: min(1120px, 98vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  background: #fff;
  border: 1px solid rgba(32, 63, 112, 0.24);
  border-radius: 14px;
  box-shadow: 0 28px 65px rgba(19, 38, 74, 0.28);
  padding: 0.85rem;
}

.call-events-table-wrap {
  max-height: 72vh;
}

.call-events-table-wrap td {
  vertical-align: top;
}

.call-event-message {
  min-width: 260px;
  max-width: 460px;
  white-space: pre-wrap;
  word-break: break-word;
}

.call-event-extra {
  min-width: 180px;
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #40577f;
}

@media (max-width: 900px) {
  .call-events-modal-card {
    width: min(100vw, 99vw);
    max-height: 95vh;
    border-radius: 10px;
    padding: 0.7rem;
  }

  .call-events-table-wrap {
    max-height: 78vh;
  }

  .call-event-message,
  .call-event-extra {
    min-width: 180px;
    max-width: 280px;
  }
}

.audio-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, 0.42);
  z-index: 12000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.audio-modal-card {
  width: min(760px, 96vw);
  background: #fff;
  border: 1px solid rgba(32, 63, 112, 0.24);
  border-radius: 14px;
  box-shadow: 0 28px 65px rgba(19, 38, 74, 0.28);
  padding: 0.85rem;
}

.audio-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.audio-modal-meta {
  margin-top: 0.55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.event-popup-host {
  position: fixed;
  left: 50%;
  top: 5rem;
  transform: translateX(-50%);
  z-index: 13000;
  width: min(560px, calc(100vw - 1.2rem));
  display: grid;
  gap: 0.5rem;
  pointer-events: none;
}

.event-popup-item {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid rgba(34, 74, 136, 0.24);
  border-left: 4px solid #2f6ee4;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(19, 37, 71, 0.2);
  padding: 0.55rem 0.65rem;
}

.event-popup-item.is-warn {
  border-left-color: #d89b28;
}

.event-popup-item.is-error {
  border-left-color: #d04545;
}

.event-popup-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: #51688e;
}

.event-popup-message {
  margin-top: 0.28rem;
  font-size: 0.9rem;
  color: #152e59;
  word-break: break-word;
}

.event-popup-actions {
  margin-top: 0.45rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.event-popup-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.82rem;
  padding: 0.24rem 0.45rem;
  border: 1px solid rgba(34, 74, 136, 0.24);
  border-radius: 8px;
  background: #f4f8ff;
}
