:root {
    --teal: #11403c;
    --teal-2: #1a5550;
    --teal-deep: #0c3837;
    --accent: #25d366;
    --accent-ink: #0b3d24;
    --connected: #1b8a4a;
    --out: #d9fdd3;
    --bg: #f5f7f8;
    --card: #ffffff;
    --ink: #1c2321;
    --muted: #6a7471;
    --line: #e6ebe9;
    --chat-bg: #fffdf2;
    --pending: #f4a259;
    --open: #25d366;
    --solved: #5b8def;
    --danger: #c0392b;
    --r: 12px;
    --r-sm: 8px;
    --shell-bar-h: 48px;
    --sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    display: flex;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    letter-spacing: -.01em;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.sidebar {
    width: 84px;
    flex: 0 0 84px;
    background: var(--teal);
    color: #e7f1ee;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
}
.brand { display: grid; place-items: center; margin-bottom: 10px; position: relative; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 50%;
    background: radial-gradient(circle at 32% 32%, #fff 0 16%, transparent 17%),
                conic-gradient(from 200deg, var(--accent), #148f4a 42%, #0d3c36 78%, var(--accent));
    position: relative;
}
.brand-mark::after {
    content: "";
    position: absolute;
    right: -1px; bottom: -1px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #6a7471;
    border: 2px solid var(--teal);
    box-shadow: 0 0 0 0 transparent;
}
.brand-mark[data-live="1"]::after {
    background: var(--accent);
}
.brand-mark[data-live="1"].is-pulse::after {
    animation: brand-live-pulse 1.6s ease-in-out infinite;
}
@keyframes brand-live-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, .55); }
    50% { box-shadow: 0 0 0 5px rgba(37, 211, 102, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .brand-mark[data-live="1"].is-pulse::after { animation: none; }
}

.shell {
    flex: 1;
    min-width: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.shell-bar {
    flex: 0 0 var(--shell-bar-h);
    height: var(--shell-bar-h);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 18px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    z-index: 5;
}
.wa-link-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--connected);
    text-decoration: none;
    padding: 4px 6px;
    border-radius: var(--r-sm);
    outline: none;
}
.wa-link-status:hover { background: #f0faf4; }
.wa-link-status:focus-visible {
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.35);
}
.wa-link-status__dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: currentColor; flex: 0 0 auto;
}
.wa-link-status.is-connected .wa-link-status__dot {
    animation: brand-live-pulse 1.6s ease-in-out infinite;
}
.wa-link-status__text { display: grid; line-height: 1.15; text-align: right; }
.wa-link-status__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.wa-link-status__phone {
    font-size: 10px;
    font-weight: 500;
    opacity: .92;
}
.wa-link-status.is-connecting { color: var(--pending); }
.wa-link-status.is-disconnected { color: var(--danger); }
.wa-link-status.is-offline { color: var(--muted); }
.wa-link-status.is-connected { color: var(--connected); }
@media (prefers-reduced-motion: reduce) {
    .wa-link-status.is-connected .wa-link-status__dot { animation: none; }
}
.side-nav {
    flex: 1;
    width: 100%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
}
.side-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 9px 4px 8px;
    border-radius: 18px;
    color: #c5d5d1;
    font-size: 9px;
    line-height: 1.15;
    text-align: center;
}
.side-link i { font-size: 18px; line-height: 1; width: 1.15em; text-align: center; }
.side-link:hover { color: #fff; background: var(--teal-2); }
.side-link.is-active { color: #fff; background: var(--teal-2); }
.side-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: #2a6d66; color: #fff;
    display: grid; place-items: center;
    font-weight: 700; margin-top: 10px;
}

.workspace {
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: var(--card);
}
.workspace.page-pad { background: var(--bg); }
.inbox-app {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) 300px;
    flex: 1;
    min-height: 0;
    height: calc(100dvh - var(--shell-bar-h));
}
.page-pad { padding: 36px 44px 56px; }
.page-kicker {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.page-head h1 { margin: 0 0 8px; font-size: 32px; font-weight: 650; letter-spacing: -.02em; }
.page-lead { max-width: 42ch; line-height: 1.5; font-size: 15px; }
.page-head.spread { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.metrics { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.metrics b { color: var(--ink); font-weight: 650; }

.inbox {
    background: var(--card);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}
.inbox-tools { padding: 16px 16px 8px; display: grid; gap: 10px; }
.btn-new, .btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}
.btn-new {
    height: 42px;
    padding: 0 18px;
    border-radius: 999px;
    color: #fff;
    background: var(--accent);
}
.btn-new i { font-size: 14px; }
.btn-new[disabled] { opacity: .4; cursor: not-allowed; }
.search {
    display: flex; align-items: center; gap: 8px;
    padding: 0 12px;
    background: var(--bg);
    border-radius: 999px;
    color: var(--muted);
}
.search i { font-size: 14px; width: 1em; text-align: center; }
.search input {
    flex: 1; border: 0; background: transparent; outline: none;
    height: 40px; color: var(--ink); font-size: 15px;
}
.tabs {
    display: flex; gap: 4px;
    padding: 4px 12px 0;
    border-bottom: 1px solid var(--line);
}
.tab {
    border: 0; background: none; cursor: pointer;
    padding: 12px 12px 14px;
    color: var(--muted); font-weight: 650; font-size: 15px;
    border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.tab span { color: var(--muted); font-weight: 600; }
.conv-list { flex: 1; overflow: auto; }
.conv {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 5.5rem;
    align-items: center;
    gap: 12px;
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 12px 16px;
    cursor: pointer;
    position: relative;
}
.conv:hover { background: #f3faf6; }
.conv.is-on { background: #eefaf3; }
.conv.is-on::before {
    content: "";
    position: absolute; left: 0; top: 10px; bottom: 10px;
    width: 3px; border-radius: 3px; background: var(--accent);
}
.avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 14px;
}
.conv-name { font-weight: 650; font-size: 15px; display: block; margin-bottom: 3px; }
.conv-snip { color: var(--muted); font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
}
.pill {
    display: inline-flex; align-items: center; justify-content: center;
    height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 12px; font-weight: 700; line-height: 1;
    white-space: nowrap;
    background: #eef2f1; color: var(--muted);
}
.pill.is-open { background: #e5f8ec; color: #157a3a; }
.pill.is-pending { background: #fff1e4; color: #b45b12; }
.pill.is-solved { background: #e8f0ff; color: #355dcc; }
.unread {
    box-sizing: border-box;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
    line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}

.thread {
    display: flex; flex-direction: column;
    min-width: 0; min-height: 0; height: 100%;
    background: var(--chat-bg);
}
.thread-bar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px;
    padding: 16px 22px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}
.thread-bar h1 { margin: 0; font-size: 18px; font-weight: 650; }
.thread-bar .muted { font-size: 14px; margin-top: 4px; }
.transcript {
    flex: 1; overflow: auto;
    padding: 28px 18% 24px;
    display: flex; flex-direction: column; gap: 10px;
}
.stage-empty { margin: auto; color: var(--muted); text-align: center; max-width: 28ch; font-size: 16px; line-height: 1.45; }
.bubble {
    max-width: 68%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 16px;
    box-shadow: 0 1px 0 rgba(16,24,20,.04);
}
.bubble.in { background: #fff; color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--out); color: var(--ink); align-self: flex-end; border-bottom-right-radius: 4px; }
.composer {
    display: flex; gap: 10px; align-items: center;
    padding: 14px 18px 18px;
    background: var(--card);
    border-top: 1px solid var(--line);
}
.composer input {
    flex: 1; border: 1px solid var(--line); background: var(--bg);
    border-radius: 999px; padding: 14px 18px; outline: none; font-size: 16px;
}
.btn-send {
    height: 46px; padding: 0 20px;
    border-radius: 999px; color: #fff; font-size: 15px;
}

.rail {
    background: var(--card);
    border-left: 1px solid var(--line);
    padding: 22px 20px 32px;
    overflow: auto;
    min-height: 0;
    height: 100%;
}
.rail-empty { color: var(--muted); margin-top: 24px; }
.rail-hero { text-align: center; padding: 8px 0 18px; }
.rail-hero .avatar { width: 64px; height: 64px; margin: 0 auto 10px; font-size: 22px; }
.rail-hero h2 { margin: 0 0 4px; font-size: 18px; }
.rail h3 {
    margin: 18px 0 8px; font-size: 12px; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { background: var(--bg); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.notes {
    width: 100%; min-height: 88px; border: 1px solid var(--line);
    border-radius: var(--r); padding: 10px 12px; background: #fffdf4; resize: vertical;
}

.table-like {
    margin-top: 28px; max-width: 720px;
    border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.table-like .row { display: grid; grid-template-columns: 1.2fr 1fr .6fr; padding: 12px 16px; }
.table-like .row + .row { border-top: 1px solid var(--line); }
.table-like .head { background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 700; }

body.login { display: grid; place-items: center; background: var(--bg); }
.login-card {
    width: min(380px, 92vw);
    background: var(--card);
    border-radius: 16px;
    padding: 32px;
    border: 1px solid var(--line);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card .muted { margin: 0 0 18px; }
.login-card label { display: block; font-size: 13px; margin: 12px 0 6px; color: var(--muted); }
.login-card input {
    width: 100%; border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 12px; background: var(--bg); outline: none;
}
.login-card button { margin-top: 18px; width: 100%; height: 44px; border-radius: 999px; }
.login-error { color: #b42318; font-size: 13px; }

.muted { color: var(--muted); margin: 0; }

@media (max-width: 1100px) {
    .inbox-app { grid-template-columns: 300px minmax(0,1fr); }
    .rail { display: none; }
}

.stack-form { max-width: 420px; margin: 8px 0 28px; }
.stack-form label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
.stack-form input, .stack-form textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 12px; background: var(--bg); outline: none;
}
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.btn-quiet { color: var(--muted); font-weight: 650; }
.form-msg { margin: 0 0 12px; font-size: 13px; }
.form-msg.is-err { color: #b42318; }
.form-msg.is-ok { color: #157a3a; }
.check-list { display: grid; gap: 8px; margin: 8px 0 4px; max-height: 240px; overflow: auto; }
.check-list label { display: flex; gap: 8px; align-items: center; color: var(--ink); }
#contact-table .row { grid-template-columns: 1.2fr 1fr .7fr auto; }

/* Dashboard */
.dash-page { max-width: 960px; }
.dash-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin: 28px 0 20px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--card);
    overflow: hidden;
}
.dash-metric {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 24px;
}
.dash-metric + .dash-metric { border-left: 1px solid var(--line); }
.dash-metric__icon {
    width: 40px; height: 40px; border-radius: 12px;
    display: grid; place-items: center;
    background: #eef8f2; color: var(--teal);
    flex: 0 0 auto; font-size: 16px;
}
.dash-metric__label {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.dash-metric__value {
    margin: 0;
    font-size: 36px;
    font-weight: 650;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--ink);
}
.dash-panel { margin: 0 0 28px; }
.dash-status {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--card);
}
.dash-status .btn-quiet { margin-left: auto; white-space: nowrap; }
.dash-status__dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--muted); flex: 0 0 auto;
}
.dash-status.is-loading .dash-status__dot { background: var(--pending); }
.dash-status.is-ok .dash-status__dot { background: var(--accent); }
.dash-status.is-warn .dash-status__dot { background: var(--pending); }
.dash-status.is-err .dash-status__dot { background: var(--danger); }
.dash-status__title {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 700;
}
.dash-status__msg {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
}
.dash-shortcuts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.dash-shortcut {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--card);
    color: var(--ink);
    font-weight: 650;
    font-size: 15px;
    transition: background .15s ease, border-color .15s ease;
}
.dash-shortcut > i:first-child,
.dash-shortcut > .fa-solid:first-child {
    width: 1.25em;
    color: var(--teal);
    text-align: center;
}
.dash-shortcut .fa-arrow-right {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
}
.dash-shortcut:hover {
    background: #f3faf6;
    border-color: #cfe6d8;
}

/* Coming soon */
.coming-page {
    background: var(--bg);
    min-height: calc(100dvh - var(--shell-bar-h));
    display: grid;
    place-items: center;
    padding: 40px 24px;
}
.coming-stage {
    width: min(480px, 100%);
    text-align: center;
}
.coming-mark {
    width: 72px; height: 72px;
    margin: 0 auto 18px;
    border-radius: 22px;
    display: grid; place-items: center;
    background: var(--teal);
    color: #e7f1ee;
    font-size: 28px;
}
.coming-stage .page-kicker { margin-bottom: 10px; }
.coming-stage h1 {
    margin: 0 0 12px;
    font-size: 36px;
    font-weight: 650;
    letter-spacing: -.03em;
}
.coming-copy {
    margin: 0 auto 24px;
    max-width: 38ch;
    font-size: 16px;
    line-height: 1.55;
}
.coming-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-bottom: 36px;
}
.coming-actions .btn-new { padding: 0 20px; }
.coming-ships {
    list-style: none;
    margin: 0;
    padding: 18px 0 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    text-align: left;
}
.coming-ships a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    color: var(--ink);
    font-size: 14px;
    font-weight: 650;
}
.coming-ships a i { color: var(--teal); width: 1.1em; text-align: center; }
.coming-ships a:hover { background: #eef8f2; }

@media (max-width: 820px) {
    .dash-metrics { grid-template-columns: 1fr; }
    .dash-metric + .dash-metric { border-left: 0; border-top: 1px solid var(--line); }
    .dash-shortcuts { grid-template-columns: 1fr; }
    .page-head.spread { flex-direction: column; align-items: flex-start; }
}

.baileys-box {
    max-width: 280px; padding: 24px;
    border: 1px solid var(--line); border-radius: var(--r);
    background: var(--card); text-align: center;
}
.baileys-qr-frame {
    width: 220px; height: 220px; margin: 0 auto 12px;
    background: #fff; border-radius: 8px; overflow: hidden;
}
.baileys-box img { width: 220px; height: 220px; display: block; }
.baileys-box.is-offline .baileys-qr-frame { filter: grayscale(1); opacity: .4; }
.baileys-box #baileys-msg { margin: 0; font-size: 14px; }
.send-notice {
    align-self: flex-end; margin: 0 4px 6px;
    font-size: 12px; color: var(--muted);
}
.bubble.out.is-queued { opacity: .85; }
