/* MyWabaLink - base theme */

:root {
  --brand: #6d3ce8;
  --brand-hover: #5b2fd6;
  --brand-soft: #f1ebff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-soft: #f7f7f9;
  --error: #b42318;
  --error-bg: #fef3f2;
  --success: #067647;
  --success-bg: #ecfdf3;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.25; margin: 0 0 24px; font-weight: 700; letter-spacing: -0.01em; }

/* ---------- logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.logo:hover { text-decoration: none; }

/* ---------- auth layout (form left, brand panel right) ---------- */
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-inner { width: 100%; max-width: 440px; }
.auth-inner .logo { margin-bottom: 56px; }
.lead { color: var(--muted); margin: -12px 0 24px; }

.auth-brand {
  position: relative; overflow: hidden; color: #fff;
  background:
    radial-gradient(circle at 80% 10%, rgba(255,255,255,0.14), transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(37, 211, 102, 0.25), transparent 45%),
    linear-gradient(150deg, #4c1fc4 0%, #6d3ce8 55%, #8b5cf6 100%);
  display: flex; align-items: center; justify-content: center; padding: 56px;
}
.brand-inner { max-width: 520px; width: 100%; }
.brand-eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; font-weight: 600; opacity: 0.8; margin: 0 0 12px; }
.brand-title { font-size: 30px; line-height: 1.25; margin: 0 0 36px; font-weight: 700; }

.chat { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.18); border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 10px; backdrop-filter: blur(4px); }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 14.5px; line-height: 1.45; }
.bubble.in { background: #fff; color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: #dcf8c6; color: #102a12; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.out.owner { background: #c9f0ad; }
.bubble-tag { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #1f7a3a; margin-bottom: 2px; }
.chat-event { align-self: center; font-size: 12px; background: rgba(0,0,0,0.25); padding: 4px 10px; border-radius: 999px; }

.brand-points { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 12px; }
.brand-points li { position: relative; padding-left: 30px; font-size: 15.5px; opacity: 0.95; }
.brand-points li::before { content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: rgba(255,255,255,0.2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M5 12l5 5 9-10'/%3E%3C/svg%3E") center/12px no-repeat; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; }
.form label { font-size: 15px; color: #374151; margin: 0 0 8px; }
.form input[type="email"], .form input[type="text"], .form input[type="password"], .form input[type="tel"], .form input[type="url"] {
  width: 100%; height: 50px; padding: 0 16px; font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px;
  transition: border-color .15s, box-shadow .15s;
}
.form input::placeholder { color: #9ca3af; }
.form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 60, 232, 0.18); }

.password-field { position: relative; }
.password-field input { padding-right: 52px; }
.toggle-password { position: absolute; right: 6px; top: 5px; width: 40px; height: 40px; border: 0; background: transparent; color: #9ca3af; cursor: pointer; border-radius: 6px; display: grid; place-items: center; }
.toggle-password:hover, .toggle-password.is-on { color: var(--brand); }
.toggle-password:focus-visible { outline: 2px solid var(--brand); }

.hint { font-size: 13px; color: var(--muted); margin: -12px 0 20px; }
.form-row-end { text-align: right; margin: -4px 0 24px; font-size: 15px; }
.form-compact { margin-top: 8px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 50px; padding: 0 20px; font: inherit; font-size: 16px; font-weight: 500; border-radius: var(--radius); cursor: pointer; border: 1px solid transparent; width: 100%; transition: background .15s, border-color .15s; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:focus-visible, .btn-social:focus-visible, .btn-secondary:focus-visible { outline: 3px solid rgba(109, 60, 232, 0.35); outline-offset: 2px; }
.btn-secondary { background: var(--brand-soft); color: var(--brand); }
.btn-secondary:hover { background: #e6dcff; }
.btn-social { background: #fff; color: var(--text); border-color: var(--border); }
.btn-social:hover { background: var(--bg-soft); }
.btn-link { background: none; border: 0; color: var(--brand); width: auto; height: auto; padding: 0; font-size: 15px; }
.btn-link:hover { text-decoration: underline; }
.btn[aria-busy="true"] { opacity: 0.7; cursor: progress; }

.switch { text-align: center; color: #4b5563; margin: 28px 0 0; font-size: 17px; }
.divider { display: flex; align-items: center; gap: 14px; color: var(--muted); margin: 32px 0 28px; font-size: 15px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }
.btn-social + .btn-social { margin-top: 14px; }
.legal { font-size: 13px; color: var(--muted); text-align: center; margin-top: 28px; }

/* ---------- alerts ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 14.5px; margin: -8px 0 20px; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #fecdca; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #abefc6; }

/* ---------- app (signed in) ---------- */
.app-page { background: var(--bg-soft); min-height: 100vh; --topbar-h: 64px; --sidebar-w: 240px; --sidebar-w-collapsed: 72px; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid var(--border); padding: 0 24px 0 16px; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar .logo { font-size: 19px; }
.topbar .logo img { width: 30px; height: 30px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user form { margin: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.topbar-name { font-weight: 500; }

.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 8px; background: transparent; color: #4b5563; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--brand); }

/* sidebar */
.app-shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar { flex: 0 0 var(--sidebar-w); width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); padding: 16px 12px; transition: width .18s ease, flex-basis .18s ease; overflow: hidden; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border-radius: 8px; color: #374151; font-weight: 500; white-space: nowrap; }
.nav-link svg { flex: 0 0 auto; color: #6b7280; }
.nav-link:hover { background: var(--bg-soft); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--brand-soft); color: var(--brand); }
.nav-link.active svg { color: var(--brand); }
.sidebar-collapsed .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .nav-label { display: none; }
.sidebar-collapsed .nav-link { justify-content: center; padding: 0; }
.sidebar-backdrop { display: none; }

.app-main { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1200px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.breadcrumb { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.empty-state { background: #fff; border: 1px dashed #d1d5db; border-radius: 12px; padding: 64px 32px; text-align: center; color: var(--muted); }

/* centred empty state (My Numbers with no numbers) */
.empty-center { min-height: calc(100vh - var(--topbar-h) - 180px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-icon { width: 80px; height: 80px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin-bottom: 20px; }
.empty-title { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.empty-text { color: var(--muted); margin: 0 0 24px; }

.btn-auto { width: auto; }
.btn-small { height: 32px; padding: 0 12px; font-size: 14px; width: auto; }

/* tables */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #fafafb; padding: 12px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.col-sno { width: 80px; color: var(--muted); }
.col-number { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status-cell { display: flex; align-items: center; gap: 12px; }

/* status tags */
.tag { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tag-not_onboarded { background: #fff6e5; color: #b54708; }
.tag-onboarded { background: var(--success-bg); color: var(--success); }
.tag-disconnected { background: #f2f4f7; color: #475467; }
.tag-on { background: var(--success-bg); color: var(--success); }
.tag-off { background: #f2f4f7; color: #667085; }

/* onboarding page */
.onboard { max-width: 720px; }
.lead-app { color: #374151; font-size: 16.5px; margin: 0 0 20px; }
.onboard-steps { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px 18px 42px; margin: 0 0 24px; line-height: 1.6; }
.onboard-steps li + li { margin-top: 6px; }
.btn-lg { height: 52px; padding: 0 28px; font-size: 16.5px; }
/* onboarding progress: stage bar + spinner */
.ob-progress { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 24px 24px 20px; margin: 4px 0 24px; }
.ob-bar { height: 10px; background: #eef0f4; border-radius: 999px; overflow: hidden; }
.ob-bar-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #8b5cf6, var(--brand)); transition: width .4s ease; }
.ob-progress.is-done .ob-bar-fill { background: linear-gradient(90deg, #12b76a, #067647); }
.ob-progress.is-error .ob-bar-fill { background: #f04438; }
.ob-stages { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0; margin: 12px 0 22px; counter-reset: obstage; }
.ob-stages li { counter-increment: obstage; font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 8px; line-height: 1.3; }
.ob-stages li::before { content: counter(obstage); flex: 0 0 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; background: #eef0f4; color: #667085; }
.ob-stages li.is-current { color: var(--text); font-weight: 600; }
.ob-stages li.is-current::before { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(109, 60, 232, .18); }
.ob-stages li.is-done { color: #067647; }
.ob-stages li.is-done::before { content: "✓"; background: #d1fadf; color: #067647; }
.ob-current { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 18px; font-weight: 600; color: var(--text); text-align: center; }
.ob-hint { text-align: center; color: var(--muted); font-size: 14px; margin: 10px 0 0; }
.spinner { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%; border: 3px solid #e4e7ec; border-top-color: var(--brand); animation: spin .8s linear infinite; }
.ob-progress.is-done .spinner, .ob-progress.is-error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .ob-bar-fill { transition: none; } }
@media (max-width: 640px) {
  .ob-stages { grid-template-columns: 1fr 1fr; }
  .ob-current { font-size: 16px; }
}

/* onboarding result modals */
.ob-modal { width: min(480px, calc(100vw - 32px)); }
.ob-modal-body { padding: 32px 28px 28px; text-align: center; }
.ob-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; }
.ob-icon-ok { background: #d1fadf; color: #067647; }
.ob-icon-error { background: #fee4e2; color: #d92d20; }
.ob-modal h2 { font-size: 22px; margin: 0 0 8px; }
.ob-modal-text { font-size: 16.5px; color: #374151; margin: 0 0 18px; line-height: 1.5; overflow-wrap: anywhere; }
.ob-summary { text-align: left; margin: 0 0 22px; }
.ob-summary:empty { display: none; }
.ob-modal-btn { width: 100%; }
.ob-modal-actions { display: flex; gap: 12px; }
.ob-modal-actions .ob-modal-btn { flex: 1; }
.ob-tech { text-align: left; margin: 0 0 20px; font-size: 14px; }
.ob-tech summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
.result-title { font-size: 17px; margin: 0 0 12px; }
.checklist { list-style: none; padding: 0; margin: 0 0 18px; display: grid; gap: 6px; font-size: 15px; }
.checklist .ok { color: var(--success); }
.checklist .fail { color: var(--error); }
.details-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.details-table th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px 16px 8px 0; width: 40%; vertical-align: top; }
.details-table td { padding: 8px 0; overflow-wrap: anywhere; }
.details-table tr + tr th, .details-table tr + tr td { border-top: 1px solid var(--border); }
.mono-text { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 14px; }
#onboard-next { margin: 18px 0 0; }

/* modal */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 48px rgba(16, 24, 40, .18); }
.modal::backdrop { background: rgba(16, 24, 40, .45); }
.modal .form { padding: 24px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-head .icon-btn { margin-right: -8px; }
.modal .alert { margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }

.phone-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 10px; }
.phone-row input { margin-bottom: 0 !important; }
.form select { width: 100%; height: 50px; padding: 0 12px; font: inherit; font-size: 15px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.form select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 60, 232, 0.18); }
.phone-row + .hint { margin: 8px 0 20px; }

/* number details: settings cards */
.inline-form { display: inline; margin: 0; }
.title-with-tag { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.settings { display: grid; gap: 16px; }
.setting-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.setting-card.setting-stack { display: block; }
.setting-text h2 { font-size: 17px; margin: 0 0 4px; }
.setting-text h2 label { font: inherit; color: inherit; margin: 0; }
.setting-text p { margin: 0; color: var(--muted); font-size: 14.5px; }
.setting-stack .setting-text { margin-bottom: 14px; }
.form.inline-field { flex-direction: row; gap: 10px; }
.form.inline-field input { margin-bottom: 0; flex: 1; min-width: 0; }
.field-error { color: var(--error); font-size: 14px; margin: 8px 0 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 14px !important; color: #374151 !important; background: var(--bg-soft) !important; }
.sub-setting { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.sub-label { display: block; font-weight: 600; font-size: 15px; margin: 0 0 10px; }
.alert-info { background: #eff4ff; color: #1d2b6b; border: 1px solid #c7d7fe; line-height: 1.5; margin: 0 0 12px; }
.field-warning { color: #b54708; font-size: 14px; margin: 0 0 12px; }
.form .mono-input { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 15px; }
.btn.is-copied { border-color: var(--success); color: var(--success); }

.btn-danger { background: #d92d20; color: #fff; }
.btn-danger:hover { background: #b42318; }
.btn-danger:focus-visible { outline: 3px solid rgba(217, 45, 32, .35); outline-offset: 2px; }
.alert-warning { background: #fffaeb; color: #93370d; border: 1px solid #fedf89; line-height: 1.5; }

/* on/off switch */
.switch-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; position: relative; }
.switch-toggle input { position: absolute; opacity: 0; width: 44px; height: 24px; margin: 0; cursor: pointer; }
.switch-track { width: 44px; height: 24px; border-radius: 999px; background: #d0d5dd; position: relative; transition: background .15s; flex: 0 0 auto; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .2); transition: transform .15s; }
.switch-toggle input:checked + .switch-track { background: var(--brand); }
.switch-toggle input:checked + .switch-track .switch-thumb { transform: translateX(20px); }
.switch-toggle input:focus-visible + .switch-track { outline: 3px solid rgba(109, 60, 232, .35); outline-offset: 2px; }
.switch-state { font-weight: 600; font-size: 14px; color: #374151; min-width: 26px; }

/* logs table */
.nowrap { white-space: nowrap; }
.wrap-anywhere { overflow-wrap: anywhere; }
.table-note { margin-top: 10px; }
.regen-form { margin: 10px 0 0; }
.test-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0 0; }
.hint-inline { color: var(--muted); font-size: 13.5px; }
.guide summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary h2 { font-size: 17px; margin: 0; }
.guide summary::before { content: "▸"; color: var(--muted); }
.guide[open] summary::before { content: "▾"; }
.guide h3 { font-size: 15.5px; margin: 22px 0 8px; }
.guide p { color: #374151; font-size: 14.5px; line-height: 1.6; margin: 0 0 10px; }
.guide code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; background: var(--bg-soft); padding: 1px 5px; border-radius: 4px; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.55; background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px 16px; overflow-x: auto; white-space: pre; margin: 0 0 12px; }
.tag-dlv-pending, .tag-dlv-delivering { background: #fff6e5; color: #b54708; }
.tag-dlv-delivered { background: #ecfdf3; color: #067647; }
.tag-dlv-failed { background: var(--error-bg); color: var(--error); }
/* ---------- admin ---------- */
.admin-badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; background: #101828; color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.admin-auth-page { background: var(--bg-soft); min-height: 100vh; }
.admin-auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.admin-auth-card { width: min(460px, 100%); background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 12px 32px rgba(16, 24, 40, .06); }
.admin-auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.admin-auth-card h1 { font-size: 24px; margin-bottom: 18px; }
.admin-auth-card .lead { margin: -8px 0 18px; }
.admin-auth-card .alert code { font-size: 13px; }
.admin-main { max-width: 1280px; margin: 0 auto; }
.admin-search { display: flex; gap: 10px; align-items: center; }
.admin-search input[type="search"] { height: 40px; width: min(320px, 60vw); padding: 0 12px; font: inherit; border: 1px solid var(--border); border-radius: var(--radius); }
.admin-search input[type="search"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 60, 232, 0.18); }
.admin-search .btn { height: 40px; }

/* "Viewing as <user>" bar shown to an admin on the user pages */
.impersonation-bar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; padding: 8px 16px; background: #b54708; color: #fff; font-size: 14.5px; }
.impersonation-bar .btn { background: #fff; color: #b54708; height: 30px; }
.impersonation-bar .btn:hover { background: #fff6e5; }
.is-impersonating .topbar { top: 46px; }
.is-impersonating .sidebar { top: calc(var(--topbar-h) + 46px); height: calc(100vh - var(--topbar-h) - 46px); }

/* two equal columns (c6 / c6); stacked on narrow screens */
.grid-2 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.col-6 { grid-column: span 6; }
.col-6.settings { align-content: start; }
.col-6 .setting-card { flex-wrap: wrap; } /* half-width cards: let the button drop below the text when tight */
.col-6 .setting-card .setting-text { flex: 1 1 240px; }
@media (max-width: 1000px) { .col-6 { grid-column: 1 / -1; } }

/* My Account */
.current-value { margin: 0 0 18px; padding: 12px 14px; background: var(--bg-soft); border-radius: var(--radius); font-size: 15px; color: #374151; }
.current-value strong { color: var(--text); }
.form-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 4px; }
.form-status { margin: 0; font-size: 14.5px; color: var(--muted); }
.form-status.is-ok { color: var(--success); }
.form-status.is-error { color: var(--error); }
.form .field-error { margin: -12px 0 16px; }
.form > .combo { margin-bottom: 20px; } /* not inside the Add Number phone row */

/* logs page: date filter + tabs */
.log-filter { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 0 0 20px; }
.log-filter-field { display: flex; flex-direction: column; gap: 4px; }
.log-filter-field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.log-filter input[type="date"] { height: 40px; padding: 0 10px; font: inherit; font-size: 15px; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.log-filter input[type="date"]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 60, 232, 0.18); }
.log-filter .btn { height: 40px; }
.page-head-stacked { flex-direction: column; align-items: flex-start; gap: 12px; }
.btn-back { gap: 6px; height: 40px; padding: 0 14px 0 10px; font-size: 15px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 16px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: #475467; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--brand); border-bottom-color: var(--brand); }
.tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 6px 6px 0 0; }
.tab-count { font-size: 12px; font-weight: 600; background: #f2f4f7; color: #475467; border-radius: 999px; padding: 1px 8px; }
.tab.is-active .tab-count { background: var(--brand-soft); color: var(--brand); }
.col-msgid { max-width: 260px; }
.msg-id { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: #475467; overflow-wrap: anywhere; word-break: break-all; user-select: all; }
.section-title { font-size: 18px; margin: 28px 0 12px; }
.page-head + .section-title { margin-top: 0; }
.tag-msg-received { background: #eff4ff; color: #3538cd; }
.tag-msg-sent { background: #f2f4f7; color: #475467; }
.tag-msg-delivered { background: #ecfdf3; color: #067647; }
.tag-msg-read { background: #d1fadf; color: #05603a; }
.tag-msg-failed { background: var(--error-bg); color: var(--error); }

@media (max-width: 700px) {
  .setting-card { flex-direction: column; align-items: flex-start; }
  .form.inline-field { flex-direction: column; }
}

/* searchable country picker (js/app.js enhanceCombobox) */
.modal { overflow: visible; } /* let the dropdown extend past the dialog edge */
.combo { position: relative; min-width: 0; }
.form .combo-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.form .combo-input { margin-bottom: 0; padding-right: 40px; text-overflow: ellipsis;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 16px; }
.combo-list { position: absolute; z-index: 50; top: calc(100% + 6px); left: 0; width: max(100%, 300px); max-height: 280px; overflow-y: auto;
  margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 16px 32px rgba(16, 24, 40, .16); }
.combo-option { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.combo-option.is-active { background: var(--brand-soft); }
.combo-option[aria-selected="true"] { font-weight: 600; color: var(--brand); }
.combo-dial { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.combo-empty { padding: 10px 12px; color: var(--muted); font-size: 14px; }
.form .is-invalid { border-color: var(--error) !important; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-inner .logo { margin-bottom: 40px; }
}
@media (max-width: 900px) {
  /* sidebar becomes a slide-in drawer */
  .sidebar { position: fixed; top: var(--topbar-h); left: 0; z-index: 25; height: calc(100vh - var(--topbar-h)); transform: translateX(-100%); transition: transform .2s ease; width: var(--sidebar-w) !important; }
  .sidebar-collapsed .nav-label { display: inline; }
  .sidebar-collapsed .nav-link { justify-content: flex-start; padding: 0 14px; }
  .sidebar-open .sidebar { transform: none; box-shadow: 0 16px 40px rgba(16, 24, 40, .18); }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(16, 24, 40, .35); z-index: 20; }
  .app-main { padding: 24px 20px; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 12px 0 8px; }
  .topbar-name { display: none; }
  .phone-row { grid-template-columns: 1fr; }
  .col-sno { width: 56px; }
  .table th, .table td { padding: 12px 14px; }
}

/* ---------- admin: navigation + email templates ---------- */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.admin-nav { display: flex; gap: 4px; margin-left: 12px; }
.admin-nav a { padding: 6px 12px; border-radius: 8px; color: #475467; font-weight: 500; font-size: 15px; }
.admin-nav a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.admin-nav a.is-active { background: var(--brand-soft); color: var(--brand); }
.section-title { font-size: 18px; margin: 28px 0 2px; }
.section-hint { display: block; margin: 0 0 12px; }
.mono-text { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 13.5px; }
.tag-custom { background: var(--brand-soft); color: var(--brand); }
.col-7 { grid-column: span 7; }
.col-5 { grid-column: span 5; }
.col-5.settings { align-content: start; }
@media (max-width: 1000px) { .col-7, .col-5 { grid-column: 1 / -1; } }
.form textarea {
  width: 100%; min-height: 220px; padding: 12px 16px; font: inherit; font-size: 15px; line-height: 1.55; color: var(--text);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; resize: vertical;
}
.form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109, 60, 232, 0.18); }
.form [aria-invalid="true"] { border-color: var(--error); }
.email-enabled { margin: 0 0 22px; display: flex; flex-direction: column; gap: 6px; }
.email-enabled .switch-toggle { margin: 0; }
.switch-state-label { font-weight: 600; font-size: 15px; color: #374151; }
.email-greeting { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: #374151; padding: 10px 16px; background: var(--bg-soft); border: 1px dashed var(--border); border-radius: var(--radius); }
.email-greeting .hint-inline { font-weight: 400; }
.vars-table { font-size: 14px; }
.vars-table td { padding: 8px 10px; }
.vars-table code { font-size: 13px; color: var(--brand); }
.email-preview { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.email-preview-subject { margin: 0; padding: 10px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.email-preview-body { padding: 16px; font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.email-preview-body p { margin: 0 0 10px; }
.email-preview-button { pointer-events: none; display: inline-flex; align-items: center; height: 40px; padding: 0 18px; }

/* ---------- billing ---------- */
.billing-alert { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 20px; }
.billing-alert span { flex: 1 1 280px; }
.billing-facts { display: grid; gap: 12px; margin: 0 0 20px; }
.billing-facts div { display: flex; gap: 16px; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.billing-facts dt { color: var(--muted); font-size: 14.5px; }
.billing-facts dd { margin: 0; text-align: right; }
.billing-list { margin: 0 0 18px; padding-left: 20px; color: #374151; font-size: 14.5px; line-height: 1.6; }
.billing-list li { margin-bottom: 6px; }
.billing-note { display: block; margin-top: 10px; }
.plan-card { max-width: 560px; }
.plan-price { margin: 0 0 16px; color: var(--muted); }
.plan-amount { font-size: 32px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin-right: 4px; }
.plan-usage { margin: -8px 0 16px; color: #374151; font-size: 15px; }

/* disconnect dialog: working / next-step states */
.modal-busy { display: flex; align-items: center; gap: 16px; padding: 12px 0 8px; }
.modal-busy[hidden], [data-step][hidden], [data-meta][hidden] { display: none; }
.modal-busy-title { margin: 0 0 4px; font-weight: 600; font-size: 16px; }
.modal-busy .hint { margin: 0; }
.modal-head h2:focus { outline: none; }
.next-step-title { font-size: 16px; margin: 4px 0 8px; }
.next-step-list { margin: 0 0 12px; padding-left: 20px; line-height: 1.6; font-size: 14.5px; }
.next-step-list li { margin-bottom: 4px; }
[data-next-step] .hint { margin: 0 0 8px; }
.next-step-card { background: #fff; border: 1px solid var(--border, #e4e7ec); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 18px 20px 10px; margin: 0 0 20px; }
.next-step-card .next-step-title { margin-top: 0; }
