/* JRJ WhatsApp API — portal + admin styles. No inline styles (strict CSP). */
:root {
    --bg: #F5F6F8; --surface: #fff; --ink: #15191F; --muted: #5C6573; --line: #E3E6EA; --line-strong: #CDD3DA;
    --accent: #0E6B5C; --accent-dark: #0A5246; --accent-soft: #E3F1EE; --wa: #25D366;
    --danger: #B42318; --danger-soft: #FDECEC; --warn: #8A4B00; --warn-soft: #FFF4E5; --radius: 14px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.card h2:first-child, .card h2:first-of-type, .card .row h2 { margin-top: 0; }
p { margin: 0 0 10px; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #EEF1F4; padding: 1px 6px; border-radius: 6px; overflow-wrap: anywhere; }
pre { background: #10151B; color: #E6EDF3; padding: 14px 16px; border-radius: 12px; overflow-x: auto; }
pre code { background: none; padding: 0; color: inherit; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 700; }
.right { text-align: right; }
.error-text { color: var(--danger); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top__in { max-width: 1180px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--wa); box-shadow: 0 0 0 3px #D6F5E1; }
.brand__tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; background: var(--ink); color: #fff; padding: 2px 7px; border-radius: 6px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-dark); }
.top__out { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; }
@media (max-width: 760px) {
    .menu-btn { display: inline-flex; margin-left: auto; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 6px 12px; font: inherit; font-weight: 600; }
    .nav { display: none; width: 100%; flex-direction: column; }
    .nav.is-open { display: flex; }
    .top__out { margin-left: 0; width: 100%; justify-content: space-between; }
    .top__who { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* layout */
.main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.main--narrow, .narrow { max-width: 680px; }
.main--narrow { padding-top: 15vh; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { margin: 0 0 4px; font-size: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 220px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; min-width: 0; }
.card--accent { border-color: var(--accent); background: #F4FBF9; }
.card--link { display: flex; flex-direction: column; gap: 4px; color: inherit; text-decoration: none; transition: border-color .15s; }
.card--link:hover { border-color: var(--accent); color: inherit; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.empty { text-align: center; color: var(--muted); padding: 32px 18px; }
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 6px; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form--inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.input { width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font: inherit; font-weight: 400; color: var(--ink); }
textarea.input { resize: vertical; }
.input--short { width: 120px; }
.input--tiny { width: 72px; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: 0 0 auto; }
.limits { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.checklist { display: flex; flex-direction: column; border-top: 1px solid var(--line); max-height: 380px; overflow-y: auto; }
.checklist .check { padding: 9px 0; border-bottom: 1px solid var(--line); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn--danger { border-color: #F0B8B3; color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn--xs { min-height: 28px; padding: 0 9px; font-size: 13px; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }

/* messages + badges */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.flash--success { background: var(--accent-soft); color: var(--accent-dark); }
.flash--error { background: var(--danger-soft); color: #8A1C12; }
.notice { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #EEF1F4; color: var(--muted); white-space: nowrap; }
.badge--connected, .badge--delivered { background: #DDF6E6; color: #126B37; }
.badge--linking, .badge--pending { background: var(--warn-soft); color: var(--warn); }
.badge--disconnected, .badge--failed { background: var(--danger-soft); color: var(--danger); }

/* tables, stats, lists */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table--num td:not(:first-child), .table--num th:not(:first-child) { text-align: right; }
.is-off { opacity: .55; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat__n { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat__l { font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.copybox { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px dashed var(--accent); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.copybox code { font-size: 14px; background: none; padding: 0; flex: 1 1 260px; }

/* QR */
.steps { padding-left: 20px; margin: 0 0 14px; }
.qr { display: flex; align-items: center; justify-content: center; min-height: 280px; margin-bottom: 10px; }
.qr img { width: 100%; max-width: 280px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 12px; background: #fff; image-rendering: pixelated; }

/* docs */
.prose h1 { font-size: 22px; margin: 6px 0 12px; }
.prose h2 { font-size: 19px; margin: 28px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.prose h3 { font-size: 16px; margin: 20px 0 8px; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 12px; }
.prose li { margin-bottom: 4px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin-bottom: 14px; }
.prose th, .prose td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { background: #F8F9FA; }
.prose blockquote { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 0 10px 10px 0; }
