/* PVCristal WhatsApp Suite – design system. No framework; light + dark; Windows-native fonts. */

:root {
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --brand: #16a34a; --brand-600: #15803d; --brand-700: #166534; --brand-50: #ecfdf3; --brand-100: #d1fadf;
  --wa: #25d366; --wa-dark: #075e54;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --surface-3: #eef2f5;
  --border: #e3e8ee; --border-strong: #cfd6de;
  --text: #0f1b2a; --text-2: #4a5768; --text-3: #7b8796;
  --blue: #2563eb; --blue-50: #eff5ff; --amber: #d97706; --amber-50: #fff8eb; --red: #dc2626; --red-50: #fef2f2;
  --purple: #7c3aed; --purple-50: #f5f0ff; --teal: #0d9488; --teal-50: #edfcfa; --pink: #db2777; --orange: #ea580c;
  --chat-bg: #efeae2; --bubble-in: #ffffff; --bubble-out: #d9fdd3; --bubble-text: #111b21;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06); --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --sidebar: 248px; --topbar: 60px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1218; --surface: #111a22; --surface-2: #15202a; --surface-3: #1b2833;
  --border: #22313d; --border-strong: #2e404e;
  --text: #e6edf3; --text-2: #a7b3bf; --text-3: #7a8896;
  --brand-50: #0d2a1a; --brand-100: #12381f; --blue-50: #0f1f3d; --amber-50: #2d2008; --red-50: #2e1212; --purple-50: #22163d; --teal-50: #0c2a28;
  --chat-bg: #0b141a; --bubble-in: #202c33; --bubble-out: #005c4b; --bubble-text: #e9edef;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 40px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 13px; }
p { margin: 0 0 .6em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; overflow-wrap: anywhere; }
pre { background: var(--surface-3); padding: 12px; border-radius: var(--r); overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.ic.sm { width: 15px; height: 15px; } .ic.lg { width: 22px; height: 22px; } .ic.xl { width: 32px; height: 32px; }
::selection { background: var(--brand-100); }

/* Windows: thin, themed scrollbars instead of the thick grey default */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #0c1a14; color: #c9d6cf; border-right: 1px solid #12261d; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; height: var(--topbar); color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--wa), #0f9d58); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 14px rgba(37, 211, 102, .35); }
.brand small { display: block; font-weight: 500; font-size: 11px; color: #7fa392; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px 16px; }
.nav-section { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #5f7d6f; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8.5px 10px; border-radius: 8px; color: #b8c9c0; font-weight: 500; margin: 1px 0; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(37, 211, 102, .14); color: #fff; box-shadow: inset 3px 0 0 var(--wa); }
.nav a.active .ic { color: var(--wa); }
.nav .count { margin-left: auto; background: var(--wa); color: #05301a; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: none; place-items: center; padding: 0 6px; }
.nav .count.on { display: inline-grid; }
.sidebar-foot { padding: 12px; border-top: 1px solid #16291f; }
.health-mini { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #9db3a7; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, .04); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 17px; }
.topbar .sub { color: var(--text-3); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 9px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid var(--surface); display: none; }
.icon-btn .dot.on { display: block; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 650; font-size: 13px; color: #fff; flex: none; background: var(--brand); text-transform: uppercase; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; } .avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.content { padding: 24px; max-width: 1480px; width: 100%; margin: 0 auto; }
.content.flush { padding: 0; max-width: none; }
#menuToggle { display: none; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 16px; border-radius: var(--r); margin-bottom: 16px; border: 1px solid; font-size: 13.5px; }
.banner .ic { margin-top: 1px; }
.banner.warn { background: var(--amber-50); border-color: color-mix(in srgb, var(--amber) 35%, transparent); color: var(--text); }
.banner.danger { background: var(--red-50); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.banner.info { background: var(--blue-50); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.banner.ok { background: var(--brand-50); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

/* ---------------------------------------------------------------- building blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); min-height: 54px; }
.card-h .muted { font-size: 12.5px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-b { padding: 18px; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-3); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; } .bold { font-weight: 650; }
.nowrap { white-space: nowrap; } .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mt-s { margin-top: 8px; } .mb-s { margin-bottom: 8px; }
.hidden { display: none !important; }
.center { text-align: center; } .right-t { text-align: right; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .desc { color: var(--text-3); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; text-decoration: none !important; }
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, .input:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: 1px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(22, 163, 74, .3); }
.btn.primary:hover { background: var(--brand-600); }
.btn.danger { color: var(--red); } .btn.danger:hover { background: var(--red-50); border-color: var(--red); }
.btn.danger.solid { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon { width: 36px; padding: 0; } .btn.sm.icon { width: 30px; } .btn.xs.icon { width: 26px; }
.btn .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; background: var(--surface); }
.btn-group button { border: 0; background: transparent; padding: 0 12px; height: 34px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.btn-group button:last-child { border-right: 0; }
.btn-group button.on { background: var(--brand-50); color: var(--brand-700); }
:root[data-theme="dark"] .btn-group button.on { color: var(--wa); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 13px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, select.input, textarea.input { width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.input { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237b8796' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); outline: 0; }
.input.sm { height: 32px; font-size: 13px; }
.input-icon { position: relative; } .input-icon .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; } .input-icon .input { padding-left: 36px; }
.input-group { display: flex; } .input-group .input { border-radius: 9px 0 0 9px; } .input-group .btn { border-radius: 0 9px 9px 0; border-left: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.secret-set { font-size: 12px; color: var(--brand-600); display: inline-flex; gap: 4px; align-items: center; }

/* badges & chips */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.green { background: var(--brand-50); color: var(--brand-700); } .badge.blue { background: var(--blue-50); color: var(--blue); }
.badge.amber { background: var(--amber-50); color: var(--amber); } .badge.red { background: var(--red-50); color: var(--red); }
.badge.purple { background: var(--purple-50); color: var(--purple); } .badge.teal { background: var(--teal-50); color: var(--teal); }
:root[data-theme="dark"] .badge.green { color: #4ade80; }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.live .bdot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
.chip.tag-green { background: #e7f8ee; border-color: #c4ecd3; color: #15803d; } .chip.tag-blue { background: #eaf1ff; border-color: #c9dbff; color: #1d4ed8; }
.chip.tag-purple { background: #f3edff; border-color: #ddd0fd; color: #6d28d9; } .chip.tag-orange { background: #fff1e7; border-color: #ffd6b8; color: #c2410c; }
.chip.tag-pink { background: #fdeef6; border-color: #f9cde3; color: #be185d; } .chip.tag-teal { background: #e7f8f6; border-color: #bfeae4; color: #0f766e; }
.chip.tag-red { background: #fdecec; border-color: #f8cbcb; color: #b91c1c; } .chip.tag-yellow { background: #fef9e6; border-color: #f7e4a6; color: #a16207; }
:root[data-theme="dark"] .chip[class*="tag-"] { background: var(--surface-3); border-color: var(--border-strong); }
:root[data-theme="dark"] .chip.tag-green { color: #6ee7a0; } :root[data-theme="dark"] .chip.tag-blue { color: #93b8ff; } :root[data-theme="dark"] .chip.tag-purple { color: #c4b0ff; }
:root[data-theme="dark"] .chip.tag-orange { color: #fdba8c; } :root[data-theme="dark"] .chip.tag-pink { color: #f9a8d4; } :root[data-theme="dark"] .chip.tag-teal { color: #7eeadb; }
:root[data-theme="dark"] .chip.tag-red { color: #fca5a5; } :root[data-theme="dark"] .chip.tag-yellow { color: #fde68a; }
.chip button { border: 0; background: none; padding: 0; color: inherit; cursor: pointer; display: inline-grid; opacity: .7; }

/* stats */
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; }
.stat .s-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.stat .s-ic.green { background: var(--brand-50); color: var(--brand); } .stat .s-ic.blue { background: var(--blue-50); color: var(--blue); }
.stat .s-ic.purple { background: var(--purple-50); color: var(--purple); } .stat .s-ic.amber { background: var(--amber-50); color: var(--amber); }
.stat .s-ic.teal { background: var(--teal-50); color: var(--teal); } .stat .s-ic.red { background: var(--red-50); color: var(--red); }
.stat .s-label { color: var(--text-3); font-size: 12.5px; font-weight: 600; }
.stat .s-val { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; display: flex; }
.progress > span { height: 100%; transition: width .4s; }
.progress .p-read { background: var(--blue); } .progress .p-del { background: var(--brand); } .progress .p-sent { background: #86efac; } .progress .p-fail { background: var(--red); } .progress .p-skip { background: var(--amber); }
.progress.thin { height: 5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
.pager { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }
.empty { padding: 48px 24px; text-align: center; color: var(--text-3); }
.empty .ic { width: 40px; height: 40px; color: var(--border-strong); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-3); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand-600); border-bottom-color: var(--brand); }
:root[data-theme="dark"] .tabs button.on { color: var(--wa); }
.pane { display: none; } .pane.on { display: block; }

/* modal / drawer */
.overlay { position: fixed; inset: 0; background: rgba(9, 17, 24, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .15s; backdrop-filter: blur(2px); }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: pop .18s cubic-bezier(.2, .9, .3, 1.2); border: 1px solid var(--border); }
.modal.wide { max-width: 860px; } .modal.xwide { max-width: 1100px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px 0; }
.modal-h h2 { font-size: 17px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 16px 22px; }
.modal-f { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); z-index: 101; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .2s; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }

/* toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; min-width: 260px; max-width: 420px; background: #0f1b2a; color: #fff; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .2s; }
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: var(--wa); } .toast.err .ic { color: #f87171; } .toast.warn .ic { color: #fbbf24; }
:root[data-theme="dark"] .toast { background: #233140; }

/* dropdown */
.dropdown { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; }
.menu.open { display: block; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border: 0; background: none; border-radius: 7px; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left; text-decoration: none !important; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu .danger { color: var(--red); }
.menu hr { margin: 5px 0; }
.alerts-panel { width: 380px; max-height: 70vh; overflow-y: auto; padding: 0; }
.alert-item { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.alert-item:last-child { border-bottom: 0; }
.alert-item .ic.danger { color: var(--red); } .alert-item .ic.warning { color: var(--amber); } .alert-item .ic.info { color: var(--blue); }

/* WhatsApp-style preview phone */
.wa-phone { background: var(--chat-bg); border-radius: 18px; padding: 16px 12px; min-height: 220px; background-image: radial-gradient(color-mix(in srgb, var(--text-3) 12%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.wa-bubble { background: var(--bubble-in); color: var(--bubble-text); border-radius: 10px; border-top-left-radius: 2px; padding: 6px 8px 6px; max-width: 320px; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); font-size: 13.5px; position: relative; overflow: hidden; }
.wa-bubble .wa-media { margin: -3px -5px 6px; border-radius: 7px; overflow: hidden; background: var(--surface-3); aspect-ratio: 1.91/1; display: grid; place-items: center; color: var(--text-3); }
.wa-bubble .wa-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wa-bubble .wa-head { font-weight: 700; margin-bottom: 3px; }
.wa-bubble .wa-body { white-space: pre-wrap; word-wrap: break-word; }
.wa-bubble .wa-foot { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.wa-bubble .wa-time { text-align: right; font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.wa-btns { max-width: 320px; margin-top: 2px; display: grid; gap: 2px; }
.wa-btns div { background: var(--bubble-in); color: #0a8ad9; text-align: center; padding: 8px; border-radius: 8px; font-size: 13.5px; font-weight: 500; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); display: flex; gap: 6px; align-items: center; justify-content: center; }
:root[data-theme="dark"] .wa-btns div { color: #53bdeb; }

/* template cards */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.tpl-card { display: flex; flex-direction: column; overflow: hidden; }
.tpl-card .wa-phone { border-radius: 0; min-height: 0; flex: 1; padding: 14px; }
.tpl-card .tpl-meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--border); }
.tpl-card .tpl-actions { padding: 10px 14px; display: flex; gap: 6px; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* drop zone */
.drop { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 26px; text-align: center; color: var(--text-3); cursor: pointer; transition: border-color .15s, background .15s; background: var(--surface-2); }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-50); color: var(--text); }
.drop .ic { width: 30px; height: 30px; color: var(--brand); }
.drop input { display: none; }
.media-thumb { width: 100%; max-height: 200px; object-fit: contain; border-radius: 10px; background: var(--surface-3); }

/* steps / wizard */
.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.steps .st { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 20px; background: var(--surface-3); color: var(--text-3); font-weight: 600; font-size: 13px; }
.steps .st b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-size: 12px; }
.steps .st.on { background: var(--brand-50); color: var(--brand-700); } .steps .st.on b { background: var(--brand); color: #fff; }
.steps .st.done b { background: var(--brand-100); color: var(--brand-700); }
:root[data-theme="dark"] .steps .st.on { color: var(--wa); }
.checklist { display: grid; gap: 4px; }
.checklist a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text); }
.checklist a:hover { background: var(--surface-3); text-decoration: none; }
.checklist .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.checklist .done .tick { background: var(--brand); border-color: var(--brand); color: #fff; }
.checklist .done span.t { color: var(--text-3); text-decoration: line-through; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; min-width: 0; word-break: break-word; }
.copybox { display: flex; align-items: center; gap: 8px; background: var(--surface-3); padding: 6px 6px 6px 12px; border-radius: 9px; font-family: var(--mono); font-size: 12.5px; }
.copybox span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* chart */
.chart { width: 100%; height: 230px; display: block; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart-tip { position: fixed; pointer-events: none; background: #0f1b2a; color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 8px; z-index: 300; box-shadow: var(--shadow-lg); }

/* ---------------------------------------------------------------- live chat */
.inbox { display: grid; grid-template-columns: 360px minmax(0, 1fr) 320px; height: calc(100vh - var(--topbar)); background: var(--surface); }
.inbox.no-info { grid-template-columns: 360px minmax(0, 1fr) 0; }
.inbox.no-info .ib-info { display: none; }
.ib-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ib-list-h { padding: 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--border); }
.ib-filters { display: flex; gap: 6px; overflow-x: auto; }
.ib-filters button { border: 1px solid var(--border); background: var(--surface); border-radius: 16px; height: 28px; padding: 0 11px; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.ib-filters button.on { background: var(--brand-50); border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--brand-700); }
:root[data-theme="dark"] .ib-filters button.on { color: var(--wa); }
.ib-convs { flex: 1; overflow-y: auto; }
.conv { display: flex; gap: 11px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); position: relative; }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--brand-50); }
.conv .c-main { flex: 1; min-width: 0; }
.conv .c-top { display: flex; gap: 6px; align-items: baseline; }
.conv .c-name { font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .c-time { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.conv.unread .c-time { color: var(--brand); font-weight: 650; }
.conv .c-prev { display: flex; gap: 5px; align-items: center; color: var(--text-3); font-size: 13px; margin-top: 2px; }
.conv .c-prev .c-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .c-un { flex: none; background: var(--wa); color: #05301a; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.conv .c-flags { display: flex; gap: 4px; margin-top: 4px; }
.tick { display: inline-flex; color: var(--text-3); } .tick.read { color: #34b7f1; } .tick.failed { color: var(--red); }
.ib-thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); background-image: radial-gradient(color-mix(in srgb, var(--text-3) 10%, transparent) 1px, transparent 1px); background-size: 20px 20px; }
.th-head { display: flex; align-items: center; gap: 11px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 60px; }
.th-head .t-name { font-weight: 650; } .th-head .t-sub { font-size: 12px; color: var(--text-3); }
.th-msgs { flex: 1; overflow-y: auto; padding: 16px 6% 10px; display: flex; flex-direction: column; gap: 3px; }
.day-sep { align-self: center; background: var(--surface); color: var(--text-2); font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 8px; margin: 10px 0; box-shadow: var(--shadow-sm); }
.msg { max-width: min(560px, 78%); padding: 6px 9px 4px; border-radius: 10px; font-size: 14px; position: relative; box-shadow: 0 1px .5px rgba(0, 0, 0, .13); color: var(--bubble-text); word-wrap: break-word; margin-top: 4px; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border-top-left-radius: 3px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-top-right-radius: 3px; }
.msg.failed { box-shadow: 0 0 0 1.5px var(--red); }
.msg .m-by { font-size: 11px; font-weight: 700; margin-bottom: 2px; display: flex; gap: 4px; align-items: center; opacity: .8; }
.msg .m-by.bot { color: var(--purple); } .msg .m-by.campaign { color: var(--orange); } .msg .m-by.followup { color: var(--teal); } .msg .m-by.n8n { color: #ea4b71; } .msg .m-by.admin { color: var(--blue); }
:root[data-theme="dark"] .msg .m-by { filter: brightness(1.6); }
.msg .m-body { white-space: pre-wrap; }
.msg .m-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 10.5px; color: color-mix(in srgb, var(--bubble-text) 55%, transparent); margin-top: 1px; margin-left: 24px; float: right; position: relative; top: 5px; }
.msg::after { content: ""; display: block; clear: both; }
.msg .m-media img, .msg .m-media video { max-width: 100%; max-height: 320px; border-radius: 7px; display: block; margin: 0 -3px 4px; cursor: zoom-in; }
.msg .m-doc { display: flex; gap: 8px; align-items: center; background: color-mix(in srgb, var(--bubble-text) 6%, transparent); padding: 8px 10px; border-radius: 7px; margin-bottom: 4px; color: inherit; }
.msg .m-quote { border-left: 3px solid var(--brand); background: color-mix(in srgb, var(--bubble-text) 6%, transparent); padding: 4px 8px; border-radius: 5px; font-size: 12.5px; margin-bottom: 4px; color: color-mix(in srgb, var(--bubble-text) 75%, transparent); max-height: 60px; overflow: hidden; }
.msg .m-err { font-size: 11.5px; color: var(--red); margin-top: 3px; }
.msg .m-react { position: absolute; bottom: -12px; right: 8px; background: var(--surface); border-radius: 12px; padding: 0 5px; font-size: 13px; box-shadow: var(--shadow); }
.msg .m-tools { position: absolute; top: 2px; display: none; gap: 2px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 2px; }
.msg.in .m-tools { right: -86px; } .msg.out .m-tools { left: -86px; }
.msg:hover .m-tools { display: flex; }
.msg .m-tools button { border: 0; background: none; width: 26px; height: 26px; border-radius: 6px; cursor: pointer; color: var(--text-2); display: grid; place-items: center; }
.msg .m-tools button:hover { background: var(--surface-3); }
.msg.tpl { border-left: 3px solid var(--orange); }
.th-window { margin: 0 16px 8px; align-self: center; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; background: var(--amber-50); color: var(--text); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); display: flex; gap: 8px; align-items: center; }
.composer { background: var(--surface); border-top: 1px solid var(--border); padding: 10px 12px; }
.composer .reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--surface-3); border-radius: 8px; margin-bottom: 8px; font-size: 12.5px; border-left: 3px solid var(--brand); }
.composer .c-row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 20px; padding: 9px 14px; font: inherit; font-size: 14px; max-height: 140px; min-height: 40px; line-height: 1.45; background: var(--surface-2); color: var(--text); }
.composer textarea:focus { outline: 0; border-color: var(--brand); background: var(--surface); }
.composer .send { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; border: 0; display: grid; place-items: center; cursor: pointer; flex: none; }
.composer .send:hover { background: var(--brand-600); }
.qr-pop { position: absolute; bottom: 64px; left: 12px; right: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 240px; overflow-y: auto; z-index: 5; }
.qr-pop button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; cursor: pointer; font: inherit; color: var(--text); }
.qr-pop button:hover, .qr-pop button.on { background: var(--surface-3); }
.emoji-pop { position: absolute; bottom: 64px; left: 12px; width: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; z-index: 5; }
.emoji-pop button { border: 0; background: none; font-size: 20px; height: 34px; border-radius: 6px; cursor: pointer; }
.emoji-pop button:hover { background: var(--surface-3); }
.ib-info { border-left: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.ib-info .i-sec { padding: 16px; border-bottom: 1px solid var(--border); }
.ib-info .i-sec h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 10px; }
.ib-empty { display: grid; place-items: center; height: 100%; text-align: center; color: var(--text-3); padding: 24px; }
.ib-empty .big { width: 84px; height: 84px; border-radius: 50%; background: var(--brand-50); display: grid; place-items: center; margin: 0 auto 14px; color: var(--brand); }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); z-index: 300; display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

/* login / installer */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art { background: radial-gradient(circle at 20% 20%, #1f8f4e 0, #0b3a24 45%, #071a12 100%); color: #e6fff0; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(37, 211, 102, .35), transparent 70%); }
.auth-art h2 { font-size: 34px; line-height: 1.15; max-width: 460px; letter-spacing: -.02em; }
.auth-art ul { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; max-width: 440px; }
.auth-art li { display: flex; gap: 10px; align-items: flex-start; color: #bfe8cf; }
.auth-art li .ic { color: var(--wa); margin-top: 2px; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-box { width: 100%; max-width: 380px; }
.install-wrap { max-width: 760px; margin: 0 auto; padding: 40px 16px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .inbox { grid-template-columns: 320px minmax(0, 1fr) 0; }
  .inbox .ib-info { display: none; }
  .inbox.show-info { grid-template-columns: 320px minmax(0, 1fr) 300px; }
  .inbox.show-info .ib-info { display: block; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .app.menu-open .sidebar { transform: none; }
  .app.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }
  #menuToggle { display: inline-grid; }
  .g3, .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth-art { display: none; }
  .inbox, .inbox.show-info { grid-template-columns: minmax(0, 1fr); }
  .inbox .ib-thread, .inbox .ib-info { display: none; }
  .inbox.open .ib-list { display: none; } .inbox.open .ib-thread { display: flex; }
  .inbox.open.show-info .ib-thread { display: none; } .inbox.open.show-info .ib-info { display: block; }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .g2, .g4, .form-grid { grid-template-columns: 1fr; }
  .th-msgs { padding: 12px 10px; }
  .msg { max-width: 88%; }
  .kv { grid-template-columns: 1fr; }
  .alerts-panel { width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
