
/* OutreachHQ — internal admin UI. Desktop-first, minimal animation. */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1c2430;
  --muted: #67717f;
  --accent: #1f4fd8;
  --accent-dark: #173ea9;
  --sidebar: #111726;
  --sidebar-text: #aab3c4;
  --green-bg: #e5f6ec; --green-fg: #137a41;
  --red-bg: #fdeaea;   --red-fg: #b42318;
  --yellow-bg: #fdf3d7;--yellow-fg: #8a6100;
  --blue-bg: #e7eefe;  --blue-fg: #1f4fd8;
  --gray-bg: #eef0f3;  --gray-fg: #5a6472;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Sidebar ----------
   Pinned (fixed) so scrolling — vertical OR horizontal — can never slide the
   navigation out of view. --sidebar-w drives both the rail width and the main
   column offset, so the two can never disagree. */
:root { --sidebar-w: 216px; }
html.nav-collapsed { --sidebar-w: 64px; }

.shell { min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  height: 100vh; overflow-y: auto; overflow-x: hidden;
  z-index: 40;
  transition: width .15s ease;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid #232b3d; }
.brand-mark {
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text small { font-size: 11px; color: #7b869b; }
.sidebar nav { flex: 1; padding: 12px 8px; }
.sidebar nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; color: var(--sidebar-text);
  margin-bottom: 2px; font-size: 13.5px;
}
.nav-icon { display: inline-flex; flex: 0 0 auto; }
.nav-icon svg { display: block; }
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar nav a:hover { background: #1b2335; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid #232b3d; font-size: 12px; }
.whoami { color: #7b869b; margin-bottom: 8px; word-break: break-all; }

/* Rail ⇄ full toggle. */
.nav-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 16px; margin-top: auto;
  background: transparent; border: 0; border-top: 1px solid #232b3d;
  color: var(--sidebar-text); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.nav-toggle:hover { background: #1b2335; color: #fff; }
.nav-toggle:focus-visible { outline: 2px solid #4d7cff; outline-offset: -2px; }
.nav-toggle .nav-icon svg { transition: transform .15s ease; }
html.nav-collapsed .nav-toggle .nav-icon svg { transform: rotate(180deg); }

/* Collapsed: icon rail. Labels stay available as native tooltips. */
html.nav-collapsed .brand-text,
html.nav-collapsed .nav-label,
html.nav-collapsed .whoami { display: none; }
html.nav-collapsed .brand { justify-content: center; padding: 18px 8px; }
html.nav-collapsed .sidebar nav { padding: 12px 6px; }
html.nav-collapsed .sidebar nav a { justify-content: center; padding: 10px 0; }
html.nav-collapsed .nav-toggle { justify-content: center; padding: 10px 8px; }
html.nav-collapsed .sidebar-foot { padding: 12px 6px; text-align: center; }
html.nav-collapsed .sidebar-foot .btn { padding: 4px 2px; font-size: 11.5px; }

/* ---------- Main ---------- */
.main {
  margin-left: var(--sidebar-w); padding: 24px 28px 60px;
  max-width: 1280px; min-width: 0; transition: margin-left .15s ease;
}
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
.page-head h1 { font-size: 20px; margin: 0; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Panels, tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 18px; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { font-size: 14.5px; margin: 0; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #fafbfc; font-weight: 600; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.compact th, table.compact td { padding: 6px 10px; }
.table-wrap { overflow-x: auto; }

/* ---------- Stat cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.card .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .value.good { color: var(--green-fg); }
.card .value.bad { color: var(--red-fg); }
.card .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Status headers (Settings: scheduler, enrollment check) ---------- */
.status-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-when { font-weight: 650; }
.sched-group {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 14px 0 6px;
}
.sched-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.sched-stat { border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; background: #fafbfc; }
.sched-stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sched-stat .v { font-size: 18px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sched-stat .v.good { color: var(--green-fg); }
.sched-stat .v.warn { color: var(--yellow-fg); }
.sched-stat .v.bad { color: var(--red-fg); }

/* ---------- Copy button (icon only) ---------- */
.copy-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border-radius: 5px;
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  cursor: pointer; vertical-align: middle; transition: color .12s, border-color .12s, background .12s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); background: #f5f8ff; }
.copy-btn:focus-visible { outline: 2px solid #bcd0ff; border-color: var(--accent); }
.copy-btn.copied { border-color: #bfe7d0; background: var(--green-bg); color: var(--green-fg); }
.copy-btn svg { pointer-events: none; display: block; }
.copy-cell { width: 1%; white-space: nowrap; text-align: right; }
td.actions-cell { width: 1%; white-space: nowrap; text-align: right; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.green { background: var(--green-bg); color: var(--green-fg); }
.badge.red { background: var(--red-bg); color: var(--red-fg); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow-fg); }
.badge.blue { background: var(--blue-bg); color: var(--blue-fg); }
.badge.gray { background: var(--gray-bg); color: var(--gray-fg); }

/* ---------- Buttons & forms ---------- */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--sidebar-text); border-color: #303a52; }
.btn-ghost:hover { background: #1b2335; color: #fff; }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: #f0f2f5; }
.btn-danger { background: var(--red-fg); }
.btn-danger:hover { background: #8f1c13; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-block { display: block; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--red-fg); }

form.inline { display: inline; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0ff; border-color: var(--accent); }
/* min(240px, 100%) keeps a single column from overflowing a narrow window. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.checks label { font-size: 13px; display: flex; gap: 6px; align-items: center; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 13px; font-weight: 650; padding: 0 6px; color: var(--muted); }

/* ---------- Filters bar ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; min-width: 130px; }
.filters input[type=text] { min-width: 200px; }

/* ---------- Banners / empty ---------- */
.banner { padding: 9px 12px; border-radius: 6px; margin-bottom: 14px; font-size: 13.5px; border: 1px solid; }
.banner-ok { background: var(--green-bg); color: var(--green-fg); border-color: #bfe7d0; }
.banner-err { background: var(--red-bg); color: var(--red-fg); border-color: #f3c2be; }
.banner-warn { background: var(--yellow-bg); color: var(--yellow-fg); border-color: #efd994; }
.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty-action { margin-top: 12px; }

/* ---------- Pager ---------- */
.pager { display: flex; gap: 6px; padding: 10px 14px; align-items: center; }
.pager a, .pager span { padding: 3px 9px; border: 1px solid var(--border); border-radius: 5px; background: #fff; font-size: 13px; }
.pager a.cur { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager span.off { color: #b3bac5; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.mono-block {
  background: #0f1420; color: #d8e0ee; padding: 14px; border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}
.email-preview { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 18px; }
.email-preview .subj { font-weight: 650; margin-bottom: 10px; }
.email-preview .body { white-space: pre-wrap; font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: -6px; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--gray-bg); color: var(--gray-fg); border-radius: 5px; padding: 2px 8px; font-size: 12px; }

/* ---------- Prospect sequence & Close Deal ---------- */
.seq-step { padding: 12px 0; border-bottom: 1px solid var(--border); }
.seq-step:last-child { border-bottom: 0; padding-bottom: 0; }
.seq-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.seq-subject { font-weight: 650; font-size: 13.5px; margin-bottom: 4px; }
.seq-body {
  white-space: pre-wrap; font-size: 13px; background: var(--gray-bg);
  border-radius: 6px; padding: 10px 12px;
}
.seq-step details { margin-top: 8px; }
.close-deal { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
tr.needs-action td { background: rgba(255, 200, 0, .07); }

/* ---------- HTML template editor & preview ---------- */
.preview-label {
  font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 2px 0 6px;
}
.preview-subj { font-size: 14px; font-weight: 650; margin-bottom: 14px; }
/* Sandboxed iframe: no scripts, no forms, opaque origin — template HTML can
   never run code or touch the surrounding admin UI. */
.email-frame {
  display: block; width: 100%; height: 420px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; margin-bottom: 16px;
}
.var-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.var-item {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--gray-bg); border-radius: 5px; padding: 1px 2px 1px 8px;
}
.var-item code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--gray-fg); }
.var-item .copy-btn { width: 20px; height: 20px; border-color: transparent; background: transparent; }
.var-item .copy-btn:hover { background: #fff; }
.auth-wrap { max-width: 380px; margin: 8vh auto 0; }
.auth-wrap .brand { justify-content: center; border: none; padding-bottom: 0; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.auth-card h1 { font-size: 18px; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 18px; font-size: 13px; }

/* ---------- Reset data (Settings → Reset data) ---------- */
.reset-list { display: grid; gap: 10px; }
.reset-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap; margin: 0; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.reset-row .reset-text { display: flex; flex-direction: column; gap: 2px; min-width: 200px; flex: 1 1 260px; }
.reset-row strong { font-size: 13.5px; }
.reset-row .muted { font-size: 12.5px; }

/* ---------- Example loader + on-demand run overlay ---------- */
.field-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px;
}
.run-overlay {
  position: fixed; inset: 0; background: rgba(17, 23, 38, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; z-index: 60;
}
/* display:flex above would otherwise beat the user-agent [hidden] rule. */
.run-overlay[hidden] { display: none; }
.run-card {
  background: var(--panel); border-radius: 10px; width: 100%; max-width: 620px;
  max-height: 82vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 18px 48px rgba(17, 23, 38, .35);
}
.run-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.run-head h2 { font-size: 15px; margin: 0; }
.run-spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: run-spin .7s linear infinite;
}
@keyframes run-spin { to { transform: rotate(360deg); } }
.run-log {
  padding: 12px 18px; overflow-y: auto; flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  line-height: 1.6; background: #fafbfc;
}
.run-line { white-space: pre-wrap; word-break: break-word; }
.run-line.info { color: var(--text); }
.run-line.ok { color: var(--green-fg); }
.run-line.warn { color: var(--yellow-fg); }
.run-line.err { color: var(--red-fg); }
.run-line.muted { color: var(--muted); }
.run-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.run-status { font-size: 12.5px; color: var(--muted); }
.run-actions { display: flex; gap: 8px; }

/* ---------- Responsive ---------- */

/* Tablet: the two-column detail layouts stack. */
@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* Narrow: the sidebar becomes a pinned top bar (still fixed, never hidden). */
@media (max-width: 860px) {
  .sidebar {
    top: 0; left: 0; right: 0; bottom: auto;
    width: 100%; height: 56px;
    flex-direction: row; align-items: center; gap: 4px;
    padding: 0 8px; overflow-x: auto; overflow-y: hidden;
  }
  .brand { padding: 0 8px; border-bottom: 0; flex: 0 0 auto; }
  .brand-text { display: none; }
  .sidebar nav { padding: 0; overflow-x: auto; }
  .sidebar nav ul { display: flex; flex-wrap: nowrap; gap: 4px; }
  .sidebar nav a { margin-bottom: 0; white-space: nowrap; }
  .sidebar-foot { border-top: 0; padding: 0 8px; margin-left: auto; }
  .whoami { display: none; }
  .nav-toggle { display: none; }   /* the bar is already compact */
  /* Always show labels here — there is no toggle to expand a rail on phones. */
  html.nav-collapsed .nav-label { display: inline; }
  html.nav-collapsed .sidebar nav a { justify-content: flex-start; padding: 8px 10px; }
  html.nav-collapsed .brand { padding: 0 8px; }
  html.nav-collapsed .sidebar-foot { padding: 0 8px; }
  .main { margin-left: 0; padding: 72px 16px 48px; }
}

/* Phone: single-column forms, tighter chrome, sections reflow to full width. */
@media (max-width: 640px) {
  .main { padding: 68px 12px 40px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  fieldset { padding: 12px; }
  .panel-body { padding: 12px; }
  .checks { gap: 10px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 6px; }
  .filters input[type=text] { min-width: 0; }
  .filters .field { min-width: 0; flex: 1 1 140px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
  table { font-size: 12.5px; }
  th, td { padding: 7px 8px; }
  .truncate { max-width: 200px; }
  .mono-block { padding: 10px; font-size: 12px; }
}
