/* kotpan design system: tokens, base, components, motion.
   Taken from AccountsPanel www/styles.css + additions.css + bots.css (state as of 2026-11-15) and gathered into one sheet.
   Screens are built only from the tokens below. Description and rules: DESIGN_SYSTEM.md */

/* ---------- Fonts: IBM Plex Sans 400/500/600 (text), Unbounded 500/600 (headings) ---------- */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: block; src: url("fonts/ibm-plex-sans-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: block; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: block; src: url("fonts/ibm-plex-sans-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: block; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: block; src: url("fonts/ibm-plex-sans-cyrillic-600-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: block; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500; font-display: block; src: url("fonts/unbounded-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 500; font-display: block; src: url("fonts/unbounded-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 600; font-display: block; src: url("fonts/unbounded-cyrillic-600-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 600; font-display: block; src: url("fonts/unbounded-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- Tokens: dark theme (the main one) ---------- */

:root {
	color-scheme: dark;

	/* Neutral base: cold gray leaning towards the accent */
	--bg: #0f1113;
	--surface: #15181b;
	--raised: #1d2125;
	--raised-hover: #242a2f;
	--divider: #2b3036;
	--field-border: #5a626a;

	--text: #e6e9ec;
	--text-muted: #a3aab1;
	--text-quiet: #868e96;

	--accent: #3db5bf;
	--accent-hover: #52c3cc;
	--on-accent: #071a1c;
	--accent-soft: rgb(61 181 191 / 0.14);

	--ok: #4cc38a;
	--warn: #e0a54a;
	--danger: #f07a69;
	--danger-soft: rgb(240 122 105 / 0.12);
	--warn-soft: rgb(224 165 74 / 0.12);

	--shadow-float: 0 12px 32px rgb(0 0 0 / 0.5), 0 0 0 1px var(--divider);

	/* Type 13 · 15 · 17 · 20 · 24 · 32 */
	--font-text: "IBM Plex Sans", system-ui, sans-serif;
	--font-display: "Unbounded", "IBM Plex Sans", system-ui, sans-serif;
	--font-mono: ui-monospace, "SF Mono", Menlo, monospace;
	--fs-13: 0.8125rem;
	--fs-15: 0.9375rem;
	--fs-17: 1.0625rem;
	--fs-20: 1.25rem;
	--fs-24: 1.5rem;
	--fs-32: 2rem;

	/* Spacing 4 · 8 · 12 · 16 · 24 · 32 · 48 */
	--s-4: 0.25rem;
	--s-8: 0.5rem;
	--s-12: 0.75rem;
	--s-16: 1rem;
	--s-24: 1.5rem;
	--s-32: 2rem;
	--s-48: 3rem;

	/* Radii 6 · 12 · 16 · 24 · round */
	--r-6: 6px;
	--r-12: 12px;
	--r-16: 16px;
	--r-24: 24px;
	--r-round: 999px;

	--control-h: 2.5rem;  /* 40px: buttons, fields, menu items */
	--hit: 2.75rem;       /* 44px: icon buttons, touch target */
	--sidebar-w: 14.5rem; /* 232px */
	--gutter: var(--s-24);

	/* Motion */
	--ease-out: cubic-bezier(0.2, 0, 0, 1);
	--ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
	--t-fast: 120ms;
	--t-base: 180ms;
	--motion: 150ms var(--ease-out);
}

/* ---------- Tokens: light theme. Its own values, not an inversion. theme.js switches this block ---------- */

@media (prefers-color-scheme: light) {
	:root {
		color-scheme: light;

		--bg: #f2f4f5;
		--surface: #fafbfb;
		--raised: #e6eaec;
		--raised-hover: #dce1e4;
		--divider: #d5dbde;
		--field-border: #8a949b;

		--text: #14181b;
		--text-muted: #4a535a;
		--text-quiet: #5e6870;

		--accent: #0b6f7a;
		--accent-hover: #095e67;
		--on-accent: #f4fbfc;
		--accent-soft: rgb(11 111 122 / 0.1);

		--ok: #1d7a4c;
		--warn: #8a5700;
		--danger: #b83a2a;
		--danger-soft: rgb(184 58 42 / 0.08);
		--warn-soft: rgb(138 87 0 / 0.08);

		--shadow-float: 0 12px 32px rgb(20 24 27 / 0.14), 0 0 0 1px var(--divider);
	}
}

@media (max-width: 47.99rem) {
	:root {
		--gutter: var(--s-16);
	}
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--font-text);
	font-size: var(--fs-15);
	line-height: 1.45;
	font-variant-numeric: tabular-nums;
	overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

.sprite { display: none; }

.icon {
	width: 1rem;
	height: 1rem;
	flex-shrink: 0;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.5;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.icon-20 { width: 1.25rem; height: 1.25rem; }

.display {
	font-family: var(--font-display);
	font-weight: 600;
	letter-spacing: -0.01em;
	line-height: 1.15;
}

.muted { color: var(--text-muted); }
.quiet { color: var(--text-quiet); }
.small { font-size: var(--fs-13); }
.mono { font-family: var(--font-mono); font-size: var(--fs-13); }
.is-ok { color: var(--ok); }
.is-warn { color: var(--warn); }
.is-danger { color: var(--danger); }

.visually-hidden {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.stack { display: flex; flex-direction: column; gap: var(--s-12); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-48); }

.section-title {
	color: var(--text-muted);
	font-size: var(--fs-13);
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

/* Logo + name. The mark is painted with the accent, so it follows the theme */
.wordmark {
	display: flex;
	align-items: center;
	gap: 0.5em;
	font-family: var(--font-display);
	font-weight: 500;
	font-size: var(--fs-15);
	letter-spacing: -0.01em;
}

.wordmark::before {
	content: "";
	flex-shrink: 0;
	width: 1.5em;
	height: 1.5em;
	background: var(--accent);
	--logo-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='5 5 38 38'%3E%3Cmask id='head'%3E%3Cpath d='M9 40V9l10 8h10l10-8v31z' fill='%23fff' stroke='%23fff' stroke-width='4' stroke-linejoin='round'/%3E%3Crect x='16' y='25' width='4' height='8' rx='2' fill='%23000'/%3E%3Crect x='28' y='25' width='4' height='8' rx='2' fill='%23000'/%3E%3C/mask%3E%3Crect x='5' y='5' width='38' height='38' fill='%233db5bf' mask='url(%23head)'/%3E%3C/svg%3E");
	-webkit-mask: var(--logo-mask) center / contain no-repeat;
	mask: var(--logo-mask) center / contain no-repeat;
}

/* ---------- Buttons ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: var(--s-8);
	min-height: var(--control-h);
	padding: 0 var(--s-12);
	border: 0;
	border-radius: var(--r-12);
	background: var(--raised);
	color: var(--text);
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), box-shadow var(--t-base) var(--ease-out), opacity var(--t-fast) var(--ease-out);
}

.btn:hover { background: var(--raised-hover); }
/* The press is a shade, not a squeeze: a squeezed button squeezes its label */
.btn:active:not(:disabled) { background: var(--raised-hover); filter: brightness(0.94); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }
.btn-ghost:active:not(:disabled) { background: var(--raised-hover); }

.btn-danger { color: var(--danger); }

.btn-sm {
	min-height: 2rem;
	padding: 0 var(--s-8);
	font-size: var(--fs-13);
	border-radius: var(--r-6);
}

.btn-block { width: 100%; }

.btn[aria-pressed="true"],
.btn.is-active { background: var(--accent-soft); color: var(--accent); }

.icon-btn {
	display: inline-grid;
	place-items: center;
	width: var(--hit);
	height: var(--hit);
	border: 0;
	border-radius: var(--r-12);
	background: transparent;
	color: var(--text-muted);
	cursor: pointer;
	transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}

.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn:active:not(:disabled) { background: var(--raised-hover); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Counter on a button or a nav item */
.count {
	min-width: 1.25rem;
	padding: 0 var(--s-4);
	border-radius: var(--r-6);
	background: var(--accent);
	color: var(--on-accent);
	font-size: var(--fs-13);
	line-height: 1.25rem;
	text-align: center;
}

.count:not([hidden]) { animation: fade-in 180ms var(--ease-out) both; }

/* A button at work: spinner + "Обновляем…" */
.spinner {
	width: 0.875rem;
	height: 0.875rem;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: spin 700ms linear infinite;
}

/* ---------- Fields ---------- */

input,
select,
textarea {
	min-height: var(--control-h);
	padding: 0 var(--s-12);
	border: 1px solid var(--field-border);
	border-radius: var(--r-12);
	background: transparent;
}

input:not([type="checkbox"], [type="radio"], [type="range"]),
select,
textarea {
	transition: border-color 160ms var(--ease-out), box-shadow 200ms var(--ease-out), background-color 160ms var(--ease-out);
}

input:not([type="checkbox"], [type="radio"], [type="range"]):hover:not(:disabled, :focus),
select:hover:not(:disabled, :focus),
textarea:hover:not(:disabled, :focus) {
	border-color: color-mix(in srgb, var(--field-border) 60%, var(--text-muted));
}

/* Focus: accent frame + a soft halo */
input:not([type="checkbox"], [type="radio"], [type="range"]):focus-visible,
select:focus-visible,
textarea:focus-visible {
	border-color: var(--accent);
	box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea {
	padding: var(--s-8) var(--s-12);
	resize: vertical;
	line-height: 1.45;
}

select {
	padding-right: var(--s-32);
	appearance: none;
	background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
	background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
	background-size: 5px 5px;
	background-repeat: no-repeat;
}

input::placeholder,
textarea::placeholder { color: var(--text-quiet); }

input[type="checkbox"] {
	min-height: 0;
	width: 1rem;
	height: 1rem;
	padding: 0;
	accent-color: var(--accent);
}

.field {
	display: flex;
	flex-direction: column;
	gap: var(--s-4);
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
}

.field-label {
	padding: 0;
	color: var(--text-muted);
	font-size: var(--fs-13);
	font-weight: 500;
}

.hint { font-size: var(--fs-13); color: var(--text-quiet); }
.form-error { color: var(--danger); font-size: var(--fs-13); }

/* Search: an icon inside the field's frame */
.search {
	display: flex;
	align-items: center;
	gap: var(--s-8);
	min-height: var(--control-h);
	padding-left: var(--s-12);
	border: 1px solid var(--field-border);
	border-radius: var(--r-12);
	color: var(--text-quiet);
	transition: border-color 160ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search:focus-within .icon { color: var(--accent); }
.search .icon { transition: color 160ms var(--ease-out); }

.search input {
	width: 13rem;
	min-height: calc(var(--control-h) - 2px);
	padding-left: 0;
	border: 0;
	color: var(--text);
	outline: none;
	box-shadow: none !important;
}

/* File drop zone */
.dropzone {
	padding: var(--s-24);
	border: 1px dashed var(--field-border);
	border-radius: 0.625rem;
	color: var(--text-muted);
	text-align: center;
	transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}

.dropzone:hover,
.dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Switch ---------- */

.switch {
	display: inline-flex;
	align-items: center;
	gap: var(--s-8);
	min-height: var(--hit);
	color: var(--text-muted);
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
	position: relative;
	width: 2.25rem;
	height: 1.25rem;
	border-radius: var(--r-round);
	background: var(--divider);
	transition: background-color 200ms var(--ease-out);
}

.switch-track::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: calc(1.25rem - 6px);
	height: calc(1.25rem - 6px);
	border-radius: 50%;
	background: var(--text);
	transition: transform var(--t-base) var(--ease-out), width 140ms var(--ease-out), background-color var(--t-base) var(--ease-out);
}

.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { background: var(--on-accent); transform: translateX(1rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:checked ~ * { color: var(--text); }
/* The thumb stretches a little while pressed */
.switch:active .switch-track::after { width: calc(1.25rem - 6px + 5px); }
.switch:active input:checked + .switch-track::after { transform: translateX(calc(1rem - 5px)); }

/* ---------- Segmented control (theme switch, filters) ---------- */

/* A recessed track (the page background) with a raised surface under the chosen option. The accent is not used here */
.segmented {
	display: inline-flex;
	padding: 2px;
	border: 1px solid var(--divider);
	border-radius: var(--r-12);
	background: var(--bg);
}

.segmented button {
	flex: 1;
	min-height: 2rem;
	padding: 0 var(--s-12);
	border: 0;
	border-radius: 10px;
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-size: var(--fs-13);
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 160ms var(--ease-out), color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

.segmented button:hover { color: var(--text); }

/* Without the script: the chosen option itself gets the surface */
.segmented button[aria-pressed="true"] {
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 0 0 1px var(--divider);
}

/* With theme.js: one thumb with the same look slides under the chosen option instead */
.segmented.has-thumb { position: relative; isolation: isolate; }
.segmented.has-thumb > button { position: relative; z-index: 1; }
.segmented.has-thumb > button[aria-pressed="true"] { background: transparent; box-shadow: none; }

.segmented-thumb {
	position: absolute;
	top: 0;
	left: 0;
	z-index: 0;
	border-radius: 10px;
	background: var(--surface);
	box-shadow: 0 0 0 1px var(--divider), 0 1px 2px rgb(0 0 0 / 0.12);
	pointer-events: none;
	opacity: 0;
	transition: transform 220ms var(--ease-out), width 220ms var(--ease-out), height 220ms var(--ease-out), opacity 160ms var(--ease-out);
}

.segmented-thumb.no-slide { transition: none; }

/* Theme switch in the sidebar footer: full width, three labels fit the sidebar */
.theme-switch { display: flex; margin-top: var(--s-12); }
.theme-switch button { flex: 1; padding: 0 var(--s-4); }

/* ---------- Tabs ---------- */

.tabs {
	display: flex;
	gap: 2px;
	overflow-x: auto;
	border-bottom: 1px solid var(--divider);
}

.tab {
	position: relative;
	padding: var(--s-8) var(--s-12);
	border: 0;
	border-bottom: 2px solid transparent;
	background: transparent;
	color: var(--text-muted);
	font: inherit;
	font-weight: 500;
	white-space: nowrap;
	cursor: pointer;
	transition: color 160ms var(--ease-out);
}

.tab:hover,
.tab[aria-selected="true"] { color: var(--text); }

.tab::after {
	content: "";
	position: absolute;
	right: var(--s-12);
	bottom: -2px;
	left: var(--s-12);
	height: 2px;
	border-radius: 2px;
	background: var(--accent);
	transform: scaleX(0);
	transition: transform 200ms var(--ease-out);
}

.tab[aria-selected="true"]::after { transform: scaleX(1); }

/* ---------- Layout: sidebar + main ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
	position: sticky;
	top: 0;
	display: flex;
	flex-direction: column;
	gap: var(--s-32);
	width: var(--sidebar-w);
	height: 100vh;
	flex-shrink: 0;
	overflow-y: auto;
	padding: var(--s-24) var(--s-12) var(--s-16);
	border-right: 1px solid var(--divider);
}

.sidebar .wordmark { padding: 0 var(--s-12); }
.sidebar .section-title { padding: 0 var(--s-12); margin-bottom: var(--s-4); }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--s-12);
	min-height: var(--control-h);
	padding: 0 var(--s-12);
	border-radius: var(--r-12);
	color: var(--text-muted);
	text-decoration: none;
	font-weight: 500;
}

.nav-link .icon { transition: color 140ms var(--ease-out); }
.nav-link:hover,
.nav-link[aria-current="page"] { background: var(--raised); color: var(--text); }
.nav-link[aria-current="page"] .icon { color: var(--accent); }
.nav-link .count { margin-left: auto; }

/* The current section: a thin accent mark on the sidebar's edge */
.nav-link::before {
	content: "";
	position: absolute;
	top: 50%;
	left: calc(var(--s-12) * -1);
	width: 3px;
	height: 1.125rem;
	margin-top: -0.5625rem;
	border-radius: 0 3px 3px 0;
	background: var(--accent);
	opacity: 0;
	transform: scaleY(0.4);
	transition: transform 200ms var(--ease-out), opacity 140ms var(--ease-out);
}

.nav-link[aria-current="page"]::before { opacity: 1; transform: none; }

.sidebar-footer {
	display: flex;
	flex-direction: column;
	gap: var(--s-8);
	margin-top: auto;
	padding: 0 var(--s-12);
}

.sidebar-scrim {
	position: fixed;
	inset: 0;
	z-index: 29;
	background: rgb(0 0 0 / 0.5);
}

.main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	padding-bottom: var(--s-48);
	/* A faint accent light at the top of the page */
	background: radial-gradient(48rem 13rem at 18% -5rem, color-mix(in srgb, var(--accent) 7%, transparent), transparent 72%) no-repeat;
}

.page-head {
	display: flex;
	align-items: center;
	gap: var(--s-12);
	padding: var(--s-16) var(--gutter) 0;
}

.page-title { font-size: var(--fs-24); }
.page-head-end { margin-left: auto; font-size: var(--fs-13); text-align: right; }

.page {
	display: flex;
	flex-direction: column;
	gap: var(--s-16);
	padding: var(--s-12) var(--gutter) 0;
}

/* A row of key figures above a table */
.summary {
	display: flex;
	flex-wrap: wrap;
	gap: var(--s-4) var(--s-24);
	color: var(--text-muted);
}

.summary b { color: var(--text); font-weight: 600; font-size: var(--fs-17); }
.summary .is-danger b { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-8); }
.toolbar-end { display: flex; gap: var(--s-8); margin-left: auto; }

/* Bar of actions over the selected rows */
.bulk-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s-8) var(--s-24);
	padding: var(--s-8) var(--s-12);
	border-radius: var(--r-12);
	background: var(--surface);
}

/* ---------- Banners ---------- */

.banner {
	display: flex;
	align-items: center;
	gap: var(--s-12);
	padding: var(--s-8) var(--s-12);
	border-radius: var(--r-12);
	background: var(--danger-soft);
	color: var(--danger);
	animation: fade-in 180ms var(--ease-out);
}

.banner span { flex: 1; color: var(--text); }
.banner.is-warn { background: var(--warn-soft); color: var(--warn); }
.banner.is-info { background: var(--accent-soft); color: var(--accent); }

/* ---------- Table ---------- */

.table-wrap {
	overflow-x: auto;
	margin: 0 calc(var(--gutter) * -1);
	padding: 0 var(--gutter);
}

.grid { width: 100%; border-collapse: collapse; }

.grid th {
	padding: var(--s-8) var(--s-12);
	border-bottom: 1px solid var(--divider);
	color: var(--text-muted);
	font-size: var(--fs-13);
	font-weight: 500;
	text-align: left;
	white-space: nowrap;
	user-select: none;
}

.grid td {
	padding: var(--s-8) var(--s-12);
	border-bottom: 1px solid var(--divider);
	vertical-align: middle;
	white-space: nowrap;
}

.grid th:first-child,
.grid td:first-child { padding-left: 0; }

.grid .num { text-align: right; }
.grid th[data-sort] { cursor: pointer; }
.grid th[data-sort]:hover,
.grid th[aria-sort] { color: var(--text); }
.grid th[aria-sort="ascending"]::after { content: " ↑"; }
.grid th[aria-sort="descending"]::after { content: " ↓"; }
.grid th[aria-sort]::after { animation: fade-in 160ms var(--ease-out); }

.grid tbody tr { transition: background-color 140ms var(--ease-out); }
.grid tbody tr:hover { background: var(--surface); }
.grid tbody tr.is-selected { background: var(--accent-soft); }
.grid tbody tr.is-menu-open { background: var(--raised); }
.grid tbody tr.is-invalid { background: color-mix(in srgb, var(--danger) 9%, transparent); }
.grid tbody tr.is-invalid:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* After a filter or a page change: a quick fade, no slide (set --i on each row) */
.rows-enter tr {
	animation: fade-in 160ms var(--ease-out) both;
	animation-delay: calc(var(--i, 0) * 8ms);
}

.avatar {
	width: 2rem;
	height: 2rem;
	flex-shrink: 0;
	border-radius: 50%;
	object-fit: cover;
	background: var(--raised);
}

.avatar-letter {
	display: grid;
	place-items: center;
	color: var(--text-muted);
	font-size: var(--fs-13);
	font-weight: 600;
}

.entity { display: flex; align-items: center; gap: var(--s-12); min-width: 12rem; }

.two-line { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.two-line .sub { color: var(--text-quiet); font-size: var(--fs-13); }

/* Status: a coloured dot + a word, never the colour alone */
.status { display: inline-flex; align-items: center; gap: var(--s-8); }

.status::before {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: currentColor;
	transition: background-color 200ms var(--ease-out);
}

.status-online { color: var(--ok); }
.status-offline { color: var(--text-muted); }
.status-stopped { color: var(--text-quiet); }
.status-error { color: var(--danger); }

/* Flags next to a name: hold, broken, busy */
.flag {
	padding: 0 var(--s-4);
	border-radius: var(--r-6);
	font-size: var(--fs-13);
	font-weight: 500;
}

.flag-warn { background: var(--warn-soft); color: var(--warn); }
.flag-danger { background: var(--danger-soft); color: var(--danger); }
.flag-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }

/* Tag chip */
.chip {
	display: inline-block;
	padding: 0 var(--s-8);
	border-radius: var(--r-6);
	background: var(--raised);
	font-size: var(--fs-13);
	line-height: 24px;
	white-space: nowrap;
}

.skeleton {
	display: block;
	height: 0.75rem;
	border-radius: var(--r-6);
	background: linear-gradient(90deg, var(--raised) 0%, var(--raised-hover) 45%, var(--raised) 90%);
	background-size: 220% 100%;
	animation: shimmer 1.3s linear infinite;
}

.empty {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--s-12);
	padding: var(--s-32) 0;
	color: var(--text-muted);
	animation: fade-in 180ms var(--ease-out);
}

/* "Обновляю…": a tiny running bar next to the live status */
.live-bar {
	position: relative;
	display: inline-block;
	width: 1.5rem;
	height: 3px;
	margin-right: var(--s-8);
	overflow: hidden;
	border-radius: 3px;
	background: var(--raised-hover);
	vertical-align: middle;
}

.live-bar::after {
	content: "";
	position: absolute;
	inset: 0;
	width: 45%;
	border-radius: inherit;
	background: var(--accent);
	animation: live-bar 900ms var(--ease-in-out) infinite;
}

/* ---------- Cards and tiles (for grids only; lists of records are tables) ---------- */

.card {
	display: flex;
	flex-direction: column;
	gap: var(--s-8);
	padding: var(--s-12) var(--s-16);
	border: 1px solid var(--divider);
	border-radius: var(--r-16);
	background: var(--surface);
	color: inherit;
	font: inherit;
	text-align: left;
	transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

/* A card answers the pointer with its frame only: lifting it moves its text across half-pixels */
button.card { cursor: pointer; }
button.card:hover,
a.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--divider)); }

/* Settings block */
.settings-card {
	max-width: 34rem;
	padding: var(--s-24);
	border-radius: 14px;
	background: var(--surface);
	transition: box-shadow 200ms var(--ease-out);
}

.settings-card:hover,
.settings-card:focus-within { box-shadow: inset 0 0 0 1px var(--divider); }

/* Figures in tiles: the first tile wider */
.bento {
	display: grid;
	grid-template-columns: minmax(16rem, 1.6fr) repeat(3, minmax(10rem, 1fr));
	gap: var(--s-12);
}

.bento-tile {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
	min-width: 0;
	padding: var(--s-12) var(--s-16);
	border: 1px solid var(--divider);
	border-radius: var(--r-12);
	background: var(--surface);
	color: inherit;
	font: inherit;
	text-align: left;
	transition: border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

button.bento-tile { cursor: pointer; }
button.bento-tile:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--divider)); }
button.bento-tile:active { background: var(--raised); }
button.bento-tile[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.bento-tile.is-warn { border-color: var(--warn); background: var(--warn-soft); }
.bento-tile.is-warn .bento-value { color: var(--warn); }
.bento-label { font-size: var(--fs-13); color: var(--text-muted); }
.bento-value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; }

/* ---------- Floating layers: the only things with a shadow ---------- */

.popover {
	position: fixed;
	z-index: 40;
	display: flex;
	flex-direction: column;
	gap: var(--s-16);
	width: max-content;
	min-width: 15rem;
	max-width: min(22rem, calc(100vw - 2 * var(--s-16)));
	max-height: min(28rem, calc(100vh - 2 * var(--s-16)));
	overflow-y: auto;
	padding: var(--s-16);
	border-radius: var(--r-16);
	background: var(--surface);
	box-shadow: var(--shadow-float);
	transition: opacity var(--t-fast) var(--ease-out), transform 140ms var(--ease-out), display 140ms allow-discrete;
}

.popover[hidden] { opacity: 0; transform: scale(0.98); }

@starting-style {
	.popover:not([hidden]) { opacity: 0; transform: scale(0.98); }
}

.popover.menu { min-width: 15rem; padding: var(--s-4); gap: 0; }

.menu-item {
	display: flex;
	align-items: center;
	gap: var(--s-12);
	width: 100%;
	min-height: var(--control-h);
	padding: 0 var(--s-12);
	border: 0;
	border-radius: var(--r-6);
	background: transparent;
	color: var(--text);
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
}

.menu-item:hover { background: var(--raised); }
.menu-item:disabled { opacity: 0.4; cursor: not-allowed; }
.menu-item .icon { color: var(--text-muted); transition: color var(--t-fast) var(--ease-out); }
.menu-item:hover:not(:disabled) .icon { color: var(--text); }
.menu-item.is-danger,
.menu-item.is-danger .icon { color: var(--danger); }
.menu-sep { height: 1px; margin: var(--s-4) 0; background: var(--divider); }

.toast {
	position: fixed;
	right: var(--s-16);
	bottom: max(var(--s-16), env(safe-area-inset-bottom));
	z-index: 50;
	display: flex;
	align-items: center;
	gap: var(--s-12);
	max-width: min(28rem, calc(100vw - 2 * var(--s-16)));
	padding: var(--s-8) var(--s-8) var(--s-8) var(--s-16);
	border-radius: var(--r-12);
	background: var(--surface);
	box-shadow: var(--shadow-float);
	transition: opacity 160ms var(--ease-out), transform 200ms var(--ease-out), bottom 200ms var(--ease-out), display 200ms allow-discrete;
}

.toast[hidden] { opacity: 0; transform: translateY(8px); }

@starting-style {
	.toast:not([hidden]) { opacity: 0; transform: translateY(8px); }
}

.toast.is-error { color: var(--danger); }

dialog {
	width: min(26rem, calc(100vw - 2 * var(--s-16)));
	padding: var(--s-24);
	border: 0;
	border-radius: var(--r-24);
	background: var(--surface);
	color: var(--text);
	box-shadow: var(--shadow-float);
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 160ms var(--ease-out), transform 200ms var(--ease-out), overlay 200ms allow-discrete, display 200ms allow-discrete;
}

dialog[open] { opacity: 1; transform: none; }

@starting-style {
	dialog[open] { opacity: 0; transform: translateY(8px); }
}

dialog:not([open]) { transform: none; transition-duration: 120ms; }
dialog:focus-visible { outline: none; }

dialog::backdrop {
	background: rgb(0 0 0 / 0);
	transition: background-color 200ms var(--ease-out), overlay 200ms allow-discrete, display 200ms allow-discrete;
}

dialog[open]::backdrop { background: rgb(0 0 0 / 0.55); }

@starting-style {
	dialog[open]::backdrop { background: rgb(0 0 0 / 0); }
}

.dialog-title { font-size: var(--fs-17); font-weight: 600; }
.dialog-text { color: var(--text-muted); font-size: var(--fs-13); line-height: 1.5; }

.dialog-actions {
	display: flex;
	justify-content: flex-end;
	gap: var(--s-8);
	margin: var(--s-8) 0 0;
	padding: 0;
}

/* Tooltip: <button data-tip="Скопировать"> */
[data-tip] { position: relative; }

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
	content: attr(data-tip);
	position: absolute;
	z-index: 30;
	bottom: calc(100% + 6px);
	left: 50%;
	transform: translateX(-50%);
	padding: var(--s-4) var(--s-8);
	border-radius: var(--r-6);
	background: var(--surface);
	box-shadow: var(--shadow-float);
	color: var(--text);
	font-size: var(--fs-13);
	font-weight: 500;
	line-height: 1.3;
	white-space: nowrap;
	pointer-events: none;
	animation: fade-in var(--t-fast) var(--ease-out);
}

/* ---------- Narrow screens ---------- */

@media (max-width: 47.99rem) {
	.sidebar {
		position: fixed;
		inset: 0 auto 0 0;
		z-index: 30;
		background: var(--surface);
	}

	.app:not(.sidebar-open) .sidebar { display: none; }
	.toolbar-end { margin-left: 0; }
	.search,
	.search input { flex: 1; width: auto; min-width: 0; }
	.search { flex-basis: 100%; }
	.bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.bento > :first-child { grid-column: 1 / -1; }

	/* iOS zooms into inputs with text smaller than 16px */
	input,
	select,
	textarea { font-size: 1rem; }
}

/* ---------- Motion ---------- */

/* A section fades in as one piece: add .is-entering when it opens */
.page.is-entering { animation: fade-in 180ms var(--ease-out); }

/* Theme change: a short cross-fade of the whole page (theme.js) */
.theme-fading::view-transition-old(root),
.theme-fading::view-transition-new(root) {
	animation-duration: 280ms;
	animation-timing-function: var(--ease-out);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
@keyframes live-bar { from { transform: translateX(-110%); } to { transform: translateX(230%); } }

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		transition: none !important;
	}
}
