/* =====================================================================
   Wasender Console — design system
   Dark-first developer console. Light theme via [data-theme="light"].
   No framework, no build step.
   ===================================================================== */

/* ---------- Tokens ---------- */
:root {
    /* Surfaces */
    --bg:            #0a0c0f;
    --bg-elev:       #0f1318;
    --surface:       #12171d;
    --surface-2:     #171d25;
    --surface-3:     #1c242e;
    --border:        #222b36;
    --border-strong: #2e3945;

    /* Text */
    --text:      #e7ecf3;
    --text-dim:  #9aa7b8;
    --text-mute: #67748a;

    /* Brand + status */
    --acc:        #00c48c;
    --acc-hover:  #00d99b;
    --acc-dim:    rgba(0, 196, 140, .12);
    --acc-text:   #052018;
    --code:       #7c9cff;
    --ok:         #2bd07a;
    --warn:       #f0b429;
    --err:        #ff5f6d;
    --info:       #4cc9f0;
    --ok-bg:      rgba(43, 208, 122, .12);
    --warn-bg:    rgba(240, 180, 41, .12);
    --err-bg:     rgba(255, 95, 109, .12);
    --info-bg:    rgba(76, 201, 240, .12);

    /* Geometry */
    --r-sm: 4px;
    --r:    6px;
    --r-lg: 10px;
    --sidebar-w: 232px;
    --topbar-h:  52px;

    /* Type */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.28);
    --shadow-lg: 0 8px 40px rgba(0,0,0,.55);
    --ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--acc);
}

[data-theme="light"] {
    --bg:            #f4f6f9;
    --bg-elev:       #ffffff;
    --surface:       #ffffff;
    --surface-2:     #f7f9fc;
    --surface-3:     #eef2f7;
    --border:        #dfe5ee;
    --border-strong: #c8d2e0;
    --text:      #101828;
    --text-dim:  #566178;
    --text-mute: #8492a8;
    --acc:       #00996e;
    --acc-hover: #00815d;
    --acc-dim:   rgba(0, 153, 110, .10);
    --acc-text:  #ffffff;
    --code:      #4054b2;
    --ok:        #128a4c;
    --warn:      #9a6a00;
    --err:       #c9313f;
    --info:      #0b6f96;
    --shadow:    0 1px 2px rgba(16,24,40,.06), 0 4px 14px rgba(16,24,40,.08);
    --shadow-lg: 0 12px 40px rgba(16,24,40,.16);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
h1, h2, h3, h4, p, figure { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg, video { max-width: 100%; }
::selection { background: var(--acc-dim); }

:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-radius: var(--r-sm);
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* Screen-reader only */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 8px; top: -60px; z-index: 200;
    background: var(--acc); color: var(--acc-text);
    padding: 8px 14px; border-radius: var(--r); font-weight: 600;
    transition: top .15s;
}
.skip-link:focus { top: 8px; }

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

.topbar {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 14px;
    padding: 0 16px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 60;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -.2px; }
.brand-mark {
    width: 26px; height: 26px; border-radius: 7px; flex: none;
    display: grid; place-items: center;
    background: linear-gradient(140deg, var(--acc), #0a9c94);
    color: #04150f;
}
.brand-mark svg { width: 15px; height: 15px; }
.brand-name { font-size: 14px; }
.brand-tag {
    font-size: 10px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase;
    color: var(--text-mute); border: 1px solid var(--border);
    padding: 1px 5px; border-radius: 3px; margin-left: 2px;
}

.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search svg {
    position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; color: var(--text-mute); pointer-events: none;
}
.topbar-search input {
    width: 100%; height: 32px; padding: 0 44px 0 30px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); font-size: 13px;
}
.topbar-search input::placeholder { color: var(--text-mute); }
.topbar-search kbd {
    position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
    font-family: var(--mono); font-size: 10px; color: var(--text-mute);
    border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.shell { flex: 1; display: flex; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w); flex: none;
    background: var(--bg-elev);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: sticky; top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}
.nav { padding: 12px 10px; flex: 1; }
.nav-label {
    font-size: 10px; font-weight: 650; letter-spacing: .7px; text-transform: uppercase;
    color: var(--text-mute); padding: 14px 8px 6px;
}
.nav-label:first-child { padding-top: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 9px; border-radius: var(--r);
    color: var(--text-dim); font-size: 13.5px; font-weight: 500;
    transition: background .12s, color .12s;
    position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--acc-dim); color: var(--acc); font-weight: 600; }
