/* Simplex Panel Web 9.8.0 — responsive admin panel. No external fonts, scripts or images (strict CSP). */
:root {
  color-scheme: dark;
  --bg: #060a17;
  --bg-2: #0a1022;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-solid: #0e152b;
  --border: rgba(148, 163, 214, 0.14);
  --border-strong: rgba(148, 163, 214, 0.26);
  --text: #e9edf9;
  --text-2: #b7bfd8;
  --muted: #7f89a8;
  --accent: #22d3ee;
  --accent-2: #6366f1;
  --accent-3: #a855f7;
  --accent-ink: #04121a;
  --grad: linear-gradient(135deg, #22d3ee 0%, #3b82f6 50%, #8b5cf6 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 50px -24px rgba(0, 0, 0, 0.8);
  --glow: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 8px 30px -8px rgba(34, 211, 238, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar: 268px;
  --topbar: 64px;
  --tabbar: 68px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6fc;
  --bg-2: #e9eef8;
  --surface: #ffffff;
  --surface-2: #f4f7fd;
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0b1224;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #0891b2;
  --accent-2: #4f46e5;
  --accent-ink: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 12px 32px -18px rgba(15, 23, 42, 0.25);
  --glow: 0 0 0 1px rgba(8, 145, 178, 0.35), 0 8px 24px -10px rgba(8, 145, 178, 0.35);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: -20vh -20vw auto; height: 70vh; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 60% at 20% 10%, rgba(34, 211, 238, 0.13), transparent 60%), radial-gradient(50% 50% at 85% 0%, rgba(139, 92, 246, 0.14), transparent 60%);
}
:root[data-theme="light"] body::before { opacity: 0.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(34, 211, 238, 0.3); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 18px 14px;
  background: linear-gradient(180deg, rgba(10, 16, 34, 0.9), rgba(6, 10, 23, 0.92)); border-right: 1px solid var(--border);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); overflow-y: auto; z-index: 40;
}
:root[data-theme="light"] .sidebar { background: rgba(255, 255, 255, 0.86); }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 16px; }
.brand img { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 6px 22px -6px rgba(34, 211, 238, 0.6); }
.brand b { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.nav-group { margin-top: 10px; }
.nav-title { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; color: var(--text-2); font-weight: 500; font-size: 14px;
  text-decoration: none; position: relative; transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, rgba(34, 211, 238, 0.16), rgba(99, 102, 241, 0.08)); color: var(--text); }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--grad); }
