/* =================================================================
   app.css -- shared styles for every page.
   Same palette and type as UpGrow SalesFlow CRM (navy + Inter), so the
   two products look like one family.
   ================================================================= */

:root {
    --primary: #0D2B5C;
    --primary-dark: #0A2249;
    --primary-light: #EEF1F7;
    --success: #2E7D5B;
    --success-bg: #E8F3EC;
    --warning: #9A6B1E;
    --warning-bg: #FBF1DF;
    --danger: #B3463F;
    --danger-bg: #FAEAE8;
    --info: #2F5E9E;
    --info-bg: #EAF1FB;
    --bg: #FAFAFA;
    --card-bg: #FFFFFF;
    --text-main: #1F2430;
    --text-muted: #6F7580;
    --border: #E8E8EA;
    --sidebar-width: 230px;
    --topbar-height: 60px;
    --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* The reset above drops the browser's own centring of pop-ups. */
dialog[open] { margin: auto; }

/* clip (not hidden): no sideways scroll, without breaking position: sticky
   (top bar, template preview, plan summary). Older browsers use hidden. */
html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-main);
    font-size: 13.5px;
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- Forms ---------------- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-control {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text-main);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--text-muted); }
.form-check input { margin-top: 3px; accent-color: var(--primary); }

/* Honeypot: hidden from people, filled in by bots */
.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--text-main); border-color: var(--border); }
.btn-outline:hover { border-color: #C9CCD2; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; font-weight: 600; }
.btn-block { width: 100%; padding: 12px; font-size: 14px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ---------------- Alerts / flash ---------------- */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert ul { margin-left: 18px; }
.alert-error   { background: var(--danger-bg);  border-color: #F3CFCB; color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: #CDE5D6; color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: #F1DDB7; color: var(--warning); }
.alert-info    { background: var(--info-bg);    border-color: #D3E1F4; color: var(--info); }

/* ---------------- Auth pages (login, signup...) ---------------- */
.auth-body {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-card {
    background: #fff;
    border-radius: 14px;
    padding: 34px 30px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}
.auth-card.wide { max-width: 520px; }
.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 700;
    font-size: 16px;
    color: var(--primary);
    margin-bottom: 20px;
}
.auth-brand i { font-size: 24px; }
.auth-card h1 { text-align: center; font-size: 19px; font-weight: 600; margin-bottom: 6px; }
.auth-card .subtitle { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--text-muted); }
.auth-footer a { font-weight: 600; }
.auth-links { display: flex; justify-content: flex-end; margin: -6px 0 16px; font-size: 12.5px; }

/* ---------------- App shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    font-weight: 700;
    font-size: 14px;
    line-height: 1.25;
}
.sidebar-brand i { font-size: 22px; }
.sidebar-brand small {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
}
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-section-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    opacity: 0.45;
    padding: 16px 18px 6px;
}
.sidebar-nav a,
.sidebar-nav .nav-soon {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    margin: 0 8px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
}
.sidebar-nav a i, .sidebar-nav .nav-soon i { width: 18px; text-align: center; font-size: 13px; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-nav a.active { background: rgba(255, 255, 255, 0.14); color: #fff; }
/* Pages not built yet: visible so the product shape is clear, but not clickable */
.sidebar-nav .nav-soon { color: rgba(255, 255, 255, 0.38); cursor: default; }
.nav-soon-tag {
    margin-left: auto;
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 100px;
    padding: 0 6px;
}
.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.6);
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 500;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { text-align: right; line-height: 1.3; }
.topbar-user strong { display: block; font-size: 13px; }
.topbar-user span { font-size: 11.5px; color: var(--text-muted); }
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-main);
    cursor: pointer;
}
.content { padding: 24px; max-width: 1200px; width: 100%; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 900;
}

