:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --ink: #1c2130;
  --muted: #667085;
  --line: #e3e6ee;
  --primary: #4361ee;
  --primary-dark: #3550d6;
  --call: #1f9d55;
  --call-dark: #197f45;
  --danger: #d64545;
  --warn: #b7791f;
  --radius: 12px;
}
* { box-sizing: border-box; }
/* Author rules below set `display` on elements we toggle with el.hidden; without this they
   would override the user-agent [hidden] rule and stay visible. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; left: -9999px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand span { color: var(--primary); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar form { margin: 0; }
.me-name { font-weight: 600; }
.line-status { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: #eef0f6; color: #4a5266; white-space: nowrap; }
.line-status::before { content: '●'; margin-right: 6px; }
.line-status.ready { background: #e8f7ee; color: #14532d; }
.line-status.starting { background: #fff4e5; color: #7a4b00; }
.line-status.blocked { background: #fdecec; color: #8a1f1f; }
.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 8px; background: #fff4e5; color: #7a4b00; border: 1px solid #f5d9a8; }
.banner.error { background: #fdecec; color: #8a1f1f; border-color: #f3c2c2; }
.banner.ok { background: #e8f7ee; color: #14532d; border-color: #b9e5c9; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #c9ceda; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-call { background: var(--call); border-color: var(--call); color: #fff; padding: 12px 22px; font-size: 16px; }
.btn-call:hover { background: var(--call-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; padding: 12px 22px; font-size: 16px; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; justify-content: center; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--card); padding: 32px; border-radius: var(--radius); width: 100%; max-width: 380px; box-shadow: 0 10px 40px rgba(28,33,48,.08); }
.login-card h1 { margin-top: 12px; }
.login-card label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-card .btn { margin-top: 18px; }
.alert { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #fdecec; color: #8a1f1f; }

.workspace { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; padding: 16px 20px 40px; align-items: start; }
.queue-panel, .contact-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.queue-panel { position: sticky; top: 12px; max-height: calc(100vh - 24px); display: flex; flex-direction: column; }
.panel-head { padding: 12px; border-bottom: 1px solid var(--line); }
.list-select { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-weight: 600; }
.queue { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.queue li { padding: 10px 10px; border-radius: 8px; cursor: pointer; display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 8px; align-items: center; }
.queue li:hover { background: #f1f3fa; }
.queue li.current { background: #e9edfd; outline: 1px solid #c6d0fb; }
.queue li.next .pos { color: var(--primary); font-weight: 700; }
.queue .pos { color: var(--muted); font-size: 13px; text-align: right; }
.queue .who { min-width: 0; }
.queue .who .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .who .sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11.5px; font-weight: 700; padding: 3px 7px; border-radius: 999px; background: #eef0f6; color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .03em; }
.badge.done { background: #e8f7ee; color: #14532d; }
.badge.skipped { background: #f3f4f6; color: #6b7280; }
.badge.dnc { background: #fdecec; color: #8a1f1f; }
.badge.callback { background: #fff4e5; color: #7a4b00; }
.badge.invalid { background: #fdecec; color: #8a1f1f; }

.contact-panel { padding: 20px 22px; min-height: 60vh; }
.empty-state { color: var(--muted); padding: 40px 0; text-align: center; }
.contact-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.phone { font-size: 18px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.call-controls { display: flex; gap: 8px; align-items: center; }
.call-status { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: #eef0f6; font-weight: 600; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.call-status.live { background: #e8f7ee; color: #14532d; }
.call-status.ringing { background: #fff4e5; color: #7a4b00; }
.call-status.ended { background: #eef0f6; color: var(--ink); }
.call-status.failed { background: #fdecec; color: #8a1f1f; }
.call-status .timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.extra { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 16px 0 0; font-size: 14px; }
.extra dt { color: var(--muted); }
.extra dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.extra-link { color: var(--primary); text-decoration: none; }
.extra-link:hover { text-decoration: underline; }
.script { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #fbfbfe; }
.script summary { cursor: pointer; font-weight: 600; }
.script pre { white-space: pre-wrap; font: inherit; margin: 8px 0 4px; }
.notes-editor, .outcome-editor, .history { margin-top: 22px; }
textarea, select, input[type="datetime-local"], input[type="text"] { font: inherit; }
.notes-editor textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.wrap { flex-wrap: wrap; }
.outcome-editor select, .outcome-editor input { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; }
.notes-list, .attempts-list { list-style: none; padding: 0; margin: 0 0 12px; }
.notes-list li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; white-space: pre-wrap; }
.notes-list .meta, .attempts-list .meta { color: var(--muted); font-size: 12.5px; }
.attempts-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; display: flex; justify-content: space-between; gap: 12px; }
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; padding: 12px; }
  .queue-panel { position: static; max-height: 40vh; }
  .contact-panel { padding: 16px; }
}
.sms-box { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.sms-box .small { flex: 1; min-width: 200px; }
