/* Valhalla — shared design system (from the approved mockup).
   Three themes, chosen per account in « Mon compte » and applied before the
   first paint by /assets/theme.js: "dark" (default), "light" and "valhalla"
   (the original navy). Every colour below is a token; nothing else in this
   file hard-codes a colour. Each theme's series palette (--s1..--s4) was
   validated with the dataviz skill's validate_palette.js against that theme's
   card surfaces (lightness band, chroma, colour-blind separation, contrast).
   Series tokens must stay 6-digit hex: charts.js derives alpha tints from them.
   Code surfaces (console, editor, diff) stay dark in every theme, like a
   terminal: the ANSI and syntax colours are tuned for a dark background. */

:root, [data-theme="dark"] {
	color-scheme: dark;
	--bg: #09090b;
	--side: #0e0e10;
	--side-line: #1a1a1e;
	--surface: #111113;
	--surface-2: #18181b;
	--surface-3: #1f1f23;
	--card-filled: #18181b;
	--card-filled-line: transparent;
	--line: #222226;
	--line-2: #2e2e34;
	--grid: #202024;
	--pill: #232328;
	--pill-hover: #1a1a1e;
	--bubble: #232328;
	--bubble-line: #303036;
	--text: #f4f4f5;
	--text-2: #a1a1aa;
	--text-3: #8b8b94;
	--placeholder: #6b6b75;
	--s1: #7c7ef0;
	--s2: #2ea89c;
	--s3: #d5783e;
	--s4: #bf62a8;
	--good: #0ca30c;
	--good-text: #4cc94c;
	--warn: #fab219;
	--warn-text: #fab219;
	--crit: #d03b3b;
	--crit-text: #f06b6b;
	--crit-hover: #dc4848;
	--accent: #5d5fe0;
	--accent-hover: #6c6ee8;
	--on-accent: #ffffff;
	--accent-soft: rgba(124, 126, 240, 0.16);
	--accent-line: rgba(124, 126, 240, 0.38);
	--accent-wash: rgba(124, 126, 240, 0.07);
	--accent-text: #b4b5f8;
	--link: #a5a6f6;
	--link-hover: #c7c8fa;
	--info-text: #a5a6f6;
	--violet-bg: rgba(191, 98, 168, 0.18);
	--violet-text: #e3a9d5;
	--focus-ring: rgba(124, 126, 240, 0.25);
	--switch-on: rgba(124, 126, 240, 0.42);
	--switch-knob: #e2e2fd;
	--brand-a: #7c7ef0;
	--brand-b: #b064d8;
	--row-hover: rgba(255, 255, 255, 0.025);
	--backdrop: rgba(0, 0, 0, 0.7);
	--overlay: rgba(9, 9, 11, 0.88);
	--scroll: #2a2a30;
	--scroll-hover: #3a3a42;
	--glow-a: rgba(124, 126, 240, 0.13);
	--glow-b: rgba(46, 168, 156, 0.08);
	--error-text: #f5b5b5;
	--ok-text: #b7e8b7;
	--code-bg: #0c0c0e;
	--code-bg-2: #17171b;
	--code-line: #222226;
	--code-text: #d8d8de;
	--code-dim: #8b8b94;
	--code-muted: #55555f;
	--code-hover: rgba(255, 255, 255, 0.03);
	--code-active: rgba(124, 126, 240, 0.07);
	--code-sel: rgba(124, 126, 240, 0.3);
	--code-cursor: #e2e2fd;
	--code-info: #a5a6f6;
	--code-scroll: #2a2a30;
	--ico-dir: #d9a441;
	--ico-lua: #8b8df3;
	--ico-cfg: #c49bea;
	--ico-data: #4fc3b6;
	--ico-img: #62cf7a;
	--shadow-pop: 0 18px 50px rgba(0, 0, 0, 0.6);
	--shadow-tip: 0 12px 30px rgba(0, 0, 0, 0.5);
	--shadow-modal: 0 30px 80px rgba(0, 0, 0, 0.6);
	--shadow-auth: 0 30px 80px rgba(0, 0, 0, 0.5);
	--shadow-card: none;
	--font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
	--mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
	--r-lg: 18px;
	--r-md: 12px;
	--r-sm: 9px;
}

[data-theme="light"] {
	color-scheme: light;
	--bg: #f4f5f8;
	--side: #ffffff;
	--side-line: #e4e7ec;
	--surface: #ffffff;
	--surface-2: #f7f8fa;
	--surface-3: #eef0f4;
	--card-filled: #ffffff;
	--card-filled-line: #e4e7ec;
	--line: #e4e7ec;
	--line-2: #d3d8e0;
	--grid: #eceef2;
	--pill: #eef0f4;
	--pill-hover: #f3f4f7;
	--bubble: #ffffff;
	--bubble-line: #e4e7ec;
	--text: #111827;
	--text-2: #4b5563;
	--text-3: #636a77;
	--placeholder: #9aa1ad;
	--s1: #5b5bd6;
	--s2: #0f8f84;
	--s3: #d9652b;
	--s4: #c2479a;
	--good: #16a34a;
	--good-text: #15803d;
	--warn: #e39b0b;
	--warn-text: #b45309;
	--crit: #dc2626;
	--crit-text: #b91c1c;
	--crit-hover: #c81e1e;
	--accent: #5b5bd6;
	--accent-hover: #4d4fc8;
	--on-accent: #ffffff;
	--accent-soft: rgba(91, 91, 214, 0.1);
	--accent-line: rgba(91, 91, 214, 0.35);
	--accent-wash: rgba(91, 91, 214, 0.05);
	--accent-text: #4545bd;
	--link: #4545bd;
	--link-hover: #34349f;
	--info-text: #4545bd;
	--violet-bg: rgba(194, 71, 154, 0.1);
	--violet-text: #9c2f78;
	--focus-ring: rgba(91, 91, 214, 0.2);
	--switch-on: #5b5bd6;
	--switch-knob: #ffffff;
	--brand-a: #5b5bd6;
	--brand-b: #a64bc4;
	--row-hover: rgba(17, 24, 39, 0.025);
	--backdrop: rgba(17, 24, 39, 0.4);
	--overlay: rgba(255, 255, 255, 0.92);
	--scroll: #d3d8e0;
	--scroll-hover: #b8bfca;
	--glow-a: rgba(91, 91, 214, 0.1);
	--glow-b: rgba(15, 143, 132, 0.07);
	--error-text: #991b1b;
	--ok-text: #166534;
	--code-bg: #16181d;
	--code-bg-2: #1f2228;
	--code-line: #2a2e36;
	--code-text: #d8dbe2;
	--code-dim: #8e95a3;
	--code-muted: #5d6472;
	--code-hover: rgba(255, 255, 255, 0.03);
	--code-active: rgba(124, 126, 240, 0.08);
	--code-sel: rgba(124, 126, 240, 0.32);
	--code-cursor: #e2e2fd;
	--code-info: #a5a6f6;
	--code-scroll: #353a44;
	--ico-dir: #c98a12;
	--ico-lua: #5b5bd6;
	--ico-cfg: #8b5cf6;
	--ico-data: #0f8f84;
	--ico-img: #16a34a;
	--shadow-pop: 0 16px 40px rgba(17, 24, 39, 0.14);
	--shadow-tip: 0 8px 24px rgba(17, 24, 39, 0.12);
	--shadow-modal: 0 24px 60px rgba(17, 24, 39, 0.18);
	--shadow-auth: 0 20px 50px rgba(17, 24, 39, 0.08);
	--shadow-card: 0 1px 2px rgba(17, 24, 39, 0.04);
}

