/* Dashboard: white + dark green + glass effect, professional UX */
:root {
  --bg: #FFFFFF;
  --bg-subtle: #F7F8F9;
  --primary: #0D5C3D;
  --primary-hover: #0A4A30;
  --primary-light: rgba(13, 92, 61, 0.08);
  --secondary: #1B7A4C;
  --text: #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-tertiary: #8A8A8A;
  --border: #E5E7EB;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-green: rgba(13, 92, 61, 0.06);
  --error: #B91C1C;
  --card: #FFFFFF;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.login-card .sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  margin-bottom: 20px;
  background: var(--bg);
}

.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.login-card button {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.login-card button:hover { background: var(--primary-hover); }

.flash-error {
  background: rgba(185, 28, 28, 0.08);
  color: var(--error);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}

/* ----- Layout ----- */
.header {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
}

.header a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
}

.header a:hover { color: var(--primary); }

.sub-tabs {
  display: flex;
  gap: 6px;
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  min-height: 48px;
  align-items: stretch;
}

.sub-tab {
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 0;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
}

.sub-tab:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.sub-tab.sub-tab-active {
  color: var(--primary);
  background: var(--primary-light);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.tab-content-active {
  display: block;
  min-height: 320px;
}

.stat-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 900px) {
  .stat-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stat-grid-4 {
    grid-template-columns: 1fr;
  }
}

.main {
  padding: 28px 32px 48px;
  width: 100%;
  min-height: calc(100vh - 56px);
  box-sizing: border-box;
}

.flash-msg {
  background: var(--primary-light);
  border: 1px solid rgba(13, 92, 61, 0.2);
  color: var(--primary);
  padding: 12px 18px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  transition: opacity 0.3s ease, margin 0.3s ease;
}
.flash-msg.flash-msg--hide {
  opacity: 0;
  margin-bottom: 0;
  pointer-events: none;
}

.card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  line-height: 1.45;
}

.live-calls-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.live-calls-legend-item {
  white-space: nowrap;
}

.live-calls-legend-item strong {
  color: var(--text);
}

.live-calls-legend-sep {
  color: var(--text-tertiary);
  user-select: none;
}

.live-calls-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 24px;
}

/* Live calls: filter + single-line table */
.live-calls-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 16px;
}

.live-calls-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  margin-right: 4px;
}

.live-calls-filter-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.live-calls-filter-btn:hover {
  background: var(--border);
}

.live-calls-filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.live-calls-table-wrap {
  overflow-x: auto;
  margin-top: 0;
}

.live-calls-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.5fr) 120px 56px 72px 72px 80px minmax(90px, 1.2fr);
  gap: 16px 20px;
  align-items: center;
  padding: 10px 16px;
  font-size: 13px;
  min-width: 0;
  white-space: nowrap;
}

.live-calls-row--head {
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  padding-top: 0;
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-calls-row--head .live-calls-cell {
  overflow: visible;
}

.live-calls-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 4px;
}

.live-calls-cell--number {
  font-family: ui-monospace, monospace;
  font-weight: 600;
  color: var(--text);
}

.live-calls-cell--status {
  white-space: nowrap;
}

.live-calls-cell--digits,
.live-calls-cell--duration,
.live-calls-cell--time {
  font-variant-numeric: tabular-nums;
}

.live-calls-empty-row {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-secondary, #64748b);
  font-size: 14px;
}

.live-call-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}

.live-call-item:last-child {
  margin-bottom: 0;
}

.live-call-item--live {
  background: var(--bg-subtle);
  border-color: var(--border);
}

.live-call-item--dtmf {
  background: rgba(13, 92, 61, 0.06);
  border-color: rgba(13, 92, 61, 0.2);
}

.live-call-item--no_answer {
  background: rgba(120, 53, 15, 0.08);
  border-color: rgba(180, 83, 9, 0.25);
}

.live-call-item--disconnected {
  background: rgba(185, 28, 28, 0.08);
  border-color: rgba(185, 28, 28, 0.25);
}

.live-call-item--no_dtmf {
  background: rgba(161, 98, 7, 0.08);
  border-color: rgba(180, 83, 9, 0.2);
}

.live-call-details {
  font-size: 12px;
  color: var(--text-secondary, #64748b);
  margin-top: 4px;
  padding-left: 0;
  line-height: 1.4;
}

.live-call-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-block;
}

