/* ===========================================================
   Messaging Console - shared design system
   One file, reused by every page, so the product reads as one
   cohesive tool rather than a stack of unrelated screens.
   =========================================================== */

:root {
  --bg:            #F6F8F7;
  --surface:       #FFFFFF;
  --surface-alt:   #F1F5F3;
  --border:        #E4EAE7;
  --border-strong: #CBD6D1;
  --ink:           #0C1F17;
  --ink-muted:     #566862;
  --ink-faint:     #8C9A94;
  --accent:        #0E6B46;
  --accent-hover:  #0A5537;
  --accent-soft:   #E3F1EA;
  --accent-ink:    #083D28;
  --wa-green:      #25D366;
  --success:       #12894E;
  --success-bg:    #E7F6EE;
  --success-border:#BCE3CD;
  --danger:        #D23A2C;
  --danger-bg:     #FDEBE9;
  --danger-border: #F4C7C1;
  --warn:          #B07A12;
  --warn-bg:       #FBF1DD;
  --sidebar-bg:    #0C1F17;
  --sidebar-ink:   #DCE7E2;
  --sidebar-muted: #8AA096;
  --sidebar-active:#163528;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(10,30,22,0.04), 0 8px 24px rgba(10,30,22,0.07);
  --font-ui:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Consolas, monospace;
}

/* RCS context: shift the accent to RCS / Google-Messages blue.
   Add class="theme-rcs" on <body> (or any wrapper) for RCS screens.
   WhatsApp screens keep the forest-green accent above. */
.theme-rcs {
  --accent:       #1A73E8;
  --accent-hover: #1667D0;
  --accent-soft:  #E6EFFD;
  --accent-ink:   #0B3D91;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-hover); }
code { font-family: var(--font-mono); }

/* ---------- App shell: sidebar + topbar + content ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: none;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar .wordmark {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  padding: 6px 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar .wordmark .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font-size: 0.78rem; font-weight: 800; font-family: var(--font-mono);
  flex: none;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.89rem;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
}
.sidebar nav a:hover { background: var(--sidebar-active); color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar nav a .ico { width: 16px; text-align: center; flex: none; font-family: var(--font-mono); font-size: 0.8rem; }
.sidebar .nav-section-label {
  color: var(--sidebar-muted); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.07em; padding: 16px 12px 6px; font-weight: 700;
}
.sidebar .sidebar-foot { margin-top: auto; padding: 12px 10px 4px; color: var(--sidebar-muted); font-size: 0.74rem; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
  gap: 16px;
}
.topbar h1 { font-size: 1.12rem; margin: 0; letter-spacing: -0.01em; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--ink-muted); }
.topbar .role-chip {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink);
}

.page { padding: 24px 28px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- Panels / cards ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.panel-head h2 { margin: 0; font-size: 1rem; }
.panel h2 { font-size: 1rem; margin: 0 0 14px; }
.panel .step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700;
  margin-right: 8px;
}
.muted { color: var(--ink-muted); }
.hint { font-size: 0.82rem; color: var(--ink-faint); margin: 5px 0 0; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field label { font-size: 0.78rem; font-weight: 600; color: var(--ink-muted); }
.field input, .field select, .field textarea {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  width: 100%;
}
.field.mono input, .field.mono textarea { font-family: var(--font-mono); font-size: 0.87rem; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: var(--surface);
}
.field textarea { resize: vertical; min-height: 70px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 18px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.checkbox-row label { font-size: 0.86rem; color: var(--ink); font-weight: 500; }

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-ui); font-size: 0.86rem; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block;
  transition: background .12s ease, border-color .12s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn.secondary:hover:not(:disabled) { background: var(--surface-alt); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn.small { padding: 6px 11px; font-size: 0.78rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 620px; }
thead th {
  text-align: left; background: var(--surface-alt); color: var(--ink-muted);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
td.mono, .mono-cell { font-family: var(--font-mono); font-size: 0.84rem; }

/* ---------- Badges / status pills ---------- */

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  color: #fff;
}
.badge.success, .badge.accepted, .badge.completed { background: var(--success); }
.badge.failed, .badge.stopped { background: var(--danger); }
.badge.pending, .badge.queued, .badge.unknown { background: var(--ink-faint); }
.badge.running, .badge.claimed { background: var(--accent); }
.badge.suppressed { background: var(--warn); }

