/* Shopbot panel — one accent (signal teal), a dark rail, quiet surfaces. */
:root {
	--canvas: #eef1f4;
	--surface: #ffffff;
	--surface-2: #f6f8fa;
	--ink: #0f1720;
	--ink-2: #46515e;
	--muted: #6b7682;
	--line: #dde2e8;
	--line-strong: #c6cdd6;
	--accent: #0b8f7e;
	--accent-ink: #ffffff;
	--accent-soft: #dff3ef;
	--warn: #a86a00;
	--warn-soft: #fbefd5;
	--danger: #c0352b;
	--danger-soft: #fbe3e0;
	--info: #2b63c4;
	--info-soft: #e1ebfb;
	--rail: #0d1520;
	--rail-ink: #b9c4d0;
	--rail-line: #1b2735;
	--shadow: 0 1px 2px rgba(15, 23, 32, 0.06), 0 8px 24px -12px rgba(15, 23, 32, 0.18);
	--radius: 10px;
	--radius-sm: 6px;
	--font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
	:root:not([data-theme='light']) {
		--canvas: #090f16;
		--surface: #111a24;
		--surface-2: #16212d;
		--ink: #e8edf2;
		--ink-2: #b4bfca;
		--muted: #8795a3;
		--line: #1f2c3a;
		--line-strong: #2c3c4e;
		--accent: #2cc4ae;
		--accent-ink: #04201b;
		--accent-soft: #11332f;
		--warn: #e5b04a;
		--warn-soft: #33270f;
		--danger: #f0786d;
		--danger-soft: #3a1815;
		--info: #7ba7f2;
		--info-soft: #15233d;
		--rail: #070c12;
		--rail-line: #141e29;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
	}
}
:root[data-theme='dark'] {
	--canvas: #090f16;
	--surface: #111a24;
	--surface-2: #16212d;
	--ink: #e8edf2;
	--ink-2: #b4bfca;
	--muted: #8795a3;
	--line: #1f2c3a;
	--line-strong: #2c3c4e;
	--accent: #2cc4ae;
	--accent-ink: #04201b;
	--accent-soft: #11332f;
	--warn: #e5b04a;
	--warn-soft: #33270f;
	--danger: #f0786d;
	--danger-soft: #3a1815;
	--info: #7ba7f2;
	--info-soft: #15233d;
	--rail: #070c12;
	--rail-line: #141e29;
	--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light dark; }
:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }
body {
	margin: 0; background: var(--canvas); color: var(--ink); font: 15px/1.5 var(--font);
	font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0.1em 0.4em; word-break: break-all; }