.live-call-status--live {
  background: var(--primary-light);
  color: var(--primary);
}

.live-call-status--dtmf {
  background: rgba(13, 92, 61, 0.15);
  color: var(--primary);
}

.live-call-status--no_answer {
  background: rgba(180, 83, 9, 0.2);
  color: #92400e;
}

.live-call-status--disconnected {
  background: rgba(185, 28, 28, 0.15);
  color: var(--error);
}

.live-call-status--no_dtmf {
  background: rgba(180, 83, 9, 0.15);
  color: #92400e;
}

.live-call-number {
  font-family: ui-monospace, monospace;
  font-weight: 600;
  color: var(--primary);
  min-width: 0;
  flex: 1 1 auto;
  word-break: break-all;
}

.live-call-dtmf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.live-call-dtmf-digits {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.live-call-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 22px;
  font-weight: 700;
  color: var(--error);
  line-height: 1;
}

.dtmf-digit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-weight: 700;
  font-size: 14px;
}

.dtmf-waiting {
  color: var(--text-tertiary);
  font-size: 13px;
}

.live-call-tag {
  display: inline-block;
  padding: 6px 12px;
  background: var(--primary-light);
  border: 1px solid rgba(13, 92, 61, 0.2);
  border-radius: 8px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  color: var(--primary);
}

.live-calls-empty {
  color: var(--text-tertiary);
  font-size: 14px;
}

