/* ==========================================================================
 * Pingoring — Wati-style light theme. Original design; layout patterns only.
 * ========================================================================== */

:root {
  --brand: #0aa47e;
  --brand-dark: #078a68;
  --brand-soft: #e6f7f1;
  --brand-ink: #065f46;
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --text: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --chat-bg: #ece7df;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- app shell ---------------- */

.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.logo-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text);
}

.nav { flex: 1; overflow-y: auto; padding: 10px 12px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  color: #4b5563;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
  position: relative;
}
.nav a svg { width: 19px; height: 19px; flex: 0 0 19px; }
.nav a:hover { background: #f3f4f6; color: var(--text); }
.nav a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; }
.nav-group { padding: 14px 12px 6px; }
.nav-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--faint);
}
.nav-badge {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-foot { border-top: 1px solid var(--border-soft); padding: 12px 14px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex: 0 0 34px;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .biz { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.api-dot { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.api-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.api-dot.ok .dot { background: var(--brand); }
.api-dot.bad .dot { background: var(--danger); }

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

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
}
.topbar-title h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.2px; }
.topbar-title p { margin: 0; font-size: 12.5px; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.biz-pill {
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-weight: 650;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
}
.sidebar-toggle { display: none; }

.main { flex: 1; overflow-y: auto; padding: 24px; }

/* ---------------- login ---------------- */

.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #e6f7f1 0%, var(--bg) 60%);
  margin: -24px;
  padding: 24px;
}
.login-card {
  width: 400px;
  max-width: 100%;
  padding: 36px 32px;
  text-align: center;
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.login-brand span { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin: 0 0 22px; }
.login-card .field { text-align: left; }
.login-err {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}

/* ---------------- generic components ---------------- */

.panel, .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-click { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
.card-click:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 21px; font-weight: 750; letter-spacing: -.3px; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: #f9fafb; border-color: var(--border); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }

.form .field, label.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.field > span em { font-style: normal; font-weight: 400; color: var(--faint); font-size: 12px; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field select, .field textarea,
input[type="text"].input, input[type="search"].input, select.input, textarea.input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
.field textarea, textarea.input { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
input.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.notice {
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 13px;
  margin: 10px 0;
}
.fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 0 0 16px; }
.fieldset legend { font-weight: 700; font-size: 13px; padding: 0 8px; color: #374151; }

.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 40px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: #d1d5db; transition: background .15s; cursor: pointer;
}
.toggle .track::before {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; top: 3px; left: 3px; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track::before { transform: translateX(18px); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 700; padding: 11px 14px;
  border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap;
}
table.table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: #fafbfc; }
table.table .sub { color: var(--muted); font-size: 12.5px; }
tr.clickable { cursor: pointer; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 650;
  padding: 3px 10px; border-radius: 999px;
  background: #f3f4f6; color: #4b5563;
  white-space: nowrap;
}
.pill.open { background: var(--info-soft); color: var(--info); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.closed, .pill.done, .pill.completed { background: var(--brand-soft); color: var(--brand-ink); }
.pill.failed { background: var(--danger-soft); color: var(--danger); }
.pill.sending { background: var(--info-soft); color: var(--info); }
.pill.draft { background: #f3f4f6; color: var(--muted); }
.pill .pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  background: #eef2ff; color: #4338ca;
  border-radius: 6px; padding: 2px 8px; margin: 1px 3px 1px 0;
}

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 9px; }
.status-dot.open { background: var(--info); }
.status-dot.pending { background: var(--warn); }
.status-dot.closed { background: var(--brand); }

.state { text-align: center; padding: 56px 20px; color: var(--muted); }
.state .big { font-size: 44px; margin-bottom: 10px; }
.state h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.state p { margin: 0 auto 14px; max-width: 420px; font-size: 13.5px; }

.error-box {
  background: #fff; border: 1px solid var(--danger-soft);
  border-left: 4px solid var(--danger);
  border-radius: 10px; padding: 16px 18px; margin: 12px 0;
}
.error-box p { margin: 0 0 10px; }

.loading-list .skeleton {
  height: 56px; border-radius: 10px; margin-bottom: 10px;
  background: linear-gradient(90deg, #eef0f3 25%, #f7f8fa 50%, #eef0f3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; border-radius: 10px;
  padding: 11px 16px; font-size: 13.5px; box-shadow: var(--shadow-lg);
  max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.ok { background: var(--brand-dark); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 480px; max-width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal .form { padding: 18px 20px 20px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs button {
  border: none; background: none; padding: 10px 14px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* ---------------- inbox (3-column, Wati-style) ---------------- */

.inbox-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 300px;
  gap: 0;
  height: calc(100vh - var(--topbar-h) - 48px);
  min-height: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.conv-list-pane { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-width: 0; }
.conv-list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border-soft); }
.conv-list-head .row { display: flex; gap: 8px; margin-top: 8px; }
.quick-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-filters button {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 4px 11px; cursor: pointer; font-family: inherit;
}
.quick-filters button:hover { border-color: var(--brand); color: var(--brand-ink); }
.quick-filters button.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.conv-list-head input[type="search"] {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  padding: 8px 12px; font-size: 13.5px; font-family: inherit;
}
.conv-list-head select {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 8px; font-size: 12.5px; font-family: inherit; background: #fff; min-width: 0;
}
.conv-rows { flex: 1; overflow-y: auto; }
.conv-row {
  display: block; width: 100%; text-align: left;
  border: none; border-bottom: 1px solid var(--border-soft);
  background: #fff; padding: 12px 14px; cursor: pointer; font-family: inherit;
}
.conv-row:hover { background: #f9fafb; }
.conv-row.selected { background: var(--brand-soft); }
.conv-row .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conv-row .name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-row .time { font-size: 11.5px; color: var(--faint); flex: 0 0 auto; }
.conv-row .phone-line { font-size: 12px; color: var(--muted); margin-top: 1px; display: flex; align-items: center; gap: 6px; }
.conv-row .preview { display: flex; align-items: center; gap: 7px; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.conv-row .preview .txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-badge {
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.channel-chip {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  border-radius: 5px; padding: 1px 6px; flex: 0 0 auto;
}
.channel-chip.whatsapp { background: #dcfce7; color: #15803d; }
.channel-chip.voice { background: #e0e7ff; color: #3730a3; }

.thread-pane { display: flex; flex-direction: column; min-width: 0; background: var(--chat-bg); }
.thread-head {
  background: #f7f6f3; border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
}
.thread-head .avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 40px; }
.thread-head .who { flex: 1; min-width: 0; }
.thread-head .who strong { display: block; font-size: 14.5px; }
.thread-head .who span { font-size: 12px; color: var(--muted); }
.thread-head .meta-actions { display: flex; gap: 6px; align-items: center; }

.messages { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; }
.msg.in { justify-content: flex-start; }
.msg.out { justify-content: flex-end; }
.bubble {
  max-width: 68%;
  padding: 8px 12px 6px;
  border-radius: 10px;
  font-size: 13.8px;
  line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0,0,0,.08);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg.in .bubble { background: var(--bubble-in); border-top-left-radius: 2px; }
.msg.out .bubble { background: var(--bubble-out); border-top-right-radius: 2px; }
.bubble .meta-line { display: block; text-align: right; font-size: 10.5px; color: #8a8f98; margin-top: 3px; }
.bubble .voice-tag {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  background: #e0e7ff; color: #3730a3; border-radius: 4px; padding: 1px 6px; margin-bottom: 4px;
}
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; margin-right: 4px; animation: pulse 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

.composer { background: #f7f6f3; border-top: 1px solid var(--border); padding: 10px 14px; }
.composer-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.composer-tabs button {
  border: 1px solid var(--border); background: #fff; border-radius: 7px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 5px 11px; cursor: pointer;
}
.composer-tabs button.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row textarea {
  flex: 1; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font-size: 13.8px; font-family: inherit; resize: none;
}
.composer-row textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer-tools { display: flex; gap: 4px; margin-bottom: 8px; align-items: center; }
.composer-tools .hint { margin: 0 0 0 auto; }

.contact-pane { border-left: 1px solid var(--border); overflow-y: auto; padding: 18px; background: #fff; }
.contact-pane h3 { margin: 0 0 4px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); font-size: 11.5px; }
.contact-card { text-align: center; padding: 8px 0 16px; border-bottom: 1px solid var(--border-soft); margin-bottom: 14px; }
.contact-card .avatar { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; }
.contact-card h2 { margin: 0; font-size: 17px; }
.contact-card .phone { color: var(--muted); font-size: 13px; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; word-break: break-word; }
.pane-section { margin-bottom: 18px; }
.pane-section > h3 { margin-bottom: 8px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }
.timeline-item { padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.timeline-item:last-child { border-bottom: none; }
.timeline-item .t { color: var(--faint); font-size: 11.5px; }
.mini-form { display: flex; gap: 6px; margin-top: 8px; }
.mini-form input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; min-width: 0; }

/* ---------------- broadcasts ---------------- */

.wizard { display: flex; gap: 0; margin-bottom: 20px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wizard .step {
  flex: 1; padding: 14px 16px; display: flex; gap: 10px; align-items: center;
  border-right: 1px solid var(--border-soft); color: var(--muted);
}
.wizard .step:last-child { border-right: none; }
.wizard .step .n {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 28px;
  background: #f3f4f6; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.wizard .step.active { color: var(--text); }
.wizard .step.active .n { background: var(--brand); color: #fff; }
.wizard .step.done .n { background: var(--brand-soft); color: var(--brand-ink); }
.wizard .step .t strong { display: block; font-size: 13.5px; }
.wizard .step .t span { font-size: 12px; }

.template-pick {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px;
  margin-bottom: 10px; cursor: pointer; display: flex; gap: 12px; align-items: center;
}
.template-pick:hover { border-color: var(--brand); }
.template-pick.selected { border-color: var(--brand); background: var(--brand-soft); }
.template-pick .radio {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border);
  flex: 0 0 18px; position: relative;
}
.template-pick.selected .radio { border-color: var(--brand); }
.template-pick.selected .radio::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--brand);
}

.audience-pick { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.audience-card {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 16px;
  cursor: pointer; min-width: 160px; flex: 1;
}
.audience-card.selected { border-color: var(--brand); background: var(--brand-soft); }
.audience-card strong { display: block; }
.audience-card span { font-size: 12.5px; color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-card .value { font-size: 27px; font-weight: 800; letter-spacing: -.5px; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; font-size: 13px; }
.bar-row .lbl { width: 130px; flex: 0 0 130px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar { flex: 1; height: 9px; background: #eef0f3; border-radius: 5px; overflow: hidden; }
.bar-row .bar > span { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
.bar-row .val { width: 56px; text-align: right; font-weight: 650; }

/* ---------------- voice ---------------- */

.voice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.call-detail { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
.transcript { max-height: 480px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.readonly-box {
  background: #f9fafb; border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 13.5px; color: #374151;
}
.readonly-box .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); font-weight: 700; margin-bottom: 4px; }

/* ---------------- automation ---------------- */

.flow-empty {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; color: var(--muted); background: #fbfcfd;
}
.node-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; background: #fff; }
.node-card.trigger { border-left: 4px solid var(--brand); }
.node-card.condition { border-left: 4px solid var(--warn); }
.node-card.action { border-left: 4px solid var(--info); }
.node-card .kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.node-card strong { display: block; margin: 2px 0; }
.node-card p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.flow-arrow { text-align: center; color: var(--faint); font-size: 20px; line-height: 1; margin: 2px 0 8px; }

/* ---------------- template preview (WhatsApp-style) ---------------- */

.tpl-preview {
  background: var(--chat-bg); border-radius: 10px; padding: 18px;
  display: flex; justify-content: center;
}
.tpl-card {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.12);
  max-width: 340px; width: 100%; overflow: hidden; font-size: 13.5px;
}
.tpl-card .tpl-body { padding: 10px 12px; white-space: pre-wrap; }
.tpl-card .tpl-foot { padding: 0 12px 8px; color: #8a8f98; font-size: 11.5px; }
.tpl-card .tpl-btn {
  border-top: 1px solid var(--border-soft); padding: 9px; text-align: center;
  color: #00a5f4; font-weight: 500;
}
.tpl-var { background: #fff3cd; border-radius: 3px; padding: 0 3px; }

/* ---------------- misc ---------------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.mt { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.section-title { margin: 0 0 12px; font-size: 15.5px; font-weight: 700; }
.divider { border: none; border-top: 1px solid var(--border-soft); margin: 16px 0; }

.setup-wrap { max-width: 860px; margin: 0 auto; }
.setup-wrap .thread {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 160px); min-height: 480px;
  overflow: hidden; box-shadow: var(--shadow);
}
.setup-wrap .messages { background: #fbfcfd; }
.action-chip {
  display: inline-block; font-size: 11px; font-weight: 650;
  background: var(--brand-soft); color: var(--brand-ink);
  border-radius: 6px; padding: 2px 8px; margin: 6px 4px 0 0;
}
.action-row { display: block; margin-top: 2px; }

@media (max-width: 1180px) {
  .inbox-layout { grid-template-columns: 280px minmax(0, 1fr); }
  .contact-pane { display: none; }
  .call-detail { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: inline-flex; }
  .inbox-layout { grid-template-columns: 1fr; height: auto; }
  .conv-list-pane { max-height: 320px; }
  .thread-pane { min-height: 480px; }
  .form-grid, .grid-2, .grid-3, .voice-grid { grid-template-columns: 1fr; }
  .main { padding: 14px; }
  .wizard { flex-direction: column; }
  .wizard .step { border-right: none; border-bottom: 1px solid var(--border-soft); }
}
