:root {
  --bg: #080b12;
  --panel: #10141f;
  --panel-2: #151a27;
  --panel-3: #1a2030;
  --border: rgba(255, 255, 255, .075);
  --border-strong: rgba(255, 255, 255, .13);
  --text: #f5f7fb;
  --muted: #8991a4;
  --muted-2: #5c6477;
  --accent: #7c5cff;
  --accent-2: #4f8cff;
  --green: #2bd69b;
  --red: #ff5d72;
  --amber: #ffbb55;
  --shadow: 0 24px 80px rgba(0, 0, 0, .32);
  --radius: 18px;
  --sidebar: 244px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, "Noto Sans Bengali", "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; padding: 27px 18px 20px; background: #0b0f17; border-right: 1px solid var(--border); z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 28px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: linear-gradient(145deg, #987cff, #5c3de3); border: 1px solid rgba(255,255,255,.25); border-radius: 12px; font-weight: 800; box-shadow: 0 9px 30px rgba(124,92,255,.3), inset 0 1px rgba(255,255,255,.22); }
.brand-mark.large { width: 52px; height: 52px; margin: 0 auto 25px; border-radius: 16px; font-size: 22px; }
.brand strong { display: block; letter-spacing: -.3px; font-size: 16px; }
.brand small { display: block; color: var(--muted-2); font-size: 10px; margin-top: 2px; text-transform: uppercase; letter-spacing: .7px; }
.nav { display: grid; gap: 7px; }
.nav-item { height: 45px; display: flex; align-items: center; gap: 13px; padding: 0 13px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; text-align: left; transition: .2s ease; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item span { flex: 1; font-size: 13px; font-weight: 650; }
.nav-item b { min-width: 24px; padding: 3px 7px; border-radius: 10px; background: rgba(255,255,255,.07); font-size: 10px; text-align: center; }
.nav-item:hover { color: #d9dded; background: rgba(255,255,255,.035); }
.nav-item.active { color: white; background: linear-gradient(90deg, rgba(124,92,255,.2), rgba(124,92,255,.08)); box-shadow: inset 3px 0 var(--accent); }
.nav-item.active svg { color: #a991ff; }
.sidebar-foot { margin-top: auto; padding: 18px 9px 0; border-top: 1px solid var(--border); }
.mini-status { display: flex; align-items: center; gap: 10px; }
.mini-status small { color: var(--muted-2); font-size: 8px; letter-spacing: 1px; }
.mini-status strong { display: block; margin-top: 3px; font-size: 11px; font-weight: 650; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; display: inline-block; background: var(--amber); border-radius: 50%; box-shadow: 0 0 0 4px rgba(255,187,85,.1); }
.status-dot.running { background: var(--green); box-shadow: 0 0 0 4px rgba(43,214,155,.1), 0 0 16px rgba(43,214,155,.5); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 4px rgba(255,93,114,.1); }
.sidebar-foot .text-button { margin-top: 17px; font-size: 11px; }

.main { min-height: 100vh; margin-left: var(--sidebar); padding: 0 36px 60px; background: radial-gradient(circle at 78% -5%, rgba(83,66,167,.16), transparent 29%), var(--bg); }
.topbar { height: 104px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); margin-bottom: 30px; }
.topbar h1 { margin: 5px 0 0; font-size: 22px; letter-spacing: -.55px; }
.eyebrow { color: #737c91; font-size: 9px; font-weight: 750; letter-spacing: 1.6px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.connection-pill { height: 36px; display: flex; align-items: center; gap: 9px; padding: 0 14px; color: var(--muted); background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 20px; font-size: 11px; font-weight: 650; }
.connection-pill .status-dot { width: 7px; height: 7px; }

.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: 11px; padding: 0 16px; font-size: 12px; font-weight: 700; cursor: pointer; transition: transform .15s ease, filter .15s ease, border-color .15s ease; }
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(135deg, #8467ff, #6644ee); border-color: rgba(255,255,255,.12); box-shadow: 0 9px 24px rgba(95,65,226,.22); color: white; }
.btn.light { background: white; color: #11131b; }
.btn.ghost { background: rgba(255,255,255,.04); border-color: var(--border); color: #c1c7d6; }
.btn.danger-ghost { background: rgba(255,93,114,.06); border-color: rgba(255,93,114,.18); color: #ff8797; }
.btn.wide { width: 100%; }
.text-button { padding: 0; border: 0; background: none; color: #9f8bff; cursor: pointer; font-size: 12px; font-weight: 650; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 11px; cursor: pointer; }
.icon-btn svg { width: 17px; height: 17px; }
.theme-toggle { height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 20px; cursor: pointer; font-size: 10px; font-weight: 700; transition: .2s ease; }
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { width: 15px; height: 15px; }

.view { display: none; animation: enter .25s ease; }
.view.active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.hero { min-height: 210px; position: relative; overflow: hidden; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: 36px 38px; color: white; background: linear-gradient(128deg, #4d34bc 0%, #7251e7 55%, #486fe3 120%); border: 1px solid rgba(255,255,255,.14); border-radius: 22px; box-shadow: var(--shadow); }
.hero > *:not(.hero-orbit) { position: relative; z-index: 2; }
.hero-kicker { display: block; margin-bottom: 14px; font-size: 9px; font-weight: 800; letter-spacing: 1.8px; color: rgba(255,255,255,.67); }
.hero h2 { max-width: 580px; margin: 0 0 10px; font-size: clamp(27px, 3vw, 39px); line-height: 1.22; letter-spacing: -1.3px; }
.hero p { max-width: 600px; margin: 0; color: rgba(255,255,255,.7); font-size: 13px; line-height: 1.65; }
.hero-orbit { position: absolute; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; }
.orbit-one { width: 360px; height: 360px; right: -80px; top: -210px; }
.orbit-two { width: 500px; height: 500px; right: -210px; top: -110px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin: 18px 0; }
.stat-card { min-height: 122px; padding: 20px; background: linear-gradient(145deg, rgba(20,25,38,.98), rgba(14,18,28,.98)); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #ab99ff; background: rgba(124,92,255,.11); }
.stat-icon svg { width: 16px; height: 16px; }
.stat-trend { color: var(--green); font-size: 9px; font-weight: 750; }
.stat-card strong { display: block; margin: 13px 0 3px; font-size: 23px; letter-spacing: -.5px; }
.stat-card > small { color: var(--muted); font-size: 10px; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.card { background: linear-gradient(145deg, rgba(17,21,32,.98), rgba(13,17,26,.98)); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 14px 50px rgba(0,0,0,.12); }
.card-head { min-height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 5px 0 0; font-size: 14px; }
.badge { padding: 5px 9px; color: var(--amber); background: rgba(255,187,85,.08); border: 1px solid rgba(255,187,85,.15); border-radius: 20px; font-size: 8px; font-weight: 750; text-transform: uppercase; letter-spacing: .5px; }
.badge.running { color: var(--green); background: rgba(43,214,155,.08); border-color: rgba(43,214,155,.15); }
.badge.error { color: var(--red); background: rgba(255,93,114,.08); border-color: rgba(255,93,114,.15); }
.health-visual { min-height: 202px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.pulse-ring { width: 72px; height: 72px; display: grid; place-items: center; border: 1px solid rgba(124,92,255,.28); border-radius: 50%; box-shadow: 0 0 0 10px rgba(124,92,255,.04), 0 0 45px rgba(124,92,255,.13); }
.pulse-core { width: 24px; height: 24px; background: radial-gradient(circle at 35% 30%, #ad99ff, #6444df); border-radius: 50%; box-shadow: 0 0 28px #7656f0; }
.health-visual strong { margin-top: 20px; font-size: 14px; }
.health-visual span { max-width: 260px; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.health-meta { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); }
.health-meta div { padding: 15px 20px; }
.health-meta div + div { border-left: 1px solid var(--border); }
.health-meta small { display: block; color: var(--muted-2); font-size: 9px; }
.health-meta strong { display: block; overflow: hidden; margin-top: 5px; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }

.activity-list { padding: 4px 20px; }
.activity-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; min-height: 70px; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: 0; }
.activity-symbol { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.045); color: var(--muted); font-size: 12px; }
.activity-item.success .activity-symbol { color: var(--green); background: rgba(43,214,155,.08); }
.activity-item.error .activity-symbol { color: var(--red); background: rgba(255,93,114,.08); }
.activity-item.blocked .activity-symbol, .activity-item.skipped .activity-symbol { color: var(--amber); background: rgba(255,187,85,.08); }
.activity-main { min-width: 0; }
.activity-main b { display: block; font-size: 11px; }
.activity-main span { display: block; overflow: hidden; margin-top: 4px; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.activity-time { color: var(--muted-2); font-size: 9px; white-space: nowrap; }
.empty-mini { padding: 45px 10px; text-align: center; color: var(--muted); font-size: 11px; }

.section-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 17px; }
.section-toolbar h2, .intro-row h2 { margin: 0 0 6px; font-size: 18px; }
.section-toolbar p, .intro-row p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.search-box { width: min(480px, 50vw); height: 43px; display: flex; align-items: center; gap: 11px; padding: 0 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.search-box:focus-within { border-color: rgba(124,92,255,.45); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.search-box svg { width: 16px; color: var(--muted-2); }
.search-box input { width: 100%; color: white; background: none; border: 0; outline: 0; font-size: 11px; }
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 950px; }
th { height: 48px; padding: 0 18px; color: var(--muted-2); font-size: 8px; font-weight: 800; letter-spacing: 1px; text-align: left; }
td { min-height: 80px; padding: 17px 18px; border-top: 1px solid var(--border); vertical-align: middle; }
.mapping-name { display: flex; align-items: center; gap: 11px; }
.mapping-avatar { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; color: #b8aaff; background: linear-gradient(145deg, rgba(124,92,255,.18), rgba(79,140,255,.08)); font-size: 10px; font-weight: 800; }
.mapping-name b, .chat-id b { display: block; max-width: 160px; overflow: hidden; font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.mapping-name small, .chat-id small { display: block; margin-top: 4px; color: var(--muted-2); font-size: 8px; }
.route-mini { color: #6852c8; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; max-width: 240px; }
.tag { padding: 4px 7px; color: #a9b0c1; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 6px; font-size: 8px; font-weight: 700; white-space: nowrap; }
.tag.accent { color: #b6a8ff; background: rgba(124,92,255,.08); border-color: rgba(124,92,255,.14); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { width: 31px; height: 31px; display: grid; place-items: center; background: rgba(255,255,255,.035); border: 1px solid var(--border); border-radius: 9px; color: var(--muted); cursor: pointer; }
.row-actions button:hover { color: white; border-color: var(--border-strong); }
.row-actions button.delete:hover { color: var(--red); border-color: rgba(255,93,114,.22); }
.row-actions svg { width: 14px; height: 14px; }
.switch { appearance: none; width: 34px; height: 19px; position: relative; flex: 0 0 auto; border-radius: 12px; background: #303746; cursor: pointer; transition: .2s; }
.switch::after { content: ""; position: absolute; width: 13px; height: 13px; top: 3px; left: 3px; background: #858da0; border-radius: 50%; transition: .2s; }
.switch:checked { background: rgba(124,92,255,.55); }
.switch:checked::after { left: 18px; background: white; }
.empty-state { min-height: 410px; display: grid; place-items: center; align-content: center; text-align: center; padding: 40px; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; color: #9a84ff; background: rgba(124,92,255,.08); border: 1px solid rgba(124,92,255,.15); border-radius: 18px; }
.empty-icon svg { width: 28px; height: 28px; }
.empty-state h3 { margin: 20px 0 6px; font-size: 16px; }
.empty-state p { margin: 0 0 22px; color: var(--muted); font-size: 11px; }

.intro-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.intro-row p { max-width: 700px; }
.privacy-chip { padding: 7px 11px; color: #a999f1; background: rgba(124,92,255,.07); border: 1px solid rgba(124,92,255,.15); border-radius: 20px; font-size: 9px; }
.filter-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 18px; align-items: start; }
.domain-form { padding: 24px; border-bottom: 1px solid var(--border); }
.inline-input { display: flex; gap: 9px; }
.inline-input input { flex: 1; }
.domain-list { padding: 6px 20px; }
.domain-row { min-height: 58px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--border); }
.domain-row:last-child { border-bottom: 0; }
.domain-favicon { width: 28px; height: 28px; display: grid; place-items: center; color: #a896ff; background: rgba(124,92,255,.08); border-radius: 8px; }
.domain-favicon svg { width: 14px; }
.domain-row b { flex: 1; font-size: 11px; }
.domain-row button { padding: 6px; border: 0; background: none; color: var(--muted-2); cursor: pointer; }
.domain-row button:hover { color: var(--red); }
.tip-card { padding: 25px; }
.tip-icon { width: 35px; height: 35px; display: grid; place-items: center; color: #b7a9ff; background: rgba(124,92,255,.09); border-radius: 10px; }
.tip-card h3 { margin: 20px 0 8px; font-size: 14px; }
.tip-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }
.rule-example { display: grid; gap: 6px; margin-top: 23px; padding: 14px; background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 11px; }
.rule-example span, .rule-example b { font-size: 10px; }
.rule-example small { color: var(--green); font-size: 8px; text-transform: uppercase; letter-spacing: 1px; }

.connection-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .75fr); gap: 18px; align-items: start; }
.connection-card { padding: 30px; }
.connection-card h2 { margin: 8px 0; font-size: 22px; }
.connection-card > p { max-width: 680px; margin: 0 0 25px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.connection-card code { padding: 2px 5px; color: #b8abf5; background: rgba(124,92,255,.08); border-radius: 4px; }
.connection-state-box { display: flex; align-items: center; gap: 14px; margin: 20px 0; padding: 16px; background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 13px; }
.connection-state-box > div:nth-child(2) { flex: 1; }
.connection-state-box b { display: block; font-size: 12px; }
.connection-state-box small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.account-avatar { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #7559ed, #496fd8); border-radius: 13px; font-weight: 800; }
.stack-form { max-width: 540px; display: grid; gap: 14px; margin-top: 22px; }
.stack-form .btn { justify-self: start; }
.auth-divider { max-width: 540px; display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; color: var(--muted-2); font-size: 8px; font-weight: 800; letter-spacing: 1px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.qr-panel { max-width: 620px; display: grid; grid-template-columns: 190px 1fr; gap: 23px; align-items: center; margin-top: 22px; padding: 18px; background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 15px; }
.qr-panel img { width: 190px; height: 190px; padding: 8px; background: white; border-radius: 12px; }
.qr-panel b { display: block; margin-bottom: 10px; font-size: 13px; }
.qr-panel ol { display: grid; gap: 7px; margin: 0 0 11px; padding-left: 18px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.qr-panel small { color: var(--amber); font-size: 8px; }
.setup-card { padding: 27px; }
.setup-card h3 { margin: 0 0 22px; font-size: 15px; }
.setup-card ol { display: grid; gap: 21px; margin: 0; padding: 0; list-style: none; }
.setup-card li { display: flex; gap: 13px; }
.setup-card li > span { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; color: #b5a7f9; background: rgba(124,92,255,.08); border: 1px solid rgba(124,92,255,.14); border-radius: 8px; font-size: 9px; font-weight: 800; }
.setup-card p { margin: 0; font-size: 11px; line-height: 1.45; }
.setup-card small { color: var(--muted); font-size: 9px; }

.mapping-dialog { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: hidden; color: var(--text); background: #0f131d; border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: 0 40px 120px rgba(0,0,0,.7); }
.mapping-dialog::backdrop { background: rgba(3,5,10,.75); backdrop-filter: blur(7px); }
.mapping-dialog form { max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; flex: 0 0 auto; padding: 24px 28px 20px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { margin: 6px 0 4px; font-size: 20px; }
.dialog-head p { margin: 0; color: var(--muted); font-size: 10px; }
.dialog-body { overflow-y: auto; padding: 24px 28px; }
.dialog-foot { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex: 0 0 auto; padding: 15px 28px; background: rgba(255,255,255,.015); border-top: 1px solid var(--border); }
.dialog-foot > div { display: flex; gap: 9px; }
.enabled-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 10px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 36px 1fr; gap: 20px; align-items: end; }
.form-grid > .full { grid-column: 1 / -1; }
.channel-panel { display: grid; gap: 13px; padding: 17px; background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 14px; }
.channel-panel.target { border-color: rgba(124,92,255,.14); }
.channel-title { display: flex; align-items: center; gap: 10px; margin-bottom: 3px; }
.channel-num { width: 28px; height: 28px; display: grid; place-items: center; color: #ae9cff; background: rgba(124,92,255,.09); border-radius: 8px; font-size: 9px; font-weight: 800; }
.channel-title b { display: block; font-size: 11px; }
.channel-title small { display: block; margin-top: 2px; color: var(--muted-2); font-size: 8px; }
.route-arrow { align-self: center; display: grid; place-items: center; color: #725ae4; }
.field { display: grid; gap: 7px; color: #abb2c3; font-size: 10px; font-weight: 650; }
.field > span em { color: var(--muted-2); font-size: 8px; font-style: normal; font-weight: 500; }
.field > small { color: var(--muted-2); font-size: 8px; font-weight: 500; }
input, select, textarea { width: 100%; color: var(--text); background: #0c1018; border: 1px solid var(--border-strong); border-radius: 10px; outline: none; }
input, select { height: 41px; padding: 0 12px; }
textarea { resize: vertical; min-height: 75px; padding: 11px 12px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #4e5668; }
input:focus, select:focus, textarea:focus { border-color: rgba(124,92,255,.55); box-shadow: 0 0 0 3px rgba(124,92,255,.08); }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 5px; background: #0b0f17; border: 1px solid var(--border); border-radius: 11px; }
.segmented input { display: none; }
.segmented span { height: 34px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); cursor: pointer; font-size: 9px; }
.segmented input:checked + span { color: white; background: rgba(124,92,255,.17); box-shadow: inset 0 0 0 1px rgba(124,92,255,.22); }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.check-card { min-height: 56px; display: flex; align-items: center; gap: 9px; padding: 10px; background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.check-card input { display: none; }
.fake-check { width: 16px; height: 16px; flex: 0 0 auto; border: 1px solid #485063; border-radius: 5px; }
.check-card input:checked + .fake-check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px #171b28; }
.check-card b { display: block; font-size: 9px; }
.check-card small { display: block; margin-top: 3px; color: var(--muted-2); font-size: 8px; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; align-items: start; }
.rules-grid textarea { min-height: 104px; }
.toggle-stack { display: grid; gap: 8px; padding: 8px 12px; background: rgba(255,255,255,.02); border: 1px solid var(--border); border-radius: 10px; }
.toggle-stack label { min-height: 27px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); cursor: pointer; }
.toggle-stack label + label { border-top: 1px solid var(--border); padding-top: 8px; }

.login-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 10%, rgba(86,62,190,.17), transparent 34%), #080b12; }
.login-card { width: min(400px, 100%); padding: 38px; text-align: center; background: linear-gradient(145deg, #141927, #0e121c); border: 1px solid var(--border-strong); border-radius: 21px; box-shadow: var(--shadow); }
.login-card h1 { margin: 8px 0; font-size: 22px; }
.login-card p { margin: 0 0 23px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.login-card .field { text-align: left; margin-bottom: 14px; }
.login-card .form-error { min-height: 16px; margin: 12px 0 0; color: var(--red); }
.toast-stack { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: grid; gap: 9px; }
.toast { width: min(340px, calc(100vw - 44px)); display: flex; align-items: flex-start; gap: 11px; padding: 14px 16px; background: #181e2b; border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); animation: toast-in .25s ease; font-size: 11px; line-height: 1.5; }
.toast.success { border-color: rgba(43,214,155,.22); }
.toast.error { border-color: rgba(255,93,114,.25); }
.toast > span { color: var(--green); }
.toast.error > span { color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.sidebar-scrim { display: none; }
.mobile-only { display: none; }

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f7f8fc;
  --panel-3: #eef1f7;
  --border: rgba(28, 36, 51, .09);
  --border-strong: rgba(28, 36, 51, .16);
  --text: #1b2230;
  --muted: #657086;
  --muted-2: #8b94a7;
  --shadow: 0 24px 70px rgba(53, 61, 84, .14);
}

html[data-theme="light"] .sidebar { background: #fff; }
html[data-theme="light"] .nav-item b { background: rgba(38, 48, 69, .06); }
html[data-theme="light"] .nav-item:hover { color: #252d3d; background: rgba(38, 48, 69, .045); }
html[data-theme="light"] .nav-item.active { color: #27233b; background: linear-gradient(90deg, rgba(124,92,255,.14), rgba(124,92,255,.055)); }
html[data-theme="light"] .connection-pill,
html[data-theme="light"] .theme-toggle,
html[data-theme="light"] .icon-btn { background: rgba(38, 48, 69, .035); }
html[data-theme="light"] .btn.ghost { color: #505a70; background: rgba(38,48,69,.04); }
html[data-theme="light"] .hero h2 { color: #fff !important; }
html[data-theme="light"] .stat-card,
html[data-theme="light"] .card { background: linear-gradient(145deg, rgba(255,255,255,.99), rgba(248,249,253,.99)); box-shadow: 0 14px 45px rgba(53,61,84,.08); }
html[data-theme="light"] .activity-symbol,
html[data-theme="light"] .tag,
html[data-theme="light"] .row-actions button,
html[data-theme="light"] .rule-example,
html[data-theme="light"] .connection-state-box,
html[data-theme="light"] .qr-panel,
html[data-theme="light"] .channel-panel,
html[data-theme="light"] .check-card,
html[data-theme="light"] .toggle-stack { background: rgba(38,48,69,.025); }
html[data-theme="light"] .search-box input { color: var(--text); }
html[data-theme="light"] .tag { color: #606a7e; }
html[data-theme="light"] .row-actions button:hover { color: #242c3c; }
html[data-theme="light"] .switch { background: #d8dce6; }
html[data-theme="light"] .switch::after { background: #fff; box-shadow: 0 1px 3px rgba(28,36,51,.18); }
html[data-theme="light"] .mapping-dialog { background: #fff; box-shadow: 0 40px 100px rgba(38,48,69,.24); }
html[data-theme="light"] .dialog-foot { background: #fafbfe; }
html[data-theme="light"] .field { color: #59647a; }
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea { background: #fff; }
html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder { color: #a0a8b8; }
html[data-theme="light"] .segmented { background: #f3f5f9; }
html[data-theme="light"] .segmented input:checked + span { color: #5d42da; background: rgba(124,92,255,.12); }
html[data-theme="light"] .fake-check { border-color: #aeb5c3; }
html[data-theme="light"] .check-card input:checked + .fake-check { box-shadow: inset 0 0 0 3px #fff; }
html[data-theme="light"] .login-overlay { background: radial-gradient(circle at 50% 10%, rgba(86,62,190,.12), transparent 35%), #f4f6fb; }
html[data-theme="light"] .login-card { background: linear-gradient(145deg, #fff, #f7f8fc); }
html[data-theme="light"] .toast { background: #fff; }

@media (max-width: 1050px) {
  :root { --sidebar: 210px; }
  .main { padding-inline: 24px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-layout, .connection-layout { grid-template-columns: 1fr; }
  .tip-card, .setup-card { order: -1; }
}

@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .sidebar { width: 244px; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.55); }
  .sidebar-scrim.show { display: block; }
  .main { margin-left: 0; padding: 0 16px 45px; }
  .topbar { height: 82px; gap: 12px; margin-bottom: 20px; }
  .topbar > div:nth-child(2) { flex: 1; }
  .topbar h1 { font-size: 17px; }
  .topbar .eyebrow { display: none; }
  .connection-pill { display: none; }
  .theme-toggle { width: 38px; padding: 0; justify-content: center; }
  .theme-toggle span { display: none; }
  .top-actions .btn { width: 38px; padding: 0; }
  .top-actions .btn { font-size: 0; }
  .hero { min-height: 260px; align-items: flex-start; flex-direction: column; padding: 28px; }
  .hero .btn { margin-top: auto; }
  .hero h2 { font-size: 27px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .section-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; }
  .section-toolbar > .btn { align-self: flex-start; }
  .intro-row { gap: 15px; }
  .table-card { margin-inline: -16px; border-radius: 0; border-left: 0; border-right: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > .full { grid-column: auto; }
  .route-arrow { transform: rotate(90deg); }
  .segmented { grid-template-columns: 1fr 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .rules-grid { grid-template-columns: 1fr; }
  .dialog-head, .dialog-body, .dialog-foot { padding-inline: 18px; }
  .dialog-foot { align-items: stretch; flex-direction: column; }
  .dialog-foot > div { display: grid; grid-template-columns: 1fr 1fr; }
  .qr-panel { grid-template-columns: 1fr; }
}

@media (max-width: 450px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 105px; }
  .activity-item { grid-template-columns: 32px 1fr; }
  .activity-time { display: none; }
  .inline-input { flex-direction: column; }
  .login-card { padding: 30px 24px; }
}