.nav-item.active::before {
    content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px;
    width: 2px; background: var(--acc); border-radius: 0 2px 2px 0;
}
.nav-item .count {
    margin-left: auto; font-size: 11px; font-family: var(--mono);
    color: var(--text-mute); background: var(--surface-2);
    padding: 0 5px; border-radius: 20px;
}

.sidebar-foot { padding: 10px; border-top: 1px solid var(--border); }
.api-status {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 9px; border-radius: var(--r);
    background: var(--surface); border: 1px solid var(--border);
    font-size: 12px;
}
.api-status .label {
    font-size: 9.5px; letter-spacing: .6px; text-transform: uppercase;
    color: var(--text-mute); display: block; font-weight: 650;
}
.api-status .value { font-weight: 600; font-size: 12.5px; }
.user-chip {
    display: flex; align-items: center; gap: 9px; margin-top: 8px;
    padding: 7px 9px; border-radius: var(--r); color: var(--text-dim);
}
.user-chip:hover { background: var(--surface-2); color: var(--text); }
.avatar {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-size: 11px; font-weight: 700;
    background: var(--surface-3); color: var(--acc);
    border: 1px solid var(--border);
}
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 11px; color: var(--text-mute); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page { padding: 20px 24px 48px; max-width: 1600px; width: 100%; }
.page-head {
    display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
    margin-bottom: 18px;
}
.page-title { font-size: 19px; font-weight: 650; letter-spacing: -.3px; }
.page-sub { font-size: 13px; color: var(--text-dim); margin-top: 3px; max-width: 76ch; }
.page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px;
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r);
    font-size: 13px; font-weight: 550; cursor: pointer;
    transition: background .12s, border-color .12s, transform .06s;
    white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; flex: none; }
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
    background: var(--acc); color: var(--acc-text);
    border-color: transparent; font-weight: 650;
}
.btn-primary:hover:not(:disabled) { background: var(--acc-hover); border-color: transparent; }
.btn-danger { color: var(--err); border-color: var(--border); }
.btn-danger:hover:not(:disabled) { background: var(--err-bg); border-color: var(--err); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-sm svg { width: 12px; height: 12px; }
.btn-lg { height: 38px; padding: 0 18px; font-size: 14px; }
.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 26px; }
.btn-block { width: 100%; }
.btn.is-busy { pointer-events: none; opacity: .75; }
.btn.is-ok    { background: var(--ok-bg);  color: var(--ok);  border-color: var(--ok); }
.btn.is-fail  { background: var(--err-bg); color: var(--err); border-color: var(--err); }

.spinner {
    width: 13px; height: 13px; flex: none;
    border: 2px solid currentColor; border-right-color: transparent;
    border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards / panels ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.card-head {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}
.card-head h2, .card-head h3 { font-size: 13px; font-weight: 650; letter-spacing: -.1px; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 14px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }

/* ---------- Stat tiles ---------- */
.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); padding: 13px 14px;
    display: flex; flex-direction: column; gap: 4px;
    min-width: 0;
}
.stat-label {
    font-size: 10px; font-weight: 650; letter-spacing: .7px; text-transform: uppercase;
    color: var(--text-mute);
    display: flex; align-items: center; gap: 5px;
}
.stat-label svg { width: 12px; height: 12px; }
.stat-value {
    font-size: 22px; font-weight: 650; letter-spacing: -.6px;
    font-variant-numeric: tabular-nums; line-height: 1.2;
}
.stat-value.sm { font-size: 15px; letter-spacing: -.2px; }
.stat-foot { font-size: 11.5px; color: var(--text-dim); }