.nav a.active svg { color: var(--accent); }
.nav a.locked { opacity: 0.42; }
.nav a .lock { margin-left: auto; width: 14px; height: 14px; }
.nav a .count { margin-left: auto; min-width: 22px; padding: 0 7px; height: 20px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.sidebar-foot { margin-top: auto; padding: 12px 0 2px; border-top: 1px solid var(--border); display: grid; gap: 8px; position: sticky; bottom: -18px; background: #070b19; }
:root[data-theme="light"] .sidebar-foot { background: #fff; }
.sidebar { scrollbar-width: thin; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who small { color: var(--muted); font-size: 12px; }
.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 28px;
  background: rgba(6, 10, 23, 0.72); border-bottom: 1px solid var(--border); backdrop-filter: saturate(160%) blur(18px); -webkit-backdrop-filter: saturate(160%) blur(18px);
}
:root[data-theme="light"] .topbar { background: rgba(243, 246, 252, 0.8); }
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.content { padding: 26px 28px 60px; width: 100%; max-width: 1480px; margin: 0 auto; }
.tabbar { display: none; }
.scrim { display: none; }

/* ---------- Primitives ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 13px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { margin-left: auto; }
.center { text-align: center; }
.hidden { display: none !important; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.span-2 { grid-column: span 2; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  min-width: 0; position: relative;
}
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.card-head .sub { color: var(--muted); font-size: 13px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card.clickable { cursor: pointer; transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s; }
.card.clickable:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--glow); }
.card.locked { opacity: 0.62; filter: grayscale(1); box-shadow: none; border-style: dashed; }
.card.locked.clickable:hover { transform: none; box-shadow: none; }
.lock-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.lock-note svg { width: 13px; height: 13px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
.section-title h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; font-weight: 600; }

.kpi { display: grid; gap: 6px; }
.kpi .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .label svg { width: 16px; height: 16px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 4px; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi .ico { position: absolute; right: 16px; top: 16px; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(34, 211, 238, 0.12); color: var(--accent); }
.kpi .ico.v { background: rgba(139, 92, 246, 0.14); color: #a78bfa; }
.kpi .ico.g { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.kpi .ico.y { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.kpi .ico.r { background: rgba(248, 113, 113, 0.14); color: var(--danger); }
.spark { width: 100%; height: 36px; margin-top: 4px; }
.spark path.l { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark path.a { fill: url(#sparkfill); stroke: none; }
.bar { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--grad); transition: width 0.4s; }
.bar.warn > i { background: linear-gradient(90deg, #f59e0b, #f97316); }
.bar.danger > i { background: linear-gradient(90deg, #ef4444, #f43f5e); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: rgba(148, 163, 214, 0.14); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { border: 0; background: var(--grad); color: #fff; box-shadow: 0 8px 24px -10px rgba(59, 130, 246, 0.8); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(248, 113, 113, 0.4); color: var(--danger); background: rgba(248, 113, 113, 0.08); }
.btn.danger.solid { background: #dc2626; color: #fff; border: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.block { width: 100%; }
.btn .spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field > small { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 11px; border: 1px solid var(--border-strong); background: rgba(0, 0, 0, 0.18);
  color: var(--text); outline: none; transition: border-color 0.15s, box-shadow 0.15s; font-size: 15px;
}
:root[data-theme="light"] .input { background: #fff; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.16); }
.input::placeholder { color: var(--muted); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input.code { font-family: var(--mono); font-size: 26px; letter-spacing: 0.4em; text-align: center; padding-left: 0.4em; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 40px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border-strong); transition: 0.2s; }
.switch i::after { content: ""; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: 0.2s; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented button.on { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge svg { width: 12px; height: 12px; }
.badge.ok { background: rgba(52, 211, 153, 0.12); color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.badge.danger { background: rgba(248, 113, 113, 0.12); color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.badge.info { background: rgba(96, 165, 250, 0.12); color: var(--info); border-color: rgba(96, 165, 250, 0.3); }
.badge.accent { background: rgba(34, 211, 238, 0.12); color: var(--accent); border-color: rgba(34, 211, 238, 0.3); }
.badge.gold { background: rgba(251, 191, 36, 0.14); color: #fcd34d; border-color: rgba(251, 191, 36, 0.35); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.dot.warn { background: var(--warn); }
.dot.off { background: #475569; }

.avatar { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; flex: none; background: var(--grad); text-transform: uppercase; }
.avatar.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 22px; }
.avatar.device { background: var(--surface-2); color: var(--accent); border: 1px solid var(--border); }

.list { display: grid; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); min-width: 0; }
.list .item:first-child { border-top: 0; }
.list .item.link { cursor: pointer; transition: background 0.12s; }
.list .item.link:hover { background: var(--surface-2); }
.list .item .meta { min-width: 0; flex: 1; }
.list .item .meta b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .meta small { display: block; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .meta p { margin: 4px 0 0; color: var(--text-2); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.list .item .side { display: flex; align-items: center; gap: 8px; flex: none; }
.chev { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.link { cursor: pointer; }
.table tr.link:hover td { background: var(--surface-2); }

.empty { display: grid; place-items: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--muted); }
.empty .big { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); }
.empty .big svg { width: 26px; height: 26px; }
.empty h3 { margin: 0; color: var(--text); font-size: 16px; }
.empty p { margin: 0; max-width: 420px; font-size: 14px; }
.notice { display: flex; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; color: var(--text-2); }
.notice svg { flex: none; margin-top: 2px; color: var(--accent); }
.notice.warn { border-color: rgba(251, 191, 36, 0.35); background: rgba(251, 191, 36, 0.08); }
.notice.warn svg { color: var(--warn); }
.notice.danger { border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); }
.notice.danger svg { color: var(--danger); }
.notice.ok { border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); }
.notice.ok svg { color: var(--ok); }
.notice b { color: var(--text); }
.locked-page { max-width: 560px; margin: 40px auto; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 10px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

.prose { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text-2); font-size: 14px; }
.prose b { color: var(--text); }
.prose code { font-family: var(--mono); font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); }
.kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - var(--topbar) - 86px); min-height: 420px; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 10px; max-width: 760px; }
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.msg .bubble { padding: 10px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.msg.mine .bubble { background: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(99, 102, 241, 0.2)); border-color: rgba(34, 211, 238, 0.3); }
.msg .bubble .by { font-size: 12px; font-weight: 700; color: var(--accent); display: flex; gap: 8px; align-items: center; }
.msg .bubble .by time { color: var(--muted); font-weight: 500; }
.msg .bubble p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.msg .attachments { display: grid; gap: 6px; margin-top: 8px; }
.msg .attachments img { max-width: min(340px, 100%); border-radius: 12px; cursor: zoom-in; }
.msg .attachments audio { width: min(300px, 100%); }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; }

/* ---------- Overlays ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(2, 6, 18, 0.66); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade 0.15s ease-out; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.8); animation: pop 0.18s ease-out; }
.modal.wide { width: min(820px, 100%); }
.modal header { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: inherit; z-index: 1; }
.modal header h2 { font-size: 17px; margin: 0; }
.modal .body { padding: 20px; display: grid; gap: 16px; }
.modal footer { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 10px; z-index: 200; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.7); animation: pop 0.2s ease-out; font-size: 14px; }
.toast svg { flex: none; margin-top: 1px; }
.toast.ok svg { color: var(--ok); }
.toast.err svg { color: var(--danger); }
.toast b { display: block; }
.toast small { color: var(--muted); display: block; white-space: pre-wrap; }
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(0, 0, 0, 0.88); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 50; padding: 6px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: 0 24px 48px -20px rgba(0, 0, 0, 0.7); }
.menu-pop button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 9px; text-align: left; cursor: pointer; font-size: 14px; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop button.danger { color: var(--danger); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.rel { position: relative; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px calc(28px + var(--safe-bottom)); }
.auth-card { width: min(440px, 100%); padding: 32px 28px; border-radius: 24px; background: rgba(14, 21, 43, 0.75); border: 1px solid var(--border-strong); box-shadow: 0 40px 100px -40px rgba(34, 211, 238, 0.35), var(--shadow); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); }
:root[data-theme="light"] .auth-card { background: rgba(255, 255, 255, 0.92); }
.auth-logo { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 18px; box-shadow: 0 12px 40px -10px rgba(34, 211, 238, 0.7); }
.auth h1 { text-align: center; margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.auth .lead { text-align: center; margin: 6px 0 24px; color: var(--muted); font-size: 14px; }
.auth form { display: grid; gap: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; margin: 4px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--muted); }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength i { height: 4px; border-radius: 3px; background: var(--surface-2); }
.strength.s1 i:nth-child(-n+1) { background: var(--danger); }
.strength.s2 i:nth-child(-n+2) { background: var(--warn); }
.strength.s3 i:nth-child(-n+3) { background: #a3e635; }
.strength.s4 i:nth-child(-n+4) { background: var(--ok); }
.qr { background: #fff; padding: 14px; border-radius: 16px; width: 220px; height: 220px; margin: 0 auto; }
.qr svg { width: 100%; height: 100%; display: block; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; font-family: var(--mono); font-size: 15px; }
.codes span { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); text-align: center; letter-spacing: 0.04em; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --topbar: 58px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform 0.25s ease; box-shadow: 30px 0 60px -30px rgba(0, 0, 0, 0.8); padding-bottom: calc(18px + var(--safe-bottom)); }
  .sidebar.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(2, 6, 18, 0.55); }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar) + env(safe-area-inset-top, 0px)); }
  .content { padding: 16px 14px calc(var(--tabbar) + 28px + var(--safe-bottom)); }
  .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .grid.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi .value { font-size: 24px; }
  .kpi .ico { width: 30px; height: 30px; right: 12px; top: 12px; }
  .card { padding: 15px; border-radius: 14px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: rgba(8, 12, 26, 0.88); border-top: 1px solid var(--border); backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  }
  :root[data-theme="light"] .tabbar { background: rgba(255, 255, 255, 0.92); }
  .tabbar a { display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; position: relative; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a.locked { opacity: 0.4; }
  .tabbar a .count { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 5px; }
  .table.responsive thead { display: none; }
  .table.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive td { padding: 0; border: 0; }
  .table.responsive td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  .table.responsive td.primary { grid-column: 1 / -1; font-weight: 600; }
  .chat { height: calc(100vh - var(--topbar) - var(--tabbar) - 40px - var(--safe-bottom)); }
  .modal-bg { align-items: end; padding: 0; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; max-height: 92vh; padding-bottom: var(--safe-bottom); animation: sheet 0.22s ease-out; }
  @keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar) + 14px + var(--safe-bottom)); width: auto; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .hide-mobile { display: none !important; }
  .topbar h1 { font-size: 17px; }
}
@media (max-width: 380px) {
  .grid.kpis { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 901px) { .hide-desktop { display: none !important; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.card.pad-list { padding: 16px 0 4px; }
.card.pad-list > .card-head { padding: 0 18px; margin-bottom: 8px; }
.card.hero { background: linear-gradient(135deg, rgba(34, 211, 238, 0.09), rgba(139, 92, 246, 0.09)), var(--surface); }
.perm-group { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.perm-group > header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); font-weight: 600; font-size: 13px; }
.perm-group > div { display: grid; }
.perm-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-top: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.perm-row small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.perm-row input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.action-card { display: flex; gap: 12px; align-items: flex-start; }
.action-card .meta { min-width: 0; }
.action-card b { display: block; font-size: 14px; }
.action-card small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.menu-grid button { text-align: left; display: grid; gap: 4px; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.menu-grid button:hover:not(:disabled) { border-color: var(--border-strong); box-shadow: var(--glow); }
.menu-grid button:disabled { opacity: 0.5; cursor: not-allowed; }
.menu-grid button small { color: var(--muted); font-size: 12.5px; white-space: pre-wrap; }