/* The original navy theme, kept as it was approved. */
[data-theme="valhalla"] {
	color-scheme: dark;
	--bg: #121926;
	--side: #1a2232;
	--side-line: transparent;
	--surface: #161e2e;
	--surface-2: #1b2438;
	--surface-3: #202a40;
	--card-filled: #1b2438;
	--card-filled-line: transparent;
	--line: #263047;
	--line-2: #2f3a52;
	--grid: #222b3d;
	--pill: #28324a;
	--pill-hover: #212a3d;
	--bubble: #2c374d;
	--bubble-line: transparent;
	--text: #f1f4f9;
	--text-2: #aab4c8;
	--text-3: #8a95aa;
	--placeholder: #66728a;
	--s1: #4a92dc;
	--s2: #d8763c;
	--s3: #8a7fe0;
	--s4: #36a275;
	--good: #0ca30c;
	--good-text: #4cc94c;
	--warn: #fab219;
	--warn-text: #fab219;
	--crit: #d03b3b;
	--crit-text: #f06b6b;
	--crit-hover: #dc4848;
	--accent: #4a92dc;
	--accent-hover: #5c9fe2;
	--on-accent: #ffffff;
	--accent-soft: rgba(74, 146, 220, 0.16);
	--accent-line: rgba(74, 146, 220, 0.35);
	--accent-wash: rgba(74, 146, 220, 0.07);
	--accent-text: #9cc7f2;
	--link: #8fbdeb;
	--link-hover: #b5d4f3;
	--info-text: #8fbdeb;
	--violet-bg: rgba(138, 127, 224, 0.18);
	--violet-text: #bdb5f3;
	--focus-ring: rgba(74, 146, 220, 0.2);
	--switch-on: rgba(74, 146, 220, 0.35);
	--switch-knob: #cfe2f7;
	--brand-a: #4a92dc;
	--brand-b: #8a7fe0;
	--row-hover: rgba(40, 50, 74, 0.35);
	--backdrop: rgba(6, 10, 18, 0.66);
	--overlay: rgba(18, 25, 38, 0.86);
	--scroll: #2c3850;
	--scroll-hover: #3a4866;
	--glow-a: rgba(74, 146, 220, 0.12);
	--glow-b: rgba(138, 127, 224, 0.1);
	--error-text: #f5b5b5;
	--ok-text: #b7e8b7;
	--code-bg: #0e141f;
	--code-bg-2: #1b2438;
	--code-line: #263047;
	--code-text: #d4dae6;
	--code-dim: #8a95aa;
	--code-muted: #4f5b73;
	--code-hover: rgba(255, 255, 255, 0.03);
	--code-active: rgba(74, 146, 220, 0.06);
	--code-sel: rgba(74, 146, 220, 0.3);
	--code-cursor: #cfe2f7;
	--code-info: #8fbdeb;
	--code-scroll: #33405a;
	--ico-dir: #d9a441;
	--ico-lua: #6f8ff0;
	--ico-cfg: #b69cf0;
	--ico-data: #5fcbd9;
	--ico-img: #62cf7a;
	--shadow-pop: 0 18px 50px rgba(0, 0, 0, 0.45);
	--shadow-tip: 0 12px 30px rgba(0, 0, 0, 0.4);
	--shadow-modal: 0 30px 80px rgba(0, 0, 0, 0.55);
	--shadow-auth: 0 30px 80px rgba(0, 0, 0, 0.35);
	--shadow-card: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 400 14px/1.5 var(--font);
	/* Plus Jakarta Sans' space is only ~0.14 em in regular weight (measured in
	   Chromium: 2 px at 14 px): words look glued together without this. */
	word-spacing: 0.1em;
	-webkit-font-smoothing: antialiased;
}
/* Browsers reset word-spacing on form controls; bold text already has a
   wider space glyph (~0.2 em), headings even more so at large sizes. */
button, input, select, textarea { word-spacing: inherit; }
.btn, .seg button, .nav a { word-spacing: 0.04em; }
h1, h2, h3, .card-title, .fig .num, .k-value, .brand { word-spacing: 0.03em; }

/* Dark scrollbars everywhere, editor included. */
* { scrollbar-width: thin; scrollbar-color: var(--scroll) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-hover); }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; border-radius: 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
.ico { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }
.ico.xs { width: 14px; height: 14px; }
.ico.lg { width: 28px; height: 28px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); word-spacing: normal; }
.muted { color: var(--text-3); }
.num-tab { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); height: 100%; }
.app.boot .main-inner > * { opacity: 0; }

.side {
	background: var(--side);
	display: flex;
	flex-direction: column;
	padding: 26px 16px 18px;
	border-right: 1px solid var(--side-line);
	overflow-y: auto;
	gap: 6px;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 22px; font-size: 21px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(145deg, var(--brand-a), var(--brand-b)); display: grid; place-items: center; flex-shrink: 0; }
.brand-mark svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
	display: flex;
	align-items: center;
	gap: 13px;
	padding: 11px 13px;
	border-radius: var(--r-md);
	color: var(--text-2);
	text-decoration: none;
	font-size: 14.5px;
	font-weight: 500;
	transition: background 0.15s ease, color 0.15s ease;
}
.nav a:hover { background: var(--pill-hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--pill); color: var(--text); font-weight: 600; }
.nav .new { margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; padding: 2px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }
.nav .count { margin-left: auto; min-width: 20px; text-align: center; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: var(--pill); color: var(--text-2); }
.nav-sep { height: 1px; background: var(--line); margin: 16px 10px 8px; }
.nav-label { font-size: 12.5px; color: var(--text-3); padding: 8px 13px 6px; }

.srv { margin-top: auto; border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; text-decoration: none; color: inherit; display: block; transition: border-color 0.15s ease; }
a.srv:hover { border-color: var(--line-2); }
.srv-top { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13.5px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.status-dot.online { background: var(--good); box-shadow: 0 0 0 3px rgba(12, 163, 12, 0.18); }
.status-dot.busy { background: var(--warn); box-shadow: 0 0 0 3px rgba(250, 178, 25, 0.18); }
.status-dot.down { background: var(--crit); box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.2); }
.status-dot.off { background: var(--text-3); }
.srv-list { margin: 12px 0 0; display: grid; gap: 7px; font-size: 12.5px; }
.srv-list div { display: flex; justify-content: space-between; gap: 10px; }
.srv-list dt { color: var(--text-3); white-space: nowrap; }
.srv-list dd { margin: 0; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout { display: flex; align-items: center; gap: 13px; padding: 11px 13px; margin-top: 8px; border-radius: var(--r-md); color: var(--text-2); background: none; border: 0; cursor: pointer; font-size: 14px; text-align: left; width: 100%; }
.logout:hover { background: var(--pill-hover); color: var(--text); }
a.logout { text-decoration: none; }
.logout[aria-current="page"] { background: var(--pill); color: var(--text); font-weight: 600; }

.main { overflow-y: auto; min-width: 0; position: relative; }
.main-inner { max-width: 1560px; margin: 0 auto; padding: 28px 34px 44px; }
.main-inner.wide { max-width: none; }

/* ---------- Header ---------- */
.top { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; min-height: 46px; }
.top h1 { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.icon-btn {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: transparent;
	display: grid;
	place-items: center;
	cursor: pointer;
	position: relative;
	color: var(--text);
	flex-shrink: 0;
	transition: background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { background: var(--pill-hover); border-color: var(--line-2); }
.icon-btn .dot { position: absolute; top: 11px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--crit); box-shadow: 0 0 0 2px var(--bg); }
.menu-btn { display: none; }
/* Search field (opens the Ctrl+K palette); the round icon replaces it on narrow screens. */
.top-search { display: flex; align-items: center; gap: 10px; height: 46px; width: clamp(240px, 26vw, 380px); padding: 0 8px 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-3); font-size: 13.5px; cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease; box-shadow: var(--shadow-card); }
.top-search:hover { border-color: var(--line-2); color: var(--text-2); }
.top-search > span { flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search .kbd { padding: 3px 8px; border-radius: 999px; }
.search-btn { display: none; }
@media (max-width: 1100px) {
	.top-search { display: none; }
	.search-btn { display: grid; }
}

/* Dashboard greeting */
.greet { min-width: 0; }
.greet h1 { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.greet p { margin: 4px 0 0; color: var(--text-3); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.greet p strong { color: var(--text-2); font-weight: 600; }
.avatar-btn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; flex-shrink: 0; }
.avatar {
	width: 46px;
	height: 46px;
	border-radius: 50%;
	display: grid;
	place-items: center;
	font-weight: 700;
	font-size: 17px;
	color: #fff;
	background: linear-gradient(145deg, var(--brand-a), var(--brand-b));
	box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--line-2);
	overflow: hidden;
	flex-shrink: 0;
	user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; box-shadow: none; }
.avatar.md { width: 38px; height: 38px; font-size: 14px; box-shadow: none; }
.avatar.xl { width: 96px; height: 96px; font-size: 34px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2); }

.presence { display: flex; align-items: center; margin-right: 4px; }
.presence .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--bg); }
.presence .avatar:first-child { margin-left: 0; }