/* ---------- Status dots / badges ---------- */
.dot {
    width: 7px; height: 7px; border-radius: 50%; flex: none;
    background: var(--text-mute); display: inline-block;
}
.dot-ok   { background: var(--ok);   box-shadow: 0 0 0 3px var(--ok-bg); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.dot-err  { background: var(--err);  box-shadow: 0 0 0 3px var(--err-bg); }
.dot-pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 20px; padding: 0 7px; border-radius: 20px;
    font-size: 11px; font-weight: 600; letter-spacing: .1px;
    background: var(--surface-3); color: var(--text-dim);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge-ok   { background: var(--ok-bg);   color: var(--ok);   border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-err  { background: var(--err-bg);  color: var(--err);  border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-mono { font-family: var(--mono); font-size: 10.5px; }

.method {
    font-family: var(--mono); font-size: 10.5px; font-weight: 700;
    padding: 2px 5px; border-radius: 3px; letter-spacing: .3px;
}
.method-get    { background: var(--info-bg); color: var(--info); }
.method-post   { background: var(--ok-bg);   color: var(--ok); }
.method-put    { background: var(--warn-bg); color: var(--warn); }
.method-patch  { background: var(--warn-bg); color: var(--warn); }
.method-delete { background: var(--err-bg);  color: var(--err); }

/* ---------- Forms ---------- */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.label {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--text-dim);
    margin-bottom: 5px;
}
.label .req { color: var(--err); font-weight: 700; }
.label .opt { color: var(--text-mute); font-weight: 500; font-size: 11px; }
.hint { font-size: 11.5px; color: var(--text-mute); margin-top: 4px; line-height: 1.45; }
.err-text { font-size: 11.5px; color: var(--err); margin-top: 4px; display: flex; gap: 4px; align-items: center; }
.err-text svg { width: 12px; height: 12px; flex: none; }

.input, .select, .textarea {
    width: 100%; min-height: 34px; padding: 6px 10px;
    background: var(--bg-elev); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r);
    font-size: 13.5px; transition: border-color .12s, background .12s;
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-dim);
}
.input::placeholder, .textarea::placeholder { color: var(--text-mute); }
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.input.invalid, .textarea.invalid, .select.invalid { border-color: var(--err); }
.select {
    appearance: none; padding-right: 30px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b95a5' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center; background-size: 13px;
}
.input-group { display: flex; gap: 6px; align-items: stretch; }
.input-group .input { flex: 1; min-width: 0; }
.char-count {
    font-size: 11px; color: var(--text-mute); font-family: var(--mono);
    text-align: right; margin-top: 4px;
}
.char-count.over { color: var(--err); }

/* Toggle */
.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
    width: 34px; height: 19px; border-radius: 20px; flex: none;
    background: var(--surface-3); border: 1px solid var(--border);
    position: relative; transition: background .16s, border-color .16s;
}
.toggle-track::after {
    content: ""; position: absolute; left: 2px; top: 2px;
    width: 13px; height: 13px; border-radius: 50%;
    background: var(--text-mute); transition: transform .16s, background .16s;
}
.toggle input:checked + .toggle-track { background: var(--acc); border-color: transparent; }
.toggle input:checked + .toggle-track::after { transform: translateX(15px); background: #fff; }
.toggle input:focus-visible + .toggle-track { box-shadow: var(--ring); }
.toggle-text { font-size: 13px; }
.toggle input:disabled + .toggle-track { opacity: .6; cursor: not-allowed; }

/* Radio pills (media source) */
.pills { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r); padding: 2px; gap: 2px; }
.pills input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 4px; font-size: 12.5px; font-weight: 550;
    color: var(--text-dim); cursor: pointer; transition: background .12s, color .12s;
}
.pill svg { width: 13px; height: 13px; }
.pill:hover { color: var(--text); }
.pills input:checked + .pill { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pills input:focus-visible + .pill { box-shadow: var(--ring); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    padding: 8px 12px; font-size: 12.5px; font-weight: 600;
    color: var(--text-mute); cursor: pointer; background: none; border: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    white-space: nowrap; transition: color .12s;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--acc); border-bottom-color: var(--acc); }
