:root {
  color-scheme: light;
  --bg: #f6f7fb; --panel: #fff; --panel-alt: #f9f9fc; --text: #202238; --muted: #63687e;
  --line: #e4e6ef; --primary: #5841d4; --primary-hover: #4932bd; --tint: #f0edff;
  --good: #107458; --good-bg: #e6f6ee; --bad: #a82e43; --bad-bg: #fcecf0;
  --warn: #8f5912; --warn-bg: #fff3db; --shadow: 0 3px 12px #2e245b07;
  font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #171824; --panel: #202131; --panel-alt: #252639; --text: #f3f2fc; --muted: #b4b5ca;
  --line: #36374b; --primary: #b5a7ff; --primary-hover: #d3cbff; --tint: #332c55;
  --good: #8be6c0; --good-bg: #233c39; --bad: #ff9aa9; --bad-bg: #422936;
  --warn: #f6ce86; --warn-bg: #403324; --shadow: none;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 300px; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
button { cursor: pointer; }
button:disabled { opacity: .58; cursor: wait; }
[hidden] { display: none !important; }
svg.icon { width: 19px; height: 19px; flex: none; vertical-align: middle; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, strong { line-height: 1.24; }
h1 { font-size: clamp(25px, 3vw, 36px); letter-spacing: -.045em; }
h2 { font-size: 19px; letter-spacing: -.022em; }
h3 { font-size: 16px; }
small, .muted { color: var(--muted); }
small { font-size: 13px; }
code { font-family: ui-monospace, monospace; font-size: .91em; overflow-wrap: anywhere; }
.startup { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); padding: 24px; text-align: center; }
.brand { display: flex; gap: 12px; align-items: center; color: var(--text); text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.brand strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand small { font-size: 12px; }
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 24px 16px 16px; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; }
.sidebar .brand { margin: 0 8px 34px; }
.nav-title, .eyebrow { font-size: 11px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.nav-title { padding: 0 11px; color: var(--muted); margin: 19px 0 7px; }
.nav-link { display: flex; gap: 11px; align-items: center; padding: 10px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; margin: 2px 0; font-weight: 550; }
.nav-link:hover { background: var(--panel-alt); color: var(--text); }
.nav-link[aria-current=page] { background: var(--tint); color: var(--primary); font-weight: 700; }
.profile { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 3px 0; display: flex; align-items: center; gap: 9px; }
.avatar { background: var(--tint); color: var(--primary); width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 750; }
.profile-text { display: grid; flex: 1; min-width: 0; }
.profile-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar { height: 66px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-label { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.topbar-actions, .actions, .between { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.mobile-menu { display: none !important; }
.main { padding: 28px 30px 44px; max-width: 1500px; margin-inline: auto; }
.page-title { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 23px; flex-wrap: wrap; }
.page-title p { color: var(--muted); margin-top: 6px; }
.eyebrow { color: var(--primary); margin-bottom: 7px; }
.hero { position: relative; padding: 24px; background: linear-gradient(115deg, var(--tint), var(--panel) 85%); margin-bottom: 19px; display: flex; align-items: center; justify-content: space-between; gap: 14px; overflow: hidden; }
.hero h2 { font-size: 23px; }
.hero p { color: var(--muted); margin-top: 5px; max-width: 570px; }
.hero .actions { flex: none; }
.card, .hero { background-color: var(--panel); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.card { min-width: 0; padding: 19px; }
.wa-controls { margin-top: 16px; }
.wa-connections { margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.split { grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 15px; }
.activity { margin-top: 16px; }
.command-toolbar { margin: 14px 0 9px; }
.group-search { display: grid; gap: 5px; margin-bottom: 12px; }
.filter-form .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { display: grid; gap: 6px; }
.metric > .between { flex-wrap: nowrap; gap: 5px; }
.metric-value { font-size: 29px; line-height: 1.16; letter-spacing: -.04em; font-weight: 740; }
.icon-box { width: 35px; height: 35px; display: grid; place-items: center; background: var(--tint); color: var(--primary); border-radius: 9px; flex: none; }
.icon-box.green { color: var(--good); background: var(--good-bg); }
.row { display: flex; gap: 10px; align-items: center; }
.row-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row-text p { font-size: 13px; color: var(--muted); }
.card-title { margin-bottom: 14px; }
.card-title p, .section-note { color: var(--muted); font-size: 13px; margin-top: 5px; }
.item { padding: 11px 0; border-top: 1px solid var(--line); }
.item:last-child { padding-bottom: 0; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; background: var(--panel-alt); border: 1px solid var(--line); padding: 3px 8px; color: var(--muted); white-space: nowrap; font-size: 11px; font-weight: 690; }
.badge.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.alert-count { border-radius: 99px; background: var(--bad); color: var(--panel); padding: 1px 5px; font-size: 11px; }
.badge::before { content: ""; background: currentColor; width: 6px; height: 6px; border-radius: 50%; flex: none; }
.btn { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); color: var(--text); background: var(--panel); text-decoration: none; font-size: 13px; line-height: 1.2; font-weight: 680; white-space: nowrap; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--panel); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--bad); }
.btn.icon-btn { width: 37px; padding: 6px; }
.btn.compact { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.step { display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 9px; padding: 7px 0; font-size: 13px; }
.step-num { background: var(--panel-alt); border: 1px solid var(--line); color: var(--muted); border-radius: 50%; width: 23px; height: 23px; display: grid; place-items: center; font-size: 11px; font-weight: 750; }
.step-num.done { background: var(--good-bg); color: var(--good); border-color: transparent; }
.step .icon { width: 14px; height: 14px; }
progress { width: 100%; height: 7px; margin-bottom: 5px; display: block; border: 0; background: var(--line); border-radius: 10px; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--primary); }
progress::-moz-progress-bar { background: var(--primary); }
.empty { padding: 22px 10px; display: grid; justify-items: center; text-align: center; gap: 7px; color: var(--muted); }
.empty strong { color: var(--text); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.details { white-space: normal; min-width: 180px; }
th { color: var(--muted); font-size: 12px; font-weight: 650; }
tr:last-child td { border-bottom: 0; }
form { display: grid; gap: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
label { display: grid; gap: 5px; font-weight: 625; font-size: 13px; min-width: 0; }
input:not([type=checkbox]), select, textarea { width: 100%; min-height: 41px; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
textarea { resize: vertical; min-height: 66px; }
input[type=checkbox] { margin: 0; accent-color: var(--primary); width: 17px; height: 17px; flex: none; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.notice { padding: 10px 12px; background: var(--tint); color: var(--text); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; }
.notice.error { background: var(--bad-bg); color: var(--bad); }
.choice-list { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; max-height: 185px; overflow: auto; }
fieldset { min-width: 0; border: 0; margin: 0; padding: 0; display: grid; gap: 7px; }
legend { font-size: 13px; font-weight: 650; margin-bottom: 5px; }
.parameter { background: var(--panel-alt); border: 1px solid var(--line); border-radius: 9px; padding: 9px; display: grid; grid-template-columns: 1fr 1.3fr 65px 65px auto; align-items: end; gap: 7px; }
.qr { display: block; width: min(244px, 100%); border-radius: 9px; border: 1px solid var(--line); margin: 0 auto; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 5; max-width: min(420px, calc(100vw - 40px)); padding: 12px 16px; background: var(--good-bg); color: var(--good); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 36px #15142926; }
.toast.error { color: var(--bad); background: var(--bad-bg); }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(650px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 20px 60px #15142950; }
dialog::backdrop { background: #19152d80; }
.dialog-header { padding: 15px 19px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.dialog-body { padding: 18px 19px; }
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-aside { background: radial-gradient(ellipse at 95% 78%, #745bed 0%, transparent 49%), #271c5e; color: #fff; padding: clamp(26px, 6vw, 86px); display: flex; flex-direction: column; justify-content: space-between; gap: 28px; }
.auth-aside .brand, .auth-aside .brand small { color: #fff; }
.auth-aside h2 { font-size: clamp(32px, 4.6vw, 64px); max-width: 590px; letter-spacing: -.05em; }
.auth-aside p, .auth-aside .eyebrow { color: #ded6ff; max-width: 410px; }
.auth-aside p { margin-top: 12px; }
.auth-path { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: #ede8ff; }
.auth-path span { padding: 6px 9px; border: 1px solid #ffffff42; border-radius: 7px; }
.auth-main { position: relative; display: grid; place-items: center; padding: 65px 22px 32px; }
.auth-main > .icon-btn { position: absolute; right: 22px; top: 16px; }
.auth-form { width: min(100%, 410px); }
.auth-form h1 { margin: 6px 0; }
.auth-form form { margin-top: 20px; }
.auth-form .btn.primary { width: 100%; }
@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; height: 100dvh; width: min(260px, 85vw); z-index: 4; box-shadow: 0 10px 45px #15142950; overflow: auto; }
  .sidebar.open { display: flex; }
  .mobile-menu { display: inline-flex !important; }
  .topbar { padding-inline: 14px; height: 56px; }
  .main { padding: 18px 14px 25px; }
  .hero { align-items: start; flex-direction: column; padding: 17px; }
  .hero .actions { flex: auto; }
  .auth { display: block; }
  .auth-aside { padding: 17px 20px; }
  .auth-aside > div:not(:first-child) { display: none; }
  .auth-main { padding-top: 62px; }
  .parameter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.narrow { grid-template-columns: minmax(0, 1fr); }
  .filter-form .form-grid { grid-template-columns: minmax(0, 1fr); }
  .wrap-row { flex-wrap: wrap; }
  .card { padding: 14px; }
  .metric .icon-box { width: 29px; height: 29px; }
  .metric .icon { width: 16px; height: 16px; }
}
