/* Pulse Dialer — modern Vicidial reskin */
:root {
  --bg: #0b1220;
  --bg2: #111a2e;
  --panel: #151f36;
  --panel2: #1a2744;
  --border: #2a3b5c;
  --text: #e8eefc;
  --muted: #8fa3c8;
  --accent: #3b82f6;
  --accent2: #22d3ee;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #a78bfa;
  --ready: #16a34a;
  --incall: #dc2626;
  --dispo: #d97706;
  --paused: #64748b;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
/* PulseLeadz clean theme */
body {
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #132d4a 0%, transparent 40%),
              var(--bg);
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(180deg, #16223c, #10192d);
  border-bottom: 1px solid var(--border);
  gap: 12px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 0.02em;
}
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center; font-size: 16px; color: #041018;
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--border); background: var(--panel2);
}
.badge.READY, .badge.QUEUE { background: #14532d; border-color: #166534; color: #bbf7d0; }
.badge.INCALL, .badge.RINGING, .badge.DIALING { background: #7f1d1d; border-color: #991b1b; color: #fecaca; animation: pulse 1.2s infinite; }
.badge.3WAY, .badge.XFER { background: #1e3a8a; border-color: #2563eb; color: #bfdbfe; animation: pulse 1.2s infinite; }
.badge.DISPO { background: #78350f; border-color: #92400e; color: #fde68a; }
.badge.PAUSED { background: #334155; color: #cbd5e1; }
@keyframes pulse { 50% { opacity: 0.75; } }

.layout { display: grid; gap: 14px; padding: 14px; }
.agent-layout {
  grid-template-columns: 280px 1fr 320px;
  grid-template-rows: auto 1fr;
  min-height: calc(100vh - 58px);
}
@media (max-width: 1100px) {
  .agent-layout { grid-template-columns: 1fr; }
}

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.25);
}
.panel h2, .panel h3 {
  margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.panel h2 { font-size: 14px; color: var(--text); letter-spacing: 0.04em; }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.stat .n { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.lead-card {
  border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  background: linear-gradient(145deg, #1b2948, #121c32);
}
.lead-card .name { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.lead-card .phone {
  font-family: var(--mono); font-size: 22px; color: var(--accent2); margin: 8px 0 12px;
  letter-spacing: 0.04em;
}
.lead-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.lead-meta div { background: rgba(0,0,0,0.2); border-radius: 8px; padding: 8px; }
.lead-meta span { display: block; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }

.timer {
  font-family: var(--mono); font-size: 42px; font-weight: 700; text-align: center;
  letter-spacing: 0.06em; color: #fff;
  text-shadow: 0 0 24px rgba(59,130,246,0.45);
  margin: 8px 0;
}
.timer.hot { color: #fecaca; text-shadow: 0 0 24px rgba(239,68,68,0.5); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button, .btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel2); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
button:hover, .btn:hover { border-color: var(--accent); background: #1f3158; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: linear-gradient(180deg, #3b82f6, #2563eb); border-color: #1d4ed8; }
button.success { background: linear-gradient(180deg, #22c55e, #16a34a); border-color: #15803d; color: #052e12; }
button.danger { background: linear-gradient(180deg, #ef4444, #dc2626); border-color: #b91c1c; }
button.warn { background: linear-gradient(180deg, #f59e0b, #d97706); border-color: #b45309; color: #1c1002; }
button.ghost { background: transparent; }

.dispo-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.dispo-grid button {
  text-align: left; padding: 12px; font-size: 12px;
  background: #1c2a48; min-height: 48px;
}
.dispo-grid button .k {
  display: inline-block; width: 18px; height: 18px; line-height: 18px; text-align: center;
  border-radius: 5px; background: #0f172a; border: 1px solid var(--border);
  font-size: 10px; margin-right: 6px; color: var(--muted);
}
.dispo-grid button:hover { border-color: var(--amber); }

.script-box {
  white-space: pre-wrap; font-size: 14px; line-height: 1.5;
  background: #0d1526; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; min-height: 140px; max-height: 280px; overflow: auto;
  color: #dbe7ff;
}

textarea, input, select {
  width: 100%; background: #0d1526; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }

/* Login */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login-card {
  width: min(420px, 100%); background: linear-gradient(180deg, #17233f, #0f172a);
  border: 1px solid var(--border); border-radius: 16px; padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login-card .hint {
  margin-top: 14px; font-size: 12px; color: var(--muted);
  background: #0b1220; border-radius: 8px; padding: 10px; border: 1px solid var(--border);
}
.err { color: #fecaca; font-size: 13px; margin-top: 8px; min-height: 1.2em; }

/* Admin */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--muted); }
.ok-toast {
  position: fixed; bottom: 16px; right: 16px; background: #14532d; color: #bbf7d0;
  border: 1px solid #166534; padding: 10px 14px; border-radius: 10px; display: none; z-index: 50;
}
.ok-toast.show { display: block; animation: fade 2.5s forwards; }
@keyframes fade { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

.vicidial-chrome {
  font-size: 11px; color: var(--muted); border-top: 1px dashed var(--border);
  margin-top: 12px; padding-top: 8px;
}
.drop-zone {
  margin-top: 10px; padding: 28px 16px; text-align: center;
  border: 2px dashed var(--border); border-radius: 12px;
  background: rgba(59,130,246,0.06); cursor: pointer; transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag {
  border-color: var(--accent2); background: rgba(34,211,238,0.08);
}
.ring-flash {
  animation: ringflash 0.6s ease infinite alternate;
}
@keyframes ringflash {
  from { box-shadow: 0 0 0 0 rgba(239,68,68,0.2); }
  to { box-shadow: 0 0 24px 4px rgba(239,68,68,0.45); }
}
.col-span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .col-span-2 { grid-column: span 1; } }


/* perf: paint isolation for large panels */
.panel, .lead-card, .script-box { content-visibility: auto; contain-intrinsic-size: 200px; }

/* snappy buttons — no laggy transitions */
button, .btn, .dispo-grid button {
  transition: background 0.06s ease, border-color 0.06s ease, opacity 0.06s ease !important;
  will-change: transform;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
}
button:active:not(:disabled), .btn:active:not(:disabled), .dispo-grid button:active {
  transform: scale(0.97);
  opacity: 0.92;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.busy { opacity: 0.7; pointer-events: none; }
button.flash-ok { box-shadow: 0 0 0 2px #22c55e inset; }

/* editable lead card */
.lead-edit-grid { display: flex; flex-direction: column; gap: 8px; }
.lead-edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lead-in {
  width: 100%;
  background: #0c1424;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
}
.lead-in:focus {
  outline: none;
  border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.2);
}
.lead-phone { font-size: 1.35rem !important; font-weight: 700; letter-spacing: 0.02em; }
.lead-ta { min-height: 52px; resize: vertical; font-family: inherit; }
.lead-edit-meta { margin-top: 4px; }
.lead-edit-meta input, .lead-edit-meta textarea { margin-top: 4px; }
.lead-edit-meta span { display: block; font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
#leadSaveHint.saving { color: var(--amber); }
#leadSaveHint.saved { color: var(--green); }
@media (max-width: 640px) {
  .lead-edit-row { grid-template-columns: 1fr; }
}

/* ========== Micro-optimizations (SEO/UX/perf hygiene) — v1.5 ========== */

/* Touch targets ≥ 44×44 (mobile / motor UX) */
button, .btn, .dispo-grid button, .topbar button, .btn-row button {
  min-height: 44px;
  min-width: 44px;
}
select, input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input:not([type]), textarea {
  min-height: 44px;
}
.dispo-grid button { min-height: 48px; padding: 12px 14px; }
.badge { min-height: 28px; }

/* Prefer system fonts already; tighten paint */
img, video, audio { max-width: 100%; height: auto; }
#softphoneRemote, .softphone-remote {
  position: fixed !important;
  left: 0; bottom: 0;
  width: 2px; height: 2px;
  opacity: 0.02;
  pointer-events: none;
  z-index: 0;
  display: block !important;
}

/* Utility classes — replace common inline styles */
.flex-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-1 { flex: 1; }
.mt-0 { margin-top: 0 !important; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.m-0 { margin: 0 !important; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-md { font-size: 13px; }
.lh-tight { line-height: 1.4; }
.max-w-140 { max-width: 140px; }
.span-full { grid-column: 1 / -1; }
.scroll-y { overflow: auto; }
.scroll-y-sm { overflow: auto; max-height: 160px; }
.scroll-y-md { overflow: auto; max-height: 220px; }
.scroll-y-lg { overflow: auto; max-height: 320px; }
.hr-soft { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.panel-sms { margin-top: 14px; border-color: #22c55e; }
.panel-sms h2 { color: #86efac; }
.panel-xfer { margin-top: 14px; background: #0f1a30; border-color: #3b82f6; }
.panel-xfer h2 { color: #93c5fd; }
.panel-accent-cyan { border-color: #22d3ee; }
.panel-accent-blue { border-color: #3b82f6; }
.panel-accent-violet { border-color: #a78bfa; }
.panel-accent-green { border-color: #34d399; }
.btn-d1 {
  flex: 1;
  font-size: 16px;
  padding: 14px 16px;
  min-height: 52px;
}
.stat .n.sm { font-size: 13px; }
.ghl-row { margin-top: 6px; align-items: center; gap: 8px; }
.pad-x { padding: 0 14px 14px; }
.inline-block { display: inline-block; }
.ok-msg { font-size: 12px; margin-top: 8px; color: #86efac; }
.ta-sm { min-height: 70px; }
.col-main { grid-column: auto; }
/* panel accents must include .panel */
.panel.panel-sms h2 { color: #86efac; }
.panel.panel-xfer h2 { color: #93c5fd; }

/* Focus rings for keyboard UX (a11y already high — keep visible) */
button:focus-visible, .btn:focus-visible, select:focus-visible,
input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .badge.INCALL, .badge.RINGING, .badge.DIALING, .badge.3WAY, .badge.XFER {
    animation: none;
  }
}

/* Slightly faster first paint for offscreen admin tables */
table { content-visibility: auto; }

/* Skip link + landmark focus (manual a11y checklist) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 12px 16px;
  background: #22d3ee;
  color: #041018;
  font-weight: 800;
  border-radius: 0 0 10px 0;
}
.skip-link:focus {
  left: 0;
  outline: 2px solid #fff;
  outline-offset: 2px;
}
#main-desk:focus {
  outline: none;
}
#main-desk:focus-visible {
  outline: 2px solid var(--accent2);
  outline-offset: 4px;
}


/* Button spinner while softphone connecting */
button.busy::after { content: ''; display: inline-block; width: 10px; height: 10px; margin-left: 6px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: btn-spin 0.6s linear infinite; vertical-align: middle; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
button.busy { opacity: 0.85; pointer-events: none; }

/* ---- Agent "My day" panel ------------------------------------------------
   The agent's own numbers, on their own screen. Deliberately compact so it
   never competes with the live-call panel for attention during a call. */
.panel-mystats { margin-top: 16px; }
.ms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
}
.ms {
  background: rgba(127, 160, 200, .07);
  border: 1px solid rgba(127, 160, 200, .16);
  border-radius: 10px;
  padding: 9px 10px;
  text-align: center;
}
.ms b {
  display: block;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.ms span {
  display: block;
  font-size: 10px;
  opacity: .68;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  margin-top: 3px;
}
.ms-dispo {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.ms-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(127, 160, 200, .12);
  border: 1px solid rgba(127, 160, 200, .2);
}
.ms-chip i { font-style: normal; opacity: .65; margin-left: 5px; }

/* ---- Admin live strip ----------------------------------------------------
   The admin desk was all forms and no signal. This is the "is the floor
   actually running" row, above the fold, linking into the wallboard. */
.admin-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
  padding: 14px max(16px, 2vw) 0;
}
.hero-k {
  background: rgba(127, 160, 200, .07);
  border: 1px solid rgba(127, 160, 200, .18);
  border-radius: 12px;
  padding: 11px 13px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color .18s ease, transform .18s ease;
}
a.hero-k:hover { border-color: #67e8f9; transform: translateY(-1px); }
.hero-k b {
  display: block;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.hero-k span {
  display: block;
  font-size: 10px;
  opacity: .66;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 700;
  margin-top: 3px;
}
/* Stuck legs are only worth shouting about when there are any. */
.hero-k.alarm { border-color: #f43f5e; background: rgba(244, 63, 94, .1); }
.hero-k.alarm b { color: #ff8fa3; }
.btn-floor { border-color: #67e8f9 !important; color: #67e8f9 !important; font-weight: 700; }