.tab .count { font-family: var(--mono); font-size: 10.5px; opacity: .8; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; font-size: 10.5px; font-weight: 650;
    letter-spacing: .6px; text-transform: uppercase; color: var(--text-mute);
    padding: 9px 12px; border-bottom: 1px solid var(--border);
    background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data td {
    padding: 9px 12px; border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: none; }
td.mono, th.mono, .mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }

/* ---------- Code / JSON viewer ---------- */
.code {
    font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--r); padding: 11px 13px;
    overflow-x: auto; white-space: pre; color: var(--text);
    tab-size: 2; margin: 0;
}
.code.wrap { white-space: pre-wrap; word-break: break-word; }
.code-head {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; background: var(--surface-2);
    border: 1px solid var(--border); border-bottom: none;
    border-radius: var(--r) var(--r) 0 0;
    font-size: 11.5px; color: var(--text-dim); font-family: var(--mono);
}
.code-head + .code { border-radius: 0 0 var(--r) var(--r); }
.code-head .spacer { margin-left: auto; }

/* JSON syntax highlighting */
.tok-key  { color: var(--code); }
.tok-str  { color: var(--acc); }
.tok-num  { color: var(--warn); }
.tok-bool { color: #d08bff; }
.tok-null { color: var(--text-mute); font-style: italic; }
.tok-punc { color: var(--text-mute); }

/* ---------- Message type picker ---------- */
.type-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px;
}
.type-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 6px; min-height: 68px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r); cursor: pointer; color: var(--text-dim);
    font-size: 12px; font-weight: 550; text-align: center;
    transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.type-btn svg { width: 17px; height: 17px; }
.type-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.type-btn[aria-pressed="true"] {
    background: var(--acc-dim); border-color: var(--acc); color: var(--acc);
    font-weight: 650;
}
.type-group-label {
    grid-column: 1 / -1; font-size: 10px; font-weight: 650; letter-spacing: .7px;
    text-transform: uppercase; color: var(--text-mute); padding: 8px 2px 2px;
}
.type-group-label:first-child { padding-top: 0; }

