/* Cyborg IVR Dialer — the CallTools "operations console" design language.
   BLUE = interactive, GREEN = money, neutral cards, 44 px controls on touch.
   Tokens come from calltools.html :root and the .afx skin. */
:root {
  --bg: #0a0d12; --surface: #0d1117; --raised: #161b22; --hover: #1c2129;
  --line: #21262d; --line2: #30363d;
  --t1: #e6edf3; --t2: #c9d1d9; --t3: #8b949e; --t4: #6e7681; --t5: #484f58;
  --accent: #58a6ff; --accent-solid: #1f6feb; --accent-2: #388bfd; --acc-bg: rgba(88, 166, 255, .12);
  --good: #3fb950; --good-bg: rgba(63, 185, 80, .14);
  --warn: #d29922; --warn-bg: rgba(210, 153, 34, .14);
  --crit: #f85149; --crit-bg: rgba(248, 81, 73, .14);
  --violet: #a371f7;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  color-scheme: dark;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { background: var(--bg); }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: var(--t2); min-height: 100vh;
  font-size: 14px; line-height: 1.45; overflow-x: hidden; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* Header + nav */
.header { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 16px;
  padding: 12px 20px; background: linear-gradient(135deg, #1a1f2e 0%, #0d1117 100%);
  border-bottom: 1px solid #1e2a3a; }
.brand { font-size: 18px; font-weight: 600; color: var(--accent); letter-spacing: .3px; white-space: nowrap; }
.brand span { color: var(--t3); font-weight: 400; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav button { padding: 7px 16px; border-radius: 20px; background: transparent; border: 1px solid transparent;
  color: var(--t3); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.nav button:hover { color: var(--t1); background: var(--hover); }
.nav button[aria-current="page"] { color: var(--accent); background: var(--acc-bg); border-color: rgba(88, 166, 255, .3); }
.who { display: flex; align-items: center; gap: 10px; color: var(--t3); font-size: 12.5px; white-space: nowrap; }
.version { font-family: var(--mono); font-size: 11px; color: var(--t4); }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
h1.page { font-size: 18px; color: var(--t1); font-weight: 650; margin-bottom: 14px; }

/* Panels + stat cards */
.panel { background: linear-gradient(180deg, #11161d, #0d1117); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 16px; overflow: hidden; }
.panel-header { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding: 14px 16px 10px; }
.panel-header h2 { font-size: 13.5px; font-weight: 700; color: var(--t1); }
.panel-header .tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 0 16px 16px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; padding: 0 16px 16px; }
.stat-card { background: var(--raised); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; position: relative; overflow: hidden; min-width: 0; }
.stat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line2); }
.stat-card.green::before { background: var(--good); }
.stat-card.amber::before { background: var(--warn); }
.stat-card.blue::before { background: var(--accent); }
.stat-card.red::before { background: var(--crit); }
.stat-value { font-family: var(--mono); font-size: 21px; font-weight: 700; color: var(--t1);
  font-variant-numeric: tabular-nums; line-height: 1.15; word-break: break-word; }
.stat-card.green .stat-value { color: var(--good); }
.stat-card.red .stat-value { color: var(--crit); }
.stat-label { font-size: 10.5px; color: var(--t3); text-transform: uppercase; letter-spacing: .7px;
  font-weight: 600; margin-top: 3px; }

/* Buttons */
.btn { background: var(--raised); border: 1px solid var(--line2); color: var(--t2); font: inherit;
  font-size: 12.5px; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  transition: .15s; line-height: 1.2; min-height: 34px; }
.btn:hover { background: var(--hover); border-color: #3d444d; }
.btn-primary { background: linear-gradient(180deg, #1f6feb, #175bc7); border-color: #1f6feb; color: #fff; }
.btn-primary:hover { filter: brightness(1.12); background: linear-gradient(180deg, #1f6feb, #175bc7); }
.btn-money { background: var(--good-bg); border-color: rgba(63, 185, 80, .4); color: var(--good); }
.btn-danger { background: var(--crit-bg); border-color: rgba(248, 81, 73, .4); color: var(--crit); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--t3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--t3); font-weight: 700; }
.field small { color: var(--t4); font-size: 11.5px; }
input, select, textarea { font: inherit; color: var(--t1); background: var(--surface); border: 1px solid var(--line2);
  border-radius: 8px; padding: 9px 11px; min-height: 40px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(56, 139, 253, .2); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.error { color: var(--crit); font-size: 12.5px; }
.ok { color: var(--good); font-size: 12.5px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--t3);
  font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); color: var(--t2); vertical-align: middle; }
tr:hover td { background: rgba(255, 255, 255, .02); }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.money-pos { color: var(--good); }
.money-neg { color: var(--crit); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line2); color: var(--t3); }
.pill.good { color: var(--good); border-color: rgba(63, 185, 80, .4); background: var(--good-bg); }
.pill.warn { color: var(--warn); border-color: rgba(210, 153, 34, .4); background: var(--warn-bg); }
.pill.crit { color: var(--crit); border-color: rgba(248, 81, 73, .4); background: var(--crit-bg); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; background: linear-gradient(180deg, #11161d, #0d1117);
  border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; }
.login .brand { font-size: 22px; margin-bottom: 4px; }
.login p { color: var(--t3); font-size: 13px; margin-bottom: 20px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login .btn-primary { min-height: 44px; font-size: 14px; }

/* Dialogs + toast */
dialog { margin: auto; background: var(--surface); color: var(--t2); border: 1px solid var(--line2);
  border-radius: 12px; padding: 20px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { color: var(--t1); font-size: 15px; margin-bottom: 14px; }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 100; max-width: min(420px, calc(100vw - 32px));
  background: var(--raised); border: 1px solid var(--line2); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; color: var(--t1); box-shadow: 0 8px 30px rgba(0, 0, 0, .4); }
.toast.error { border-left-color: var(--crit); }
.toast.good { border-left-color: var(--good); }
.empty { color: var(--t4); padding: 24px 16px; text-align: center; }

@media (max-width: 640px) {
  .header { flex-wrap: wrap; padding: 10px 16px; row-gap: 8px; }
  .who { margin-left: auto; }
  .nav { order: 3; flex: 0 0 100%; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .nav button { white-space: nowrap; }
  .btn, input, select { min-height: 44px; }
  /* tables become one card per row; each cell shows its column name */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 10px; padding: 6px 4px;
    background: var(--raised); }
  table.cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px;
    border-bottom: 0; padding: 6px 10px; text-align: right; }
  table.cards td::before { content: attr(data-label); font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .7px; color: var(--t3); font-weight: 700; text-align: left; }
  table.cards td.actions::before { content: none; }
  table.cards td.actions .tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
}
.panel > .stat-cards:first-child { padding-top: 16px; }

/* lead lists */
dialog.wide { width: min(880px, calc(100vw - 24px)); max-width: none; }
dialog h4 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--t3); font-weight: 700;
  margin: 16px 0 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--t2); cursor: pointer;
  min-height: 32px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent-2); }
.stat-cards.flush { padding: 0 0 4px; }
.mono { font-family: var(--mono); font-size: 12px; }
.small { font-size: 12px; color: var(--t3); }
.table-wrap.sample { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px; }
.table-wrap.sample td, .table-wrap.sample th { white-space: nowrap; max-width: 220px; overflow: hidden;
  text-overflow: ellipsis; }
.progress-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
td .pill { margin-left: 8px; }
@media (max-width: 600px) {
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-value { font-size: 18px; }
}

/* trunk groups + campaigns */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.member-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; counter-reset: m; }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--raised); }
.member-list li::before { counter-increment: m; content: counter(m) '.'; color: var(--t4); font-family: var(--mono); }
.member-list li.small::before { content: none; }
.member-list .member-name { flex: 1; color: var(--t1); }
.member-list input { width: 84px; }
.member-list .btn-ghost { padding: 4px 8px; min-width: 32px; }
.problems { margin: 4px 0 0; padding-left: 18px; color: var(--warn); font-size: 12.5px; }
.note { border-left: 3px solid var(--warn); background: var(--warn-bg); padding: 8px 12px; border-radius: 6px;
  font-size: 12.5px; color: var(--t2); margin: 8px 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; margin-top: 12px; min-width: 0; }