.pop-wrap { position: relative; }
.pop {
	position: absolute;
	right: 0;
	top: calc(100% + 10px);
	width: 300px;
	background: var(--surface-2);
	border: 1px solid var(--line);
	border-radius: 14px;
	box-shadow: var(--shadow-pop);
	padding: 8px;
	z-index: 40;
	animation: pop-in 0.14s ease-out;
}
.pop.wide { width: 380px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.pop-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; align-items: center; gap: 12px; }
.pop-head > div { min-width: 0; flex: 1; }
.pop-head strong { display: block; font-size: 14px; }
.pop-head span { color: var(--text-3); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-head .link-btn { margin-left: auto; flex: 0 0 auto; }
.pop a, .pop button.item {
	display: flex;
	align-items: center;
	gap: 11px;
	width: 100%;
	padding: 9px 10px;
	border-radius: 9px;
	color: var(--text-2);
	text-decoration: none;
	font-size: 13.5px;
	border: 0;
	background: none;
	cursor: pointer;
	text-align: left;
}
.pop a:hover, .pop button.item:hover { background: var(--pill); color: var(--text); }
.pop-scroll { max-height: min(420px, 60vh); overflow-y: auto; }
.notif { display: flex; gap: 11px; padding: 10px; border-radius: 9px; color: inherit; text-decoration: none; position: relative; }
a.notif:hover { background: var(--pill); }
.notif .n-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--pill); flex-shrink: 0; color: var(--text-2); }
.notif .n-ico.success { color: var(--good-text); }
.notif .n-ico.warning { color: var(--warn-text); }
.notif .n-ico.critical { color: var(--crit-text); }
.notif .n-ico.info { color: var(--info-text); }
.notif p { margin: 0; font-size: 13px; color: var(--text); line-height: 1.4; }
.notif .n-body { margin-top: 2px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.notif small { color: var(--text-3); font-size: 12px; }
.notif.unread::after { content: ""; position: absolute; right: 10px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--s1); }
.pop-empty { padding: 26px 12px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- Filters row ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 22px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: none; color: var(--text-2); font-weight: 600; font-size: 13px; padding: 7px 15px; border-radius: 9px; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--pill); color: var(--text); }
.seg.sm button { padding: 5px 11px; font-size: 12.5px; }
.switch { display: inline-flex; align-items: center; gap: 10px; border: 0; background: none; cursor: pointer; color: var(--text-2); font-size: 13.5px; padding: 6px 4px; text-align: left; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--pill); position: relative; transition: background 0.15s ease; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-3); transition: transform 0.18s ease, background 0.18s ease; }
.switch[aria-checked="true"] .track { background: var(--switch-on); }
.switch[aria-checked="true"] .track::after { transform: translateX(16px); background: var(--switch-knob); }
.switch:disabled { opacity: 0.5; cursor: not-allowed; }
.meta { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 12.5px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Dashboard grid ---------- */
.dash { display: grid; grid-template-columns: minmax(0, 2.15fr) minmax(320px, 1fr); gap: 22px; transition: opacity 0.2s ease; }
.refetching { opacity: 0.55; transition: opacity 0.2s ease; }
.col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.pair { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.pair .card { display: flex; flex-direction: column; }
.col.right .list-card { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.stack { display: flex; flex-direction: column; gap: 22px; }
.section-title { margin: 34px 0 14px; font-size: 19px; font-weight: 700; letter-spacing: -0.015em; display: flex; align-items: baseline; gap: 12px; }
.section-title:first-child { margin-top: 0; }
.section-title small { font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px 20px; min-width: 0; transition: border-color 0.2s ease; position: relative; box-shadow: var(--shadow-card); }
.card:hover { border-color: var(--line-2); }
.card.filled { background: var(--card-filled); border-color: var(--card-filled-line); }
.card.flat:hover { border-color: var(--line); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-head > div:first-child { flex: 1 1 auto; min-width: 0; }
.card-title { margin: 0; font-size: 16.5px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.card-sub { margin: 5px 0 0; font-size: 13px; color: var(--text-2); }
.fig { flex: 0 0 auto; text-align: right; }
.fig .num { font-size: 27px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fig .cap { margin-top: 5px; font-size: 12px; color: var(--text-3); display: flex; flex-direction: column; align-items: flex-end; gap: 3px; white-space: nowrap; }
.delta { display: inline-flex; align-items: center; gap: 3px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta .ico { width: 13px; height: 13px; stroke-width: 2.4; }
.delta.good .ico { color: var(--good); }
.delta.bad .ico { color: var(--crit); }

.tools { display: flex; align-items: center; gap: 12px; margin: 16px 0 2px; min-height: 28px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.key-line { width: 16px; height: 2px; border-radius: 2px; }
.key-dash { width: 16px; height: 2px; background: repeating-linear-gradient(90deg, var(--text-3) 0 4px, transparent 4px 7px); }
.key-rect { width: 10px; height: 10px; border-radius: 3px; }
.view-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: none; color: var(--text-3); font-size: 12px; padding: 5px 9px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.view-btn:hover { color: var(--text); background: var(--pill-hover); }
.view-btn[aria-pressed="true"] { color: var(--text); border-color: var(--line); }

/* Chart.js needs a box with an explicit height (responsive +
   maintainAspectRatio:false), x-axis included — otherwise it resizes in a loop. */
.chart-box { position: relative; height: 300px; margin-top: 10px; }
.chart-box.sm { height: auto; flex: 1 1 0; min-height: 220px; }
.chart-box.md { height: 260px; }
.chart-box.xs { height: 200px; }
/* Canvas out of the flow: it can never influence its box's height. */
.chart-box canvas, .donut-box canvas { position: absolute; inset: 0; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--text-3); font-size: 13px; padding: 20px; pointer-events: none; }
.chart-empty strong { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 4px; font-weight: 600; }
.donut-box { position: relative; height: 214px; margin-top: 12px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center .dc-num { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.donut-center .dc-cap { font-size: 12px; color: var(--text-3); }

.table-box { margin-top: 12px; max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.table-box table { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.table-box th, .table-box td { padding: 7px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-box th:first-child, .table-box td:first-child { text-align: left; }
.table-box th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-3); font-weight: 600; }

/* Tooltip bubble (from the reference) */
.tt {
	position: absolute;
	left: 0;
	top: 0;
	pointer-events: none;
	background: var(--bubble);
	border-radius: 10px;
	padding: 8px 12px 9px;
	font-size: 12px;
	box-shadow: var(--shadow-tip);
	opacity: 0;
	transition: opacity 0.12s ease;
	white-space: nowrap;
	border: 1px solid var(--bubble-line);
	z-index: 5;
}
.tt.show { opacity: 1; }
.tt-title { color: var(--text-2); font-size: 11.5px; margin-bottom: 4px; }
.tt-row { display: flex; align-items: center; gap: 8px; line-height: 1.75; }
.tt-row strong { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; font-size: 13px; }
.tt-row span { color: var(--text-2); }
.tt-key { width: 12px; height: 2px; border-radius: 2px; }
.tt-key.dash { background: repeating-linear-gradient(90deg, var(--text-2) 0 3px, transparent 3px 5px) !important; }
.tt-key.rect { width: 9px; height: 9px; border-radius: 3px; }

/* Tiles under the donut (colour key = donut segment) */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.tile { border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px 11px; min-width: 0; }
.tile .t-label { font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .t-val { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tile .rail { width: 3px; height: 15px; border-radius: 2px; flex-shrink: 0; }
.tile .t-val span:last-child { color: var(--text-3); margin-left: auto; }

/* Player list */
.link { color: var(--text-2); font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.link:hover { color: var(--text); }
.list-head { display: flex; justify-content: space-between; margin-top: 18px; padding: 9px 12px; border-radius: 9px; background: var(--pill); font-size: 13px; color: var(--text-2); }
.plist { list-style: none; margin: 4px 0 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 12px; padding: 11px 6px; border-bottom: 1px solid var(--line); }
.plist li:last-child { border-bottom: 0; }
.p-av { width: 34px; height: 34px; border-radius: 50%; background: var(--pill); display: grid; place-items: center; font-weight: 700; font-size: 13px; position: relative; flex-shrink: 0; text-transform: uppercase; }
.p-av .on { position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 2px var(--surface-2); }
.p-main { flex: 1 1 auto; min-width: 0; }
.p-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; white-space: nowrap; min-width: 0; }
.p-name > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.p-live { font-size: 11px; font-weight: 600; color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; line-height: 17px; flex-shrink: 0; }
.p-id { font: 11.5px var(--mono); word-spacing: normal; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-time { flex: 0 0 auto; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.list-empty { padding: 34px 10px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------- KPI tiles (statistics) ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1700px) { .kpis.six { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.timeline.wrap .tl-main > span { white-space: normal; }

/* Horizontal bar list (ranked categories, no chart library needed) */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.bar-list li { min-width: 0; }
.bar-list .list-empty { padding: 26px 10px; }
.bl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.bl-label { min-width: 0; color: var(--text); display: inline-flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-label code { font-size: 12.5px; }
.bl-value { color: var(--text-2); white-space: nowrap; font-size: 13px; }
.bl-track { margin-top: 6px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bl-fill { display: block; height: 100%; border-radius: 3px; }
.badge-row { display: inline-flex; flex-wrap: wrap; gap: 5px; }

/* Server crash reports (Statistics > Stability) */
.crash { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; }
.crash summary { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; list-style: none; }
.crash summary::-webkit-details-marker { display: none; }
.crash summary:hover { background: var(--row-hover); }
.crash[open] summary { border-bottom: 1px solid var(--line); }
.crash-main { min-width: 0; font-size: 13.5px; }
.crash-main > span { display: block; color: var(--text-3); font-size: 12.5px; }
.crash-suspect { display: block; margin-top: 5px; font-size: 12px; color: var(--crit-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crash-log { margin: 0; padding: 12px 14px; max-height: 320px; overflow: auto; background: var(--code-bg); color: var(--code-text); font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.crash-log .hl { background: rgba(208, 59, 59, 0.22); color: #ffd4d4; border-radius: 3px; }
.tl-ico.crit { background: rgba(208, 59, 59, 0.14); color: var(--crit-text); }
.timeline .tl-main .badge + .badge { margin-left: 4px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; min-width: 0; box-shadow: var(--shadow-card); }
.kpi .k-label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { margin-top: 8px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .k-foot { margin-top: 8px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 18px; }
.info-tip { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-2); color: var(--text-3); font-size: 10.5px; font-weight: 700; cursor: help; position: relative; flex-shrink: 0; }
.info-tip:hover, .info-tip:focus-visible { color: var(--text); border-color: var(--text-3); }
.info-tip .tip { display: none; position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: 260px; background: var(--bubble); color: var(--text); font-size: 12.5px; font-weight: 400; line-height: 1.5; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--bubble-line); box-shadow: var(--shadow-tip); z-index: 30; text-align: left; word-spacing: 0.04em; }
.info-tip:hover .tip, .info-tip:focus-visible .tip { display: block; }

/* Cohort triangle + heatmap */
.cohort { width: 100%; border-collapse: separate; border-spacing: 3px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cohort th { color: var(--text-3); font-weight: 600; padding: 4px 6px; text-align: center; white-space: nowrap; }
.cohort th:first-child, .cohort td:first-child { text-align: left; }
.cohort td { padding: 7px 6px; text-align: center; border-radius: 6px; white-space: nowrap; }
.cohort td.head { color: var(--text-2); background: none; padding-left: 0; }
.cohort td.size { color: var(--text-2); background: var(--pill); }
.cohort td.na { background: transparent; color: transparent; }
.cohort td.zero { background: var(--surface-3); color: var(--text-3); }
.scroll-x { overflow-x: auto; }
.heatmap { display: grid; grid-template-columns: 36px repeat(24, minmax(14px, 1fr)); gap: 4px; font-size: 11px; color: var(--text-3); min-width: 480px; }
.heatmap .hm-cell { height: 22px; border-radius: 4px; background: var(--surface-3); }
.heatmap .hm-row { display: contents; }
.heatmap .hm-day { align-self: center; }
.heatmap .hm-hour { text-align: center; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-3); margin-top: 12px; }
.scale .bar { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, color-mix(in srgb, var(--s1) 15%, transparent), var(--s1)); }

/* ---------- Buttons ---------- */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 40px;
	padding: 0 16px;
	border-radius: 11px;
	border: 1px solid var(--line);
	background: var(--surface-2);
	color: var(--text);
	font-weight: 600;
	font-size: 13.5px;
	cursor: pointer;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
	position: relative;
}
.btn:hover { background: var(--pill); border-color: var(--line-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: rgba(208, 59, 59, 0.12); border-color: rgba(208, 59, 59, 0.45); color: var(--crit-text); }
.btn.danger:hover { background: rgba(208, 59, 59, 0.2); border-color: var(--crit); }
.btn.danger.solid { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.danger.solid:hover { background: var(--crit-hover); border-color: var(--crit-hover); }
.btn.success { background: rgba(12, 163, 12, 0.12); border-color: rgba(12, 163, 12, 0.45); color: var(--good-text); }
.btn.success:hover { background: rgba(12, 163, 12, 0.2); border-color: var(--good); }
.btn.warn { background: rgba(250, 178, 25, 0.1); border-color: rgba(250, 178, 25, 0.4); color: var(--warn-text); }
.btn.warn:hover { background: rgba(250, 178, 25, 0.18); border-color: var(--warn); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--pill-hover); color: var(--text); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; gap: 6px; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading > * { visibility: hidden; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; animation: spin 0.7s linear infinite; }
.btn:not(.primary):not(.danger.solid).loading::after { border-color: var(--line-2); border-top-color: var(--text); }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-size: 13px; font-weight: 600; }
.link-btn:hover { color: var(--link-hover); text-decoration: underline; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--s1); animation: spin 0.7s linear infinite; display: inline-block; flex-shrink: 0; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12.5px; color: var(--text-3); }
.field .error { font-size: 12.5px; color: var(--crit-text); }
.input, .select, .textarea {
	width: 100%;
	height: 42px;
	padding: 0 14px;
	border-radius: 11px;
	border: 1px solid var(--line);
	background: var(--bg);
	color: var(--text);
	font-size: 14px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { height: auto; min-height: 110px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px var(--focus-ring); }
.input.invalid { border-color: var(--crit); }
.input.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.input.code { font-family: var(--mono); font-size: 22px; letter-spacing: 0.4em; text-align: center; height: 54px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a95aa' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 38px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .ico { position: absolute; left: 13px; color: var(--text-3); pointer-events: none; }
.input-wrap .input { padding-left: 40px; }
.input-wrap .suffix { position: absolute; right: 6px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text); padding: 6px 0; }
.check input { appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); background: var(--bg); margin: 1px 0 0; flex-shrink: 0; cursor: pointer; display: grid; place-items: center; transition: background 0.12s ease, border-color 0.12s ease; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.check input:disabled { opacity: 0.5; cursor: not-allowed; }
.check small { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.perm-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 0; min-width: 0; }
.perm-group legend { padding: 0 4px; margin-left: -4px; }
.perm-group legend .check { padding: 0; font-size: 13.5px; }
.perm-items { display: grid; gap: 0; padding-left: 28px; }
.perm-items .check { font-size: 13px; color: var(--text-2); }
.check input:indeterminate { background: var(--accent); border-color: var(--accent); }
.check input:indeterminate::after { content: ""; width: 8px; height: 2px; background: #fff; border: 0; transform: none; }
@media (max-width: 700px) { .perm-grid { grid-template-columns: minmax(0, 1fr); } }
.pw-meter { height: 5px; border-radius: 3px; background: var(--pill); overflow: hidden; }
.pw-meter i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width 0.2s ease, background 0.2s ease; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--pill); color: var(--text-2); white-space: nowrap; line-height: 18px; }
.badge.ok { background: rgba(12, 163, 12, 0.14); color: var(--good-text); }
.badge.warn { background: rgba(250, 178, 25, 0.13); color: var(--warn-text); }
.badge.crit { background: rgba(208, 59, 59, 0.16); color: var(--crit-text); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); }
.badge.violet { background: var(--violet-bg); color: var(--violet-text); }
.badge .status-dot { width: 7px; height: 7px; box-shadow: none; }

/* ---------- Data tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-card); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: var(--row-hover); }
.table tr.highlight td { background: rgba(250, 178, 25, 0.07); }
.table .r { text-align: right; }
.table .nowrap { white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 6px; }
.table.compact td, .table.compact th { padding: 8px 12px; }
.table.data td { font-family: var(--mono); font-size: 12.5px; word-spacing: normal; white-space: nowrap; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.table.data td.null { color: var(--text-3); font-style: italic; }
.th-sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--text); }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-user strong { display: block; font-weight: 600; white-space: nowrap; }
.cell-user div > span { display: block; color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-user div > span.badge { display: inline-flex; margin-top: 3px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 0; color: var(--text-3); font-size: 13px; flex-wrap: wrap; }

/* ---------- Empty states & notices ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty .e-ico { width: 56px; height: 56px; border-radius: 16px; background: var(--pill); display: grid; place-items: center; margin: 0 auto 16px; color: var(--text-2); }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); font-weight: 600; }
.empty p { margin: 0 auto; max-width: 440px; font-size: 13.5px; line-height: 1.6; color: var(--text-2); }
.empty .btn-row { justify-content: center; margin-top: 18px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13.5px; line-height: 1.55; color: var(--text-2); }
.notice .ico { margin-top: 1px; }
.notice strong { color: var(--text); }
.notice.info { border-color: var(--accent-line); background: var(--accent-wash); }
.notice.info > .ico { color: var(--info-text); }
.notice.warn { border-color: rgba(250, 178, 25, 0.35); background: rgba(250, 178, 25, 0.06); }
.notice.warn > .ico { color: var(--warn-text); }
.notice.crit { border-color: rgba(208, 59, 59, 0.4); background: rgba(208, 59, 59, 0.07); }
.notice.crit > .ico { color: var(--crit-text); }
.notice.ok { border-color: rgba(12, 163, 12, 0.35); background: rgba(12, 163, 12, 0.06); }
.notice.ok > .ico { color: var(--good-text); }
.notice > div { flex: 1; min-width: 0; }
.notice .btn-row { margin-top: 10px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--pill) 50%, var(--surface-2) 75%); background-size: 400px 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 8px; color: transparent !important; }
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: 200px 0; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--backdrop); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade 0.15s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: min(460px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-modal); padding: 24px; animation: modal-in 0.18s ease-out; }
.modal.lg { width: min(620px, 100%); }
.modal.xl { width: min(900px, 100%); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.modal-head .m-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--pill); flex-shrink: 0; color: var(--text-2); }
.modal-head .m-ico.danger { background: rgba(208, 59, 59, 0.14); color: var(--crit-text); }
.modal-head .m-ico.warn { background: rgba(250, 178, 25, 0.12); color: var(--warn-text); }
.modal-head .m-ico.ok { background: rgba(12, 163, 12, 0.14); color: var(--good-text); }
.modal-head .m-ico.info { background: var(--accent-soft); color: var(--info-text); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.modal-head p { margin: 6px 0 0; color: var(--text-2); font-size: 13.5px; line-height: 1.55; }
.modal-body { font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.secret-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 11px; background: var(--bg); border: 1px dashed var(--line-2); font-family: var(--mono); font-size: 16px; letter-spacing: 0.04em; word-spacing: normal; color: var(--text); }
.secret-box span { flex: 1; overflow-wrap: anywhere; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 14px; background: var(--bubble); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop); font-size: 13.5px; line-height: 1.45; color: var(--text); animation: toast-in 0.2s ease-out; }
.toast.leaving { animation: toast-out 0.18s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
.toast .t-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: var(--pill); }
.toast.success .t-ico { color: var(--good-text); }
.toast.error .t-ico { color: var(--crit-text); }
.toast.warning .t-ico { color: var(--warn-text); }
.toast.info .t-ico { color: var(--info-text); }
.toast > div { flex: 1; min-width: 0; padding-top: 2px; }
.toast strong { display: block; font-weight: 600; }
.toast span { color: var(--text-2); font-size: 13px; }
.toast .t-close { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 2px; border-radius: 6px; }
.toast .t-close:hover { color: var(--text); }
.toast .t-action { margin-top: 6px; }

/* ---------- Command palette (Ctrl+K) ---------- */
.palette-backdrop { position: fixed; inset: 0; background: var(--backdrop); backdrop-filter: blur(2px); z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; animation: fade 0.12s ease-out; }
.palette { width: min(620px, 100%); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow-modal); overflow: hidden; animation: modal-in 0.15s ease-out; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; height: 56px; background: none; border: 0; outline: none; font-size: 16px; color: var(--text); }
.palette-input kbd, .kbd { font: 600 11px var(--font); color: var(--text-3); border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--surface); white-space: nowrap; }
.palette-list { max-height: min(420px, 55vh); overflow-y: auto; padding: 8px; }
.palette-group { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 10px 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; cursor: pointer; color: var(--text-2); font-size: 14px; }
.palette-item .pi-text { flex: 1; min-width: 0; }
.palette-item .pi-text strong { display: block; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-text span { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item[aria-selected="true"] { background: var(--pill); color: var(--text); }
.palette-empty { padding: 30px; text-align: center; color: var(--text-3); font-size: 13.5px; }
.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }

/* ---------- Context menu ---------- */
.ctx { position: fixed; z-index: 160; min-width: 210px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; animation: pop-in 0.1s ease-out; }
.ctx button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--text-2); font-size: 13.5px; cursor: pointer; text-align: left; }
.ctx button:hover, .ctx button:focus-visible { background: var(--pill); color: var(--text); outline: none; }
.ctx button.danger { color: var(--crit-text); }
.ctx button.danger:hover { background: rgba(208, 59, 59, 0.14); }
.ctx button .kbd { margin-left: auto; }
.ctx button:disabled, .ctx button:disabled:hover { opacity: 0.6; cursor: not-allowed; background: none; color: var(--text-3); }
.ctx hr { border: 0; height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- Console ---------- */
.console-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .console-layout { grid-template-columns: minmax(0, 1fr); } }
.server-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.state-pill { display: inline-flex; align-items: center; gap: 10px; padding: 9px 16px 9px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 14px; white-space: nowrap; }
.state-pill small { font-weight: 500; color: var(--text-3); font-size: 12.5px; }
.state-facts { display: flex; gap: 22px; color: var(--text-3); font-size: 13px; flex-wrap: wrap; }
.state-facts strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.steps { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); }
.steps .st { display: inline-flex; align-items: center; gap: 6px; }
.steps .st.done { color: var(--good-text); }
.steps .st.active { color: var(--text); }
.steps .sep { width: 16px; height: 1px; background: var(--line-2); }
.console-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.console-tools { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.console-tools .input-wrap { flex: 1 1 220px; max-width: 320px; }
.console-tools .input { height: 34px; font-size: 13px; }
.console-out {
	background: var(--code-bg);
	height: calc(100vh - 360px);
	min-height: 320px;
	overflow-y: auto;
	padding: 14px 18px;
	font: 12.5px/1.65 var(--mono);
	word-spacing: normal;
	color: var(--code-text);
	white-space: pre-wrap;
	word-break: break-word;
	tab-size: 4;
}
.console-out .ln { display: block; padding: 0 4px; border-radius: 4px; }
.console-out .ln:hover { background: var(--code-hover); }
.console-out .ln.hl { background: rgba(250, 178, 25, 0.1); }
.console-out mark { background: rgba(250, 178, 25, 0.35); color: #fff; border-radius: 2px; }
.console-out .sys { color: var(--code-info); }
.console-foot { display: flex; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: center; position: relative; }
.console-foot .prompt { color: var(--s1); font: 600 14px var(--mono); }
.console-foot .input { font-family: var(--mono); font-size: 13px; word-spacing: normal; }
.console-paused { position: absolute; right: 26px; bottom: 76px; }
.suggest { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 6px); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-pop); padding: 6px; max-height: 260px; overflow-y: auto; z-index: 10; }
.suggest div { display: flex; gap: 14px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.suggest div[aria-selected="true"], .suggest div:hover { background: var(--pill); }
.suggest code { font-family: var(--mono); color: var(--text); word-spacing: normal; white-space: nowrap; }
.suggest span { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ansi-red { color: #f07575; } .ansi-green { color: #62cf7a; } .ansi-yellow { color: #f3c24f; } .ansi-blue { color: #74aef0; }
.ansi-magenta { color: #d58ae6; } .ansi-cyan { color: #5fcbd9; } .ansi-gray { color: #7b869c; } .ansi-white { color: #eef1f6; } .ansi-bold { font-weight: 700; }

/* ---------- Files ---------- */
.fm { display: grid; grid-template-columns: minmax(280px, 400px) minmax(0, 1fr); gap: 18px; height: calc(100vh - 150px); min-height: 520px; }
.fm-pane { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; position: relative; box-shadow: var(--shadow-card); }
.fm-pane.tree { container-type: inline-size; }
.fm-toolbar { display: flex; align-items: center; gap: 5px; padding: 9px; border-bottom: 1px solid var(--line); }
/* Narrow explorer: the toolbar keeps one row, icons only (labels stay as tooltips). */
@container (max-width: 390px) {
	.fm-toolbar .btn > span { display: none; }
	.fm-toolbar .btn { width: 34px; padding: 0; }
}
.fm-toolbar .grow { flex: 1; }
.crumbs { display: flex; align-items: center; gap: 2px; padding: 10px 14px; font-size: 13px; color: var(--text-3); border-bottom: 1px solid var(--line); overflow-x: auto; white-space: nowrap; min-height: 42px; }
.crumbs button { background: none; border: 0; color: var(--text-2); cursor: pointer; padding: 3px 6px; border-radius: 6px; font-size: 13px; }
.crumbs button:hover { background: var(--pill-hover); color: var(--text); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.fm-filter { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.fm-filter .input { height: 34px; font-size: 13px; }
.fm-list { flex: 1; overflow-y: auto; padding: 6px; outline: none; }
.fm-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; }
.fm-row:hover { background: var(--pill-hover); color: var(--text); }
.fm-row.selected { background: var(--pill); color: var(--text); }
.fm-row.open { box-shadow: inset 3px 0 0 var(--s1); }
.fm-row.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--s1); }
.fm-row .f-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-row .f-meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.fm-row .ico { width: 18px; height: 18px; }
.fm-row .ico.dir { color: var(--ico-dir); }
.fm-row .ico.lua { color: var(--ico-lua); }
.fm-row .ico.cfg { color: var(--ico-cfg); }
.fm-row .ico.data { color: var(--ico-data); }
.fm-row .ico.img { color: var(--ico-img); }
.fm-status { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); display: flex; justify-content: space-between; gap: 10px; }
.drop-overlay { position: absolute; inset: 8px; border: 2px dashed var(--s1); border-radius: 14px; background: var(--overlay); display: grid; place-items: center; text-align: center; z-index: 20; pointer-events: none; color: var(--text); font-weight: 600; }
.drop-overlay span { display: block; margin-top: 6px; color: var(--text-2); font-weight: 400; font-size: 13px; }
.drop-overlay.locked { border-color: var(--text-3); color: var(--text-2); }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); min-height: 58px; flex-wrap: wrap; }
.ed-title { flex: 1; min-width: 0; }
.ed-title strong { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-title span { display: block; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.ed-body { flex: 1; min-height: 0; position: relative; }
.ed-body .CodeMirror { height: 100%; }
.ed-foot { display: flex; gap: 18px; padding: 7px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ed-foot .grow { flex: 1; }
.ed-empty { position: absolute; inset: 0; display: grid; place-items: center; }

/* CodeMirror 5 — dark theme matched to the dashboard (no white corners or
   default scrollbars anywhere). */
.CodeMirror { background: var(--code-bg); color: var(--code-text); font: 13px/1.6 var(--mono); word-spacing: normal; }
.CodeMirror-gutters { background: var(--code-bg); border-right: 1px solid var(--code-line); }
.CodeMirror-linenumber { color: var(--code-muted); padding: 0 10px 0 6px; }
.CodeMirror-activeline-background { background: var(--code-active); }
.CodeMirror-activeline-gutter .CodeMirror-linenumber { color: var(--code-text); }
.CodeMirror-cursor { border-left: 2px solid var(--code-cursor); }
.CodeMirror-selected { background: var(--code-sel) !important; }
.CodeMirror-focused .CodeMirror-selected { background: var(--code-sel) !important; }
.CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: var(--code-sel); }
.CodeMirror-matchingbracket { color: #ffffff !important; background: var(--code-sel); border-radius: 2px; }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background: var(--code-bg); }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar { scrollbar-color: var(--code-scroll) var(--code-bg); }
.CodeMirror-vscrollbar::-webkit-scrollbar-track, .CodeMirror-hscrollbar::-webkit-scrollbar-track { background: var(--code-bg); }
.CodeMirror-dialog { background: var(--code-bg-2); color: var(--code-text); border-color: var(--code-line) !important; padding: 8px 12px; font-family: var(--font); font-size: 13px; }
.CodeMirror-dialog input { background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 6px; color: var(--code-text); padding: 3px 8px; font-family: var(--mono); outline: none; width: 18em; }
.CodeMirror-dialog button { background: var(--code-bg-2); border: 1px solid var(--code-line); color: var(--code-text); border-radius: 6px; padding: 2px 10px; cursor: pointer; }
.cm-searching { background: rgba(250, 178, 25, 0.3); }
.cm-s-valhalla .cm-keyword { color: #c792ea; }
.cm-s-valhalla .cm-atom, .cm-s-valhalla .cm-number { color: #f3a15a; }
.cm-s-valhalla .cm-def { color: #82aaff; }
.cm-s-valhalla .cm-variable { color: var(--code-text); }
.cm-s-valhalla .cm-variable-2 { color: #9ec3f5; }
.cm-s-valhalla .cm-variable-3, .cm-s-valhalla .cm-type { color: #ffcb6b; }
.cm-s-valhalla .cm-property { color: #80cbc4; }
.cm-s-valhalla .cm-operator { color: #89ddff; }
.cm-s-valhalla .cm-comment { color: #5f6e88; font-style: italic; }
.cm-s-valhalla .cm-string, .cm-s-valhalla .cm-string-2 { color: #a5d97c; }
.cm-s-valhalla .cm-builtin { color: #ffcb6b; }
.cm-s-valhalla .cm-bracket, .cm-s-valhalla .cm-punctuation { color: #9aa6bd; }
.cm-s-valhalla .cm-tag { color: #f07178; }
.cm-s-valhalla .cm-attribute { color: #c792ea; }
.cm-s-valhalla .cm-header { color: #82aaff; font-weight: 700; }
.cm-s-valhalla .cm-meta, .cm-s-valhalla .cm-qualifier { color: #ffcb6b; }
.cm-s-valhalla .cm-error { color: #f07575; }

/* Diff view in the history dialog */
.diff { font: 12px/1.6 var(--mono); word-spacing: normal; background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 10px; max-height: 50vh; overflow: auto; padding: 8px 0; white-space: pre; }
.diff .d-add { background: rgba(12, 163, 12, 0.14); color: #9fe39f; display: block; padding: 0 12px; }
.diff .d-del { background: rgba(208, 59, 59, 0.14); color: #f5a3a3; display: block; padding: 0 12px; }
.diff .d-ctx { color: var(--code-dim); display: block; padding: 0 12px; }
.diff .d-gap { color: var(--code-dim); display: block; padding: 2px 12px; background: var(--code-bg-2); }

/* ---------- Database ---------- */
.db-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.db-tables { position: sticky; top: 0; }
.db-tables .list { max-height: calc(100vh - 360px); overflow-y: auto; margin: 10px -8px 0; }
.db-tables button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 9px; background: none; color: var(--text-2); cursor: pointer; text-align: left; font-size: 13.5px; }
.db-tables button:hover { background: var(--pill-hover); color: var(--text); }
.db-tables button[aria-current="true"] { background: var(--pill); color: var(--text); }
.db-tables button span:first-of-type { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-tables button small { color: var(--text-3); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.fact { min-width: 0; }
.fact dt { font-size: 12.5px; color: var(--text-3); }
.fact dd { margin: 4px 0 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sql-editor .CodeMirror { height: 150px; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- Account ---------- */
.profile-card { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.profile-card .avatar-edit { position: relative; }
.profile-card .avatar-edit .btn { position: absolute; right: -6px; bottom: -6px; border-radius: 50%; width: 34px; height: 34px; padding: 0; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.row-list { list-style: none; margin: 0; padding: 0; }
.row-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.row-list li:last-child { border-bottom: 0; }
.row-list .grow { flex: 1; min-width: 0; }
.row-list .grow strong { display: block; font-weight: 600; }
.row-list .grow > span { display: block; color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guide { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 13.5px; color: var(--text-2); line-height: 1.55; }
.guide li::marker { color: var(--s1); font-weight: 700; }
.guide strong { color: var(--text); }
.guide code { font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--text); overflow-wrap: anywhere; }
.code-template { border: 1px solid var(--code-line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-template-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; background: var(--code-bg-2); border-bottom: 1px solid var(--code-line); color: var(--code-dim); font-size: 12.5px; }
.code-template-head .btn { background: var(--code-bg); border-color: var(--code-line); color: var(--code-text); }
.code-template-head .btn:hover { background: var(--code-bg-2); border-color: var(--code-muted); }
.code-template pre { margin: 0; padding: 12px 14px; font-size: 12.5px; line-height: 1.6; color: var(--code-text); overflow-x: auto; }

/* Theme picker: each preview is a miniature dashboard in its own theme. */
.theme-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.theme-opt { display: flex; flex-direction: column; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; overflow: hidden; text-align: left; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.theme-opt:hover { border-color: var(--line-2); }
.theme-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.tp { display: grid; grid-template-columns: 24% minmax(0, 1fr); height: 132px; background: var(--bg); border-bottom: 1px solid var(--line); }
.tp-side { background: var(--side); border-right: 1px solid var(--side-line); padding: 12px 9px; display: flex; flex-direction: column; gap: 7px; }
.tp-side i { display: block; height: 6px; border-radius: 3px; background: var(--pill); }
.tp-side i.tp-brand { width: 70%; height: 9px; margin-bottom: 4px; background: linear-gradient(90deg, var(--brand-a), var(--brand-b)); }
.tp-side i.on { background: var(--line-2); }
.tp-main { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tp-head i { display: block; height: 8px; width: 46%; border-radius: 4px; background: var(--text); opacity: 0.85; }
.tp-head b { display: block; height: 12px; width: 30%; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.tp-cards { flex: 1; display: grid; grid-template-columns: 1.6fr 1fr; gap: 7px; min-height: 0; }
.tp-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.tp-card svg { position: absolute; left: 0; right: 0; bottom: 6px; width: 100%; height: 62%; }
.tp-card path { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.tp-card .tp-l1 { stroke: var(--s1); }
.tp-card .tp-l2 { stroke: var(--s2); }
.tp-bars { display: flex; align-items: flex-end; justify-content: center; gap: 4px; padding: 8px 8px 7px; }
.tp-bars i { display: block; width: 7px; border-radius: 2px 2px 0 0; }
.tp-bars i:nth-child(1) { height: 40%; background: var(--s1); }
.tp-bars i:nth-child(2) { height: 70%; background: var(--s2); }
.tp-bars i:nth-child(3) { height: 52%; background: var(--s3); }
.tp-bars i:nth-child(4) { height: 84%; background: var(--s4); }
.to-foot { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.to-text { flex: 1; min-width: 0; }
.to-text strong { display: block; font-size: 14px; font-weight: 600; }
.to-text small { display: block; color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.to-radio { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); flex-shrink: 0; display: grid; place-items: center; transition: border-color 0.15s ease; }
.theme-opt[aria-checked="true"] .to-radio { border-color: var(--accent); }
.theme-opt[aria-checked="true"] .to-radio::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
@media (max-width: 900px) { .theme-grid { grid-template-columns: minmax(0, 1fr); } }
/* Guide page */
.doc-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 26px; align-items: start; }
.doc-toc { position: sticky; top: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-toc .label { padding: 0 12px 8px; }
.doc-toc a { padding: 7px 12px; border-radius: 9px; color: var(--text-2); text-decoration: none; font-size: 13.5px; }
.doc-toc a:hover { background: var(--pill-hover); color: var(--text); }
.doc-toc a[aria-current="true"] { background: var(--pill); color: var(--text); font-weight: 600; }
.doc { display: flex; flex-direction: column; gap: 22px; min-width: 0; max-width: 920px; }
.doc section { scroll-margin-top: 12px; }
.doc h2 { margin: 0 0 10px; font-size: 20px; letter-spacing: -0.015em; }
.doc h3 { margin: 22px 0 8px; font-size: 15px; color: var(--text); }
.doc p { margin: 0 0 12px; color: var(--text-2); font-size: 14px; line-height: 1.65; }
.doc code { font: 12.5px var(--mono); word-spacing: normal; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--text); }
.doc .guide { margin-top: 4px; }
.defs { margin: 6px 0 0; display: grid; grid-template-columns: minmax(170px, 230px) minmax(0, 1fr); border-top: 1px solid var(--line); }
.defs dt, .defs dd { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; line-height: 1.6; }
.defs dt { font-weight: 600; color: var(--text); padding-right: 18px; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.defs dd { margin: 0; color: var(--text-2); }
.defs .info-tip { vertical-align: -3px; cursor: default; }
@media (max-width: 1100px) {
	.doc-layout { grid-template-columns: minmax(0, 1fr); }
	.doc-toc { position: static; flex-direction: row; flex-wrap: wrap; }
	.doc-toc .label { width: 100%; }
}
@media (max-width: 640px) {
	.defs { grid-template-columns: minmax(0, 1fr); }
	.defs dt { border-bottom: 0; padding-bottom: 2px; }
	.defs dd { padding-top: 0; }
}
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 200px; height: 200px; display: block; margin: 0 auto 14px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); align-items: center; }
.timeline li:last-child { border-bottom: 0; }
.tl-ico { width: 34px; height: 34px; border-radius: 50%; background: var(--pill); display: grid; place-items: center; color: var(--text-2); }
.timeline .tl-main { min-width: 0; font-size: 13.5px; }
.timeline .tl-main > span { display: block; color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline .tl-main .badge { display: inline-flex; vertical-align: 1px; }
.timeline .tl-time, .crash .tl-time { font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(900px 500px at 15% -10%, var(--glow-a), transparent 60%), radial-gradient(700px 500px at 110% 110%, var(--glow-b), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 32px 32px 28px; box-shadow: var(--shadow-auth); }
.auth-card .brand { padding: 0 0 26px; }
.auth-card h1 { margin: 0; font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.auth-card .lead { margin: 8px 0 24px; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.auth-card .btn.block { width: 100%; height: 46px; font-size: 14.5px; }
.auth-foot { margin-top: 20px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.auth-foot a { color: var(--text-2); text-decoration: none; }
.auth-foot a:hover { color: var(--text); text-decoration: underline; }
.auth-note { margin-top: 22px; text-align: center; font-size: 12px; color: var(--text-3); }
.form-error { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 11px; background: rgba(208, 59, 59, 0.1); border: 1px solid rgba(208, 59, 59, 0.35); color: var(--error-text); font-size: 13px; margin-bottom: 16px; line-height: 1.45; }
.form-error .ico { color: var(--crit-text); margin-top: 1px; }
.form-ok { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 11px; background: rgba(12, 163, 12, 0.09); border: 1px solid rgba(12, 163, 12, 0.35); color: var(--ok-text); font-size: 13px; margin-bottom: 16px; line-height: 1.45; }
.form-ok .ico { color: var(--good-text); margin-top: 1px; }

/* ---------- 404 ---------- */
.notfound { min-height: 100%; display: grid; place-items: center; text-align: center; padding: 24px; }
.notfound .big { font-size: 64px; font-weight: 800; letter-spacing: -0.04em; background: linear-gradient(145deg, var(--brand-a), var(--brand-b)); -webkit-background-clip: text; background-clip: text; color: transparent; }

@media (prefers-reduced-motion: no-preference) {
	.status-dot.online { animation: pulse 2.4s ease-out infinite; }
	@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.45); } 70% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
	.status-dot.busy { animation: pulse-warn 1.4s ease-out infinite; }
	@keyframes pulse-warn { 0% { box-shadow: 0 0 0 0 rgba(250, 178, 25, 0.5); } 70% { box-shadow: 0 0 0 7px rgba(250, 178, 25, 0); } 100% { box-shadow: 0 0 0 0 rgba(250, 178, 25, 0); } }
	.main-inner > * { animation: rise 0.28s ease-out backwards; }
	@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
	.kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
	.kpis.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 1300px) {
	.kpis.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1240px) {
	.dash { grid-template-columns: minmax(0, 1fr); }
	.col.right { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.settings-grid { grid-template-columns: minmax(0, 1fr); }
	.fm { grid-template-columns: minmax(240px, 300px) minmax(0, 1fr); }
}
@media (max-width: 1100px) {
	.kpis, .kpis.five, .kpis.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.db-layout { grid-template-columns: minmax(0, 1fr); }
	.db-tables { position: static; }
	.db-tables .list { max-height: 260px; }
}
@media (max-width: 900px) {
	.app { grid-template-columns: minmax(0, 1fr); }
	.side { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 60; transform: translateX(-100%); transition: transform 0.2s ease, box-shadow 0.2s ease; }
	/* Shadow only while open: off-canvas it would bleed onto the page edge. */
	.app.nav-open .side { transform: none; box-shadow: 20px 0 50px rgba(0, 0, 0, 0.4); }
	.menu-btn { display: grid; }
	.main-inner { padding: 20px 16px 36px; }
	.pair, .col.right, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
	.top h1 { font-size: 22px; }
	.meta { margin-left: 0; }
	.presence { display: none; }
	.fm { grid-template-columns: minmax(0, 1fr); height: auto; }
	.fm-pane.tree { height: 420px; }
	.fm-pane.editor { height: 70vh; }
	.console-out { height: 60vh; }
}
@media (max-width: 480px) {
	.greet h1 { font-size: 21px; white-space: normal; line-height: 1.25; }
	.greet p { white-space: normal; }
	.top-actions { gap: 8px; }
	.top-actions .search-btn { display: none; }
	.icon-btn, .avatar { width: 40px; height: 40px; }
	.fig .num { font-size: 23px; }
	.card { padding: 18px 16px 16px; }
	.pop, .pop.wide { width: min(300px, calc(100vw - 32px)); }
	.kpis, .kpis.five, .kpis.six { grid-template-columns: minmax(0, 1fr); }
	.auth-card { padding: 26px 20px 22px; }
	.modal { padding: 20px 18px; }
}