/* ---------- WhatsApp-style preview ---------- */
.preview-stage {
    background:
        linear-gradient(rgba(6,10,8,.9), rgba(6,10,8,.9)),
        repeating-linear-gradient(45deg, #14201a 0 8px, #16241d 8px 16px);
    border-radius: var(--r-lg); padding: 16px;
    min-height: 130px; display: flex; flex-direction: column; gap: 8px;
    justify-content: flex-end; align-items: flex-end;
}
[data-theme="light"] .preview-stage {
    background:
        linear-gradient(rgba(233,238,231,.94), rgba(233,238,231,.94)),
        repeating-linear-gradient(45deg, #d9ded6 0 8px, #e2e7de 8px 16px);
}
.bubble {
    max-width: 84%; background: #075e54; color: #eef6f2;
    border-radius: 9px 2px 9px 9px; padding: 7px 9px 5px;
    font-size: 13.5px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.3);
    position: relative; word-break: break-word;
}
[data-theme="light"] .bubble { background: #d9fdd3; color: #111b21; }
.bubble .meta {
    font-size: 10.5px; opacity: .65; text-align: right;
    margin-top: 3px; display: flex; gap: 3px; justify-content: flex-end; align-items: center;
}
.bubble .meta svg { width: 13px; height: 13px; }
.bubble-media {
    border-radius: 6px; overflow: hidden; margin: -2px -3px 5px;
    background: rgba(0,0,0,.28); display: block;
}
.bubble-media img, .bubble-media video { display: block; width: 100%; max-height: 210px; object-fit: cover; }
.bubble-media audio { display: block; width: 100%; }
.bubble-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    height: 110px; color: rgba(255,255,255,.5); font-size: 11.5px;
}
[data-theme="light"] .bubble-placeholder { color: rgba(0,0,0,.4); }
.bubble-placeholder svg { width: 22px; height: 22px; }
.bubble-file {
    display: flex; align-items: center; gap: 9px; padding: 8px;
    background: rgba(0,0,0,.22); border-radius: 6px; margin-bottom: 5px;
}
[data-theme="light"] .bubble-file { background: rgba(0,0,0,.06); }
.bubble-file svg { width: 22px; height: 22px; flex: none; opacity: .85; }
.bubble-file .fname { font-size: 12.5px; font-weight: 600; word-break: break-all; }
.bubble-file .fmeta { font-size: 10.5px; opacity: .7; }
.bubble-quote {
    border-left: 3px solid var(--acc); background: rgba(0,0,0,.2);
    padding: 4px 7px; border-radius: 4px; margin-bottom: 4px; font-size: 12px;
}
[data-theme="light"] .bubble-quote { background: rgba(0,0,0,.05); }
.bubble-quote .qname { color: var(--acc); font-weight: 650; font-size: 11.5px; }
.bubble-quote .qtext { opacity: .75; }
.poll-preview .poll-q { font-weight: 600; margin-bottom: 7px; display: flex; gap: 6px; align-items: center; }
.poll-preview .poll-q svg { width: 14px; height: 14px; flex: none; }
.poll-opt {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px; border: 1px solid rgba(255,255,255,.18);
    border-radius: 6px; margin-bottom: 5px; font-size: 12.5px;
}
[data-theme="light"] .poll-opt { border-color: rgba(0,0,0,.14); }
.poll-radio { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid currentColor;
    opacity: .55; flex: none; }
.poll-radio.multi { border-radius: 3px; }
.poll-foot { font-size: 10.5px; opacity: .7; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.location-preview {
    background: rgba(0,0,0,.25); border-radius: 6px; padding: 0; overflow: hidden; margin-bottom: 5px;
}
.location-map {
    height: 92px; display: flex; align-items: center; justify-content: center;
    background:
      repeating-linear-gradient(0deg, rgba(255,255,255,.05) 0 1px, transparent 1px 22px),
      repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 22px),
      #1d3a30;
    color: var(--acc);
}
.location-map svg { width: 24px; height: 24px; }
.location-body { padding: 7px 9px; }
.contact-preview {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    background: rgba(0,0,0,.2); border-radius: 6px; margin-bottom: 5px;
}
[data-theme="light"] .contact-preview { background: rgba(0,0,0,.05); }
.contact-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex: none;
    background: rgba(255,255,255,.15); display: grid; place-items: center;
    font-weight: 700; font-size: 14px;
}
.viewonce-flag {
    display: flex; align-items: center; gap: 5px; font-size: 11px;
    color: var(--warn); margin-top: 4px;
}
.viewonce-flag svg { width: 12px; height: 12px; }

/* ---------- Notice / alert ---------- */
.notice {
    display: flex; gap: 9px; padding: 10px 12px;
    border-radius: var(--r); font-size: 12.5px; line-height: 1.5;
    border: 1px solid var(--border); background: var(--surface-2);
}
.notice svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.notice strong { display: block; margin-bottom: 2px; font-size: 12.5px; }
.notice-warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.notice-warn strong { color: var(--warn); }
.notice-err  { background: var(--err-bg);  border-color: transparent; color: var(--err); }
.notice-info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.notice-ok   { background: var(--ok-bg);   border-color: transparent; color: var(--ok); }
.notice p { color: var(--text-dim); }
.notice-warn p, .notice-err p, .notice-info p, .notice-ok p { color: inherit; opacity: .92; }

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; bottom: 18px; right: 18px; z-index: 300;
    display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