legend { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--t3); font-weight: 700; padding: 0 6px; }
.days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent-2); }
input[type="checkbox"]:focus { box-shadow: none; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* audio */
audio.player { width: 100%; max-width: 280px; height: 36px; }
.player-slot audio.player { margin-top: 6px; max-width: none; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 46ch; }
.tts-text { margin-top: 12px; }
textarea { resize: vertical; min-height: 110px; }
td audio.player { min-width: 220px; }
.who-name { padding: 4px 8px; font-size: 12.5px; }

/* agent workspace */
.agent-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px; }
.agent-bar .tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.pill.big { font-size: 14px; padding: 6px 14px; }
.lead-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 16px; margin-bottom: 12px; }
.lead-facts > div { display: flex; flex-direction: column; gap: 2px; }
.lead-facts strong { color: var(--t1); font-size: 15px; }
table.kv { margin: 6px 0 12px; }
table.kv th { width: 34%; text-transform: none; letter-spacing: 0; font-size: 12.5px; }
.call-tools { margin: 8px 0 12px; }
.keypad { display: grid; grid-template-columns: repeat(3, 64px); gap: 8px; }
.keypad .btn { min-height: 44px; font-family: var(--mono); font-size: 16px; }
.wrap-buttons { margin-bottom: 12px; }
.wrap-buttons .btn { min-height: 40px; }

/* dashboard */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 16px; }
tr.sub td { padding-top: 0; border-bottom-color: var(--line); color: var(--t3); }
.row-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-controls .cps { display: inline-flex; align-items: center; gap: 6px; }
.row-controls .cps .btn { min-width: 36px; justify-content: center; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* bill check */
.btn[aria-pressed="true"] { border-color: var(--accent); color: var(--t1); background: var(--raised); box-shadow: inset 0 -2px 0 var(--accent); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.bill-head { justify-content: space-between; margin-bottom: 8px; }
.bill-items .pill { white-space: nowrap; margin-left: 0; }
.bill-items .line-no { display: block; margin-top: 3px; color: var(--t4); font-family: var(--mono); }
dialog .chips { margin: 12px 0 8px; }

/* reports */
table.report tfoot td { border-top: 2px solid var(--line2); font-weight: 700; color: var(--t1); }
table.report td.num { white-space: nowrap; }

/* nightly checks */
.checks-bad { border-color: var(--crit); background: var(--crit-bg); }
.checks-bad h2 { color: var(--crit); }
.checks-bad .panel-body .small { margin-top: 8px; }

/* do-not-call lists */
.page-intro { margin: -6px 0 14px; max-width: 760px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.inline-form input { flex: 1 1 220px; max-width: 320px; }
.picker { display: flex; flex-direction: column; gap: 6px; }
.lookup-out p { margin: 6px 0; }
.lookup-out .pill { margin-right: 4px; }
.progress-line strong { flex: none; }
