/* CommsPanel design system tokens (Nora + Tailwind portal, replicated in plain CSS) */
:root {
  --primary-50: #EFF6FF;
  --primary-100: #DBEAFE;
  --primary-500: #3B82F6;
  --primary-600: #2563EB;
  --primary-700: #1D4ED8;
  --primary-800: #1E40AF;
  --secondary: #E0E0E0;
  --surface: #EDF1F7;
  --card: #ffffff;
  --text: #1A2233;
  --text-2: #495670;
  --text-neutral: #8291A9;
  --line: #e5e7eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --menubar-h: 64px;
  --sidebar-w: 5rem;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-width: 1100px;
}
.hidden { display: none !important; }
.muted { color: var(--text-neutral); }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
:focus-visible { outline: 1px solid var(--primary-500); outline-offset: 1px; }

/* ---------- top menubar ---------- */
.menubar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--menubar-h);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  z-index: 30;
}
.brand { font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand span { font-weight: 500; color: var(--text-2); }
.metrics { margin-left: auto; display: flex; align-items: center; gap: 24px; }
.metric { text-align: right; line-height: 1.25; }
.metric b {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-neutral);
  white-space: nowrap;
}
.metric.warn b { color: var(--amber); }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed;
  top: var(--menubar-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 55%, #f3f4f6 100%);
  border-right: 1px solid #e5e7eb;
  box-shadow: 1px 0 3px rgba(0, 0, 0, .04);
  display: flex;
  flex-direction: column;
  padding: 12px 8px 14px;
  z-index: 20;
}
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a,
.sidebar-foot button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 10px 2px 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: #374151;
  text-decoration: none;
  text-align: center;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
}
.nav a svg,
.sidebar-foot button svg { width: 22px; height: 22px; }
.nav a:hover,
.nav a.active,
.sidebar-foot button:hover {
  background: linear-gradient(180deg, var(--primary-50), var(--primary-100));
  color: var(--primary-700);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- content + cards ---------- */
.content {
  margin: var(--menubar-h) 0 0 var(--sidebar-w);
  padding: 24px;
  max-width: 1400px;
  min-height: calc(100vh - var(--menubar-h));
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 12px; font-size: 15px; font-weight: 600; color: var(--text); }
.card p { margin: 8px 0; color: var(--text-2); font-size: 13px; }
.card .hint, .hint { color: var(--text-neutral); font-size: 12px; }
.table-card { padding: 4px 8px 8px; overflow-x: auto; }
.toolbar { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin: 4px 0 14px; }
.toolbar .field { min-width: 230px; }
.stat-big { margin-top: 14px; font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat-big-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-neutral);
  margin-top: 3px;
}
.empty { padding: 24px; text-align: center; color: var(--text-neutral); font-size: 13px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-neutral);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--primary-50); }
.table tbody tr.clickable { cursor: pointer; }