.status-pill {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 4px 11px; border-radius: 999px; background: var(--ink-faint); color: #fff;
}
.status-pill.running { background: var(--accent); }
.status-pill.completed { background: var(--success); }
.status-pill.stopped, .status-pill.failed { background: var(--danger); }
.status-pill.queued, .status-pill.stopping { background: var(--warn); }

/* ---------- Alerts / flash ---------- */

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 0.86rem; margin-bottom: 14px; border: 1px solid transparent; }
.alert.ok { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert.err { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Stats / progress ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 10px; text-align: center; }
.stat .num { display: block; font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; }
.stat label { font-size: 0.68rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat.success .num { color: var(--success); }
.stat.failed .num { color: var(--danger); }

.progress-track { height: 9px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width .25s ease; }
.progress-fill.active {
  background-image: linear-gradient(90deg, var(--accent) 0%, #6FCB9F 50%, var(--accent) 100%);
  background-size: 200% 100%; animation: scan 1.4s linear infinite;
}
@media (prefers-reduced-motion: reduce) { .progress-fill.active { animation: none; } }
@keyframes scan { 0% { background-position: 200% 0; } 100% { background-position: 0 0; } }

/* ---------- Empty states ---------- */

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-faint); }
.empty-state .big { font-size: 1.8rem; margin-bottom: 6px; }

/* ---------- Login screen ---------- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 30px; }
.login-card .wordmark { text-align: center; margin-bottom: 18px; font-weight: 700; font-size: 1.2rem; }

/* ---------- Misc ---------- */

.pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { padding: 5px 10px; border-radius: 6px; font-size: 0.82rem; border: 1px solid var(--border); color: var(--ink-muted); text-decoration: none; }
.pagination a:hover { background: var(--surface-alt); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

details summary { cursor: pointer; color: var(--accent-hover); font-size: 0.8rem; }
details pre { margin: 6px 0 0; padding: 8px; background: #0C1F17; color: #DCE7E2; border-radius: 6px; font-size: 0.76rem; max-width: 420px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters-bar .field { margin-bottom: 0; min-width: 140px; }

.sidebar .wordmark .mark-img { width: 26px; height: 26px; border-radius: 7px; object-fit: contain; background: #fff; flex: none; }
.sidebar .wordmark .wordmark-name { min-width: 0; }
.nav-toggle {
  display: none; margin-left: auto; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--sidebar-active); background: var(--sidebar-active); color: var(--sidebar-ink);
  font: inherit; font-size: 0.82rem; font-weight: 600;
}

/* Phones and narrow windows: the menu folds away behind a Menu button. */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; padding: 10px 12px; position: sticky; top: 0; z-index: 30; }
  .sidebar .wordmark { padding: 2px 4px; margin-bottom: 0; display: flex; align-items: center; width: 100%; }
  .nav-toggle { display: inline-block; }
  .sidebar nav, .sidebar .sidebar-foot { display: none; }
  .sidebar.open nav { display: flex; flex-direction: column; margin-top: 10px; max-height: 70vh; overflow-y: auto; }
  .sidebar.open .sidebar-foot { display: block; }
  .page { padding: 18px 14px 50px; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .topbar .who { flex-wrap: wrap; gap: 8px; }
  .topbar .who .who-name { display: none; }
  .panel { padding: 16px 14px; }
  .filters-bar .field { min-width: 0; flex: 1 1 140px; }
  .filters-bar .field input, .filters-bar .field select { width: 100% !important; }
}
}

/* ===========================================================
   Stage B — daily-use screens
   =========================================================== */

/* ---------- Phone-style template preview (assets/phone-preview.js) ---------- */

.pp-phone {
  width: 100%; max-width: 320px; margin: 0 auto;
  border: 6px solid #1B2420; border-radius: 30px; overflow: hidden;
  background: #fff; box-shadow: 0 10px 30px rgba(10,30,22,0.14);
  font-family: var(--font-ui);
}
.pp-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; }
.pp-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
}
.pp-names { min-width: 0; }
.pp-name { font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-sub { font-size: 0.68rem; opacity: 0.8; }
.pp-chat { padding: 12px 12px 18px; min-height: 330px; }
.pp-date {
  width: fit-content; margin: 0 auto 10px; padding: 3px 10px; border-radius: 8px;
  font-size: 0.66rem; color: #54656F; background: rgba(255,255,255,0.92);
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}
.pp-bubble {
  position: relative; max-width: 92%; padding: 6px 6px 4px;
  border-radius: 10px; border-top-left-radius: 2px; background: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,0.10);
}
.pp-media { border-radius: 7px; overflow: hidden; margin-bottom: 6px; background: #E9EDEF; }
/* The whole picture is shown, never cropped (a poster stays readable). */
.pp-media img { display: block; width: 100%; height: auto; max-height: 440px; object-fit: contain; }
.pp-media-ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: 120px; color: #667781;
}
.pp-media-ico { font-size: 1.5rem; line-height: 1; }
.pp-media-lbl { font-size: 0.72rem; font-weight: 600; }
.pp-text {
  padding: 2px 6px 0; font-size: 0.84rem; line-height: 1.45; color: #111B21;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.pp-var.filled {
  background: var(--accent-soft); color: var(--accent-ink); border-radius: 3px; padding: 0 2px; font-weight: 500;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.pp-para { margin: 0 0 8px; }
.pp-para:last-of-type { margin-bottom: 0; }
.pp-var.empty { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 0 4px; font-size: 0.74rem; font-weight: 600; }
.pp-line-k { color: #667781; }
.pp-note { margin-top: 6px; font-size: 0.72rem; color: #667781; white-space: normal; }
.pp-time { text-align: right; padding: 2px 6px 0; font-size: 0.62rem; color: #667781; }
.pp-buttons { margin-top: 6px; border-top: 1px solid #E9EDEF; }
.pp-btn {
  padding: 9px 8px; text-align: center; font-size: 0.82rem; font-weight: 600; color: #027EB5;
  border-bottom: 1px solid #E9EDEF;
}
.pp-btn:last-child { border-bottom: none; }

/* WhatsApp look */
.pp-wa .pp-head { background: #075E54; color: #fff; }
.pp-wa .pp-avatar { background: #DFE5E7; color: #075E54; }
.pp-wa .pp-chat { background: #ECE5DD; }

/* RCS look (blue) */
.pp-rcs .pp-head { background: #fff; color: #1F1F1F; border-bottom: 1px solid #E3E8EF; }
.pp-rcs .pp-avatar { background: #1A73E8; color: #fff; }
.pp-rcs .pp-sub { color: #1A73E8; opacity: 1; font-weight: 600; }
.pp-rcs .pp-chat { background: #F8FAFD; }
.pp-rcs .pp-date { background: transparent; box-shadow: none; }
.pp-rcs .pp-bubble { background: #E9EEF6; border-radius: 18px; border-top-left-radius: 4px; box-shadow: none; padding: 8px 8px 6px; }
.pp-rcs .pp-media { border-radius: 12px; }
.pp-rcs .pp-var.filled { background: #D3E3FD; color: #0B3D91; }
.pp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pp-chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid #C4D7F5; background: #fff;
  color: #1A73E8; font-size: 0.78rem; font-weight: 600;
}

/* Variables on the left, phone on the right */
.preview-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.preview-split .preview-side { position: sticky; top: 14px; }
/* Nothing to fill in (fixed text, or values set by the administrator): the
   phone stands alone in the middle instead of beside an empty column. */
.preview-split.preview-only { grid-template-columns: minmax(0, 1fr); }
.preview-split.preview-only .preview-side { position: static; justify-self: center; width: 100%; max-width: 360px; }
/* A value box grows with its text, so a long line is always fully readable. */
.vars-side .field { margin-bottom: 14px; }
.vars-side .field textarea.var-input { min-height: 44px; resize: none; overflow: hidden; line-height: 1.5; }
.vars-side .var-count { display: block; margin-top: 4px; font-size: 0.72rem; color: var(--ink-faint); text-align: right; }
.preview-side .preview-cap {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); text-align: center; margin-bottom: 10px;
}
@media (max-width: 900px) {
  .preview-split { grid-template-columns: 1fr; }
  .preview-split .preview-side { position: static; }
}

/* ---------- Gateway form: template details block ---------- */
.tpl-box {
  margin: 14px 0; padding: 16px 18px; background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.tpl-box-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 14px; }
.tpl-box .field input, .tpl-box .field select, .tpl-box .field textarea { background: var(--surface); }

/* ---------- Channel tags + RCS (blue) context ---------- */
.channel-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.channel-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.channel-tag.wa  { background: #E3F1EA; color: #0A5537; }
.channel-tag.rcs { background: #E6EFFD; color: #0B3D91; }
.channel-banner {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700;
}
.channel-banner::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.channel-banner.wa  { background: #E3F1EA; color: #0A5537; }
.channel-banner.rcs { background: #E6EFFD; color: #0B3D91; }

/* While an RCS campaign is being built the whole page leans blue. */
body.theme-rcs .topbar { border-bottom-color: #C9DCF9; box-shadow: inset 0 -2px 0 #1A73E8; }
body.theme-rcs .panel { border-color: #DCE7F8; }
body.theme-rcs .progress-fill.active {
  background-image: linear-gradient(90deg, var(--accent) 0%, #8AB4F8 50%, var(--accent) 100%);
}

.adv-box { padding: 12px 16px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.adv-box > summary { font-weight: 600; font-size: 0.84rem; color: var(--ink); }

/* ---------- Dashboard: range switch, charts, running campaigns ---------- */
.seg-bar {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--border);
}
.seg-bar a {
  padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 500;
  color: var(--ink-muted); text-decoration: none;
}
.seg-bar a:hover { color: var(--ink); }
.seg-bar a.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 4px rgba(10,30,22,0.12); }
.pill-select {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 0.82rem; font-weight: 600; color: var(--ink);
}

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-grid .panel { margin-bottom: 18px; min-width: 0; }
@media (max-width: 980px) { .chart-grid { grid-template-columns: 1fr; gap: 0; } }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.78rem; color: var(--ink-muted); margin-bottom: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend strong { color: var(--ink); font-weight: 600; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.c-ok  { background: #12894E; }
.c-bad { background: #D23A2C; }
.c-wa  { background: #128C4B; }
.c-rcs { background: #1A73E8; }

.chart-plot { display: flex; gap: 8px; align-items: stretch; }
.chart-axis {
  display: flex; flex-direction: column; justify-content: space-between; height: 150px;
  font-size: 0.66rem; color: var(--ink-faint); font-family: var(--font-mono); text-align: right; min-width: 34px;
}
.chart-bars {
  flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 8px; height: 170px;
  /* recessive guide lines: top, middle and the zero baseline of the 150px plot */
  background:
    linear-gradient(var(--border), var(--border)) 0 0 / 100% 1px no-repeat,
    linear-gradient(var(--border), var(--border)) 0 75px / 100% 1px no-repeat,
    linear-gradient(var(--border-strong), var(--border-strong)) 0 150px / 100% 1px no-repeat;
}
.chart-bars.dense { gap: 3px; }
.chart-col {
  position: relative; height: 170px; min-width: 0; outline: none;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.chart-col::before { /* full-height hit area so thin or empty days are still hoverable */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 150px; border-radius: 4px;
}
.chart-col:hover::before, .chart-col:focus-visible::before { background: rgba(10,30,22,0.05); }
.chart-stack {
  position: relative; width: 100%; max-width: 34px; flex: none;
  display: flex; flex-direction: column; gap: 2px;
}
.chart-stack .seg { min-height: 2px; }
.chart-stack .seg:first-child { border-radius: 4px 4px 0 0; }
.chart-lbl { flex: none; height: 20px; line-height: 20px; font-size: 0.66rem; color: var(--ink-muted); white-space: nowrap; }
.chart-tip {
  display: none; position: absolute; bottom: calc(100% - 14px); left: 50%; transform: translateX(-50%);
  z-index: 5; min-width: 150px; padding: 8px 10px; border-radius: 8px;
  background: #0C1F17; color: #fff; font-size: 0.74rem; line-height: 1.5; text-align: left;
  box-shadow: 0 6px 18px rgba(10,30,22,0.25); pointer-events: none; white-space: nowrap;
}
.chart-tip strong, .chart-tip span { display: block; }
.chart-tip span { display: flex; align-items: center; gap: 6px; }
.chart-tip .tot { margin-top: 3px; padding-top: 3px; border-top: 1px solid rgba(255,255,255,0.2); }
.chart-col:hover .chart-tip, .chart-col:focus-visible .chart-tip { display: block; }
.chart-col:first-child .chart-tip, .chart-col:nth-child(2) .chart-tip { left: 0; transform: none; }
.chart-col:last-child .chart-tip, .chart-col:nth-last-child(2) .chart-tip { left: auto; right: 0; transform: none; }

.rate-bar {
  display: inline-block; width: 70px; height: 7px; background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 6px;
}
.rate-bar > span { display: block; height: 100%; background: var(--success); }

.table-toggle > summary { font-size: 0.9rem; font-weight: 600; color: var(--ink); }

.run-card { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.run-card + .run-card { margin-top: 10px; }
.run-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.run-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.run-title:hover { text-decoration: underline; }
.run-owner { font-size: 0.74rem; font-weight: 600; color: var(--ink-muted); padding: 2px 8px; border-radius: 999px; background: var(--surface-alt); }
.run-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.run-stats { font-size: 0.82rem; color: var(--ink-muted); font-family: var(--font-mono); }
.run-stats strong { color: var(--ink); }
.run-ok { color: var(--success); font-weight: 600; }
.run-bad { color: var(--danger); font-weight: 600; }
.run-actions { display: flex; gap: 6px; }
.run-empty { padding: 14px; text-align: center; color: var(--ink-faint); font-size: 0.86rem; background: var(--surface-alt); border-radius: var(--radius-sm); }

/* ---------- Campaign Logs report: summary cards ---------- */
.report-cards { display: grid; grid-template-columns: repeat(var(--cards, 4), minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 760px) { .report-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.report-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px 18px 12px; min-width: 0;
}
.report-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.rc-main { display: block; text-decoration: none; color: inherit; }
.rc-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-muted); }
.rc-num { display: block; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); margin: 2px 0 10px; overflow-wrap: anywhere; }
.rc-bar { display: block; height: 6px; border-radius: 999px; background: var(--surface-alt); overflow: hidden; }
.rc-bar > span { display: block; height: 100%; border-radius: 999px; }
.c-total { background: #566862; }
.c-warn  { background: #B07A12; }
.rc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 0.82rem; color: var(--ink-muted); min-height: 26px; }
.rc-dl {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid var(--border-strong); color: var(--ink); text-decoration: none; font-size: 0.95rem; line-height: 1;
}
.rc-dl:hover { background: var(--surface-alt); border-color: var(--accent); color: var(--accent-hover); }

/* ---------- Per-account Template ID (Admin, when allowed by the Super Admin) ---------- */
.tpl-change { margin-top: 6px; }
.tpl-change > summary { font-size: 0.76rem; font-weight: 600; color: var(--accent-hover); cursor: pointer; }
.tpl-change form { margin: 8px 0 0; padding: 10px; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius-sm); max-width: 300px; }
.tpl-change input[type="text"] { width: 100%; padding: 7px 9px; border: 1px solid var(--border-strong); border-radius: 7px; font-family: var(--font-mono); font-size: 0.8rem; background: var(--surface); }
.tpl-change-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ===========================================================
   Stage C — admin platform
   =========================================================== */

/* ---------- Settings hub / Help: menu on the left, one section on the right ---------- */
.hub { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.hub-menu {
  position: sticky; top: 14px; display: flex; flex-direction: column; gap: 2px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.hub-menu a {
  display: block; padding: 9px 12px; border-radius: 8px; text-decoration: none;
  color: var(--ink-muted); font-size: 0.88rem; font-weight: 500;
}
.hub-menu a small { display: block; font-size: 0.72rem; font-weight: 400; color: var(--ink-faint); margin-top: 1px; }
.hub-menu a:hover { background: var(--surface-alt); color: var(--ink); }
.hub-menu a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.hub-menu a.active small { color: var(--accent-hover); }
@media (max-width: 860px) {
  .hub { grid-template-columns: 1fr; }
  .hub-menu { position: static; flex-direction: row; flex-wrap: wrap; }
  .hub-menu a small { display: none; }
}
.kv { width: 100%; font-size: 0.88rem; min-width: 0; }
.kv td { padding: 6px 0; vertical-align: top; border: none; }
.kv td:first-child { width: 230px; color: var(--ink-muted); }
.code-line {
  display: block; background: #0C1F17; color: #DCE7E2; padding: 10px 12px; border-radius: 8px;
  overflow: auto; font-family: var(--font-mono); font-size: 0.8rem; white-space: pre; margin: 0 0 10px;
}
.step-list { margin: 0; padding-left: 20px; font-size: 0.9rem; line-height: 1.6; }
.step-list li { margin-bottom: 6px; }

/* ---------- UI Design builder ---------- */
.design-split { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 20px; align-items: start; }
.design-preview { position: sticky; top: 14px; }
.preview-stage {
  position: relative; height: 76vh; overflow: hidden; background: #fff;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.preview-stage iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; }
@media (max-width: 1100px) { .design-split { grid-template-columns: 1fr; } .design-preview { position: static; } .preview-stage { height: 60vh; } }
.swatch-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.swatch-row:last-child { border-bottom: none; }
.swatch-row input[type="color"] { width: 42px; height: 32px; padding: 0; border: 1px solid var(--border-strong); border-radius: 7px; background: none; cursor: pointer; flex: none; }
.swatch-row .sw-text { flex: 1; min-width: 0; }
.swatch-row .sw-text strong { display: block; font-size: 0.86rem; }
.swatch-row .sw-text span { font-size: 0.74rem; color: var(--ink-faint); }
.swatch-row code { font-size: 0.76rem; color: var(--ink-muted); }
.order-list { list-style: none; margin: 0; padding: 0; }
.order-list li {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; margin-bottom: 6px;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px; font-size: 0.86rem;
}
.order-list li .grow { flex: 1; min-width: 0; }
.order-list button { padding: 2px 8px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 6px; cursor: pointer; font-size: 0.8rem; }
.order-list button:disabled { opacity: 0.35; cursor: default; }
.nav-edit { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.nav-edit input[type="text"] { padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: 7px; font-size: 0.84rem; width: 100%; }

/* ---------- Gateway Database (spreadsheet-style) ---------- */
.sheet-wrap { overflow: auto; max-height: 72vh; border: 1px solid var(--border); border-radius: var(--radius); }
table.sheet { border-collapse: separate; border-spacing: 0; font-size: 0.8rem; min-width: 1500px; }
table.sheet th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-alt); white-space: nowrap;
  border-bottom: 1px solid var(--border-strong); padding: 8px 10px; text-align: left;
}
table.sheet td { padding: 5px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: top; background: var(--surface); }
table.sheet td:first-child, table.sheet th:first-child { position: sticky; left: 0; z-index: 1; }
table.sheet th:first-child { z-index: 3; }
table.sheet tr.changed td { background: #FFFBEA; }
table.sheet input[type="text"], table.sheet textarea, table.sheet select {
  width: 100%; min-width: 120px; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; font: inherit; color: var(--ink);
}
table.sheet textarea { min-width: 240px; min-height: 34px; resize: vertical; }
table.sheet input:hover, table.sheet textarea:hover, table.sheet select:hover { border-color: var(--border-strong); }
table.sheet input:focus, table.sheet textarea:focus, table.sheet select:focus { border-color: var(--accent); background: var(--surface); outline: none; }
table.sheet .cell-ro { display: flex; align-items: flex-start; gap: 6px; }
table.sheet .cell-ro .val { overflow-wrap: anywhere; max-width: 260px; }
.copy-btn {
  flex: none; padding: 1px 6px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 5px;
  font-size: 0.68rem; cursor: pointer; color: var(--ink-muted);
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent-hover); }
select.pill-state { border-radius: 999px !important; font-weight: 700; font-size: 0.72rem; min-width: 96px !important; padding: 4px 8px !important; }
select.pill-state.is-on  { background: var(--success-bg) !important; color: var(--success); border-color: var(--success-border) !important; }
select.pill-state.is-off { background: var(--danger-bg) !important; color: var(--danger); border-color: var(--danger-border) !important; }
.sheet-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-bar .spacer { flex: 1; }

.choice-list { margin-bottom: 14px; }
.choice { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 0.9rem; cursor: pointer; }
.choice input[type="radio"] { width: auto; margin: 0; flex: none; accent-color: var(--accent); }