.upload-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-input-hidden {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.file-button {
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.file-button:hover {
  background: var(--border);
}

.file-name {
  font-size: 14px;
  color: var(--text-secondary);
}

.telegram-info {
  font-size: 14px;
  padding-top: 4px;
}

.telegram-info .telegram-status {
  display: inline-block;
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 8px;
  font-weight: 600;
  margin-right: 10px;
}

.telegram-info .telegram-chat {
  color: var(--text-secondary);
  font-size: 14px;
}

.telegram-note {
  margin: 14px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 700px) {
  .card-row {
    grid-template-columns: 1fr;
  }

  .card-row .card {
    margin-bottom: 20px;
  }

  .card-row .card:last-child {
    margin-bottom: 0;
  }
}

/* ----- Glass cards ----- */
.card {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 4px;
}

.card-row .card {
  margin-bottom: 0;
}

.batch-control-card {
  margin-top: 24px;
}

/* ----- AI-RING: side-by-side + Agent window ----- */
.ai-ring-split {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
  min-height: 520px;
}
.ai-ring-left {
  min-width: 0;
}
.agent-window {
  background: #1a1d21;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  min-height: 520px;
  display: flex;
  flex-direction: column;
}
.agent-window-inner {
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-height: 0;
}
.agent-window-select-wrap {
  width: 100%;
  max-width: 280px;
}
.agent-window-select-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #a0aec0;
  margin-bottom: 6px;
}
.agent-window-select {
  width: 100%;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 14px;
  background: rgba(255,255,255,0.08);
  color: #e2e8f0;
}
.agent-window-selected-name {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #94a3b8;
}
.agent-circle-wrap {
  width: 160px;
  height: 160px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.agent-circle-animation {
  border-radius: 50%;
  border: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.agent-circle-outer {
  width: 120px;
  height: 120px;
  border-top-color: #ec4899;
  border-right-color: #a855f7;
  border-bottom-color: #14b8a6;
  border-left-color: #ec4899;
  animation: agent-circle-spin 2.2s linear infinite;
  box-shadow: 0 0 28px rgba(236,72,153,0.4), 0 0 48px rgba(168,85,247,0.25), 0 0 28px rgba(20,184,166,0.35);
}
.agent-circle-mid {
  width: 80px;
  height: 80px;
  border-top-color: #a855f7;
  border-right-color: #14b8a6;
  border-bottom-color: #ec4899;
  border-left-color: #a855f7;
  animation: agent-circle-spin-reverse 2.8s linear infinite;
  box-shadow: 0 0 20px rgba(168,85,247,0.5), 0 0 16px rgba(20,184,166,0.3);
}
.agent-circle-inner {
  width: 40px;
  height: 40px;
  border-top-color: #14b8a6;
  border-right-color: #ec4899;
  border-bottom-color: #a855f7;
  border-left-color: #14b8a6;
  animation: agent-circle-spin 1.6s linear infinite;
  box-shadow: 0 0 16px rgba(20,184,166,0.6), 0 0 12px rgba(236,72,153,0.4);
}
@keyframes agent-circle-spin {
  to { transform: rotate(360deg); }
}
@keyframes agent-circle-spin-reverse {
  to { transform: rotate(-360deg); }
}
.btn-talk-agent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 4px 20px rgba(13,92,61,0.4);
  flex-shrink: 0;
  margin-top: auto;
  transition: background 0.2s, box-shadow 0.2s;
}
.btn-talk-agent:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 24px rgba(13,92,61,0.45);
}
.btn-talk-agent:active {
  transform: scale(0.98);
}
.btn-talk-agent.btn-talk-agent-recording {
  background: #b91c1c;
  box-shadow: 0 4px 20px rgba(185,28,28,0.4);
}
.btn-talk-agent.btn-talk-agent-recording:hover {
  background: #991b1b;
}
.btn-talk-agent .btn-talk-icon {
  flex-shrink: 0;
}
.agent-chat {
  width: 100%;
  max-width: 480px;
  flex: 1;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.agent-chat-msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.agent-chat-msg.user-msg {
  flex-direction: row-reverse;
}
.agent-chat-msg-left {
  flex-direction: row;
}
.agent-chat-msg-right {
  flex-direction: row-reverse;
}
.agent-chat-bubble-agent {
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.4);
}
.agent-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  flex-shrink: 0;
}
.agent-chat-avatar.user-avatar {
  background: rgba(13,92,61,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.agent-chat-avatar-circle {
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.agent-circle-mini {
  border-radius: 50%;
  border: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.agent-circle-mini-outer {
  width: 36px;
  height: 36px;
  border-top-color: #ec4899;
  border-right-color: #a855f7;
  border-bottom-color: #14b8a6;
  border-left-color: #ec4899;
  animation: agent-circle-spin 2.2s linear infinite;
  box-shadow: 0 0 10px rgba(236,72,153,0.5), 0 0 14px rgba(168,85,247,0.3);
}
.agent-circle-mini-mid {
  width: 24px;
  height: 24px;
  border-top-color: #a855f7;
  border-right-color: #14b8a6;
  border-bottom-color: #ec4899;
  border-left-color: #a855f7;
  animation: agent-circle-spin-reverse 2.8s linear infinite;
}
.agent-circle-mini-inner {
  width: 12px;
  height: 12px;
  border-top-color: #14b8a6;
  border-right-color: #ec4899;
  border-bottom-color: #a855f7;
  border-left-color: #14b8a6;
  animation: agent-circle-spin 1.6s linear infinite;
}
.agent-chat-bubble {
  background: #2d3238;
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  max-width: 85%;
}
.agent-chat-bubble.user-bubble {
  background: rgba(13,92,61,0.35);
  border: 1px solid rgba(13,92,61,0.5);
}
.agent-chat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  margin-bottom: 4px;
}
.agent-chat-bubble p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}
.agent-prompt-box {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 10px 12px;
  max-height: 140px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.agent-prompt-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.agent-prompt-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  max-height: 120px;
}
.agent-selectable {
  background: var(--primary-light);
  border-radius: 8px;
  margin: 0 -8px;
  padding: 14px 8px !important;
}
.agent-selectable:hover {
  filter: brightness(0.97);
}
.ai-agent-delete-form {
  margin: 0;
  padding: 0;
}
.ai-agent-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.ai-agent-delete-btn:hover {
  background: rgba(185, 28, 28, 0.1);
  color: var(--error);
}
@media (max-width: 1000px) {
  .ai-ring-split {
    grid-template-columns: 1fr;
  }
}

.card-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

.stat {
  background: var(--glass-green);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(13, 92, 61, 0.12);
  border-radius: 12px;
  padding: 18px;
  min-height: 140px;
  height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-sizing: border-box;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.stat-label-highlight {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.stat-value-secondary {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
}

.stat-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin: 2px 0 0;
  line-height: 1.3;
}

.stat-upload {
  cursor: pointer;
  position: relative;
  height: auto;
  min-height: 140px;
}

.stat-upload.stat-dragover {
  border-color: var(--primary);
  background: rgba(13, 92, 61, 0.12);
}

.stat-delete-form {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
}
.stat-delete-x {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-delete-x:hover {
  background: rgba(185, 28, 28, 0.15);
  color: #b91c1c;
}

.stat-listen-btn, .stat-download-btn {
  margin-right: 8px;
  font-size: 12px;
}
.tts-listen-download .stat-download-btn {
  text-decoration: none;
  color: var(--text-secondary);
}
.tts-listen-download .stat-download-btn:hover {
  color: var(--primary);
}

.stat-telegram {
  cursor: pointer;
  height: auto;
  min-height: 140px;
  overflow: visible;
}

/* Match upload card layout; align button to the right */
.stat-telegram .telegram-actions {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.stat-telegram:hover {
  background: rgba(13, 92, 61, 0.1);
}

.upload-form-inline {
  margin-top: 4px;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.upload-count {
  font-size: 13px;
  color: var(--text-secondary);
}

.upload-result {
  font-size: 13px;
  margin-top: 6px;
  padding: 6px 0;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.35;
}
.upload-result-ok {
  color: var(--success, #22c55e);
}
.upload-result-error {
  color: var(--danger, #ef4444);
}

.btn-icon-only {
  padding: 10px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon-only svg {
  display: block;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  border: 1px solid var(--glass-border);
}

.modal-box-wide {
  max-width: 560px;
}

.modal-form .modal-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  background: #fff;
  color: #111827;
}
.modal-form .modal-textarea::placeholder {
  color: #6b7280;
}

.modal-form .modal-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-form .char-count {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: #111827;
}

.modal-desc {
  font-size: 14px;
  color: #4b5563;
  margin: 0 0 20px;
  line-height: 1.45;
}

.modal-form .field {
  margin-bottom: 16px;
}

.modal-form .field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #1f2937;
  margin-bottom: 6px;
}

.modal-form .field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: #111827;
}
.modal-form .field input::placeholder {
  color: #6b7280;
}

.modal-form .field input:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-form .field select.modal-form-select,
.modal-form .field select {
  width: 100%;
  max-width: 320px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: #111827;
}

.modal-form .field-hint {
  display: block;
  font-size: 12px;
  color: #4b5563;
  margin-top: 4px;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
}

.status-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.status-badge.running { background: var(--primary-light); color: var(--primary); }
.status-badge.stopped { background: var(--bg-subtle); color: var(--text-secondary); }
.status-badge.paused { background: rgba(234, 179, 8, 0.15); color: #92400e; }

.sip-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.sip-server-masked {
  font-size: 14px;
  color: var(--text-secondary);
}

.status-block {
  margin-bottom: 20px;
}
.status-label {
  display: block;
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 6px;
}
.status-text {
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 14px 18px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

.card-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #991b1b; }

.btn-secondary { background: var(--bg-subtle); color: var(--text); }
.btn-secondary:hover { background: var(--border); }

.btn-primary-light {
  background: var(--primary-light);
  border: 1px solid rgba(13, 92, 61, 0.25);
  color: var(--primary);
}
.btn-primary-light:hover {
  background: rgba(13, 92, 61, 0.15);
  border-color: rgba(13, 92, 61, 0.35);
}

.btn-primary-bright {
  background: var(--secondary);
  border: 1px solid var(--secondary);
  color: #fff;
}
.btn-primary-bright:hover {
  background: #15803d;
  border-color: #15803d;
}

.btn-clear { border: 1px solid var(--text-tertiary, #94a3b8); color: var(--text-secondary); }
.btn-clear:hover { background: rgba(148, 163, 184, 0.15); }

.card-actions button:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.unreachable {
  color: var(--text-secondary);
  font-style: italic;
}

@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .card { padding: 20px; }
}

/* ----- AI Ring Settings block (dark theme) ----- */
.ai-ring-settings-card .ai-ring-settings-block {
  background: #2d3748;
  border-radius: 12px;
  padding: 24px;
  color: #e2e8f0;
}
.ai-ring-settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #4a5568;
  margin-bottom: 24px;
  padding: 0;
}
.ai-ring-settings-tab {
  background: none;
  border: none;
  color: #a0aec0;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 20px;
  cursor: pointer;
  position: relative;
  margin-bottom: -1px;
  font-family: var(--font);
}
.ai-ring-settings-tab:hover {
  color: #e2e8f0;
}
.ai-ring-settings-tab.ai-ring-settings-tab-active {
  color: #e2e8f0;
}
.ai-ring-settings-tab.ai-ring-settings-tab-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #805ad5;
}
.ai-ring-settings-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: #48bb78;
}
.ai-ring-settings-icon {
  font-size: 18px;
}
.ai-ring-settings-desc {
  font-size: 13px;
  color: #a0aec0;
  margin: 0 0 16px;
  line-height: 1.5;
}
.ai-ring-settings-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 520px) {
  .ai-ring-settings-fields { grid-template-columns: 1fr; }
}
.ai-ring-settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ai-ring-settings-field label {
  font-size: 13px;
  color: #e2e8f0;
  font-weight: 500;
}
.ai-ring-settings-select {
  width: 100%;
  max-width: 220px;
  padding: 10px 36px 10px 12px;
  background: #1a202c;
  border: 1px solid #4a5568;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 14px;
  font-family: var(--font);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a0aec0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.ai-ring-settings-select:focus {
  outline: none;
  border-color: #718096;
}
.ai-ring-settings-panel {
  display: none;
}
.ai-ring-settings-panel.ai-ring-settings-panel-active {
  display: block;
}
.ai-ring-settings-panel[hidden] {
  display: none !important;
}
.ai-ring-settings-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  background: #1a202c;
  border: 1px solid #4a5568;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 14px;
  font-family: var(--font);
}
.ai-ring-settings-input:focus {
  outline: none;
  border-color: #718096;
}
textarea.ai-ring-settings-input {
  max-width: 100%;
  min-height: 80px;
  resize: vertical;
}
.api-management-list { display: flex; flex-direction: column; gap: 20px; }
.api-management-item {
  padding: 14px 16px;
  background: #1a202c;
  border: 1px solid #2d3748;
  border-radius: 10px;
}
.api-management-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.api-management-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}
.api-management-badge.configured { background: #276749; color: #9ae6b0; }
.api-management-badge.not-configured { background: #553c9a; color: #d6bcfa; }
.api-management-desc {
  font-size: 12px;
  color: #a0aec0;
  margin-bottom: 12px;
}
.api-management-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}
.api-management-fields .ai-ring-settings-field { max-width: 280px; }

/* Dynamic Variables (AI-RING) – matches card theme */
.dynamic-variables-card .card-title { margin: 0 0 8px; }
.dynamic-variables-card .card-desc { margin-bottom: 16px; }
.dynamic-vars-add-first { margin-bottom: 12px; }
.dynamic-vars-add-fields {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 520px) {
  .dynamic-vars-add-fields { grid-template-columns: 1fr; }
}
.dynamic-vars-field { display: flex; flex-direction: column; gap: 4px; }
.dynamic-vars-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.dynamic-vars-input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
.dynamic-vars-input:focus {
  outline: none;
  border-color: var(--primary);
}
.dynamic-vars-field-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dynamic-vars-checkbox-label {
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dynamic-vars-list { display: flex; flex-direction: column; gap: 6px; }
.dynamic-var-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 12px;
  background: var(--bg-secondary, rgba(0,0,0,0.04));
  border-radius: 8px;
  border: 1px solid var(--border);
}
.dynamic-var-key {
  font-weight: 600;
  min-width: 90px;
  font-size: 14px;
  color: var(--text);
}
.dynamic-var-value {
  flex: 1;
  min-width: 60px;
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-word;
}
.dynamic-var-secret-label {
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.dynamic-var-delete.btn-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.dynamic-var-delete.btn-icon:hover {
  background: rgba(252,129,129,0.2);
  color: #fc8181;
}
.dynamic-vars-bulk {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.dynamic-vars-bulk summary {
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
}
.dynamic-vars-bulk-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 8px 0 6px;
}
.dynamic-vars-bulk-hint code { font-size: 11px; background: var(--bg-secondary); padding: 2px 6px; border-radius: 4px; }
.dynamic-vars-paste { margin-bottom: 8px; resize: vertical; min-height: 56px; }
.dynamic-vars-bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dynamic-vars-file { font-size: 13px; }
.dynamic-vars-save-row { margin-top: 16px; margin-bottom: 0; }
.dynamic-vars-saved-msg { margin-left: 12px; font-size: 13px; color: var(--secondary); }
.dynamic-vars-empty { color: var(--text-secondary); font-size: 13px; }