/* ---------------- Cards / stats ---------------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.card-subtitle { font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.stat-label { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 7px; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Setup steps on the dashboard */
.steps { list-style: none; }
.step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}
.step:first-child { border-top: none; padding-top: 4px; }
.step-icon {
    flex: 0 0 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
}
.step.done .step-icon { background: var(--success-bg); color: var(--success); }
.step-body { flex: 1; min-width: 0; }
.step-title { font-weight: 600; }
.step.done .step-title { color: var(--text-muted); text-decoration: line-through; }
.step-text { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.step-action { flex: 0 0 auto; }

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 100px;
    background: var(--primary-light);
    color: var(--primary);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.text-muted { color: var(--text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- Page pieces ---------------- */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.checklist { list-style: none; }
.checklist li {
    position: relative;
    padding: 5px 0 5px 24px;
    font-size: 13px;
}
.checklist li::before {
    content: "\f00c";   /* Font Awesome check */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 0;
    top: 6px;
    font-size: 11px;
    color: var(--success);
}
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.option-card { display: flex; flex-direction: column; margin-bottom: 0; }
.option-card .badge { align-self: flex-start; margin-bottom: 12px; }
.option-card .checklist { flex: 1; margin-bottom: 18px; }
.option-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state > i { font-size: 34px; color: var(--primary); margin-bottom: 10px; }
.empty-state p { max-width: 460px; margin: 6px auto 18px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline-block; margin-left: 4px; }
.form-narrow { max-width: 720px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-bar .form-control { width: auto; min-width: 180px; padding: 8px 10px; }
details > summary { cursor: pointer; color: var(--primary); font-size: 12.5px; }
pre.payload {
    margin-top: 8px;
    max-height: 420px;
    overflow: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre;
}
textarea.form-control { resize: vertical; line-height: 1.5; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { border-color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.auth-legal { text-align: center; margin-top: 14px; font-size: 11.5px; }
.auth-legal a { color: rgba(255, 255, 255, 0.75); margin: 0 6px; }

/* ---------------- Messages (chat) ---------------- */
.chat-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 16px;
    height: calc(100vh - var(--topbar-height) - 150px);
    min-height: 460px;
}
.chat-layout .card { margin-bottom: 0; padding: 0; overflow: hidden; }
.chat-list { overflow-y: auto; }   /* the inbox below makes it a column with .chat-items scrolling */
.chat-empty { padding: 18px; }
.chat-item {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
}
.chat-item:hover { background: var(--bg); text-decoration: none; }
.chat-item.active { background: var(--primary-light); }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chat-item-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-time { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.chat-preview { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

/* Inbox: tabs, unread, closed */
[hidden] { display: none !important; }
.chat-layout .chat-list { display: flex; flex-direction: column; overflow: hidden; }
.chat-items { flex: 1; overflow-y: auto; }
.chat-tabs { display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-tabs a { flex: 1; text-align: center; padding: 10px 4px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.chat-tabs a:hover { color: var(--text-main); text-decoration: none; }
.chat-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.chat-tab-count { font-size: 11px; color: var(--text-muted); margin-left: 2px; }
.chat-tabs-search { display: block; padding: 10px 16px; font-size: 12.5px; color: var(--text-muted); }
.chat-item-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chat-item-bottom .chat-preview { flex: 1; min-width: 0; margin-top: 0; }
.chat-item.unread strong { font-weight: 700; }
.chat-item.unread .chat-preview { color: var(--text-main); }
.chat-item.unread .chat-time { color: #1A9E4B; font-weight: 600; }
.chat-unread, .nav-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: #25D366; color: #fff; font-size: 11px; font-weight: 700;
}
.nav-badge { margin-left: auto; }
.chat-closed { font-size: 10.5px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
.thread-more { text-align: center; font-size: 12.5px; margin: 0 0 8px; }
.thread-body mark { background: #FFE58A; padding: 0 1px; border-radius: 2px; }
video.msg-img { background: #000; }

/* Inbox: reply box, files, quick replies */
.reply-form { position: relative; }
.reply-box { flex: 1; min-width: 0; }
.reply-form textarea { min-height: 40px; max-height: 160px; }
.reply-form.drag .reply-box { outline: 2px dashed var(--primary); outline-offset: 2px; border-radius: 8px; }
.btn-icon { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attach-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 100px;
    padding: 3px 6px 3px 10px; margin-bottom: 6px;
}
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button { border: none; background: none; cursor: pointer; color: var(--text-muted); padding: 0 4px; }
.qr-pop {
    position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 20;
    display: flex; flex-direction: column; gap: 6px; max-height: 300px; padding: 8px;
    background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.qr-list { overflow-y: auto; }
.qr-item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 7px 9px; border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; color: var(--text-main); }
.qr-item b { display: block; font-size: 12px; color: var(--primary); }
.qr-item span { display: block; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-item:hover, .qr-item.sel { background: var(--primary-light); }
.qr-empty { padding: 8px; font-size: 12.5px; margin: 0; }
.qr-manage { font-size: 12px; padding: 2px 9px; }
@media (pointer: coarse) { .hide-touch { display: none; } }
.thread-flow { display: flex; gap: 6px; align-items: center; }
.thread-flow select { max-width: 170px; padding: 5px 8px; font-size: 12.5px; }
@media (max-width: 860px) { .thread-flow { display: none; } }

.chat-thread { display: flex; flex-direction: column; min-width: 0; }
.chat-placeholder { margin: auto; text-align: center; }
.chat-placeholder i { font-size: 34px; margin-bottom: 8px; }
.thread-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.thread-head > div { flex: 1; min-width: 0; }
.thread-head .text-muted { font-size: 12.5px; }
.thread-back { display: none; color: var(--text-main); }
.thread-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F4F1EC;   /* WhatsApp-like paper tone for the conversation only */
}
.day-sep { text-align: center; margin: 10px 0; }
.day-sep span { font-size: 11.5px; background: #fff; color: var(--text-muted); padding: 3px 10px; border-radius: 100px; }
.msg { display: flex; margin: 4px 0; }
.msg.out { justify-content: flex-end; }
.bubble {
    max-width: min(560px, 80%);
    background: #fff;
    border-radius: 10px;
    padding: 7px 10px 5px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
    overflow-wrap: anywhere;
}
.msg.out .bubble { background: #DCF3E3; }
.msg-text { font-size: 13.5px; line-height: 1.45; }
.msg-meta { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 2px; display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.tick-read { color: #2F80ED; }
.tick-failed { color: var(--danger); }
.msg-error { font-size: 11.5px; color: var(--danger); margin-top: 3px; }
.msg-img { display: block; max-width: 260px; max-height: 260px; border-radius: 6px; margin-bottom: 4px; }
.msg-file { display: inline-block; font-size: 12.5px; margin-bottom: 4px; }
.bubble audio { max-width: 260px; margin-bottom: 4px; }

.thread-reply { border-top: 1px solid var(--border); padding: 12px 16px; }
.reply-form { display: flex; gap: 10px; align-items: flex-end; }
.reply-form textarea { resize: none; }
.reply-form > .btn { flex-shrink: 0; }
.tpl-preview {
    white-space: pre-wrap;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* Ad source on a chat */
.ad-panel { padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--info-bg); font-size: 13px; }
.ad-panel-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--info); margin-bottom: 3px; }
.ad-path { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ad-path i { font-size: 9px; color: var(--text-muted); }
.ad-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-muted); font-size: 12px; margin-top: 3px; }

/* ---------------- Integrations ---------------- */
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 6px; }
.int-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.int-card p { font-size: 12.5px; flex: 1; }
.int-card-off { opacity: 0.6; }
.int-card-icon { width: 38px; height: 38px; border-radius: 9px; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; font-size: 17px; }
.int-card-title { font-weight: 600; }
.int-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.ads-who { margin: 4px 0 12px; }
.ads-accounts { display: grid; gap: 8px; max-width: 560px; margin: 10px 0 14px; }
.ads-acc-title { font-weight: 600; font-size: 13px; }
.ads-acc { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.ads-acc.is-on { border-color: var(--primary); background: var(--primary-light); }
.ads-acc-name { font-weight: 600; }
.ads-acc-id { color: var(--text-muted); font-size: 12.5px; }
.ads-acc .badge { margin-left: auto; }
.ads-accounts .btn { justify-self: start; }
.secret-box { display: block; margin: 6px 0 2px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; font-size: 12.5px; overflow-wrap: anywhere; }
.check-row { padding: 6px 0; font-size: 13px; color: var(--text-main); }

/* ---------------- Template editor ---------------- */
.tpl-editor { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: start; }
.tpl-phone { position: sticky; top: calc(var(--topbar-height) + 16px); background: #F4F1EC; border-radius: 14px; padding: 16px; }
.tpl-phone-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 10px; font-weight: 600; }
.tpl-bubble { background: #fff; border-radius: 10px; padding: 9px 11px; box-shadow: 0 1px 1px rgba(0,0,0,.06); overflow-wrap: anywhere; }
.tpl-bubble-header { font-weight: 700; margin-bottom: 4px; }
.tpl-bubble-header:empty, .tpl-bubble-footer:empty { display: none; }
.tpl-bubble-body { white-space: pre-wrap; font-size: 13.5px; }
.tpl-bubble-footer { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.tpl-buttons { display: grid; gap: 4px; margin-top: 4px; }
.tpl-btn { background: #fff; border-radius: 8px; text-align: center; padding: 7px; color: #2F80ED; font-size: 13px; }

/* ---------------- Public pages (Terms, Privacy...) ---------------- */
.public-body { background: #fff; }
.public-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
}
.public-header nav { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.public-brand { font-weight: 700; font-size: 15px; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.public-brand:hover { text-decoration: none; }
.public-brand i { font-size: 20px; }
.legal { max-width: 760px; margin: 0 auto; padding: 40px 20px 60px; font-size: 14.5px; line-height: 1.7; }
.legal h1 { font-size: 28px; line-height: 1.25; margin-bottom: 6px; }
.legal h2 { font-size: 17px; margin: 30px 0 8px; }
.legal p, .legal ul, .legal ol { margin-bottom: 12px; }
.legal ul, .legal ol { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal-updated { color: var(--text-muted); font-size: 13px; margin-bottom: 26px; }
.legal h3.legal-h3 { font-size: 15px; margin: 18px 0 6px; }
.public-footer {
    border-top: 1px solid var(--border);
    padding: 18px 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    justify-content: center;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ---------------- Homepage (public/index.php) ---------------- */
.landing { font-size: 15px; line-height: 1.65; }
.lp-wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.lp-hero { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: #fff; padding: 72px 0 64px; }
.lp-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); }
.lp-hero h1 { font-size: 40px; line-height: 1.15; max-width: 720px; margin: 10px 0 16px; text-wrap: balance; }
.lp-lead { font-size: 17px; max-width: 640px; color: rgba(255, 255, 255, 0.86); }
.lp-cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 26px 0 14px; }
.lp-hero .btn-primary { background: #fff; color: var(--primary); }
.lp-hero .btn-primary:hover { background: var(--primary-light); }
.lp-hero .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.45); }
.lp-hero .btn-outline:hover { border-color: #fff; }
.lp-note { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
.lp-section { padding: 56px 0; }
.lp-alt { background: var(--bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.lp-section h2, .lp-final h2 { font-size: 26px; line-height: 1.25; margin-bottom: 22px; text-wrap: balance; }
.lp-steps { list-style: none; counter-reset: lp; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.lp-steps li { counter-increment: lp; display: flex; flex-direction: column; gap: 6px; }
.lp-steps li::before {
    content: counter(lp);
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--primary-light); color: var(--primary); font-weight: 700;
}
.lp-steps span { color: var(--text-muted); font-size: 14px; }
.lp-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.lp-feature { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.lp-feature > i { font-size: 20px; color: var(--primary); margin-bottom: 10px; }
.lp-feature h3 { font-size: 15.5px; margin-bottom: 6px; }
.lp-feature p { font-size: 14px; color: var(--text-muted); }
.lp-about { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 32px; align-items: start; }
.lp-about p { color: var(--text-muted); max-width: 60ch; }
.lp-contact { font-style: normal; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; font-size: 14px; }
.lp-final { background: var(--primary-light); padding: 48px 0; text-align: center; }
.lp-final h2 { margin-bottom: 18px; }

/* ---------------- Contacts ---------------- */
.tag-chip {
    display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1.6;
    padding: 0 9px; margin: 0 4px 4px 0; border-radius: 100px;
    background: var(--primary-light); color: var(--primary);
}
a.tag-chip:hover { text-decoration: none; background: #dfe5f0; }
.bulk-bar { margin-bottom: 10px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.bulk-bar .form-control { min-width: 0; }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "\f067"; font-family: "Font Awesome 6 Free"; font-weight: 900; font-size: 11px; margin-right: 8px; }
details.card[open] > summary::before { content: "\f068"; }

/* ---------------- Plans & billing ---------------- */
.sidebar-nav a.nav-locked { opacity: 0.5; }
.sidebar-nav a.nav-locked:hover { opacity: 0.8; }
.nav-lock { margin-left: auto; font-size: 10px; width: auto !important; }
.alert-link { font-weight: 600; margin-left: 6px; color: inherit; text-decoration: underline; white-space: nowrap; }

.cycle-toggle { display: inline-flex; background: var(--primary-light); border-radius: 100px; padding: 3px; gap: 2px; }
.cycle-toggle button {
    border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--primary);
    padding: 7px 16px; border-radius: 100px; cursor: pointer;
}
.cycle-toggle button.on { background: #fff; box-shadow: 0 1px 2px rgba(13, 43, 92, 0.15); }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.plan-card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px 20px; display: flex; flex-direction: column; gap: 10px; position: relative;
}
.plan-card.featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.plan-card.current { border-color: var(--success); box-shadow: 0 0 0 1px var(--success); }
.plan-flag {
    position: absolute; top: -10px; left: 20px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    background: var(--primary); color: #fff; padding: 2px 10px; border-radius: 100px;
}
.plan-card.current .plan-flag { background: var(--success); }
.plan-name { font-size: 16px; font-weight: 700; }
.plan-desc { font-size: 12.5px; color: var(--text-muted); min-height: 2.6em; }
.plan-price { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.plan-price small { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.plan-tax { font-size: 12px; color: var(--text-muted); margin-top: -6px; }
.plan-card .checklist { flex: 1; margin: 4px 0 8px; }
.plan-card .btn { width: 100%; justify-content: center; }
.plan-note { font-size: 12px; color: var(--text-muted); }
.plan-note.bad { color: var(--danger); }
[data-cycle="monthly"] .only-yearly, [data-cycle="yearly"] .only-monthly { display: none; }

.usage-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; }
.usage-bar { height: 8px; border-radius: 100px; background: var(--primary-light); overflow: hidden; }
.usage-fill { height: 100%; border-radius: 100px; background: var(--primary); }
.usage-fill.warn { background: var(--warning); }
.usage-fill.full { background: var(--danger); }
.usage-num { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

.plan-summary { display: flex; flex-wrap: wrap; gap: 14px 40px; align-items: flex-start; justify-content: space-between; }
.plan-summary .big { font-size: 22px; font-weight: 700; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.pay-status { margin-top: 14px; }

/* Public pricing page / homepage section */
.lp-pricing .plan-grid { margin-top: 8px; }
.lp-pricing-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.lp-pricing-head h2 { margin-bottom: 0; }
.lp-fine { font-size: 13px; color: var(--text-muted); margin-top: 18px; }

/* ---------------- Super Admin analytics ----------------
   Chart colours: two categorical slots, checked for colour-blind
   separation and 3:1 contrast on the white card. */
.an-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.an-tabs a { padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.an-tabs a:hover { color: var(--text-main); text-decoration: none; }
.an-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.an-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 100px; background: var(--bg); border: 1px solid var(--border); font-size: 11px; text-align: center; }
.an-count.on { background: var(--danger-bg); border-color: var(--danger-bg); color: var(--danger); }
.an-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.an-filter .form-control { width: auto; padding: 8px 10px; }
.an-custom:not([hidden]) { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.an-period { font-size: 12.5px; color: var(--text-muted); }
p.an-period { margin-bottom: 16px; }
.an-section { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 6px 0 10px; }
.an-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.an-delta { font-size: 12px; margin-top: 4px; color: var(--text-muted); }
.an-delta.good { color: var(--success); }
.an-delta.bad { color: var(--danger); }
.an-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
.an-two > .card { margin-bottom: 0; }
.an-total-row td { background: var(--bg); }
.an-phone a { margin-left: 4px; }
.an-phone .fa-whatsapp { color: #1F8F4E; }

.an-chart { position: relative; }
.an-scroll { overflow-x: auto; }   /* phones: keep the axis text readable, scroll sideways */
.an-chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.an-grid { stroke: var(--border); stroke-width: 1; }
.an-base { stroke: #C3C2B7; stroke-width: 1; }
.an-axis { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.an-s1 { fill: #2A78D6; }
.an-s2 { fill: #EB6834; }
.an-key-1 { background: #2A78D6; }
.an-key-2 { background: #EB6834; }
.an-hit { fill: transparent; }
.an-col { outline: none; }
.an-col:hover .an-seg, .an-col:focus .an-seg { opacity: .75; }
.an-col:focus-visible .an-hit { stroke: var(--primary); stroke-width: 1; }
.an-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; margin-bottom: 6px; }
.an-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.an-tip { display: none; position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 8px 10px; background: var(--card-bg);
          border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .12); font-size: 12px; }
.an-tip-title { color: var(--text-muted); margin-bottom: 4px; }
.an-tip-row { display: flex; align-items: center; gap: 7px; margin-top: 2px; }
.an-tip-row b { font-variant-numeric: tabular-nums; }
.an-tip-line { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.an-tip-total { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 4px; color: var(--text-muted); }
.an-table { margin-top: 8px; }

.an-hbars { display: grid; gap: 10px; }
.an-hrow { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.an-hfill { height: 12px; min-width: 2px; background: #2A78D6; border-radius: 0 4px 4px 0; }
.an-hval { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1000px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .an-two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1000px) {
    .lp-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .int-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tpl-editor { grid-template-columns: 1fr; }
    .tpl-phone { position: static; }
}
@media (max-width: 860px) {
    .lp-steps, .lp-about { grid-template-columns: 1fr; }
    .lp-hero { padding: 52px 0 44px; }
    .lp-hero h1 { font-size: 30px; }
    .option-grid { grid-template-columns: 1fr; }
    /* Chats: list OR conversation, one at a time */
    .chat-layout { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-height) - 130px); }
    .chat-layout.has-open .chat-list { display: none; }
    .chat-layout:not(.has-open) .chat-thread { display: none; }
    .thread-back { display: inline-block; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open { display: block; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-block; }
    .topbar { padding: 0 16px; }
    .topbar-user { display: none; }
    .content { padding: 16px; }
}
@media (max-width: 520px) {
    .lp-features { grid-template-columns: 1fr; }
    .int-grid { grid-template-columns: 1fr; }
    .public-header { padding: 12px 16px; }
    .public-header nav { gap: 10px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .auth-card { padding: 28px 20px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .usage-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
    .usage-row .usage-bar { grid-column: 1 / -1; grid-row: 2; }
    .step { flex-wrap: wrap; }
    .step-action { flex-basis: 100%; padding-left: 42px; }
}