small, .muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.rail {
	background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column;
	position: sticky; top: 0; height: 100vh; padding: 18px 12px; gap: 18px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: #fff; font-weight: 700; font-size: 1.05rem; }
.brand svg { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
	display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
	color: var(--rail-ink); font-weight: 500; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, 0.05); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(44, 196, 174, 0.12); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .count { margin-left: auto; font-size: 0.75rem; background: var(--danger); color: #fff; border-radius: 99px; padding: 0 7px; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.bots { border: 1px solid var(--rail-line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.bot-row { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; }
.bot-row .name { flex: 1; color: #fff; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7682; flex: none; }
.dot.on { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.rail-actions { display: flex; gap: 6px; }
.rail .btn-ghost { color: var(--rail-ink); border-color: var(--rail-line); background: transparent; }
.rail .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.main { padding: 28px clamp(16px, 3vw, 40px) 56px; min-width: 0; max-width: 1280px; width: 100%; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel, .panel + .grid, .grid + .panel, .grid + .grid { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-body { padding: 18px; }
.panel-body > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > * + * { margin-top: 14px; }

/* ---------- buttons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--accent);
	background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-sm); padding: 8px 14px;
	font: 600 0.9rem/1.2 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); filter: none; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); filter: none; }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; }
.btn-icon { padding: 7px; }
form.inline { display: inline; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: 0.86rem; color: var(--ink-2); }
.hint { font-size: 0.82rem; color: var(--muted); }
.input, select.input, textarea.input {
	width: 100%; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm); padding: 8px 10px; font: inherit; min-height: 38px;
}
textarea.input { resize: vertical; min-height: 88px; line-height: 1.45; }
.input:hover { border-color: var(--muted); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.input-group { position: relative; display: flex; }
.input-group .input { padding-right: 42px; }
.input-group .reveal { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 4px; display: grid; place-items: center; }
.input-group .reveal:hover { background: var(--surface-2); color: var(--ink); }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.switch { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch + .switch { border-top: 1px solid var(--line); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 38px; height: 22px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background 0.15s; margin-top: 1px; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .txt b { display: block; font-weight: 600; }
.switch .txt span { color: var(--muted); font-size: 0.85rem; }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 6px; flex-wrap: wrap; }
.savebar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; justify-content: flex-end; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: 0.8rem; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.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:hover { background: var(--surface-2); }
.table .num { text-align: right; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { margin-left: 4px; }
.cell-sub { display: block; color: var(--muted); font-size: 0.82rem; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* ---------- filters / pagination ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.filters .input { width: auto; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; gap: 10px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager a, .pager span.cur { padding: 4px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--ink); }
.pager span.cur { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager .off { opacity: 0.4; pointer-events: none; }

/* ---------- dashboard ---------- */
.summary { font-size: 1.25rem; line-height: 1.4; max-width: 46ch; }
.summary b { font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.kpi { padding: 14px 18px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi .v { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.kpi .k { color: var(--muted); font-size: 0.84rem; }
.chart { width: 100%; height: 220px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--accent); opacity: 0.85; transition: opacity 0.1s; }
.chart .bar:hover, .chart .bar.hot { opacity: 1; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke: var(--info); stroke-width: 2; }
.chart .area { fill: var(--info); opacity: 0.12; }
.chart-tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--canvas); padding: 5px 9px; border-radius: 6px; font-size: 0.8rem; z-index: 40; opacity: 0; transition: opacity 0.1s; white-space: nowrap; }
.health { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--line); margin: 8px 0 12px; }
.health i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.86rem; color: var(--ink-2); }
.legend span::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; background: var(--c); }
.check { list-style: none; margin: 0; padding: 0; }
.check li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.check li:last-child { border-bottom: 0; }
.check .tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; display: grid; place-items: center; }
.check .done .tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check .done span { color: var(--muted); text-decoration: line-through; }
.method-list { list-style: none; margin: 0; padding: 0; }
.method-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.method-list li:last-child { border-bottom: 0; }

/* ---------- misc blocks ---------- */
.alert { border-radius: var(--radius-sm); padding: 11px 14px; border: 1px solid transparent; margin-bottom: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--accent-soft); color: var(--accent); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: 600 0.92rem var(--font); color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--accent); }
[data-tabpanel][hidden] { display: none; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
.secret { display: flex; gap: 8px; align-items: center; }
.secret code { flex: 1; padding: 8px 10px; }
.steps { counter-reset: s; list-style: none; margin: 0; padding: 0; }
.steps > li { counter-increment: s; position: relative; padding: 2px 0 16px 40px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 0.85rem; }
.steps > li::after { content: ''; position: absolute; left: 12px; top: 30px; bottom: 4px; width: 2px; background: var(--line); }
.steps > li:last-child::after { display: none; }
pre.code { background: #0d1520; color: #d6e1ec; padding: 14px 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 8px 0 14px; font: 0.82rem/1.55 var(--mono); position: relative; }
pre.code .copy { position: absolute; top: 8px; right: 8px; }
.endpoint { display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.endpoint:last-child { border-bottom: 0; }
.method { font: 700 0.75rem var(--mono); padding: 2px 6px; border-radius: 4px; text-align: center; }
.method.get { background: var(--info-soft); color: var(--info); }
.method.post { background: var(--accent-soft); color: var(--accent); }
.method.delete { background: var(--danger-soft); color: var(--danger); }
.endpoint .path { font-family: var(--mono); font-size: 0.88rem; word-break: break-all; }
.endpoint .desc { grid-column: 2; color: var(--muted); font-size: 0.86rem; }
.host-card { padding: 18px; }
.host-card + .host-card { border-top: 1px solid var(--line); }
.host-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.plan-table td, .plan-table th { padding: 8px 12px; }
.plan-table input.input { min-height: 32px; padding: 4px 8px; }
.test-result { margin-top: 10px; font-size: 0.9rem; }
.guide-card { padding: 18px; }
.guide-card + .guide-card { border-top: 1px solid var(--line); }

/* ---------- dialog / toasts ---------- */
dialog { border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.5); }
dialog::backdrop { background: rgba(8, 14, 22, 0.55); }
dialog form, dialog .dlg { padding: 22px; }
dialog h2 { margin-bottom: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toasts { position: fixed; right: 16px; top: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--info); border-radius: var(--radius-sm); padding: 11px 14px; box-shadow: var(--shadow); display: flex; gap: 10px; animation: toast-in 0.18s ease-out; }
.toast.success { border-left-color: var(--accent); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warn); }
.toast button { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); }
.login-side { background: var(--rail); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-side .brand { padding: 0; font-size: 1.2rem; }
.login-side h1 { font-size: 2rem; max-width: 16ch; line-height: 1.15; }
.login-side p { color: var(--rail-ink); max-width: 38ch; }
.login-side svg.waves { position: absolute; inset: auto 0 0 0; width: 100%; opacity: 0.5; pointer-events: none; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form form { width: min(380px, 100%); }
.login-form h2 { font-size: 1.4rem; margin-bottom: 18px; }

@media (max-width: 980px) {
	.grid.two, .grid.main-side, .grid.three { grid-template-columns: minmax(0, 1fr); }
	.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.kpi:nth-child(2) { border-right: 0; }
	.kpi:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 820px) {
	.app { grid-template-columns: minmax(0, 1fr); }
	.rail { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform 0.2s; }
	body.nav-open .rail { transform: none; }
	body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(8, 14, 22, 0.5); z-index: 45; }
	.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--rail); color: #fff; position: sticky; top: 0; z-index: 30; }
	.topbar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; display: grid; }
	.login-wrap { grid-template-columns: minmax(0, 1fr); }
	.login-side { display: none; }
}
@media (max-width: 560px) {
	.main { padding-top: 20px; }
	h1 { font-size: 1.3rem; }
	.kpis { grid-template-columns: minmax(0, 1fr); }
	.kpi { border-right: 0; border-bottom: 1px solid var(--line); }
	.kpi:last-child { border-bottom: 0; }
	.table th, .table td { padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
	* { animation: none !important; transition: none !important; }
}