.toast {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 11px 13px; border-radius: var(--r);
    background: var(--surface-3); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg); font-size: 13px;
    animation: toast-in .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.toast.out { animation: toast-out .18s forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
.toast svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.toast-ok   svg { color: var(--ok); }
.toast-err  svg { color: var(--err); }
.toast-warn svg { color: var(--warn); }
.toast-info svg { color: var(--info); }
.toast .body { flex: 1; min-width: 0; }
.toast .body strong { display: block; font-weight: 650; margin-bottom: 1px; }
.toast .body span { color: var(--text-dim); font-size: 12.5px; }
.toast button { background: none; border: none; color: var(--text-mute); cursor: pointer; padding: 0; }
.toast button:hover { color: var(--text); }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(3,6,9,.72);
    backdrop-filter: blur(3px); z-index: 200;
    display: flex; align-items: center; justify-content: center; padding: 20px;
    animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; max-height: 88vh;
    display: flex; flex-direction: column;
    animation: modal-in .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal.wide { max-width: 880px; }
.modal-head {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 14.5px; font-weight: 650; }
.modal-head .spacer { margin-left: auto; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2);
}

/* ---------- Empty / skeleton ---------- */
.empty {
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    padding: 46px 20px; text-align: center; color: var(--text-mute);
}
.empty svg { width: 30px; height: 30px; opacity: .55; }
.empty strong { color: var(--text-dim); font-size: 13.5px; font-weight: 600; }
.empty p { font-size: 12.5px; max-width: 44ch; }

.skel {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%; animation: shimmer 1.3s infinite;
    border-radius: var(--r-sm); height: 12px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-row { height: 34px; margin-bottom: 6px; border-radius: var(--r); }

/* ---------- QR ---------- */
.qr-frame {
    width: 232px; height: 232px; margin: 0 auto;
    background: #fff; border-radius: var(--r-lg); padding: 10px;
    display: grid; place-items: center;
}
.qr-frame img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-wait {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 12.5px; color: var(--text-dim); margin-top: 12px;
}

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 5px; }
.spacer { margin-left: auto; }
.muted { color: var(--text-mute); }
.dim   { color: var(--text-dim); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

.src-flag {
    font-size: 9.5px; font-weight: 650; letter-spacing: .4px; text-transform: uppercase;
    color: var(--warn); background: var(--warn-bg);
    padding: 1px 4px; border-radius: 3px; cursor: help;
}

/* Sticky response / send rail */
.sticky-rail { position: sticky; top: calc(var(--topbar-h) + 14px); }

/* ---------- Auth screen ---------- */
.auth-wrap {
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
    background:
        radial-gradient(900px 480px at 15% -8%, rgba(0,196,140,.10), transparent 60%),
        radial-gradient(700px 420px at 92% 108%, rgba(124,156,255,.09), transparent 60%),
        var(--bg);
}
.auth-card {
    width: 100%; max-width: 396px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; padding: 28px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.auth-brand .brand-mark svg { width: 18px; height: 18px; }
.auth-title { font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.auth-sub { font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.auth-foot { text-align: center; font-size: 11.5px; color: var(--text-mute); margin-top: 18px; }

/* ---------- Responsive ---------- */
.sidebar-toggle { display: none; }
.backdrop { display: none; }

@media (max-width: 1180px) {
    .grid-6 { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 980px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .tester-layout { grid-template-columns: 1fr !important; }
    .sticky-rail { position: static; }
}
@media (max-width: 760px) {
    :root { --sidebar-w: 258px; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar {
        position: fixed; left: 0; top: var(--topbar-h); z-index: 90;
        transform: translateX(-100%); transition: transform .2s cubic-bezier(.2,.8,.3,1);
        box-shadow: var(--shadow-lg);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .backdrop {
        display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
        background: rgba(3,6,9,.6); z-index: 80;
    }
    .page { padding: 14px 14px 40px; }
    .grid-6, .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .topbar-search { display: none; }
    .page-head { gap: 10px; }
    .page-actions { width: 100%; }
    .stat-value { font-size: 19px; }
    .type-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
    .modal { max-height: 92vh; }
}
@media (max-width: 420px) {
    .grid-6, .grid-4 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

@media print {
    .sidebar, .topbar, .page-actions, .toasts { display: none !important; }
    body { background: #fff; color: #000; }
}
