:root {
  --bg: #101114;
  --sidebar: #17191e;
  --card: #1b1e25;
  --card-2: #20242c;
  --line: #2c313b;
  --ink: #eceff4;
  --muted: #8d95a3;
  --dim: #6d7582;
  --green: #3dd68c;
  --red: #ff5d73;
  --yellow: #f0c14a;
  --blue: #4c8dff;
  --cyan: #7ec8ff;
  color-scheme: dark;
  font-family: Inter, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: transparent; color: var(--ink); }
#stars, #glow { position: fixed; inset: 0; pointer-events: none; }
#stars { z-index: 0; background: var(--bg); }
#glow {
  z-index: 1;
  background: radial-gradient(460px circle at var(--x, 50%) var(--y, 18%), rgba(154, 246, 255, 0.16), transparent 62%);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); }

.sidebar {
  position: fixed;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 228px;
  background: var(--sidebar);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  overflow: auto;
  z-index: 5;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.logo { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px; text-decoration: none; color: var(--ink); }
.logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: #243044; color: var(--cyan); font-weight: 700;
}
.logo-text { font-weight: 700; letter-spacing: -0.03em; }
.nav-label {
  margin: 16px 8px 6px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #c5cad3;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
}
.sidebar button.nav-row, .nav-disabled { display: flex; align-items: center; gap: 10px; }
.nav-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-disabled { opacity: 0.38; color: var(--dim); padding: 7px 10px; font-size: 13px; cursor: not-allowed; user-select: none; }
.log-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.log-tools button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--muted); }
.log-tools button.on { background: #243044; color: var(--ink); border-color: #3d5f86; }
html.light .log-tools button.on { background: #e7eef8; color: #1c1f26; border-color: #c5d4ea; }
.log-answer { white-space: pre-wrap; color: var(--muted); font-size: 12px; max-width: 420px; }
.sidebar button.active { background: #243044; color: var(--ink); }

.shell { position: relative; z-index: 2; margin-left: 248px; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  background: rgba(16, 17, 20, 0.78);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
#finder { flex: 1; }
#finder input {
  width: min(520px, 100%);
  background: #14161b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  outline: none;
}
#finder input:focus { border-color: #3d4654; }
.status { margin-left: auto; display: flex; gap: 8px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.status b { color: var(--ink); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--green); margin-right: 6px; }
.dot.off { background: var(--red); }

main { padding: 16px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.03em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 12px; }
.eyebrow { color: var(--dim); font-size: 12px; margin-bottom: 4px; }
.lede { color: var(--muted); font-size: 13px; line-height: 1.45; max-width: 70ch; }

.kpi-grid, .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.metric, .kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.metric span, .kpi span { display: block; color: var(--muted); font-size: 12px; }
.metric strong, .kpi strong { display: block; margin-top: 6px; font-size: 26px; font-weight: 650; letter-spacing: -0.04em; }
.metric small, .kpi small { display: block; margin-top: 4px; color: var(--dim); font-size: 12px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.chart-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; }
.chart-card, .panel, .zone {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
}
.chart-card header, .panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.chart-scroll { overflow-x: auto; }
.chart { width: 100%; min-width: 520px; height: 240px; display: block; }
.legend { display: flex; gap: 12px; color: var(--muted); font-size: 12px; align-items: center; }
.swatch { width: 8px; height: 8px; border-radius: 99px; display: inline-block; }
.swatch.in, .swatch.sales { background: var(--yellow); }
.swatch.out { background: var(--blue); }
.swatch.line { background: var(--green); }

.db-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 10px; }
.cards, .local-portals { display: grid; gap: 8px; }
.card, .portal, .rowbtn, .back, .chips button {
  border: 1px solid var(--line);
  background: var(--card-2);
  border-radius: 8px;
  color: var(--ink);
}
.card, .portal, .rowbtn { width: 100%; text-align: left; padding: 10px 12px; }
.card:hover, .portal:hover, .rowbtn:hover, .sidebar button:hover { border-color: #3c4452; }
.card .k, .portal .k { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.card .t, .portal .t { display: block; margin: 2px 0; font-size: 16px; font-weight: 650; }
.card p, .portal p { margin: 0; color: var(--muted); font-size: 12px; }
.tag { display: inline-block; margin-top: 6px; font-size: 11px; color: var(--green); }
.card.guest .tag { color: var(--muted); }
.sys { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sys button, .back, .chips button {
  background: transparent;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.planes { display: none; }
.filters, .pager, .room-head, .modal-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.room-head { justify-content: space-between; margin-bottom: 12px; }
input[type="date"], input[type="search"], select {
  background: #14161b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}
.chips button.on { background: #243044; border-color: #3d5f86; color: var(--cyan); }
.list { display: grid; gap: 6px; }
.rowbtn { display: grid; grid-template-columns: 1.5fr 0.7fr 110px; gap: 8px; align-items: center; }
.rowbtn small, .muted { color: var(--muted); }
.sheet, .table-card { overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #16181d; }
table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 12px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #262a32; text-align: left; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
th { position: sticky; top: 0; background: #1d2128; color: var(--muted); font-weight: 600; font-size: 11px; }
th span { display: block; color: var(--dim); font-weight: 500; }
td { color: #d7dbe3; }
.empty { color: var(--muted); padding: 12px 0; }
.ghosts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.ghosts div { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; color: var(--muted); }
.error { color: var(--red); }
.blob { border: 0; background: transparent; color: var(--cyan); padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,0.62); display: grid; place-items: center; padding: 24px; }
.modal[hidden] { display: none; }
.modal-card { width: min(980px, 100%); max-height: 80vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
#blob-body { white-space: pre-wrap; word-break: break-word; font-family: Consolas, monospace; font-size: 12px; color: #d7dbe3; }
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.hbar i { height: 8px; border-radius: 99px; background: var(--yellow); display: block; }
.thread-empty { margin: 4px 10px; color: var(--dim); font-size: 12px; }
body.is-chat #finder,
body.is-chat #status { display: none; }
body.is-chat .topbar {
  justify-content: flex-end;
  background: transparent;
  border-bottom: 0;
  backdrop-filter: none;
}
body.is-chat .shell { display: block; height: auto; min-height: 100vh; overflow: visible; }
body.is-chat main { height: auto; overflow: visible; }
body.is-chat #glow { opacity: 0.25; }
body.is-chat .shell {
  background:
    radial-gradient(ellipse 58% 42% at 50% 40%, rgba(56, 104, 230, 0.42), transparent 70%),
    radial-gradient(ellipse 34% 24% at 50% 38%, rgba(120, 160, 255, 0.22), transparent 72%),
    #0c1018;
}
body.is-chat main { padding: 6px 22px 18px; }
.gem { display: flex; flex-direction: column; font-family: Manrope, Inter, "Segoe UI", sans-serif; }
.gem-bar { display: flex; gap: 4px; padding: 6px 0 4px; }
.gem-bar button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #e8eaed;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}
.gem-bar button:hover { background: rgba(255,255,255,0.07); }
.gem-bar svg, .search-row svg, #search-list svg, #dialogs-list svg, .composer svg, .msg-actions svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-empty {
  flex: 1;
  min-height: calc(100vh - 210px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 22px;
}
.chat-empty h1 { font-size: 44px; font-weight: 400; letter-spacing: -0.03em; color: #f4f6fb; }
.composer {
  width: min(720px, calc(100% - 96px));
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(18, 22, 34, 0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 32px;
  padding: 8px 8px 8px 18px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.28);
}
.composer input { flex: 1; border: 0; background: transparent; outline: none; padding: 10px 0; font-size: 16px; }
.composer button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #2a3142;
  display: grid;
  place-items: center;
  color: #e8eaed;
}
.composer button:hover { background: #364056; }
.mode-pills { display: flex; gap: 8px; justify-content: center; color: #b7c0ce; font-size: 14px; }
.mode-pills span { padding: 8px 14px; border-radius: 999px; }
.mode-pills .on { background: #2a3140; color: #fff; }
.plus { color: #c5cad3; font-size: 26px; line-height: 1; width: 24px; text-align: center; }
.thread {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 28px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: visible;
}
.bubble.user {
  align-self: flex-end;
  scroll-margin-top: 18px;
  max-width: min(520px, 86%);
  background: #2c3038;
  border-radius: 22px;
  padding: 12px 16px;
  line-height: 1.45;
}
.agent-block { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.bubble.agent { white-space: pre-wrap; line-height: 1.6; font-size: 16px; color: #e8eaed; }
body.is-chat .composer-dock {
  position: fixed;
  left: 248px;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: center;
  padding: 18px 0 16px;
  background: linear-gradient(to top, #0c1018 68%, rgba(12, 16, 24, 0));
}
.thread { padding-bottom: 110px; }
.pending { flex-direction: row; align-items: center; gap: 6px; min-height: 28px; }
.pending i {
  width: 7px; height: 7px; border-radius: 50%; background: #b7c0ce;
  animation: blink 1s infinite ease-in-out;
}
.pending i:nth-child(2) { animation-delay: 0.15s; }
.pending i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
html.light .composer-dock { background: linear-gradient(to top, #f5f7fb 64%, rgba(245, 247, 251, 0)); }
.msg-actions { display: flex; gap: 2px; margin-left: -6px; }
.msg-actions button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #c4c7c5;
  display: grid;
  place-items: center;
}
.msg-actions button:hover, .msg-actions button.on { background: rgba(255,255,255,0.08); color: #fff; }
.msg-actions circle { fill: currentColor; stroke: none; }
.model-tag { color: #6d7582; font-size: 11px; margin: 2px 0 0 8px; }
.proof-card { width: min(920px, 100%); }
.proof-card h2 { margin: 0; font-size: 18px; }
.proof-verdict { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 14px; line-height: 1.45; }
.proof-verdict p { margin: 6px 0 0; color: var(--muted); }
.proof-verdict.ok { border-color: rgba(61, 214, 140, 0.55); }
.proof-verdict.warn { border-color: rgba(240, 193, 74, 0.7); }
.proof-verdict.bad { border-color: rgba(255, 93, 115, 0.7); }
.proof-meta { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.proof-block { margin: 0 0 16px; }
.proof-block h3 { margin: 0 0 6px; font-size: 15px; }
.proof-block p { margin: 0 0 8px; color: var(--muted); line-height: 1.5; }
.proof-card .proof-text { color: var(--ink); white-space: pre-wrap; }
.proof-block p.error { color: var(--red); }
.proof-k { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); margin: 10px 0 6px; }
.proof-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 8px 0; }
.proof-facts div { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--card-2); }
.proof-facts span { display: block; color: var(--dim); font-size: 11px; }
.proof-facts b { display: block; margin-top: 2px; font-size: 16px; }
.proof-facts small { display: block; margin-top: 2px; color: var(--muted); }
.proof-sql {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, monospace;
  font-size: 12px;
  background: #12141a;
  border-radius: 8px;
  padding: 10px;
  color: #d7dbe3;
  margin: 0;
}
.proof-card .table-card { margin: 8px 0; }
#ai-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 50%;
  color: white;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: transparent;
  isolation: isolate;
}
#ai-fab::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #22e7ff, #7c3aed, #ff2bd6, #22e7ff);
  animation: ai-spin 2.6s linear infinite;
  z-index: -2;
}
#ai-fab::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22e7ff, #7c3aed 48%, #ff2bd6);
  background-size: 180% 180%;
  animation: ai-flow 2.8s ease-in-out infinite;
  box-shadow: inset 0 0 12px rgba(255,255,255,0.25);
  z-index: -1;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-flow {
  0% { background-position: 0% 40%; }
  50% { background-position: 100% 60%; }
  100% { background-position: 0% 40%; }
}
.search-modal { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,0.55); display: grid; place-items: start center; padding-top: 12vh; }
.search-modal[hidden] { display: none; }
.search-card {
  width: min(680px, calc(100% - 32px));
  background: #1c1f26;
  border: 1px solid #343a46;
  border-radius: 24px;
  overflow: hidden;
  font-family: Manrope, Inter, "Segoe UI", sans-serif;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}
.search-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #2c313b; color: #9aa3b2; }
.search-row strong { flex: 1; font-weight: 500; color: #e8eaed; font-size: 16px; }
.search-row input { flex: 1; background: transparent; border: 0; outline: none; padding: 8px 4px; font-size: 16px; color: #e8eaed; }
.search-row button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 22px; color: #e8eaed; }
.search-row button:hover { background: rgba(255,255,255,0.06); }
.search-card h2 { margin: 0; padding: 16px 18px 6px; font-size: 13px; color: #9aa3b2; font-weight: 500; letter-spacing: 0; }
#search-list, #dialogs-list { max-height: 460px; overflow: auto; padding: 6px; }
#search-list button, #dialogs-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  color: #e8eaed;
}
#search-list button:hover, #dialogs-list button:hover, #dialogs-list button.active { background: #262b34; }
#search-list small, #dialogs-list small { color: #8d95a3; }
.mast { display: flex; align-items: center; gap: 8px; margin-left: 8px; white-space: nowrap; }
#build { color: var(--muted); font-size: 12px; letter-spacing: 0.01em; }
#today { background: #22262e; border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.icon-btn, .avatar {
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); display: grid; place-items: center; padding: 0;
}
.avatar { background: #243044; color: var(--cyan); font-weight: 700; font-size: 13px; }
.icon-btn:hover, #account-btn:hover { background: rgba(255,255,255,0.08); }
.account { position: relative; }
.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 260px; z-index: 30;
  background: #1c1f26; border: 1px solid #343a46; border-radius: 14px; padding: 6px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.45);
}
.account-menu[hidden], #open-admin[hidden] { display: none; }
.account-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 10px; }
.account-head strong { flex: 1; font-size: 14px; font-weight: 600; }
.account-menu > button, .account-head button {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent;
  color: var(--ink); border-radius: 8px; text-align: left; font-size: 14px;
}
.account-menu > button { width: 100%; padding: 9px 10px; }
.account-head button { width: 32px; height: 32px; padding: 0; justify-content: center; color: var(--muted); }
.account-menu > button:hover, .account-head button:hover { background: rgba(255,255,255,0.06); }
#theme-toggle.on { color: var(--cyan); }
.mast svg, .account-menu svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none;
}
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: #1c1f26; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 13px;
}
#toast[hidden] { display: none; }
html.light {
  --bg: #f3f4f6;
  --sidebar: #ffffff;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --line: #e3e6ec;
  --ink: #1c1f26;
  --muted: #5c6573;
  --dim: #7a8494;
  color-scheme: light;
  background: var(--bg);
}
html.light body { background: var(--bg); }
html.light #stars { display: none; }
html.light #glow { background: radial-gradient(460px circle at var(--x, 50%) var(--y, 18%), rgba(90, 150, 255, 0.16), transparent 62%); }
html.light .sidebar button { color: #3a4250; }
html.light .sidebar button:hover { background: #f0f2f6; }
html.light .sidebar button.active { background: #e7eef8; color: #1c1f26; }
html.light .topbar { background: rgba(255,255,255,0.88); }
html.light #finder input, html.light .composer, html.light .search-card, html.light .sheet, html.light .table-card, html.light .modal-card,
html.light input[type="date"], html.light input[type="search"], html.light select {
  background: #fff;
  color: var(--ink);
  color-scheme: light;
}
html.light #today, html.light .account-menu, html.light #toast { background: #fff; color: var(--ink); border: 1px solid var(--line); }
html.light .bubble.user { background: #e6ebf3; color: #1c1f26; }
html.light .bubble.agent, html.light .chat-empty h1, html.light .gem-bar button { color: #1c1f26; }
html.light .composer { border-color: #d5dae3; box-shadow: 0 8px 28px rgba(20, 30, 50, 0.08); }
html.light .composer button { background: #e7ebf2; color: #1c1f26; }
html.light .mode-pills .on { background: #e7ebf2; color: #1c1f26; }
html.light.is-chat .shell, html.light body.is-chat .shell {
  background:
    radial-gradient(ellipse 58% 42% at 50% 40%, rgba(170, 196, 255, 0.65), transparent 70%),
    #f5f7fb;
}
html.light th { background: #f7f8fa; }
html.light .proof-sql { background: #f4f6f9; color: var(--ink); }
html.light .icon-btn:hover, html.light #account-btn:hover, html.light .account-menu > button:hover { background: #f0f2f6; }
html.light #search-list button:hover, html.light #dialogs-list button:hover, html.light #dialogs-list button.active { background: #f3f5f8; }
html.light .search-row strong { color: var(--ink); }
#veil {
  position: fixed;
  z-index: 24;
  left: 256px;
  right: 8px;
  top: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  background: rgba(7, 9, 16, 0.62);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0s linear 0.32s;
}
#veil.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.12s ease, visibility 0s;
}
.spinner { position: relative; width: 92px; height: 92px; }
.spinner .ring, .spinner .core, .spinner .sat { position: absolute; border-radius: 50%; }
.spinner .ring {
  inset: 0;
  background: conic-gradient(from 0deg, transparent 0 30%, #22e7ff 55%, #d946ef 78%, transparent 100%);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%);
  mask: radial-gradient(circle, transparent 58%, #000 60%);
  animation: spin 1.15s linear infinite;
  filter: drop-shadow(0 0 8px rgba(34, 231, 255, 0.65));
}
.spinner .ring.inner {
  inset: 14px;
  background: conic-gradient(from 180deg, transparent 0 40%, #ff2bd6 62%, #7c3aed 80%, transparent 100%);
  animation-duration: 0.8s;
  animation-direction: reverse;
  filter: drop-shadow(0 0 6px rgba(217, 70, 239, 0.7));
}
.spinner .core {
  inset: 34px;
  background: radial-gradient(circle, #fff 0 18%, #22e7ff 46%, #7c3aed 76%, transparent 80%);
  animation: pulse 1.4s ease-in-out infinite;
}
.spinner .sat {
  width: 7px;
  height: 7px;
  margin: auto;
  background: #fff;
  box-shadow: 0 0 10px #22e7ff;
  offset-path: circle(46px at 46px 46px);
  animation: orbit 2.2s linear infinite;
}
.spinner .s2 { animation-duration: 1.5s; animation-direction: reverse; background: #ff7af0; box-shadow: 0 0 10px #d946ef; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { transform: scale(0.82); opacity: 0.75; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes orbit { to { offset-distance: 100%; } }
#app.page-in { animation: page-in 0.42s ease; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(2px); }
  to { opacity: 1; transform: none; filter: none; }
}
html.light #veil { background: rgba(243, 246, 252, 0.72); }
@media (prefers-reduced-motion: reduce) {
  #veil, #app.page-in, .spinner .ring, .spinner .core, .spinner .sat { animation: none; transition: none; }
}
@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; height: auto; margin: 8px; }
  .shell { margin-left: 0; }
  body.is-chat .composer-dock { left: 0; }
  #veil { left: 8px; }
  .kpi-grid, .metrics, .chart-grid, .db-grid, .ghosts, .rowbtn { grid-template-columns: 1fr; }
}
body.auth-locked .sidebar,
body.auth-locked .shell,
body.auth-locked #ai-fab,
body.auth-locked #search-modal,
body.auth-locked #dialogs-modal,
body.auth-locked #veil { display: none; }
#gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; }
#gate[hidden], body:not(.auth-locked) #gate { display: none; }
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  background: rgba(23, 25, 30, 0.94);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-card h1 { font-size: 28px; }
.login-card .lede { margin: 0; }
.login-card label, .admin-form label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.login-card input, .admin-form input[type="text"], .admin-form input[type="password"] {
  width: 100%;
  background: #14161b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  outline: none;
}
.login-card input:focus, .admin-form input:focus { border-color: #3d5f86; }
.login-card button[type="submit"], .btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: #243044;
  color: var(--cyan);
  font-weight: 600;
}
.btn:hover, .login-card button[type="submit"]:hover { background: #2c3c52; }
.login-card button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }
.admin-grid { display: grid; grid-template-columns: 280px 1fr; gap: 12px; align-items: start; }
.user-list { display: grid; gap: 6px; }
.user-list button {
  display: grid;
  gap: 2px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
}
.user-list button.on { border-color: #3d5f86; background: #243044; }
.user-list span, .user-list small { color: var(--muted); font-size: 12px; }
.admin-form { display: grid; gap: 12px; margin-top: 0; }
.admin-form header { margin: 0; }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--ink) !important; }
.check input { accent-color: var(--cyan); }
.grant-groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grant-groups section {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.grant-groups h3 { margin: 0 0 6px; font-size: 12px; color: var(--dim); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.back.danger { color: var(--red); }
html.light .login-card { background: #fff; }
html.light .login-card input,
html.light .admin-form input[type="text"],
html.light .admin-form input[type="password"] { background: #fff; color: var(--ink); }
@media (max-width: 1100px) {
  .admin-grid, .grant-groups { grid-template-columns: 1fr; }
}
