/* NagaZapGO panel styles (Bootstrap 5.3 based, light/dark aware) */
/* Brand palette, matte: hues taken from the logo (green "GO", lime/cyan "N", navy ink letters) but
 * desaturated and lowered in contrast so long sessions stay easy on the eyes. Neon logo green is
 * only used for tiny indicators; text never sits on pure white or pure black. */
:root {
  --nzg-ink: #1d2935;            /* navy ink of the wordmark, softened */
  --nzg-green: #4caf6a;          /* matte brand green: dots, indicators, accents */
  --nzg-green-dark: #2c7a4b;     /* matte accessible green: buttons, links, active text (5:1 on surface) */
  --nzg-lime: #a3cf7c;
  --nzg-cyan: #6bb8c6;
  --nzg-gradient: linear-gradient(135deg, #a3cf7c 0%, #4caf6a 50%, #6bb8c6 100%);
  --nzg-sidebar-bg: #17222e;
  --nzg-sidebar-fg: #a9b5c1;
  --bs-primary: #2c7a4b;
  --bs-primary-rgb: 44, 122, 75;
  --bs-success: #2c7a4b;
  --bs-success-rgb: 44, 122, 75;
  --bs-warning: #c08a2d;
  --bs-warning-rgb: 192, 138, 45;
  --bs-danger: #c0504d;
  --bs-danger-rgb: 192, 80, 77;
  --bs-info: #4a90a4;
  --bs-info-rgb: 74, 144, 164;
  --bs-link-color: #2c7a4b;
  --bs-link-color-rgb: 44, 122, 75;
  --bs-link-hover-color: #23633d;
  --bs-link-hover-color-rgb: 35, 99, 61;
  --nzg-nav-h: 0px; /* height of the mobile bottom bar (0 on desktop) */
  /* design tokens: one radius, border and shadow scale for every surface */
  --nzg-radius: .75rem;
  --nzg-radius-sm: .5rem;
  --nzg-border: rgba(29, 41, 53, .09);
  --nzg-border-strong: rgba(29, 41, 53, .16);
  --nzg-shadow: 0 1px 2px rgba(29, 41, 53, .04);
  --nzg-shadow-lg: 0 12px 28px -14px rgba(29, 41, 53, .2);
  --nzg-muted-bg: #ebefee;
  --nzg-accent-soft: rgba(76, 175, 106, .12);
  --bs-body-font-family: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-bg: #fbfcfb;         /* cards: off-white, never pure #fff */
  --bs-body-bg-rgb: 251, 252, 251;
  --bs-body-color: #26323d;
  --bs-emphasis-color: #1d2935;
  --bs-secondary-color: rgba(38, 50, 61, .62);
  --bs-tertiary-bg: #f0f3f2;
  --bs-border-color: #d9e0de;
  --bs-border-radius: .55rem;
  --nzg-surface: #eff2f1;        /* page background: soft grey-green */
}
[data-bs-theme="dark"] {
  --nzg-surface: #121a23;
  --nzg-sidebar-bg: #0f161e;
  --bs-body-bg: #18222d;
  --bs-body-bg-rgb: 24, 34, 45;
  --bs-body-color: #cfd8e0;      /* soft grey, not white */
  --bs-emphasis-color: #e4eaef;
  --bs-secondary-color: rgba(207, 216, 224, .58);
  --bs-border-color: #2a3744;
  --bs-tertiary-bg: #1d2834;
  --bs-primary: #6fbf8a;
  --bs-primary-rgb: 111, 191, 138;
  --bs-success: #6fbf8a;
  --bs-success-rgb: 111, 191, 138;
  --bs-warning: #d6a95a;
  --bs-danger: #d9817e;
  --bs-link-color: #7cc795;
  --bs-link-color-rgb: 124, 199, 149;
  --bs-link-hover-color: #a3cf7c;
  --nzg-green: #6fbf8a;
  --nzg-green-dark: #6fbf8a;
  --nzg-border: rgba(255, 255, 255, .06);
  --nzg-border-strong: rgba(255, 255, 255, .11);
  --nzg-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  --nzg-shadow-lg: 0 12px 28px -14px rgba(0, 0, 0, .55);
  --nzg-muted-bg: #1f2b37;
  --nzg-accent-soft: rgba(111, 191, 138, .12);
}
[data-bs-theme="dark"] .card { --bs-card-bg: #18222d; }

body.app { background: var(--nzg-surface); min-height: 100vh; -webkit-font-smoothing: antialiased; }
@media (min-width: 992px) { body.app { font-size: .9375rem; } }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .h6 { letter-spacing: -.01em; }
body.auth { min-height: 100vh; min-height: 100dvh; background: radial-gradient(60rem 40rem at 10% -10%, rgba(163, 207, 124, .22), transparent 60%), radial-gradient(50rem 40rem at 110% 110%, rgba(107, 184, 198, .2), transparent 60%), var(--nzg-surface); }
.min-w-0 { min-width: 0; }

/* "More" sheet (phones only: on desktop the navigation lives in the top bar) */
.app-sidebar { --bs-offcanvas-width: min(300px, 85vw); background: var(--nzg-sidebar-bg) !important; color: var(--nzg-sidebar-fg); }
.app-sidebar .offcanvas-header { padding: 1.25rem 1.25rem .75rem; }
.app-sidebar .offcanvas-body { padding: .5rem 1rem 1.25rem; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; min-width: 0; }
.brand-icon { width: 40px; height: 40px; flex-shrink: 0; object-fit: contain; }
.brand-word { height: 26px; width: auto; max-width: 160px; object-fit: contain; }
.app-sidebar { border-right: 1px solid rgba(255, 255, 255, .05); }
.sidebar-section { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: rgba(200, 214, 209, .45); padding: .25rem .85rem .5rem; }
.app-sidebar .nav-link { position: relative; color: var(--nzg-sidebar-fg); border-radius: var(--nzg-radius-sm); padding: .55rem .8rem; display: flex; align-items: center; gap: .7rem; font-size: .9rem; font-weight: 500; transition: background .15s, color .15s; }
.app-sidebar .nav-link i { font-size: 1.05rem; opacity: .85; width: 1.15rem; text-align: center; }
.app-sidebar .nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.app-sidebar .nav-link.active { background: rgba(76, 175, 106, .14); color: #fff; }
.app-sidebar .nav-link.active i { color: var(--nzg-green); opacity: 1; }
.app-sidebar .nav-link.active::before { content: ""; position: absolute; left: -1rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: var(--nzg-green); }
.sidebar-footer { color: var(--nzg-sidebar-fg); border-top: 1px solid rgba(255, 255, 255, .06); }
.sidebar-user { display: flex; align-items: center; gap: .65rem; padding: .5rem .35rem; border-radius: var(--nzg-radius-sm); }
.sidebar-avatar { width: 2.1rem; height: 2.1rem; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: rgba(76, 175, 106, .18); color: var(--nzg-green); font-weight: 700; font-size: .85rem; text-transform: uppercase; }
.sidebar-user-name { font-size: .85rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user-role { font-size: .72rem; color: rgba(200, 214, 209, .55); line-height: 1.2; }
.sidebar-logout { width: 2.1rem; height: 2.1rem; flex-shrink: 0; display: grid; place-items: center; padding: 0; border: 0; border-radius: var(--nzg-radius-sm); background: transparent; color: var(--nzg-sidebar-fg); font-size: 1.05rem; transition: background .15s, color .15s; }
.sidebar-logout:hover { background: rgba(255, 255, 255, .07); color: #fff; }

/* Topbar & content */
.app-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .6rem; min-height: 60px; padding: .6rem 2rem; background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--nzg-border); }
.app-topbar h1 { font-size: 1.05rem; font-weight: 650; }
.app-topbar .btn-outline-secondary { height: 34px; }
.app-content { padding: 1.75rem 2rem 2rem; width: 100%; max-width: 1480px; margin-inline: auto; }
@media (max-width: 575.98px) { .app-content { padding: 1rem; } .app-topbar { padding: .75rem 1rem; } }

.live-chip { display: inline-flex; align-items: center; gap: .45rem; height: 28px; font-size: .75rem; font-weight: 500; color: var(--bs-secondary-color); background: var(--nzg-muted-bg); border-radius: 50rem; padding: 0 .65rem; cursor: help; white-space: nowrap; }
.live-dot { width: .5rem; height: .5rem; border-radius: 50%; background: #9aa6b0; display: inline-block; flex-shrink: 0; }
.live-dot.on { background: #4caf6a; box-shadow: 0 0 0 0 rgba(76, 175, 106, .5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(76, 175, 106, .5); } 70% { box-shadow: 0 0 0 6px rgba(76, 175, 106, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 175, 106, 0); } }
.live-chip:has(.live-dot.on) { color: #2c7a4b; background: rgba(76, 175, 106, .1); }
[data-bs-theme="dark"] .live-chip:has(.live-dot.on) { color: #7cc795; background: rgba(111, 191, 138, .1); }
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } }

/* Cards: one surface style everywhere (hairline border + soft shadow) */
.card { border-radius: var(--nzg-radius); --bs-card-border-color: var(--nzg-border); --bs-card-cap-padding-y: .85rem; --bs-card-cap-padding-x: 1.25rem; --bs-card-spacer-x: 1.25rem; --bs-card-spacer-y: 1.15rem; }
.card.border-0 { border: 1px solid var(--nzg-border) !important; }
.card.shadow-sm { box-shadow: var(--nzg-shadow) !important; }
.card > .card-header { border-bottom-color: var(--nzg-border); }
.card > .card-header .h6, .card > .card-header h2 { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; }
.card > .card-header .h6 > .bi, .card > .card-header h2 > .bi { color: var(--bs-secondary-color); }
.card > .card-footer { border-top-color: var(--nzg-border); padding: .75rem 1.25rem; }
.card .list-group-item { border-color: var(--nzg-border); }
.list-group-item-action { padding: .8rem 1.25rem; }
.dropdown-menu { --bs-dropdown-border-color: var(--nzg-border); --bs-dropdown-border-radius: var(--nzg-radius-sm); --bs-dropdown-link-active-bg: var(--nzg-accent-soft); --bs-dropdown-link-active-color: var(--bs-body-color); box-shadow: var(--nzg-shadow-lg); padding: .35rem; }
.dropdown-item { border-radius: .4rem; padding: .45rem .7rem; font-size: .9rem; }
.modal-content { border: 1px solid var(--nzg-border); border-radius: calc(var(--nzg-radius) + .25rem); box-shadow: var(--nzg-shadow-lg); }
.modal-header, .modal-footer { border-color: var(--nzg-border); }

/* Buttons & form controls */
.btn { font-weight: 500; border-radius: var(--bs-border-radius); display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn-sm { border-radius: .45rem; }
.btn-outline-secondary { --bs-btn-color: var(--bs-body-color); --bs-btn-border-color: var(--bs-border-color); --bs-btn-bg: var(--bs-body-bg); --bs-btn-hover-bg: var(--nzg-muted-bg); --bs-btn-hover-color: var(--bs-body-color); --bs-btn-hover-border-color: var(--nzg-border-strong); --bs-btn-active-bg: var(--nzg-accent-soft); --bs-btn-active-color: var(--bs-primary); --bs-btn-active-border-color: rgba(var(--bs-primary-rgb), .35); }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-active-color: var(--bs-link-color); }
.form-control, .form-select { border-color: var(--bs-border-color); }
.form-control:focus, .form-select:focus { border-color: rgba(var(--bs-primary-rgb), .55); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .15); }
.form-check-input:checked { background-color: var(--nzg-green-dark); border-color: var(--nzg-green-dark); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .15); border-color: rgba(var(--bs-primary-rgb), .55); }
.form-label { font-weight: 500; font-size: .875rem; margin-bottom: .35rem; }
.input-group-text { background: var(--nzg-muted-bg); border-color: var(--bs-border-color); color: var(--bs-secondary-color); }
.input-search .input-group-text { background: var(--bs-body-bg); border-right: 0; padding-right: .25rem; }
.input-search .form-control { border-left: 0; }
.input-search:focus-within .input-group-text { border-color: rgba(var(--bs-primary-rgb), .55); }
.input-search:focus-within .form-control { box-shadow: none; }
.input-search:focus-within { border-radius: var(--bs-border-radius); box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .15); }

/* Toolbars above lists */
.page-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.page-toolbar .search-box { flex: 1 1 260px; max-width: 380px; }
.page-toolbar .toolbar-actions { margin-left: auto; display: flex; gap: .5rem; }
@media (max-width: 575.98px) {
  .page-toolbar { flex-wrap: nowrap; gap: .5rem; margin-bottom: 1rem; }
  .page-toolbar .search-box { max-width: none; flex: 1 1 auto; min-width: 0; }
  .page-toolbar .btn-label { display: none; }
  .page-toolbar .toolbar-actions .btn { width: 44px; padding-inline: 0; }
}

/* Stat tiles */
.stat-card { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-radius: var(--nzg-radius); background: var(--bs-body-bg); border: 1px solid var(--nzg-border); box-shadow: var(--nzg-shadow); height: 100%; }
.stat-card > i { order: 2; font-size: 1.15rem; width: 2.4rem; height: 2.4rem; border-radius: .65rem; display: grid; place-items: center; background: var(--nzg-accent-soft); color: var(--bs-primary); flex-shrink: 0; }
[data-bs-theme="dark"] .stat-card > i { color: var(--bs-link-color); }
.stat-success > i { background: rgba(76, 175, 106, .12); color: #2c7a4b; }
.stat-warning > i { background: rgba(192, 138, 45, .12); color: #9a6a1c; }
.stat-danger > i { background: rgba(100, 116, 110, .12); color: #5b6763; }
[data-bs-theme="dark"] .stat-success > i { color: #7cc795; }
[data-bs-theme="dark"] .stat-warning > i { color: #d6a95a; }
[data-bs-theme="dark"] .stat-danger > i { color: #a3b1ac; }
.stat-card > div { display: flex; flex-direction: column-reverse; gap: .35rem; min-width: 0; }
.stat-value { font-size: 1.85rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-label { font-size: .82rem; font-weight: 500; color: var(--bs-secondary-color); }

.avatar { width: 2.4rem; height: 2.4rem; border-radius: .65rem; display: grid; place-items: center; background: rgba(76, 175, 106, .13); color: var(--nzg-green-dark); flex-shrink: 0; font-size: 1.15rem; }
.avatar-lg { width: 3rem; height: 3rem; font-size: 1.4rem; border-radius: .8rem; }
[data-bs-theme="dark"] .avatar { color: var(--nzg-green); }
.avatar.is-connected { background: rgba(76, 175, 106, .14); }
.instance-card { transition: border-color .15s, box-shadow .15s; }
.instance-card:hover { border-color: rgba(var(--bs-primary-rgb), .35) !important; box-shadow: var(--nzg-shadow-lg) !important; }
.instance-card .card-body { padding: 1.1rem 1.25rem; }
.instance-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .78rem; color: var(--bs-secondary-color); }
.instance-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.instance-card .card-footer { background: transparent; }
.row-chevron { color: var(--bs-secondary-color); opacity: .6; font-size: .9rem; flex-shrink: 0; }
.search-box { max-width: 360px; }

/* Status pills: tinted background + dot, semantic per status (overrides Bootstrap's solid badges) */
.badge.status-badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .72rem; font-weight: 600; padding: .3rem .6rem .3rem .5rem; letter-spacing: .01em; flex-shrink: 0;
  background: var(--nzg-muted-bg) !important; color: #5a6672 !important; }
.status-badge::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; opacity: .85; }
.status-badge[data-status="connected"] { background: rgba(76, 175, 106, .12) !important; color: #2c7a4b !important; }
.status-badge[data-status="qrcode"], .status-badge[data-status="connecting"] { background: rgba(192, 138, 45, .12) !important; color: #9a6a1c !important; }
.status-badge[data-status="connecting"]::before { animation: rec-blink 1s infinite; }
[data-bs-theme="dark"] .badge.status-badge { color: #a9b5c1 !important; }
[data-bs-theme="dark"] .status-badge[data-status="connected"] { background: rgba(111, 191, 138, .12) !important; color: #7cc795 !important; }
[data-bs-theme="dark"] .status-badge[data-status="qrcode"], [data-bs-theme="dark"] .status-badge[data-status="connecting"] { background: rgba(214, 169, 90, .12) !important; color: #d6a95a !important; }

/* Empty states */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--bs-secondary-color); }
.empty-icon { width: 3.5rem; height: 3.5rem; margin: 0 auto 1rem; border-radius: 1rem; display: grid; place-items: center; font-size: 1.6rem; background: var(--nzg-accent-soft); color: var(--bs-primary); }
[data-bs-theme="dark"] .empty-icon { color: var(--bs-link-color); }
.empty-title { font-weight: 600; color: var(--bs-body-color); margin-bottom: .25rem; }
.empty-text { font-size: .875rem; max-width: 360px; margin: 0 auto; }

/* Tabs scroll horizontally on small screens */
.nav-scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; gap: .25rem; padding-bottom: .25rem; }
.nav-scroll .nav-link { white-space: nowrap; border-radius: .6rem; }
.nav-pills .nav-link.active { background: var(--bs-primary); }

/* QR */
.qr-box { background: #fff; padding: 12px; border-radius: 1rem; display: inline-block; box-shadow: 0 .25rem 1rem rgba(0, 0, 0, .08); }
.qr-box img { display: block; max-width: 100%; height: auto; }
.qr-progress { height: 4px; width: 280px; max-width: 100%; margin-inline: auto; }
.pair-code { font-family: var(--bs-font-monospace); font-size: 2rem; letter-spacing: .35rem; font-weight: 700; text-align: center; padding: .75rem; border-radius: .75rem; background: rgba(76, 175, 106, .12); color: var(--nzg-green-dark); }
[data-bs-theme="dark"] .pair-code { color: var(--nzg-green); }

/* Events */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .25rem .75rem; }
.event-feed li { padding: .55rem 1rem; border-bottom: 1px solid var(--bs-border-color-translucent); font-size: .85rem; display: flex; gap: .5rem; align-items: center; }
.event-feed li .ev-name { font-family: var(--bs-font-monospace); font-size: .78rem; }
.event-feed li time { margin-left: auto; color: var(--bs-secondary-color); font-size: .75rem; white-space: nowrap; }
.event-log { max-height: 60vh; overflow-y: auto; }
.event-log pre, .event-log .ev-name { font-family: var(--bs-font-monospace); }
.event-log details { border-bottom: 1px solid var(--bs-border-color-translucent); padding: .4rem 1rem; }
.event-log summary { cursor: pointer; }
.event-log pre { margin: .4rem 0 0; white-space: pre-wrap; word-break: break-all; color: var(--bs-secondary-color); }
.feed-enter { animation: fadein .35s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.code-block { background: #1d2935; color: #cfe3d6; padding: .9rem 1rem; border-radius: .6rem; font-size: .8rem; white-space: pre-wrap; word-break: break-all; }

/* Integrations: see "Modules" below */

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; border-radius: 1.25rem; }
.btn-success { --bs-btn-bg: var(--nzg-green-dark); --bs-btn-border-color: var(--nzg-green-dark); --bs-btn-hover-bg: #23633d; --bs-btn-hover-border-color: #23633d; }

/* ---------- History (chat UI) ---------- */
.chat-shell { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; height: calc(100vh - 250px); min-height: 460px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--bs-border-color-translucent); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { display: flex; gap: .5rem; padding: .75rem; border-bottom: 1px solid var(--bs-border-color-translucent); }
.chat-items { overflow-y: auto; flex: 1; }
.chat-item { display: flex; gap: .75rem; align-items: center; width: 100%; padding: .7rem .85rem; border: 0; background: transparent; text-align: left; color: inherit; border-bottom: 1px solid var(--bs-border-color-translucent); transition: background .12s; }
.chat-item:hover { background: var(--bs-tertiary-bg); }
.chat-item.active { background: rgba(76, 175, 106, .12); box-shadow: inset 3px 0 0 var(--nzg-green); }
.chat-item .meta { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.chat-item .name { font-weight: 600; font-size: .9rem; }
.chat-item .when { font-size: .72rem; color: var(--bs-secondary-color); white-space: nowrap; }
.chat-item .preview { font-size: .8rem; color: var(--bs-secondary-color); }
.chat-avatar { width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; font-weight: 600; font-size: .9rem; text-transform: uppercase; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: .75rem; padding: .65rem 1rem; border-bottom: 1px solid var(--bs-border-color-translucent); background: var(--bs-body-bg); }
.chat-body { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .25rem;
  background-color: #efeae2; background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px); background-size: 18px 18px; }
[data-bs-theme="dark"] .chat-body { background-color: #0b141a; background-image: radial-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px); }
.chat-empty { margin: auto; text-align: center; color: var(--bs-secondary-color); max-width: 300px; font-size: .9rem; }
.chat-empty i { font-size: 2.6rem; display: block; margin-bottom: .5rem; opacity: .6; }
.chat-day { align-self: center; font-size: .72rem; background: var(--bs-body-bg); color: var(--bs-secondary-color); padding: .2rem .65rem; border-radius: 50rem; margin: .6rem 0 .3rem; box-shadow: 0 1px 1px rgba(0, 0, 0, .06); }
.bubble { position: relative; max-width: min(75%, 560px); padding: .4rem .6rem .3rem; border-radius: .6rem; font-size: .9rem; line-height: 1.35; white-space: pre-wrap; word-break: break-word;
  background: #fff; color: #111b21; align-self: flex-start; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); border-top-left-radius: .15rem; }
.bubble.me { background: #d9fdd3; align-self: flex-end; border-top-left-radius: .6rem; border-top-right-radius: .15rem; }
[data-bs-theme="dark"] .bubble { background: #202c33; color: #e9edef; }
[data-bs-theme="dark"] .bubble.me { background: #005c4b; }
.bubble .foot { display: flex; justify-content: flex-end; align-items: center; gap: .2rem; font-size: .68rem; color: #667781; margin-top: .1rem; float: right; margin-left: .6rem; position: relative; top: .25rem; }
[data-bs-theme="dark"] .bubble .foot { color: #8696a0; }
.bubble .foot .read { color: #53bdeb; }
.bubble .kind { font-style: italic; color: #667781; }
.bubble .media-chip { display: inline-flex; align-items: center; gap: .35rem; font-size: .82rem; text-decoration: none; padding: .25rem .5rem; border-radius: .4rem; background: rgba(0, 0, 0, .05); margin-bottom: .2rem; }
.bubble::after { content: ""; display: block; clear: both; }
.chat-more { align-self: center; margin-bottom: .5rem; }
@media (max-width: 767.98px) {
  .chat-shell { grid-template-columns: 1fr; height: calc(100vh - 248px - var(--nzg-nav-h)); height: calc(100dvh - 248px - var(--nzg-nav-h)); min-height: 340px; }
  .chat-shell .chat-pane { display: none; }
  .chat-shell.open .chat-list { display: none; }
  .chat-shell.open .chat-pane { display: flex; }
  .bubble { max-width: 88%; }
  /* open conversation = full-screen view above the app bars, like a native chat app */
  .chat-shell.open { position: fixed; inset: 0; z-index: 1045; height: 100vh; height: 100dvh; min-height: 0; border-radius: 0 !important;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); background: var(--bs-body-bg); }
  body:has(.chat-shell.open) { overflow: hidden; }
  body:has(.chat-shell.open) .bottom-nav { display: none; }
}

/* ---------- Instance page ---------- */
/* underline tab bar: same component on desktop and phone (scrolls sideways on narrow screens) */
.instance-tabs { flex-wrap: nowrap; gap: .25rem; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; border-bottom: 1px solid var(--nzg-border); margin-bottom: 1.25rem !important; scroll-padding-inline: 1rem; }
.instance-tabs::-webkit-scrollbar { display: none; }
.instance-tabs .nav-item { flex-shrink: 0; }
.instance-tabs .nav-link { position: relative; display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; border-radius: 0; padding: .7rem .85rem; font-size: .875rem; font-weight: 500; color: var(--bs-secondary-color); background: none; }
.instance-tabs .nav-link i { font-size: 1rem; }
.instance-tabs .nav-link:hover { color: var(--bs-body-color); }
.instance-tabs .nav-link.active { background: none; color: var(--bs-primary); }
[data-bs-theme="dark"] .instance-tabs .nav-link.active { color: var(--bs-link-color); }
.instance-tabs .nav-link.active::after { content: ""; position: absolute; left: .6rem; right: .6rem; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: currentColor; }
@media (max-width: 991.98px) {
  .instance-tabs { margin-inline: -1rem; padding-inline: .5rem; position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 1010; background: color-mix(in srgb, var(--nzg-surface) 92%, transparent); backdrop-filter: blur(10px); }
  .instance-tabs .nav-link { padding: .75rem .7rem; }
}
.instance-head { padding: 1.1rem 1.25rem; }
.instance-head .instance-title { font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
.instance-head .h5 { max-width: 100%; }
.detail-list { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: .55rem 1rem; font-size: .85rem; margin: 0; }
.detail-list dt { font-weight: 500; color: var(--bs-secondary-color); }
.detail-list dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-title { font-size: .95rem; font-weight: 600; display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.section-title > .bi { color: var(--bs-secondary-color); }

/* ---------- Events picker (webhooks) ---------- */
.events-picker { border: 1px solid var(--bs-border-color); border-radius: .6rem; }
.events-picker > summary { list-style: none; cursor: pointer; padding: .55rem .85rem; display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.events-picker > summary::-webkit-details-marker { display: none; }
.events-picker > summary::after { content: "\F282"; font-family: "bootstrap-icons"; margin-left: auto; transition: transform .15s; }
.events-picker[open] > summary::after { transform: rotate(180deg); }
.events-picker .events-body { padding: .25rem .85rem .75rem; border-top: 1px solid var(--bs-border-color-translucent); }

/* ---------- API docs ---------- */
.endpoint { display: grid; grid-template-columns: 4.2rem 1fr; gap: .25rem .75rem; align-items: start; padding: .65rem .25rem; border-bottom: 1px solid var(--bs-border-color-translucent); }
.endpoint .badge { width: 100%; font-family: var(--bs-font-monospace); }
.endpoint code { word-break: break-all; font-size: .82rem; }
.endpoint .desc { grid-column: 2; font-size: .82rem; color: var(--bs-secondary-color); }

/* ---------- Small screens ---------- */
@media (max-width: 575.98px) {
  .stat-card { padding: .8rem; gap: .65rem; }
  .stat-card > i { width: 2.4rem; height: 2.4rem; font-size: 1.2rem; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: .68rem; letter-spacing: 0; }
  .app-topbar h1 { font-size: 1rem; }
  .card-body.p-4 { padding: 1rem !important; }
}

/* ---------- Analytics (palette validated with the dataviz validator, light + dark) ---------- */
.viz-root {
  --series-1: #2a78d6; --series-2: #eb6834;
  --viz-grid: #e9ecea; --viz-axis: #c3c2b7; --viz-muted: #898781; --viz-ink: #0b0b0b; --viz-ink-2: #52514e;
  --viz-surface: #ffffff;
  --h0: #f1f3f2; --h1: #cde2fb; --h2: #9ec5f4; --h3: #6da7ec; --h4: #3987e5; --h5: #256abf; --h6: #184f95; --h7: #0d366b;
  --ord-1: #2a78d6; --ord-2: #5598e7; --ord-3: #86b6ef;
}
[data-bs-theme="dark"] .viz-root {
  --series-1: #3987e5; --series-2: #d95926;
  --viz-grid: #1f2c3b; --viz-axis: #383835; --viz-muted: #898781; --viz-ink: #f0efec; --viz-ink-2: #c3c2b7;
  --viz-surface: #18222d;
  --h0: #172433; --h1: #104281; --h2: #184f95; --h3: #1c5cab; --h4: #256abf; --h5: #3987e5; --h6: #6da7ec; --h7: #9ec5f4;
  --ord-1: #3987e5; --ord-2: #256abf; --ord-3: #184f95;
}
.viz-filters { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.viz-instance { width: auto; min-width: 180px; }
.viz-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .5rem; }
.viz-legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--viz-ink-2); }
.viz-legend .key { display: inline-flex; align-items: center; gap: .4rem; }
.viz-legend .line { width: 16px; height: 2px; border-radius: 2px; display: inline-block; }
.viz-legend .line.s1 { background: var(--series-1); }
.viz-legend .line.s2 { background: var(--series-2); }
.viz-chart { position: relative; width: 100%; }
.viz-chart svg { display: block; width: 100%; overflow: visible; }
.viz-chart text { fill: var(--viz-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-chart .end-label { fill: var(--viz-ink-2); font-size: 11px; font-weight: 600; }
.viz-chart .grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-chart .baseline { stroke: var(--viz-axis); stroke-width: 1; }
.viz-chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-chart .ln.s1 { stroke: var(--series-1); } .viz-chart .ln.s2 { stroke: var(--series-2); }
.viz-chart .ar.s1 { fill: var(--series-1); opacity: .1; } .viz-chart .ar.s2 { fill: var(--series-2); opacity: .1; }
.viz-chart .dot { stroke: var(--viz-surface); stroke-width: 2; }
.viz-chart .dot.s1 { fill: var(--series-1); } .viz-chart .dot.s2 { fill: var(--series-2); }
.viz-chart .crosshair { stroke: var(--viz-axis); stroke-width: 1; }
.viz-chart .cell { stroke: var(--viz-surface); stroke-width: 2; rx: 3; }
.viz-chart .cell:hover, .viz-chart .cell.on { stroke: var(--viz-ink); }
.h0 { fill: var(--h0); } .h1 { fill: var(--h1); } .h2 { fill: var(--h2); } .h3 { fill: var(--h3); }
.h4 { fill: var(--h4); } .h5 { fill: var(--h5); } .h6 { fill: var(--h6); } .h7 { fill: var(--h7); }
/* heatmap legend is an SVG (see analytics.js): words centered on the x-height next to the swatches */
.viz-scale { margin-top: .5rem; }
.viz-scale svg { display: block; overflow: visible; }
.viz-scale text { fill: currentColor; font-size: 12px; }
.viz-scale .sw.h0 { fill: var(--h0); } .viz-scale .sw.h1 { fill: var(--h1); } .viz-scale .sw.h2 { fill: var(--h2); }
.viz-scale .sw.h3 { fill: var(--h3); } .viz-scale .sw.h4 { fill: var(--h4); } .viz-scale .sw.h5 { fill: var(--h5); }
.viz-scale .sw.h6 { fill: var(--h6); } .viz-scale .sw.h7 { fill: var(--h7); }
.viz-tooltip { position: fixed; z-index: 1080; pointer-events: none; background: var(--bs-body-bg); color: var(--viz-ink); border: 1px solid var(--bs-border-color-translucent);
  box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .12); border-radius: .5rem; padding: .45rem .6rem; font-size: .8rem; min-width: 120px; }
.viz-tooltip .tt-title { color: var(--viz-ink-2); font-size: .75rem; margin-bottom: .2rem; }
.viz-tooltip .tt-row { display: flex; align-items: center; gap: .45rem; }
.viz-tooltip .tt-row strong { font-variant-numeric: tabular-nums; }
.viz-tooltip .tt-key { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }
.viz-tooltip .tt-key.s1 { background: var(--series-1); } .viz-tooltip .tt-key.s2 { background: var(--series-2); }
.viz-tooltip .tt-muted { color: var(--viz-ink-2); }
/* stat tiles */
.kpi { height: 100%; padding: 1rem 1.1rem; border-radius: .9rem; background: var(--bs-body-bg); box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .06); }
.kpi .kpi-label { font-size: .8rem; color: var(--bs-secondary-color); display: flex; align-items: center; gap: .4rem; }
.kpi .kpi-value { font-size: 1.7rem; font-weight: 600; line-height: 1.2; margin-top: .15rem; }
.kpi .kpi-foot { font-size: .75rem; color: var(--bs-secondary-color); display: flex; flex-wrap: wrap; gap: .25rem .6rem; align-items: center; margin-top: .2rem; }
.kpi .delta { font-weight: 600; display: inline-flex; align-items: center; gap: .15rem; }
.kpi .delta.good { color: #006300; } .kpi .delta.bad { color: #d03b3b; } .kpi .delta.flat { color: var(--bs-secondary-color); }
[data-bs-theme="dark"] .kpi .delta.good { color: #0ca30c; } [data-bs-theme="dark"] .kpi .delta.bad { color: #e66767; }
/* horizontal bar rows (top contacts, types, funnel) */
.hbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: .6rem; padding: .3rem 0; }
.hbar .hb-label { font-size: .82rem; min-width: 0; }
.hbar .hb-label .sub { display: block; font-size: .7rem; color: var(--bs-secondary-color); }
.hbar .hb-track { height: 12px; position: relative; }
.hbar .hb-fill { height: 12px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar .hb-fill.o2 { background: var(--ord-2); } .hbar .hb-fill.o3 { background: var(--ord-3); }
.hbar .hb-value { font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--viz-ink); text-align: right; white-space: nowrap; }
.hbar .hb-value .pct { font-weight: 400; color: var(--bs-secondary-color); margin-left: .25rem; }
.hbar:hover .hb-fill { filter: brightness(1.12); }
.viz-loading { opacity: .45; transition: opacity .15s; }
.seg { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; margin: .4rem 0 .5rem; }
.seg span { display: block; height: 100%; }
.seg .s1 { background: var(--series-1); } .seg .s2 { background: var(--series-2); }
.seg-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .78rem; color: var(--bs-secondary-color); }
.seg-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.seg-legend i.s1 { background: var(--series-1); } .seg-legend i.s2 { background: var(--series-2); }

/* ---------- Chat composer ---------- */
.chat-composer { display: flex; align-items: flex-end; gap: .4rem; padding: .55rem .75rem; border-top: 1px solid var(--bs-border-color-translucent); background: var(--bs-body-bg); }
.chat-composer.d-none { display: none !important; }
.chat-attach { padding: .35rem .4rem; }
.chat-input-wrap { flex: 1; min-width: 0; }
.chat-input { resize: none; overflow-y: hidden; max-height: 140px; border-radius: 1.2rem; padding: .5rem .9rem; line-height: 1.35; }
.chat-send { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; padding: 0; flex-shrink: 0; }
.chat-send .spinner-border:not(.d-none) + i { display: none; }
.chat-file-chip { display: flex; align-items: center; gap: .45rem; font-size: .8rem; padding: .3rem .6rem; margin-bottom: .35rem; border-radius: .6rem; background: var(--bs-tertiary-bg); max-width: 100%; }
.chat-file-chip.d-none { display: none !important; }
.chat-file-chip .btn-close { margin-left: auto; font-size: .6rem; }
.bubble.pending { opacity: .65; }
.bubble.failed { box-shadow: 0 0 0 1px var(--bs-danger); }
.chat-start { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .8rem .9rem; border: 0; background: transparent; color: var(--bs-primary); font-weight: 500; text-align: left; }
.chat-start:hover { background: var(--bs-tertiary-bg); }

/* ---------- Chat media ---------- */
.media-wrap { margin: -.1rem -.2rem .25rem; }
.media-img { display: block; border-radius: .45rem; overflow: hidden; background: rgba(0, 0, 0, .06); }
.media-img img { display: block; max-width: min(320px, 100%); max-height: 320px; width: auto; height: auto; object-fit: cover; }
.media-img.sticker { background: transparent; }
.media-img.sticker img { max-width: 160px; max-height: 160px; }
.media-wrap audio { width: min(280px, 62vw); height: 40px; display: block; } /* fixed width: a % of the shrink-to-fit bubble collapsed the player */
.media-wrap video { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: .45rem; background: #000; }
.bubble:not(.has-caption) .media-wrap { margin-bottom: 0; }

/* ---------- Modules ---------- */
.integration-logo { width: 2.5rem; height: 2.5rem; border-radius: .7rem; display: grid; place-items: center; color: #fff; font-size: 1.15rem; flex-shrink: 0; }
.module-row { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; }
.module-info { flex: 1; }
.module-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: .15rem; }
.module-actions { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.module-actions .form-switch .form-check-input { width: 2.4em; height: 1.3em; cursor: pointer; }
.module-status { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 500; }
.module-status.on { color: var(--bs-success); } .module-status.off { color: var(--bs-secondary-color); } .module-status.todo { color: #9a6a1c; }
[data-bs-theme="dark"] .module-status.on { color: #7cc795; } [data-bs-theme="dark"] .module-status.todo { color: #fab219; }
.module-drawer { --bs-offcanvas-width: 520px; }
.module-drawer .offcanvas-header { gap: .25rem; }
.module-form { padding: 1.1rem 1.25rem; }
.module-section { border: 1px solid var(--bs-border-color-translucent); border-radius: .75rem; padding: .85rem 1rem 1rem; margin-bottom: 1rem; }
.module-section-title { float: none; width: auto; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); padding: 0 .35rem; margin: 0 0 .25rem -.35rem; }
.module-extra:empty { display: none; }
.module-extra { border: 1px dashed var(--bs-border-color); border-radius: .75rem; padding: .85rem 1rem; }
.module-drawer-foot { display: flex; align-items: center; gap: .5rem; padding: .75rem 1.25rem; background: var(--bs-body-bg); }
@media (max-width: 575.98px) {
  .module-drawer { --bs-offcanvas-width: 100%; }
  .module-row { flex-wrap: wrap; }
  .module-row .module-info { flex-basis: calc(100% - 3.5rem); }
  .module-actions { width: 100%; justify-content: space-between; padding-left: 3.4rem; }
}

/* ---------- Live events ---------- */
.events-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.events-live { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 500; color: var(--bs-secondary-color); }
.events-live.paused .live-dot { background: var(--bs-warning); animation: none; box-shadow: none; }
.events-filter { width: auto; max-width: 220px; }
.events-empty { text-align: center; padding: 2.5rem 1rem; color: var(--bs-secondary-color); }
.events-empty i { font-size: 2rem; display: block; margin-bottom: .4rem; opacity: .6; }
.event-row summary { display: flex; align-items: center; gap: .6rem; list-style: none; padding: .45rem 0; }
.event-row summary::-webkit-details-marker { display: none; }
.event-row time { color: var(--bs-secondary-color); font-size: .75rem; flex-shrink: 0; }
.event-row .event-info { color: var(--bs-secondary-color); font-family: var(--bs-body-font-family); min-width: 0; }
.event-name { font-size: .72rem; padding: .1rem .45rem; border-radius: .35rem; background: var(--bs-tertiary-bg); color: var(--bs-body-color); flex-shrink: 0; }
.event-name.g-message { background: rgba(42, 120, 214, .12); }
.event-name.g-connection, .event-name.g-qrcode, .event-name.g-pairing, .event-name.g-instance { background: rgba(25, 135, 84, .14); }
.event-name.g-call { background: rgba(235, 104, 52, .14); }
@media (max-width: 575.98px) { .event-row summary { flex-wrap: wrap; row-gap: .15rem; } .event-row .event-info { flex-basis: 100%; padding-left: 3.6rem; font-size: .78rem; } .events-filter { max-width: 150px; } }

/* ---------- Message notifications ---------- */
.unread-badge { background: var(--nzg-green-dark); color: #fff; font-size: .68rem; font-weight: 600; min-width: 1.35rem; }
.instance-tabs .nav-link.active .unread-badge { background: #fff; color: var(--nzg-green-dark); }
.chat-item .when.unread { color: var(--nzg-green-dark); font-weight: 600; }
[data-bs-theme="dark"] .chat-item .when.unread { color: var(--nzg-green); }
.chat-item.flash { animation: chatflash 1.4s ease-out 3; }
@keyframes chatflash { 0% { background: rgba(76, 175, 106, .5); box-shadow: inset 4px 0 0 #4caf6a; } 100% { background: transparent; box-shadow: inset 4px 0 0 transparent; } }
.msg-toast { background: var(--bs-body-bg); border-left: 4px solid var(--nzg-green) !important; }
.msg-toast-body { display: flex; align-items: center; gap: .7rem; width: 100%; border: 0; background: transparent; color: inherit; text-align: left; }
.msg-toast-body > i { color: var(--nzg-green-dark); font-size: 1.3rem; }
@media (prefers-reduced-motion: reduce) { .chat-item.flash { animation: none; background: rgba(76, 175, 106, .2); } }

/* ---------- WhatsApp text formatting ---------- */
.bubble strong { font-weight: 700; }
.bubble .wa-code { font-family: var(--bs-font-monospace); font-size: .85em; padding: .05rem .3rem; border-radius: .25rem; background: rgba(0, 0, 0, .07); color: inherit; }
.bubble .wa-pre { display: block; white-space: pre-wrap; font-family: var(--bs-font-monospace); font-size: .82em; padding: .35rem .5rem; margin: .2rem 0; border-radius: .35rem; background: rgba(0, 0, 0, .06); color: inherit; }
[data-bs-theme="dark"] .bubble .wa-code, [data-bs-theme="dark"] .bubble .wa-pre { background: rgba(255, 255, 255, .1); }
.bubble .wa-quote { display: block; border-left: 3px solid rgba(0, 0, 0, .25); padding-left: .55rem; margin: .1rem 0; color: #54656f; }
[data-bs-theme="dark"] .bubble .wa-quote { border-left-color: rgba(255, 255, 255, .3); color: #aebac1; }
.bubble .wa-li { display: block; padding-left: 1.1rem; text-indent: -1.1rem; }
.bubble .wa-bullet { display: inline-block; width: 1.1rem; text-indent: 0; }
.bubble a { color: #027eb5; text-decoration: underline; word-break: break-all; }
[data-bs-theme="dark"] .bubble a { color: #53bdeb; }

/* Side-by-side module fields: every column starts at the top, so the inputs line up even when a
 * neighbour has a hint below its input ("Current: ••••"); labels stay on one line. */
.module-section .row { align-items: flex-start; }
.module-section .row > [data-field-col] { display: flex; flex-direction: column; }
.module-section .row > [data-field-col] > .form-label { min-height: 1.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Mobile app shell (below lg): app bar + bottom tab bar, installable as a PWA ----------
 * Safe-area insets keep content clear of notches and the home-gesture strip when the panel runs
 * standalone (home screen, Capacitor or TWA wrapper). */
@media (max-width: 991.98px) {
  :root { --nzg-nav-h: calc(68px + env(safe-area-inset-bottom)); /* bar height + a little air so the footer never hides under it */ }
  html { -webkit-tap-highlight-color: transparent; }
  body.app { overscroll-behavior-y: none; padding-bottom: var(--nzg-nav-h); }
  .app-topbar { padding: calc(.55rem + env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .55rem max(.5rem, env(safe-area-inset-left)); min-height: calc(56px + env(safe-area-inset-top)); gap: .35rem; }
  .app-topbar h1 { font-size: 1.05rem; font-weight: 600; }
  .app-content { padding: 1rem max(1rem, env(safe-area-inset-right)) 1.25rem max(1rem, env(safe-area-inset-left)); }
  .topbar-back, .topbar-brand { width: 44px; height: 44px; flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 50%; color: var(--bs-body-color); text-decoration: none; }
  .topbar-back { font-size: 1.45rem; }
  .topbar-back:active { background: var(--bs-tertiary-bg); }

  .bottom-nav { position: fixed; inset: auto 0 0 0; z-index: 1035; display: grid; grid-template-columns: repeat(5, 1fr); gap: .15rem;
    padding: .35rem max(.35rem, env(safe-area-inset-right)) calc(.35rem + env(safe-area-inset-bottom)) max(.35rem, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--bs-body-bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--bs-border-color-translucent); box-shadow: 0 -6px 20px rgba(0, 0, 0, .06); }
  .bottom-nav > a, .bottom-nav > button { min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
    border: 0; background: none; border-radius: .9rem; color: var(--bs-secondary-color); text-decoration: none; font-size: .68rem; line-height: 1.1; transition: color .15s, background .15s; }
  .bottom-nav i { font-size: 1.3rem; line-height: 1; padding: .2rem 1rem; border-radius: 50rem; transition: background .15s; }
  .bottom-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav .active { color: var(--bs-primary); font-weight: 600; }
  .bottom-nav .active i { background: rgba(var(--bs-primary-rgb), .14); }
  .bottom-nav > :active i { background: var(--bs-tertiary-bg); }
  [data-bs-theme="dark"] .bottom-nav .active { color: var(--bs-link-color); }

  /* "More" sheet: the sidebar slides in above the tab bar, clear of the notch */
  .app-sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .app-sidebar .nav-link { min-height: 48px; }
  .sidebar-prefs { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, .08); }
  .sidebar-prefs-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin-bottom: .4rem; }
  .sidebar-langs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .sidebar-langs a { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; border-radius: .6rem; color: var(--nzg-sidebar-fg); text-decoration: none; background: rgba(255, 255, 255, .05); font-size: .85rem; }
  .sidebar-langs a { text-transform: uppercase; font-weight: 600; letter-spacing: .03em; }
  .sidebar-langs a.active { background: rgba(76, 175, 106, .22); color: #fff; }
  .sidebar-prefs .nav-link { background: none; border: 0; text-align: left; }

  /* floating UI stays above the tab bar */
  .toast-container { bottom: var(--nzg-nav-h) !important; }
  /* touch-friendly controls; 16px inputs stop iOS from zooming in on focus */
  .form-control, .form-select { font-size: 16px; }
  .btn:not(.btn-sm):not(.btn-link):not(.btn-close) { min-height: 44px; }
  .modal-dialog { margin-bottom: calc(.5rem + env(safe-area-inset-bottom)); }
}
@media (min-width: 992px) { .bottom-nav, .topbar-back, .topbar-brand { display: none !important; } }
/* installed app (standalone): no text selection on chrome elements, like a native app */
@media (display-mode: standalone) {
  .app-topbar, .bottom-nav, .app-sidebar { -webkit-user-select: none; user-select: none; }
}

/* ---------- Audit log (activity feed: same layout on phone and desktop, no sideways scroll) ---------- */
.audit-day { padding: .6rem 1rem .3rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--bs-secondary-color); }
.audit-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; border-top: 1px solid var(--bs-border-color-translucent); }
.audit-day + .audit-row { border-top: 0; }
.audit-icon { width: 2.25rem; height: 2.25rem; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-size: 1rem; }
.audit-title { font-size: .9rem; font-weight: 500; line-height: 1.3; }
.audit-meta { display: flex; flex-wrap: wrap; gap: .1rem .75rem; font-size: .76rem; color: var(--bs-secondary-color); min-width: 0; }
.audit-meta i { opacity: .7; }
.audit-time { font-size: .76rem; color: var(--bs-secondary-color); font-variant-numeric: tabular-nums; align-self: flex-start; padding-top: .15rem; }
.audit-footer { border-top: 1px solid var(--bs-border-color-translucent); }

/* language flags (local SVGs: Windows has no flag emoji) */
.flag { display: inline-block; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); vertical-align: middle; }
.sidebar-langs .flag { width: 24px; height: 16px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .15); }
.sidebar-langs a:not(.active) .flag { opacity: .85; }

/* dashboard live feed empty state */
.event-feed .feed-empty { display: flex; gap: .75rem; align-items: flex-start; padding: 1.25rem 1rem; }
.event-feed .feed-empty.d-none { display: none; }
.event-feed .feed-empty > i { font-size: 1.4rem; color: var(--bs-info); line-height: 1; margin-top: .1rem; }
/* footer: pinned to the bottom of the screen when the page is short, after the content when it is long */
.app-main { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app-content { flex: 1 0 auto; }
.app-footer { display: flex; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap; padding: .9rem 1.5rem; font-size: .8rem;
  color: var(--bs-secondary-color); background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color-translucent); }
.app-footer-brand { display: flex; align-items: center; gap: .55rem; }
.app-footer-brand img { height: 18px; width: auto; }
.app-footer-version { font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 50rem; background: rgba(var(--bs-primary-rgb), .1); color: var(--bs-primary); }
[data-bs-theme="dark"] .app-footer-version { color: var(--bs-link-color); }
.app-footer-links { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; margin-left: auto; }
.app-footer-links a { color: var(--bs-secondary-color); text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.app-footer-links a:hover { color: var(--bs-primary); }
.app-footer-copy { opacity: .8; }
/* phones: the bottom tab bar already anchors the screen, so the footer is a compact line after the content */
@media (max-width: 991.98px) {
  .app-main { min-height: calc(100dvh - var(--nzg-nav-h)); }
  .app-footer { justify-content: center; text-align: center; padding: .75rem 1rem; background: none; }
  .app-footer-links { display: none; }
}
.auth-logo { max-width: 100%; height: 64px; width: auto; object-fit: contain; }

/* theme-aware brand images: original wordmark on light surfaces, white-letter variant on dark ones */
.on-dark { display: none !important; }
[data-bs-theme="dark"] .on-light { display: none !important; }
[data-bs-theme="dark"] .on-dark { display: inline-block !important; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; }
.auth-brand-icon { width: 64px; height: 64px; object-fit: contain; }
.auth-brand-word { height: 40px; width: auto; max-width: 70%; object-fit: contain; }
.auth-brand .auth-brand-icon:only-child { margin: 0 auto; }

/* ---------- voice notes & live contact state ---------- */
.chat-mic { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; padding: 0; flex-shrink: 0; }
/* WhatsApp-like: mic while the box is empty, send button once there is text or a file */
.chat-composer .chat-send { display: none; }
.chat-composer.has-content .chat-send, .chat-composer.recording .chat-send { display: grid; }
.chat-composer.has-content .chat-mic, .chat-composer.recording .chat-mic { display: none; }
.chat-rec { display: none; flex: 1; align-items: center; gap: .6rem; min-width: 0; min-height: 2.6rem; }
.chat-composer.recording .chat-rec { display: flex; }
.chat-composer.recording .chat-input-wrap, .chat-composer.recording .chat-attach { display: none; }
.chat-rec-cancel { padding: .25rem .4rem; }
.chat-rec-dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--bs-danger); animation: rec-blink 1s infinite; flex-shrink: 0; }
.chat-rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.chat-rec-label { color: var(--bs-secondary-color); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-rec-wave { flex: 1; min-width: 0; height: 28px; color: var(--nzg-green-dark); }
[data-bs-theme="dark"] .chat-rec-wave { color: var(--nzg-green); }
@keyframes rec-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .chat-rec-dot { animation: none; } }
.chat-head-live { color: var(--nzg-green-dark) !important; font-weight: 500; }
[data-bs-theme="dark"] .chat-head-live { color: var(--nzg-green) !important; }

/* ---------- readable events (live log + dashboard feed) ---------- */
.event-feed li.event-row { display: block; padding: 0; }
.ev-head { display: flex; align-items: center; gap: .7rem; padding: .55rem .25rem; list-style: none; cursor: default; }
details.event-row > .ev-head { cursor: pointer; }
.event-feed .ev-head { padding: .55rem 1rem; }
.ev-head::-webkit-details-marker { display: none; }
.ev-icon { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; font-size: .95rem; background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
.ev-icon.tone-in { background: rgba(42, 120, 214, .12); color: #1f6fca; }
.ev-icon.tone-out { background: rgba(76, 175, 106, .15); color: var(--nzg-green-dark); }
.ev-icon.tone-read { background: rgba(83, 189, 235, .16); color: #2b9fd6; }
.ev-icon.tone-ok { background: rgba(25, 135, 84, .14); color: var(--bs-success); }
.ev-icon.tone-warn { background: rgba(255, 193, 7, .2); color: #a07200; }
.ev-icon.tone-bad { background: rgba(220, 53, 69, .13); color: var(--bs-danger); }
[data-bs-theme="dark"] .ev-icon.tone-out { color: var(--nzg-green); }
[data-bs-theme="dark"] .ev-icon.tone-in { color: #6aa8f0; }
.ev-text { flex: 1; min-width: 0; }
.ev-title { font-size: .9rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-detail { font-size: .78rem; color: var(--bs-secondary-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-time { font-size: .75rem; color: var(--bs-secondary-color); flex-shrink: 0; font-variant-numeric: tabular-nums; align-self: flex-start; padding-top: .2rem; }
.ev-tech { padding: 0 .25rem .6rem 3rem; }
.ev-tech .ev-name { display: inline-block; font-size: .72rem; padding: .1rem .45rem; border-radius: .35rem; background: var(--bs-tertiary-bg); margin-bottom: .35rem; }
.ev-tech pre { font-size: .75rem; max-height: 260px; overflow: auto; background: var(--bs-tertiary-bg); border-radius: .5rem; padding: .6rem .75rem; margin: 0; }

/* license / credits (AGPL-3.0 appropriate legal notices) */
.app-footer-copy a, .auth-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.auth-legal { margin: 1.25rem 0 0; text-align: center; font-size: .75rem; color: var(--bs-secondary-color); }

/* ======================================================================================
 * Matte brand layer: Bootstrap's compiled colors (bright blue/green/red) are re-tinted to the
 * soft palette above so buttons, alerts and badges never glare against the calm surfaces.
 * ====================================================================================== */
:root {
  --bs-success-bg-subtle: #e3f0e7; --bs-success-text-emphasis: #23633d; --bs-success-border-subtle: #c5dfcd;
  --bs-warning-bg-subtle: #f6ecd9; --bs-warning-text-emphasis: #7d5716; --bs-warning-border-subtle: #ead6b0;
  --bs-danger-bg-subtle: #f6e2e1;  --bs-danger-text-emphasis: #8f3a37;  --bs-danger-border-subtle: #ebc6c4;
  --bs-info-bg-subtle: #e1eef1;    --bs-info-text-emphasis: #355f6b;    --bs-info-border-subtle: #c3dde3;
  --bs-primary-bg-subtle: #e3f0e7; --bs-primary-text-emphasis: #23633d; --bs-primary-border-subtle: #c5dfcd;
  --bs-secondary-bg-subtle: #e9edec; --bs-secondary-text-emphasis: #4a5661;
  --bs-focus-ring-color: rgba(76, 175, 106, .22);
}
[data-bs-theme="dark"] {
  --bs-success-bg-subtle: rgba(111, 191, 138, .12); --bs-success-text-emphasis: #9ed3b0; --bs-success-border-subtle: rgba(111, 191, 138, .25);
  --bs-warning-bg-subtle: rgba(214, 169, 90, .12);  --bs-warning-text-emphasis: #e3c58f; --bs-warning-border-subtle: rgba(214, 169, 90, .25);
  --bs-danger-bg-subtle: rgba(217, 129, 126, .12);  --bs-danger-text-emphasis: #eab0ae;  --bs-danger-border-subtle: rgba(217, 129, 126, .25);
  --bs-info-bg-subtle: rgba(107, 184, 198, .12);    --bs-info-text-emphasis: #a5d3dc;    --bs-info-border-subtle: rgba(107, 184, 198, .25);
  --bs-primary-bg-subtle: rgba(111, 191, 138, .12); --bs-primary-text-emphasis: #9ed3b0; --bs-primary-border-subtle: rgba(111, 191, 138, .25);
  --bs-secondary-bg-subtle: #1f2b37; --bs-secondary-text-emphasis: #b3bfca;
}

/* buttons */
.btn-success, .btn-primary { --bs-btn-color: #f7faf8; --bs-btn-bg: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #23633d; --bs-btn-hover-border-color: #23633d;
  --bs-btn-active-bg: #1e5735; --bs-btn-active-border-color: #1e5735; --bs-btn-disabled-bg: var(--bs-primary); --bs-btn-disabled-border-color: var(--bs-primary); box-shadow: 0 1px 1px rgba(29, 41, 53, .08); }
[data-bs-theme="dark"] .btn-success, [data-bs-theme="dark"] .btn-primary { --bs-btn-color: #10221a; --bs-btn-hover-color: #0c1a13; --bs-btn-hover-bg: #85cb9c; --bs-btn-hover-border-color: #85cb9c; --bs-btn-active-bg: #95d3aa; --bs-btn-active-border-color: #95d3aa; --bs-btn-active-color: #0c1a13; --bs-btn-disabled-color: #10221a; }
.btn-outline-success, .btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: rgba(var(--bs-primary-rgb), .45); --bs-btn-hover-color: var(--bs-primary); --bs-btn-hover-bg: var(--nzg-accent-soft); --bs-btn-hover-border-color: var(--bs-primary); --bs-btn-active-bg: var(--nzg-accent-soft); --bs-btn-active-color: var(--bs-primary); --bs-btn-active-border-color: var(--bs-primary); }
.btn-outline-warning { --bs-btn-color: var(--bs-warning-text-emphasis); --bs-btn-border-color: var(--bs-warning-border-subtle); --bs-btn-hover-color: var(--bs-warning-text-emphasis); --bs-btn-hover-bg: var(--bs-warning-bg-subtle); --bs-btn-hover-border-color: var(--bs-warning); }
.btn-outline-danger { --bs-btn-color: var(--bs-danger-text-emphasis); --bs-btn-border-color: var(--bs-danger-border-subtle); --bs-btn-hover-color: var(--bs-danger-text-emphasis); --bs-btn-hover-bg: var(--bs-danger-bg-subtle); --bs-btn-hover-border-color: var(--bs-danger); }
.btn-danger { --bs-btn-bg: #b8504d; --bs-btn-border-color: #b8504d; --bs-btn-hover-bg: #a24542; --bs-btn-hover-border-color: #a24542; --bs-btn-active-bg: #8f3a37; }
.btn-link { --bs-btn-color: var(--bs-link-color); --bs-btn-hover-color: var(--bs-link-hover-color); }
.text-success { color: var(--bs-success) !important; }
.text-warning { color: var(--bs-warning) !important; }
.text-danger { color: var(--bs-danger) !important; }
.dropdown-item.text-warning { color: var(--bs-warning-text-emphasis) !important; }
.dropdown-item.text-danger { color: var(--bs-danger-text-emphasis) !important; }

/* alerts, toasts, solid badges: soft tints instead of saturated fills */
.alert { border-radius: var(--nzg-radius-sm); }
.text-bg-success { background-color: var(--bs-primary) !important; color: #f7faf8 !important; }
.text-bg-danger { background-color: #b8504d !important; color: #fdf6f6 !important; }
.text-bg-warning { background-color: var(--bs-warning-bg-subtle) !important; color: var(--bs-warning-text-emphasis) !important; }
.text-bg-primary { background-color: var(--bs-info-bg-subtle) !important; color: var(--bs-info-text-emphasis) !important; }
.text-bg-light { background-color: var(--nzg-muted-bg) !important; color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .text-bg-success { color: #10221a !important; }
.toast { border-radius: var(--nzg-radius-sm); box-shadow: var(--nzg-shadow-lg); }
.progress { --bs-progress-bg: var(--nzg-muted-bg); }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link { background: var(--bs-primary); color: #f7faf8; }

/* sidebar: navy ink with a faint brand glow at the top (logo colours, very low opacity) */
.app-sidebar { background: radial-gradient(28rem 16rem at -20% -10%, rgba(163, 207, 124, .09), transparent 70%), radial-gradient(20rem 14rem at 120% 0%, rgba(107, 184, 198, .06), transparent 70%), var(--nzg-sidebar-bg) !important; }
.app-sidebar .nav-link.active { background: rgba(124, 199, 149, .12); color: #e6ece9; }
.app-sidebar .nav-link.active i { color: #8fd0a4; }
.app-sidebar .nav-link.active::before { background: var(--nzg-gradient); }
.app-sidebar .nav-link:hover { color: #dfe6ec; }
.sidebar-avatar { background: rgba(124, 199, 149, .16); color: #9ed3b0; }
.sidebar-user-name { color: #dfe6ec; }

/* brand accents used sparingly */
.empty-icon { background: linear-gradient(135deg, rgba(163, 207, 124, .25), rgba(107, 184, 198, .22)); color: var(--bs-primary); }
.avatar { background: linear-gradient(135deg, rgba(163, 207, 124, .22), rgba(107, 184, 198, .18)); color: var(--bs-primary); }
[data-bs-theme="dark"] .avatar { color: var(--bs-primary); }
.unread-badge { background: var(--bs-primary); color: #f7faf8; }
.msg-toast { border-left-color: var(--nzg-green) !important; }
.pair-code { background: var(--nzg-accent-soft); color: var(--bs-primary); }
.auth-card { border: 1px solid var(--nzg-border) !important; box-shadow: var(--nzg-shadow-lg) !important; background: var(--bs-body-bg); overflow: hidden; }
.auth-card::before { content: ""; display: block; height: 4px; background: var(--nzg-gradient); opacity: .75; }

/* chat stays WhatsApp-like but with softer, less contrasty bubbles */
.chat-body { background-color: #e9ece6; }
.bubble { background: #fbfcfb; color: #26323d; }
.bubble.me { background: #dcefd9; }
[data-bs-theme="dark"] .chat-body { background-color: #111a22; }
[data-bs-theme="dark"] .bubble { background: #1f2b36; color: #d3dbe2; }
[data-bs-theme="dark"] .bubble.me { background: #24483a; }

/* analytics series: muted blue/terracotta instead of saturated */
.viz-root { --series-1: #4f86b8; --series-2: #c9805a; --ord-1: #4f86b8; --ord-2: #75a1c9; --ord-3: #a3c0db; }
[data-bs-theme="dark"] .viz-root { --series-1: #6c9fcc; --series-2: #c98c6a; }
.kpi { border: 1px solid var(--nzg-border); box-shadow: var(--nzg-shadow); border-radius: var(--nzg-radius); }
.kpi .delta.good, [data-bs-theme="dark"] .kpi .delta.good { color: var(--bs-success); }
.kpi .delta.bad, [data-bs-theme="dark"] .kpi .delta.bad { color: var(--bs-danger); }

/* footer: quiet single line */
.app-footer { background: transparent; border-top: 1px solid var(--nzg-border); padding: .85rem 2rem; font-size: .76rem; }
.app-footer-version, [data-bs-theme="dark"] .app-footer-version { background: var(--nzg-muted-bg); color: var(--bs-secondary-color); }
.app-footer-brand img { height: 16px; opacity: .8; }

/* phones */
@media (max-width: 991.98px) {
  .bottom-nav { background: color-mix(in srgb, var(--bs-body-bg) 94%, transparent); box-shadow: 0 -4px 16px rgba(29, 41, 53, .05); }
  .bottom-nav .active i { background: var(--nzg-accent-soft); }
  .stat-card { padding: .9rem 1rem; }
  .stat-card > i { width: 2.1rem; height: 2.1rem; font-size: 1rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-label { font-size: .75rem; }
  .app-topbar { background: color-mix(in srgb, var(--bs-body-bg) 94%, transparent); }
  .app-footer { padding: .75rem 1rem; }
}
/* analytics filter bar: period buttons read as a segmented control */
#an-period .btn { min-width: 3.5rem; }
@media (max-width: 575.98px) {
  .viz-filters .viz-instance { flex: 1 1 100%; }
  .viz-filters #an-period { flex: 1 1 auto; }
  .viz-filters #an-period .btn { flex: 1; }
  .viz-filters #an-range { flex-basis: 100%; margin-left: 0 !important; font-size: .78rem; }
}

/* ======================================================================================
 * Top-navigation layout (from the "painel fosco" design canvas): navy top bar with pill links,
 * page heads with an eyebrow + title, pill buttons, 16px cards, instances -> integrations map.
 * ====================================================================================== */
:root { --nzg-radius: 1rem; --nzg-top: #17222e; --nzg-top-fg: #b9c4ce; --nzg-top-fg-strong: #e6ecef; }
[data-bs-theme="dark"] { --nzg-top: #0f161e; }

/* top bar */
.app-topbar { background: radial-gradient(40rem 8rem at 0% 0%, rgba(163, 207, 124, .07), transparent 70%), var(--nzg-top) !important; color: var(--nzg-top-fg); border-bottom: 1px solid rgba(255, 255, 255, .05); backdrop-filter: none; }
.app-topbar h1 { color: var(--nzg-top-fg-strong); }
.app-topbar .topbar-back, .app-topbar .topbar-back:active { color: var(--nzg-top-fg-strong); }
.app-topbar .topbar-back:active { background: rgba(255, 255, 255, .08); }
.app-topbar .live-chip { background: rgba(255, 255, 255, .06); color: var(--nzg-top-fg); }
.app-topbar .live-chip:has(.live-dot.on), [data-bs-theme="dark"] .app-topbar .live-chip:has(.live-dot.on) { background: rgba(124, 199, 149, .12); color: #9ed3b0; }
.app-topbar .live-dot.on { background: #7cc795; }
.topnav-brand { align-items: center; gap: .6rem; min-height: 44px; text-decoration: none; flex-shrink: 0; }
.topnav-brand img { height: 34px; width: auto; }
.topnav-brand .topnav-word { height: 20px; opacity: .9; }
.topnav { gap: .25rem; flex-wrap: wrap; }
.topnav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .9rem; border-radius: 50rem; color: var(--nzg-top-fg); text-decoration: none; font-weight: 500; font-size: .92rem; transition: background .15s, color .15s; }
.topnav a:hover { background: rgba(255, 255, 255, .06); color: var(--nzg-top-fg-strong); }
.topnav a.active { background: rgba(124, 199, 149, .16); color: var(--nzg-top-fg-strong); }
.topnav-icon { width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: .6rem; background: transparent; color: var(--nzg-top-fg); }
.topnav-icon:hover { background: rgba(255, 255, 255, .07); color: var(--nzg-top-fg-strong); }
.app-topbar .dropdown > .btn-outline-secondary { --bs-btn-color: var(--nzg-top-fg); --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-bg: rgba(255, 255, 255, .07); --bs-btn-hover-color: var(--nzg-top-fg-strong); --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: rgba(255, 255, 255, .1); --bs-btn-active-color: var(--nzg-top-fg-strong); height: 38px; box-shadow: none; }
.topnav-user { display: inline-flex; align-items: center; gap: .5rem; max-width: 180px; min-height: 40px; padding: 0 .75rem 0 .35rem; border: 1px solid rgba(255, 255, 255, .12); border-radius: 50rem; background: transparent; color: var(--nzg-top-fg-strong); font-size: .9rem; font-weight: 500; }
.topnav-user:hover { background: rgba(255, 255, 255, .06); }
.topnav-avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: rgba(124, 199, 149, .18); color: #9ed3b0; font-weight: 700; font-size: .78rem; text-transform: uppercase; }
@media (min-width: 992px) {
  .app-topbar { min-height: 64px; padding: .5rem 2.5rem; gap: 1.5rem; }
}

/* content area */
.app-content { max-width: 1440px; }
@media (min-width: 992px) { .app-content { padding: 2rem 2.5rem 2.5rem; } }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2rem; margin-bottom: 1.5rem; }
.page-head:empty { display: none !important; }
.page-eyebrow { font-size: .875rem; font-weight: 600; color: var(--bs-secondary-color); margin-bottom: .35rem; }
.page-title { margin: 0; font-size: 2rem; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; color: var(--bs-emphasis-color); }
.page-hero { justify-content: space-between; }
.page-hero > .min-w-0 { max-width: 860px; }
.page-headline { margin: 0; font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); line-height: 1.12; font-weight: 700; letter-spacing: -.015em; color: var(--bs-emphasis-color); text-wrap: balance; }
.summary-pills { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.summary-pill { display: inline-flex; align-items: center; gap: .4rem; height: 30px; padding: 0 .8rem; border-radius: 50rem; font-size: .85rem; background: var(--nzg-muted-bg); color: var(--bs-secondary-color); }
.summary-pill b { color: var(--bs-emphasis-color); font-variant-numeric: tabular-nums; }
.summary-pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.summary-pill.is-ok { color: #2c6b45; background: rgba(76, 175, 106, .12); }
.summary-pill.is-qr { color: #80591a; background: rgba(192, 138, 45, .12); }
.summary-pill.is-off { color: #56626d; }
[data-bs-theme="dark"] .summary-pill.is-ok { color: #9ed3b0; }
[data-bs-theme="dark"] .summary-pill.is-qr { color: #e3c58f; }
[data-bs-theme="dark"] .summary-pill.is-off { color: #a9b5c1; }
@media (max-width: 991.98px) {
  .page-hero { margin-bottom: 1.25rem; }
  .page-hero .btn { width: 100%; }
}

/* pill buttons (form controls keep their 10px corners) */
.btn:not(.btn-link):not(.btn-close) { border-radius: 50rem; padding-inline: 1.1rem; }
.btn-sm:not(.btn-link) { padding-inline: .8rem; }
.input-group > .btn { border-radius: var(--bs-border-radius); }
.input-group > .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.form-control, .form-select { border-radius: .65rem; }
.form-control-lg { border-radius: .7rem; font-size: 1rem; min-height: 48px; }

/* segmented control (filters, analytics period) */
.segmented, #an-period { display: inline-flex; flex-wrap: wrap; gap: .25rem; padding: .25rem; border-radius: 50rem; background: var(--nzg-muted-bg); }
.segmented > button, #an-period > .btn { min-height: 36px; padding: 0 1rem; border: 0 !important; border-radius: 50rem !important; background: transparent; color: var(--bs-secondary-color); font-size: .9rem; font-weight: 500; box-shadow: none; }
.segmented > button:hover, #an-period > .btn:hover { color: var(--bs-body-color); background: transparent; }
.segmented > button.active, #an-period > .btn.active { background: var(--bs-body-bg); color: var(--bs-primary); font-weight: 650; box-shadow: 0 1px 2px rgba(29, 41, 53, .1); }
[data-bs-theme="dark"] .segmented > button.active, [data-bs-theme="dark"] #an-period > .btn.active { color: var(--bs-link-color); }

/* dashboard: instances -> integrations map */
.flow { overflow-x: auto; }
.flow-grid { display: grid; grid-template-columns: minmax(360px, 440px) minmax(120px, 1fr) minmax(260px, 300px); min-width: 860px; }
.flow-col { background: var(--bs-body-bg); border: 1px solid var(--nzg-border); box-shadow: var(--nzg-shadow); display: flex; flex-direction: column; min-height: var(--flow-h); }
.flow-instances { border-radius: var(--nzg-radius) 0 0 var(--nzg-radius); border-right: 0; }
.flow-dests { border-radius: 0 var(--nzg-radius) var(--nzg-radius) 0; border-left: 0; }
.flow-row { position: relative; display: flex; align-items: center; gap: .9rem; box-sizing: border-box; color: inherit; text-decoration: none; border-top: 1px solid var(--nzg-border); }
.flow-row:first-child { border-top: 0; }
.flow-instances .flow-row { height: var(--row-i); padding-left: 1.4rem; }
.flow-dests .flow-row { height: var(--row-d); padding-right: 1.4rem; }
a.flow-row:hover { background: var(--nzg-accent-soft); }
.flow-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.flow-text b { font-size: 1.05rem; font-weight: 650; color: var(--bs-emphasis-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-sub { font-size: .8rem; color: var(--bs-secondary-color); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-ring { width: 34px; height: 34px; margin-right: -17px; flex-shrink: 0; position: relative; z-index: 1; border-radius: 50%; background: var(--bs-body-bg); border: 3px solid var(--tone, #b3bdc4); box-shadow: inset 0 0 0 6px var(--bs-body-bg), inset 0 0 0 20px var(--tone, transparent); }
.flow-ring[data-ring-status="qrcode"], .flow-ring[data-ring-status="connecting"] { --tone: transparent; border: 3px dashed #c08a2d; box-shadow: none; }
.flow-ring[data-ring-status="disconnected"], .flow-ring[data-ring-status="logged_out"] { --tone: transparent; border-color: #b3bdc4; box-shadow: none; }
.flow-node { width: 34px; height: 34px; margin-left: -17px; flex-shrink: 0; position: relative; z-index: 1; border-radius: 10px; background: var(--bs-body-bg); border: 3px solid var(--tone, #b3bdc4); box-shadow: inset 0 0 0 7px var(--bs-body-bg), inset 0 0 0 20px var(--tone, transparent); }
.tone-1 { --tone: #8dbf63; } .tone-2 { --tone: #4caf6a; } .tone-3 { --tone: #5fa9b8; } .tone-4 { --tone: #7fa6cc; }
[data-bs-theme="dark"] .tone-1 { --tone: #9ccb78; } [data-bs-theme="dark"] .tone-2 { --tone: #6fbf8a; } [data-bs-theme="dark"] .tone-3 { --tone: #6bb8c6; }
.flow-lines { width: 100%; height: var(--flow-h); display: block; overflow: visible; fill: none; stroke-linecap: round; }
.flow-lines path { stroke: var(--tone, #b3bdc4); stroke-width: 6; }
.flow-lines path.is-dead { stroke: #b3bdc4; stroke-width: 3; stroke-dasharray: 2 10; }
[data-bs-theme="dark"] .flow-lines path.is-dead { stroke: #4a5866; }
.flow-lines path.flow-signal { stroke: var(--bs-body-bg); stroke-width: 3; stroke-dasharray: 2 118; animation: flow-pulse 3.6s linear infinite; }
@keyframes flow-pulse { to { stroke-dashoffset: -240; } }
@media (prefers-reduced-motion: reduce) { .flow-lines path.flow-signal { animation: none; display: none; } }
.flow-health { font-size: .8rem; font-weight: 600; color: var(--bs-secondary-color); white-space: nowrap; }
.flow-health.is-live { color: #2c6b45; }
[data-bs-theme="dark"] .flow-health.is-live { color: #9ed3b0; }
.flow-empty { flex: 1; display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.4rem 1.25rem 1.6rem; color: var(--bs-secondary-color); }
.flow-empty > i { font-size: 1.4rem; color: var(--bs-primary); }
/* phones and tablets: the two lists stack as cards, no curves */
@media (max-width: 991.98px) {
  .flow { overflow: visible; }
  .flow-grid { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
  .flow-lines, .flow-ring, .flow-node { display: none; }
  .flow-col { min-height: 0; border: 1px solid var(--nzg-border) !important; border-radius: var(--nzg-radius) !important; overflow: hidden; }
  .flow-instances .flow-row, .flow-dests .flow-row { height: auto; min-height: 64px; padding: .7rem 1rem; }
}

/* dashboard "Agora" feed */
.now-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.25rem; margin-bottom: .75rem; }
.now-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--bs-emphasis-color); }

/* instance page header + pill tab track */
.instance-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; padding: 0; margin-bottom: 1.25rem; }
.instance-id { flex: 1 1 auto; }
.instance-crumb { align-items: center; gap: .25rem; font-size: .85rem; font-weight: 500; color: var(--bs-secondary-color); text-decoration: none; margin-bottom: .35rem; }
.instance-crumb:hover { color: var(--bs-primary); }
.instance-head .instance-title { margin: 0; font-size: 2rem; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; color: var(--bs-emphasis-color); }
.instance-phone { font-size: .9rem; color: var(--bs-secondary-color); }
.instance-tabs { border-bottom: 0; gap: .25rem; padding: .25rem; border-radius: 50rem; background: var(--nzg-muted-bg); width: fit-content; max-width: 100%; margin-bottom: 1.5rem !important; }
.instance-tabs .nav-link { border-radius: 50rem; padding: .5rem 1rem; color: var(--bs-secondary-color); }
.instance-tabs .nav-link:hover { color: var(--bs-body-color); }
.instance-tabs .nav-link.active, [data-bs-theme="dark"] .instance-tabs .nav-link.active { background: var(--bs-body-bg); color: var(--bs-primary); font-weight: 650; box-shadow: 0 1px 2px rgba(29, 41, 53, .1); }
[data-bs-theme="dark"] .instance-tabs .nav-link.active { color: var(--bs-link-color); }
.instance-tabs .nav-link.active::after { display: none; }
/* phones/tablets: the 8 sections as a 4 x 2 grid of icon tiles, all visible and one tap away
 * (a sideways-scrolling strip hid most of them with no hint that more existed) */
@media (max-width: 991.98px) {
  .instance-head .instance-title { display: none; } /* the app bar already shows the name */
  .instance-head { flex-wrap: nowrap; margin-bottom: 1rem; }
  .instance-head .instance-id { flex: 1 1 auto; min-width: 0; }
  .instance-head .instance-id > .d-flex { flex-wrap: nowrap !important; }
  .instance-head .instance-actions .btn { width: 40px; height: 40px; min-height: 40px; padding: 0; }
  .instance-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .3rem; width: auto; overflow: visible; padding: .35rem;
    border-radius: 1.1rem; margin-inline: 0; margin-bottom: 1.25rem !important; background: var(--nzg-muted-bg); }
  .instance-tabs .nav-item { min-width: 0; }
  .instance-tabs .nav-link { width: 100%; height: 100%; min-height: 62px; flex-direction: column; justify-content: center; gap: .3rem; padding: .5rem .2rem;
    border-radius: .8rem; font-size: .72rem; line-height: 1.15; text-align: center; white-space: normal; text-wrap: balance; }
  .instance-tabs .nav-link i { font-size: 1.15rem; }
  /* tiles: the active one is not bolded (bold widens a label past the tile) */
  .instance-tabs .nav-link, .instance-tabs .nav-link.active, [data-bs-theme="dark"] .instance-tabs .nav-link.active { font-weight: 600; }
  .instance-tabs .nav-link > span { max-width: 100%; overflow-wrap: anywhere; }
  .instance-tabs .nav-link .unread-badge { position: absolute; top: .3rem; right: .35rem; margin: 0 !important; }
}
@media (max-width: 359.98px) { .instance-tabs .nav-link { font-size: .66rem; } }

/* instances table (cards on phones) */
.inst-table-wrap { overflow: hidden; }
.inst-table { width: 100%; border-collapse: collapse; }
.inst-table th { padding: .85rem 1rem; font-size: .78rem; font-weight: 600; color: var(--bs-secondary-color); text-align: left; white-space: nowrap; }
.inst-table th:first-child, .inst-table td:first-child { padding-left: 1.5rem; }
.inst-table th:last-child, .inst-table td:last-child { padding-right: 1.5rem; }
.inst-table td { padding: .6rem 1rem; height: 64px; border-top: 1px solid var(--nzg-border); font-size: .92rem; vertical-align: middle; }
.inst-table tbody tr { position: relative; transition: background .12s; }
.inst-table tbody tr:hover { background: var(--nzg-accent-soft); }
.inst-table .stretched-row { display: inline-flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.inst-table .stretched-row::after { content: ""; position: absolute; inset: 0; }
.inst-table .stretched-row b { font-weight: 650; color: var(--bs-emphasis-color); }
.inst-table .it-phone, .inst-table .it-token { font-size: .85rem; white-space: nowrap; }
@media (max-width: 767.98px) {
  .inst-table thead { display: none; }
  .inst-table, .inst-table tbody { display: block; }
  .inst-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .75rem; padding: .85rem 1rem; border-top: 1px solid var(--nzg-border); }
  .inst-table tr:first-child { border-top: 0; }
  .inst-table td { display: block; height: auto; padding: 0 !important; border: 0; }
  .inst-table .it-name { grid-column: 1; }
  .inst-table .it-status { grid-column: 2; grid-row: 1; align-self: center; }
  .inst-table .it-phone, .inst-table .it-dests { grid-column: 1 / -1; padding-left: 3.15rem !important; font-size: .8rem; color: var(--bs-secondary-color); }
  .inst-table .it-last, .inst-table .it-token { display: none; }
}
@media (max-width: 575.98px) { .page-toolbar { flex-wrap: wrap; } .page-toolbar .search-box { flex: 1 1 calc(100% - 3.5rem); } .page-toolbar .segmented { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; } .page-toolbar .segmented > button { flex: 1 0 auto; padding-inline: .75rem; font-size: .82rem; white-space: nowrap; } }

/* login: split brand panel + form */
.auth-split { min-height: 100vh; min-height: 100dvh; display: flex; flex-wrap: wrap; background: var(--nzg-top); }
.auth-art { flex: 999 1 480px; min-width: 0; min-height: 240px; position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 3rem; box-sizing: border-box; }
.auth-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-art path { stroke-width: 22; stroke-linecap: round; stroke-opacity: .35; }
.auth-art .w1 { stroke: #5fa9b8; } .auth-art .w2 { stroke: #4caf6a; } .auth-art .w3 { stroke: #a3cf7c; }
.auth-tagline { position: relative; margin: 0; max-width: 34ch; font-size: 1.35rem; line-height: 1.3; font-weight: 600; color: var(--nzg-top-fg-strong); }
.auth-form { flex: 1 1 400px; box-sizing: border-box; padding: 4rem 3rem; display: flex; flex-direction: column; justify-content: center; gap: 1.5rem; background: var(--bs-body-bg); }
.auth-form > * { width: 100%; max-width: 420px; }
.auth-brand-row { display: flex; align-items: center; gap: .75rem; }
.auth-brand-row .auth-brand-icon { width: 52px; height: 52px; }
.auth-brand-row .auth-brand-word { height: 30px; width: auto; }
.auth-title { margin: 0 0 .25rem; font-size: 1.9rem; font-weight: 700; letter-spacing: -.015em; color: var(--bs-emphasis-color); }
.auth-form .auth-legal { margin: 0; text-align: left; }
.auth-prefs { display: flex; align-items: center; gap: .5rem; }
.auth-art-brand { display: none; }
/* desktop/tablet: a wider form column, content centred in it */
@media (min-width: 768px) {
  .auth-split { flex-wrap: nowrap; }
  .auth-art { flex: 1 1 auto; }
  .auth-form { flex: 0 0 clamp(460px, 42vw, 680px); align-items: center; padding: 4rem clamp(2.5rem, 5vw, 5rem); }
  .auth-form > * { max-width: 460px; }
}
/* browser autofill: matte tint instead of the default bright yellow */
.form-control:-webkit-autofill, .form-control:-webkit-autofill:hover, .form-control:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--bs-body-color); caret-color: var(--bs-body-color);
  -webkit-box-shadow: 0 0 0 1000px var(--nzg-accent-soft) inset, 0 0 0 1000px var(--bs-body-bg) inset; transition: background-color 9999s ease-out;
}
/* phones: navy screen, brand on top, the form in a floating card. The screen is exactly the visible
 * height (dvh: mobile browser bars excluded) and the brand band shrinks first, so there is no scroll. */
@media (max-width: 767.98px) {
  body.auth { background: var(--nzg-top); }
  .auth-split { position: relative; overflow: hidden; flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; min-height: 100vh; min-height: 100dvh; }
  .auth-art { position: static; overflow: visible; flex: 0 0 auto; min-height: 0; flex-direction: column; align-items: center; justify-content: flex-start; gap: .6rem; text-align: center;
    padding: calc(2rem + env(safe-area-inset-top)) 1.5rem 1.5rem; }
  .auth-art svg { inset: 0; width: 100%; height: 100%; opacity: .7; } /* waves cover the whole screen behind the card */
  .auth-art path { stroke-width: 12; stroke-opacity: .22; }
  .auth-art-brand { position: relative; display: flex; align-items: center; gap: .6rem; }
  .auth-art-brand img { width: 46px; height: 46px; }
  .auth-art-brand .auth-art-word { width: auto; height: 25px; }
  .auth-tagline { max-width: 30ch; font-size: .88rem; line-height: 1.4; font-weight: 500; color: rgba(230, 236, 239, .72); }
  .auth-form { position: relative; flex: 0 0 auto; align-self: center; width: calc(100% - 1.8rem); max-width: 460px; margin: 0 auto calc(.9rem + env(safe-area-inset-bottom)); padding: 1.4rem 1.2rem 1.1rem; gap: .95rem;
    border-radius: 1.4rem; box-shadow: 0 24px 48px -24px rgba(0, 0, 0, .55); justify-content: flex-start; }
  .auth-form > * { max-width: none; }
  .auth-form .auth-brand-row { display: none; }
  .auth-form form { gap: .85rem !important; }
  .auth-form .form-control-lg { min-height: 46px; }
  .auth-heading { text-align: center; }
  .auth-title { font-size: 1.4rem; margin-bottom: .15rem; }
  .auth-heading p { font-size: .88rem; }
  .auth-form .form-label { font-size: .85rem; margin-bottom: .3rem; }
  .auth-prefs { justify-content: center; }
  .auth-form .auth-legal { text-align: center; font-size: .72rem; }
}
@media (max-width: 767.98px) and (max-height: 700px) {
  .auth-tagline { display: none; } /* shorter phones: brand only, the whole form stays on screen */
  .auth-art { padding-top: calc(1.25rem + env(safe-area-inset-top)); padding-bottom: .75rem; }
}

/* ======================================================================================
 * Human attendance: amber = a person must act (waiting / human), green = bot or neutral.
 * Colour always comes with an icon (headset, hourglass) and text, never colour alone.
 * ====================================================================================== */
:root { --nzg-amber: #c08a2d; --nzg-amber-ink: #80591a; --nzg-amber-bg: #f5ebd8; }
[data-bs-theme="dark"] { --nzg-amber: #d6a95a; --nzg-amber-ink: #e3c58f; --nzg-amber-bg: rgba(214, 169, 90, .14); }

/* toasts by kind */
.msg-toast { position: relative; }
.msg-toast.is-human, .msg-toast.is-waiting { border-left-color: var(--nzg-amber) !important; }
.msg-toast.is-human .msg-toast-body > i, .msg-toast.is-waiting .msg-toast-body > i { color: var(--nzg-amber); }
.msg-toast-badge { display: inline-flex; align-items: center; gap: .3rem; margin-bottom: .15rem; font-size: .68rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--bs-secondary-color); }
.msg-toast.is-human .msg-toast-badge, .msg-toast.is-waiting .msg-toast-badge { color: var(--nzg-amber-ink); }
.msg-toast.is-waiting { box-shadow: 0 0 0 1px var(--nzg-amber), var(--nzg-shadow-lg) !important; }
.msg-toast.is-waiting .msg-toast-body { padding-right: 2.2rem; }
.msg-toast.is-waiting .msg-toast-body > i { animation: nzg-wait-pulse 1.6s ease-in-out infinite; }
.msg-toast-close { position: absolute; top: .6rem; right: .6rem; font-size: .65rem; }
@keyframes nzg-wait-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.15); opacity: .7; } }

/* chat header: attendance chip + pause / hand back */
.chat-head { flex-wrap: nowrap; }
.chat-head > .min-w-0 { flex: 1 1 auto; min-width: 72px !important; }
.chat-handoff { display: flex; align-items: center; gap: .5rem; flex-shrink: 1; min-width: 0; margin-left: auto; }
.chat-handoff:empty { display: none; }
.handoff-chip { display: inline-flex; align-items: center; gap: .35rem; min-width: 0; flex: 0 1 auto; max-width: 360px; height: 30px; padding: 0 .7rem; border-radius: 50rem; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.handoff-chip.is-bot { background: var(--nzg-accent-soft); color: var(--bs-primary); }
[data-bs-theme="dark"] .handoff-chip.is-bot { color: var(--bs-link-color); }
.handoff-chip.is-human, .handoff-chip.is-waiting { background: var(--nzg-amber-bg); color: var(--nzg-amber-ink); }
.handoff-chip.is-waiting i { animation: nzg-wait-pulse 1.6s ease-in-out infinite; }
.handoff-action { flex-shrink: 0; white-space: nowrap; }
@media (max-width: 575.98px) {
  .handoff-chip { max-width: 150px; font-size: .72rem; padding: 0 .55rem; }
  .handoff-action-label { display: none; }
  .handoff-action { width: 34px; padding: 0 !important; }
}

/* chat list: who is waiting, who is in human attendance */
.chat-item .handoff-mark { margin-right: .35rem; color: var(--nzg-amber); font-size: .9em; }
.chat-item.is-waiting { box-shadow: inset 3px 0 0 var(--nzg-amber); background: color-mix(in srgb, var(--nzg-amber-bg) 55%, transparent); }
.chat-item.is-waiting .handoff-mark { animation: nzg-wait-pulse 1.6s ease-in-out infinite; }
.chat-item.is-human { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--nzg-amber) 60%, transparent); }
.chat-item.is-waiting.active, .chat-item.is-human.active { box-shadow: inset 3px 0 0 var(--nzg-amber); }

/* settings: notification switches with a sound preview */
/* instance Options: a titled group inside the behavior card */
.settings-sub { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--nzg-border); }
.settings-sub-title { font-size: .9rem; font-weight: 600; margin-bottom: .35rem; display: flex; align-items: center; gap: .4rem; }
.settings-sub-title i { color: var(--bs-secondary-color); }
.settings-hours { max-width: 200px; }
/* Settings -> System: label above value, compact */
.system-facts dt { font-weight: 500; color: var(--bs-secondary-color); margin-bottom: .15rem; }
.system-facts dd { margin-bottom: 0; font-weight: 600; overflow-wrap: anywhere; }
/* Settings: paired cards share a height; the footer (Save) sits at the bottom of each */
.settings-grid > [class*="col-"] > .card.h-100 { display: flex; flex-direction: column; }
.settings-grid > [class*="col-"] > .card.h-100 > .card-body { flex: 1 1 auto; }
.notify-list { display: flex; flex-direction: column; max-width: 680px; } /* keeps "Listen" next to its label on wide screens */
.notify-row { display: flex; align-items: center; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--nzg-border); }
.notify-row:first-child { border-top: 0; padding-top: 0; }
.notify-sub-row { padding-left: 2.75rem; border-top: 0; padding-top: 0; }
.notify-sub { display: block; font-size: .78rem; color: var(--bs-secondary-color); font-weight: 400; }
.notify-swatch { width: 2rem; height: 2rem; flex-shrink: 0; border-radius: .6rem; display: grid; place-items: center; font-size: .95rem; }
.notify-swatch.is-new, .notify-swatch.is-bot { background: var(--nzg-accent-soft); color: var(--bs-primary); }
[data-bs-theme="dark"] .notify-swatch.is-new, [data-bs-theme="dark"] .notify-swatch.is-bot { color: var(--bs-link-color); }
.notify-swatch.is-human, .notify-swatch.is-waiting { background: var(--nzg-amber-bg); color: var(--nzg-amber-ink); }
.notify-row .btn { flex-shrink: 0; }
@media (max-width: 575.98px) { /* phones: the listen button is an icon, the label gets the width */
  .notify-test-label { display: none; }
  .notify-row .btn[data-notify-test] { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
  .notify-row { gap: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .msg-toast.is-waiting .msg-toast-body > i, .handoff-chip.is-waiting i, .chat-item.is-waiting .handoff-mark { animation: none; }
}

/* ---------- Doc. App (guide) ---------- */
.guide-hero { display: flex; gap: 1.1rem; align-items: flex-start; background: var(--bs-body-bg); border: 1px solid var(--nzg-border); border-radius: var(--nzg-radius); padding: 1.5rem 1.6rem; margin-bottom: 1.25rem; box-shadow: var(--nzg-shadow); }
.guide-hero-icon { width: 52px; height: 52px; flex-shrink: 0; border-radius: .9rem; display: grid; place-items: center; font-size: 1.5rem; color: #fff; background: var(--nzg-gradient); }
.guide-title { font-size: clamp(1.3rem, 2.4vw, 1.75rem); font-weight: 720; margin: 0 0 .35rem; color: var(--bs-emphasis-color); }
.guide-intro p { margin: 0 0 .4rem; color: var(--bs-secondary-color); max-width: 62rem; }
.guide-intro p:last-child { margin-bottom: 0; }
.guide-chips { display: flex; gap: .45rem; overflow-x: auto; padding: .1rem .1rem .6rem; margin-bottom: .75rem; scrollbar-width: thin; }
.guide-chips a { flex-shrink: 0; display: inline-flex; align-items: center; gap: .35rem; padding: .4rem .8rem; border-radius: 50rem; border: 1px solid var(--nzg-border-strong); background: var(--bs-body-bg); color: var(--bs-body-color); text-decoration: none; font-size: .84rem; font-weight: 550; }
.guide-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.guide-toc { position: sticky; top: calc(64px + 1rem); background: var(--bs-body-bg); border: 1px solid var(--nzg-border); border-radius: var(--nzg-radius); padding: 1rem .75rem; box-shadow: var(--nzg-shadow); max-height: calc(100vh - 64px - 2rem); overflow-y: auto; }
.guide-toc-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--bs-secondary-color); padding: 0 .5rem .5rem; }
.guide-toc ol { list-style: none; padding: 0; margin: 0; }
.guide-toc li a { display: flex; align-items: center; gap: .55rem; padding: .42rem .5rem; border-radius: .5rem; color: var(--bs-body-color); text-decoration: none; font-size: .88rem; }
.guide-toc li a:hover { background: var(--nzg-muted-bg); }
.guide-toc li a.active { background: var(--nzg-accent-soft); color: var(--bs-primary); font-weight: 600; }
.guide-toc-n { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 700; background: var(--nzg-muted-bg); color: var(--bs-secondary-color); }
.guide-toc li a.active .guide-toc-n { background: var(--bs-primary); color: #fff; }
.guide-toc-api { display: flex; gap: .45rem; align-items: center; margin-top: .75rem; padding: .6rem .55rem 0; border-top: 1px solid var(--nzg-border); font-size: .82rem; text-decoration: none; }
.guide-section { background: var(--bs-body-bg); border: 1px solid var(--nzg-border); border-radius: var(--nzg-radius); padding: 1.5rem 1.6rem 1.1rem; margin-bottom: 1.25rem; box-shadow: var(--nzg-shadow); scroll-margin-top: calc(64px + 1rem); }
.guide-section-head { display: flex; gap: 1rem; align-items: flex-start; padding-bottom: 1rem; margin-bottom: 1.1rem; border-bottom: 1px solid var(--nzg-border); }
.guide-section-icon { width: 44px; height: 44px; flex-shrink: 0; border-radius: .8rem; display: grid; place-items: center; font-size: 1.25rem; background: var(--nzg-accent-soft); color: var(--bs-primary); }
.guide-section-n { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--bs-secondary-color); }
.guide-section h2 { font-size: 1.25rem; font-weight: 700; margin: .1rem 0 .3rem; color: var(--bs-emphasis-color); }
.guide-summary p { margin: 0; color: var(--bs-secondary-color); }
.guide-steps { list-style: none; padding: 0; margin: 0; }
.guide-step { display: flex; gap: .95rem; padding-bottom: 1.4rem; position: relative; }
.guide-step:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 4px; width: 2px; background: var(--nzg-border-strong); border-radius: 2px; }
.guide-step-n { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: #fff; background: var(--nzg-green-dark); position: relative; z-index: 1; }
[data-bs-theme="dark"] .guide-step-n { color: #10241a; }
.guide-step-body { min-width: 0; flex: 1; }
.guide-step-body h3 { font-size: 1.02rem; font-weight: 650; margin: .35rem 0 .45rem; }
.guide-text p { margin: 0 0 .55rem; line-height: 1.6; }
.guide-text code, .guide-tips code { background: var(--nzg-muted-bg); padding: .08rem .35rem; border-radius: .3rem; font-size: .86em; color: var(--bs-emphasis-color); }
.guide-shot { margin: .75rem 0 .25rem; }
.guide-shot a { display: block; border-radius: .7rem; overflow: hidden; border: 1px solid var(--nzg-border-strong); box-shadow: var(--nzg-shadow-lg); transition: transform .15s, box-shadow .15s; }
.guide-shot a:hover { transform: translateY(-2px); }
.guide-shot img { display: block; width: 100%; height: auto; }
.guide-shot.is-phone a { max-width: 300px; border-radius: 1.2rem; border-width: 6px; border-color: #1b2631; }
.guide-shot figcaption { font-size: .8rem; color: var(--bs-secondary-color); margin-top: .45rem; }
.guide-tips { background: rgba(192, 138, 45, .08); border: 1px solid rgba(192, 138, 45, .22); border-radius: .7rem; padding: .85rem 1rem .4rem; margin: .25rem 0 .9rem; }
.guide-tips-title { font-weight: 650; font-size: .9rem; margin-bottom: .35rem; color: #8a6219; }
[data-bs-theme="dark"] .guide-tips-title { color: #d6a95a; }
.guide-tips ul { margin: 0; padding-left: 1.1rem; }
.guide-tips li p { margin: 0 0 .45rem; font-size: .92rem; }
.guide-top { display: inline-flex; gap: .3rem; align-items: center; font-size: .82rem; text-decoration: none; color: var(--bs-secondary-color); }
@media (max-width: 991.98px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-hero { padding: 1.1rem; }
  .guide-section { padding: 1.1rem 1rem .8rem; }
  .guide-step { gap: .7rem; }
}
@media (prefers-reduced-motion: reduce) { .guide-shot a { transition: none; } .guide-shot a:hover { transform: none; } }