/* ---------- status pills ---------- */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-green { background: #f0fdf4; color: var(--green); }
.pill-red { background: #fef2f2; color: var(--red); }
.pill-amber { background: #fffbeb; color: var(--amber); }
.pill-blue { background: var(--primary-50); color: var(--primary-600); }
.pill-gray { background: #f3f4f6; color: var(--text-neutral); }
.count-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.summary-pills { margin-top: 14px; }

/* ---------- buttons ---------- */
.btn, .btn-danger, .btn-subtle {
  border: 0;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn { background: var(--primary-600); color: #fff; }
.btn:hover { background: var(--primary-700); }
.btn:active { background: var(--primary-800); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-subtle { background: var(--card); border: 1px solid var(--line); color: var(--text-2); }
.btn-subtle:hover { background: var(--primary-50); }
.btn:disabled, .btn-danger:disabled, .btn-subtle:disabled { opacity: .55; cursor: default; }
.btn-block { width: 100%; }
.icon-btn {
  border: 0;
  background: none;
  color: var(--text-neutral);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}
.icon-btn:hover { color: var(--text); background: var(--surface); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field > span {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-neutral);
}
.field input, .field select, .field textarea, .input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
}
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--primary-500);
  outline: none;
}
.field textarea { resize: vertical; }
.field input[type="file"] { padding: 6px; }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
.input-sm { width: 110px; padding: 5px 8px; font-size: 12.5px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-600); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check > span {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.radio-row { display: flex; gap: 16px; align-items: center; padding: 8px 0; }
.radio { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text-2); }
.section-title {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-neutral);
}
.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 16px;
}
.upload-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; }


/* A row the preview has already rejected is never sent, so it is dimmed rather than
   presented as something that is about to be uploaded. */
tr.row-bad td { background: var(--red-soft, rgba(200, 60, 60, 0.05)); }

/* A look at the file as it was read, so the chosen phone column can be checked against the
   data rather than against a header. Scrolls sideways: a real export has 25 columns. */
.csv-peek { overflow-x: auto; margin-top: 12px; border: 1px solid var(--border); border-radius: 8px; }
.csv-peek table { margin: 0; font-size: 12px; white-space: nowrap; }
.csv-peek th, .csv-peek td { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.csv-peek .col-phone { background: rgba(37, 129, 90, 0.10); font-weight: 600; }
.map-note { margin: 10px 0 4px; }
.map-ok { color: var(--green, #1a7f4b); }
.map-warn { color: var(--amber-text, #8a5a00); }

/* ---------- monday.com integration screen ---------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.card-sub { margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 9px 18px; margin: 4px 0 16px; }
.kv dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-neutral);
}
.kv dd { margin: 0; font-size: 13px; color: var(--text); }
.field.narrow { max-width: 420px; }
.req { margin-left: 6px; color: var(--red); font-size: 10px; font-weight: 700; }
.map-rows { display: flex; flex-direction: column; gap: 16px; max-width: 780px; margin-top: 16px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; }
.check-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.label-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px; }
.form-error { color: var(--red); font-size: 12px; }

/* ---------- switch toggle ---------- */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; vertical-align: middle; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.switch .knob {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background .15s;
  pointer-events: none;
}
.switch .knob::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(26, 34, 51, .25);
  transition: left .15s;
}
.switch input:checked + .knob { background: var(--primary-600); }
.switch input:checked + .knob::after { left: 18px; }

/* ---------- calling-hours editor ---------- */
.hours { display: flex; flex-direction: column; gap: 6px; max-width: 460px; }
.hours-row {
  display: grid;
  grid-template-columns: 92px 1fr 26px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.hours-row .muted { text-align: center; }
.hours-row input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.hours-row input:focus { border-color: var(--primary-500); outline: none; }

/* ---------- modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 34, 51, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 44px 16px;
  overflow: auto;
  z-index: 50;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: 0 10px 30px rgba(26, 34, 51, .18);
  width: 720px;
  max-width: 100%;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

/* ---------- saved flash ---------- */
.saved-flash { opacity: 0; transition: opacity .25s; color: var(--green); font-size: 12px; font-weight: 600; }
tr.saved .saved-flash { opacity: 1; }

/* ---------- progress ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 14px; }
.progress > div { height: 100%; width: 0; background: var(--primary-600); transition: width .15s; }
.progress-label { font-size: 12px; color: var(--text-neutral); margin-top: 6px; }

/* ---------- toasts ---------- */
#toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  max-width: 360px;
  box-shadow: 0 4px 12px rgba(26, 34, 51, .12);
  transition: opacity .3s, transform .3s;
}
.toast-error { border-left-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); }

/* ---------- login ---------- */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 40;
}
.login-card {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--card-shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-brand b { font-size: 18px; font-weight: 700; color: var(--text); }
.login-brand b span { font-weight: 500; color: var(--text-2); }
.login-brand p { margin: 4px 0 0; font-size: 12px; color: var(--text-neutral); }
.login-card.shake { animation: shake .4s; }
.login-error { min-height: 16px; color: var(--red); font-size: 12px; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@media (max-width: 1280px) {
  .content { padding: 18px; }
  .menubar { padding: 0 18px; gap: 20px; }
  .metrics { gap: 16px; }
}

/* Read-only hand-off queue indicator. It sits before .metrics, whose margin-left:auto
   pushes the tiles right, so a long "dialing held" reason takes the slack in the middle
   of the bar and truncates instead of pushing the tiles off a narrow screen. */
.handoff {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface);
}
.handoff .muted {
  font-weight: 500;
  margin-right: 6px;
}
.handoff.warn {
  border-color: var(--amber);
  /* Darker than --amber: the pill's text must stay readable on its own background. */
  color: #92400e;
  background: #fffbeb;
}
.handoff.warn::before {
  content: '! ';
  font-weight: 700;
}

.pacing-badge { margin-left: 8px; white-space: nowrap; }

/* Destructive action in a modal footer; sits away from the primary button. */
.btn-danger {
  margin-right: auto;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: #b91c1c;
  background: #fff;
  border: 1px solid #fca5a5;
}
.btn-danger:hover { background: #fef2f2; }

/* Inline form failure: stays on screen after the toast has gone. */
.field-error:empty { display: none; }
.field-error {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid var(--amber);
}

.row-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.link-danger {
  border: 0;
  background: none;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  color: #b91c1c;
  cursor: pointer;
}
.link-danger:hover { text-decoration: underline; }

/* Dashboard cards: each one opens the campaigns behind its number. */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.dash-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--card-shadow);
}
.dash-card b {
  font-size: 26px;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.dash-card span { font-size: 13px; font-weight: 600; color: var(--text); }
.dash-card small { font-size: 11px; color: var(--text-neutral); }
.dash-card:hover { border-color: var(--primary-500); }
.dash-card.open {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 2px var(--primary-100), var(--card-shadow);
}

/* Board checkboxes in the campaign form: a campaign can draw from several. */
.board-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 14px;
  max-height: 210px;
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}
.board-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.board-option input { margin: 0; }
.field.span-2 { grid-column: span 2; }

/* ---------- reports ---------- */
/* Two halves of a number's story, kept visually apart: what is true now, and what happened. */
.report-block { margin-top: 18px; }
.report-block:first-child { margin-top: 8px; }
.report-block h3 { margin: 0 0 8px; font-size: 14px; }
.field-grow { flex: 1 1 260px; }
/* A campaign row opens its detail, so it has to look like it does something. */
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--surface-hover, rgba(127, 140, 158, 0.08)); }

/* The one place a generated password is ever shown. Monospace so an O and a 0 are
   distinguishable while it is being transcribed -- though the generator excludes both. */
.pw-reveal { display: flex; align-items: center; gap: 8px; }
.pw-reveal .input { flex: 1; letter-spacing: 0.04em; }
.pw-reveal .btn-subtle { white-space: nowrap; }

/* Lead filter blocks on the campaign modal. One per board the campaign draws from. */
.filter-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.filter-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.filter-cond { gap: 8px; align-items: center; margin-bottom: 6px; }
.input-sm { max-width: 120px; }
/* The rule read back in English. It is the thing an operator actually checks before
   applying, so it is given weight rather than tucked away as a hint. */
.filter-sentence { margin: 10px 0 6px; padding: 8px 10px; border-left: 3px solid var(--accent, #4a7);
                   background: var(--surface-2, rgba(127,127,127,0.06)); border-radius: 4px; }

/* ---------- softphone ---------- */

.sp-status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.sp-error { flex-basis: 100%; color: var(--red); margin: 6px 0 0; }
.sp-steps { margin: 6px 0 4px; padding-left: 20px; color: var(--text-2); font-size: 13px; line-height: 1.7; }

/* Outside #view on purpose: the call survives moving between screens. */
.softphone-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 900;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  overflow: hidden;
}
.softphone-dock.hidden { display: none; }
.softphone-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.softphone-dock-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  width: 26px;
  height: 24px;
  cursor: pointer;
  color: var(--text-2);
}
.softphone-dock.min .softphone-root { display: none; }
.softphone-dock.min .softphone-dock-head { border-bottom: 0; }
.softphone-root { max-height: 70vh; overflow: auto; }
