:root {
	--bg: #eef2f7;
	--panel: #ffffff;
	--panel-soft: #f8fafc;
	--text: #111827;
	--muted: #64748b;
	--line: #d8e0ea;
	--line-strong: #bdc9d8;
	--brand: #255893;
	--brand-strong: #1d4676;
	--brand-soft: #e6eef8;
	--ok: #0f7a4f;
	--ok-soft: #e4f5ed;
	--warn: #a15c00;
	--warn-soft: #fff1d6;
	--bad: #b42318;
	--bad-soft: #fde8e7;
	--shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
	font-family:
		Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-weight: 400;
}

button,
input,
select,
textarea {
	font: inherit;
}

button {
	cursor: pointer;
}

button:disabled {
	cursor: not-allowed;
	opacity: 0.62;
}

.app-shell {
	min-height: 100vh;
}

.boot {
	display: grid;
	min-height: 100vh;
	place-items: center;
	color: var(--muted);
	font-size: 18px;
	font-weight: 700;
}

.login-layout {
	display: grid;
	min-height: 100vh;
	grid-template-columns: minmax(360px, 500px) 1fr;
}

.login-panel {
	display: flex;
	flex-direction: column;
	justify-content: center;
	padding: 48px;
	background: var(--panel);
	border-right: 1px solid var(--line);
}

.login-visual {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: 56px;
	background:
		linear-gradient(135deg, rgba(12, 24, 39, 0.88), rgba(64, 101, 124, 0.74)),
		linear-gradient(24deg, #13253b 0%, #315f73 58%, #d4dee7 100%);
	background-size: cover;
	background-position: center;
	color: #ffffff;
}

.brand {
	margin-bottom: 36px;
}

.brand-mark {
	width: 48px;
	height: 48px;
	margin-bottom: 18px;
	border-radius: 8px;
	background: var(--brand);
	box-shadow: inset 0 0 0 12px rgba(255, 255, 255, 0.14);
}

h1,
h2,
h3,
p {
	margin-top: 0;
}

h1 {
	margin-bottom: 8px;
	font-size: 28px;
	font-weight: 800;
	line-height: 1.12;
	letter-spacing: 0;
}

h2 {
	margin-bottom: 10px;
	font-size: 20px;
	font-weight: 720;
	line-height: 1.16;
	letter-spacing: 0;
}

h3 {
	margin-bottom: 8px;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: 0;
}

h4 {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0;
}

.lead,
.muted {
	color: var(--muted);
}

.mono {
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 12px;
}

.login-visual .lead {
	max-width: 620px;
	color: rgba(255, 255, 255, 0.84);
	font-size: 20px;
	line-height: 1.45;
}

.form {
	display: grid;
	gap: 16px;
}

.field {
	display: grid;
	gap: 8px;
}

.field span {
	color: #475569;
	font-size: 14px;
	font-weight: 650;
}

.field input,
.field select,
.field textarea {
	width: 100%;
	min-height: 38px;
	padding: 9px 11px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: #ffffff;
	color: var(--text);
}

.field textarea {
	min-height: 110px;
	resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
	border-color: var(--brand);
	box-shadow: 0 0 0 3px rgba(37, 88, 147, 0.14);
	outline: none;
}

.compact-select {
	width: 100%;
	min-width: 120px;
	min-height: 34px;
	padding: 7px 9px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: #ffffff;
	color: var(--text);
}

.user-form {
	display: grid;
	grid-template-columns: minmax(220px, 1fr) minmax(140px, 180px) auto;
	gap: 12px;
	align-items: end;
}

.compact-help {
	align-self: center;
	margin: 0;
	font-size: 13px;
}

.license-form .compact-help {
	grid-column: 1 / -1;
}

.button-row {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

.btn {
	min-height: 36px;
	padding: 8px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: #ffffff;
	color: var(--text);
	font-weight: 700;
}

.btn.primary {
	border-color: var(--brand);
	background: var(--brand);
	color: #ffffff;
}

.btn.primary:hover {
	background: var(--brand-strong);
}

.btn.danger {
	border-color: #f0b4ae;
	background: var(--bad-soft);
	color: var(--bad);
}

.btn.ghost {
	background: transparent;
}

.error,
.notice {
	display: none;
	margin: 0;
	padding: 12px 14px;
	border-radius: 8px;
	font-weight: 700;
	line-height: 1.35;
}

.error.show {
	display: block;
	border: 1px solid #f0b4ae;
	background: var(--bad-soft);
	color: var(--bad);
}

.notice.show {
	display: block;
	border: 1px solid #b9d7c8;
	background: var(--ok-soft);
	color: var(--ok);
}

.dashboard {
	display: grid;
	min-height: 100vh;
	grid-template-columns: 220px 1fr;
}

.sidebar {
	display: flex;
	flex-direction: column;
	gap: 18px;
	padding: 22px 16px;
	background: #111827;
	color: #ffffff;
}

.sidebar .brand-mark {
	background: #ffffff;
	box-shadow: inset 0 0 0 12px rgba(37, 88, 147, 0.24);
}

.nav {
	display: grid;
	gap: 8px;
}

.nav button {
	width: 100%;
	padding: 12px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: rgba(255, 255, 255, 0.76);
	font-weight: 700;
	text-align: left;
}

.nav button.active,
.nav button:hover {
	background: rgba(255, 255, 255, 0.12);
	color: #ffffff;
}

.sidebar-footer {
	margin-top: auto;
	display: grid;
	gap: 12px;
}

.user-card {
	padding: 12px;
	border: 1px solid rgba(255, 255, 255, 0.16);
	border-radius: 8px;
	color: rgba(255, 255, 255, 0.82);
	font-size: 13px;
	line-height: 1.35;
}

.main {
	padding: 20px;
	overflow: auto;
}

.topbar {
	display: flex;
	gap: 16px;
	align-items: flex-start;
	justify-content: space-between;
	margin-bottom: 16px;
}

.topbar p {
	margin-bottom: 0;
}

.grid {
	display: grid;
	gap: 12px;
}

.grid.two {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
	box-shadow: var(--shadow);
}

.detail-back {
	margin-bottom: 12px;
	padding-left: 0;
	border: 0;
	color: var(--brand);
}

.device-title {
	margin-bottom: 6px;
	overflow-wrap: anywhere;
}

.device-subtitle {
	max-width: 920px;
	overflow-wrap: anywhere;
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 13px;
}

.detail-metrics {
	margin-bottom: 18px;
}

.detail-layout {
	align-items: start;
}

.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 10px;
}

.state-card {
	min-width: 0;
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel-soft);
}

.state-card-head {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.remote-config-form {
	display: grid;
	gap: 12px;
}

.license-form {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
	gap: 10px;
	align-items: end;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel-soft);
}

.license-reason-field {
	grid-column: span 1;
}

.remote-config-head {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	justify-content: space-between;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
}

.remote-config-head h3 {
	margin-bottom: 3px;
}

.remote-screen {
	display: grid;
	gap: 10px;
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel-soft);
}

.remote-screen-head {
	display: flex;
	gap: 12px;
	align-items: flex-start;
	justify-content: space-between;
}

.remote-screen-head h3 {
	margin-bottom: 3px;
}

.box-name-field {
	width: min(360px, 100%);
}

.channel-config-grid,
.network-output-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 10px;
}

.network-output-grid.single {
	grid-template-columns: 1fr;
}

.operation-mode-grid {
	display: grid;
	grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
	align-items: end;
	gap: 10px;
}

.mode-summary {
	min-height: 34px;
	display: flex;
	align-items: center;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
	color: var(--muted);
	padding: 0 10px;
	overflow-wrap: anywhere;
}

.channel-config {
	min-width: 0;
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
}

.channel-head {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 10px;
}

.rows.compact {
	margin-top: 10px;
}

.output-list {
	display: grid;
}

.output-row {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
	min-height: 54px;
	padding: 9px 0;
	border-bottom: 1px solid var(--line);
}

.output-row:first-child {
	border-top: 1px solid var(--line);
}

.output-main {
	min-width: 0;
	display: grid;
	gap: 3px;
}

.output-main strong {
	font-weight: 700;
}

.output-main span {
	color: var(--muted);
	font-size: 12px;
	overflow-wrap: anywhere;
	white-space: pre-line;
}

.output-row.disabled .output-main span,
.output-row.disabled .output-main strong {
	color: #8a95a5;
}

.remote-toggle {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	cursor: pointer;
}

.remote-toggle input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.remote-toggle span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 48px;
	min-height: 30px;
	border: 1px solid var(--line-strong);
	border-radius: 6px;
	background: #ffffff;
	color: var(--muted);
	font-size: 12px;
	font-weight: 750;
}

.remote-toggle input:checked + span {
	border-color: var(--brand);
	background: var(--brand);
	color: #ffffff;
}

.wan-output-toggle {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 4px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 650;
}

.wan-output-toggle input {
	width: 14px;
	height: 14px;
	margin: 0;
	accent-color: var(--brand);
}

.monitor-selectors {
	display: grid;
	gap: 10px;
}

.monitor-selector {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
}

.segmented {
	display: inline-flex;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	overflow: hidden;
}

.segmented button {
	min-height: 34px;
	border: 0;
	border-radius: 0;
	background: #ffffff;
	color: var(--text);
}

.segmented button.active {
	background: var(--brand);
	color: #ffffff;
}

.config-grid {
	display: grid;
	gap: 10px;
}

.config-grid.two {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.config-grid.four {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-field {
	gap: 5px;
}

.compact-field span {
	font-size: 12px;
}

.compact-field input,
.compact-field select {
	width: 100%;
	min-height: 34px;
	padding: 7px 9px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: #ffffff;
	color: var(--text);
}

.compact-field input[readonly] {
	background: #eef2f7;
	color: var(--muted);
}

.output-toggle-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
	gap: 6px;
	margin-bottom: 8px;
}

.output-check {
	display: flex;
	gap: 7px;
	align-items: center;
	min-height: 32px;
	padding: 6px 8px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #ffffff;
	font-size: 12px;
	font-weight: 650;
}

.output-check input {
	margin: 0;
}

.output-settings {
	border-top: 1px solid var(--line);
	margin-top: 10px;
	padding-top: 8px;
}

.output-settings summary {
	cursor: pointer;
	font-weight: 700;
}

.output-settings .config-grid {
	margin-top: 10px;
}

.copy-line {
	display: grid;
	grid-template-columns: minmax(0, 1fr) auto;
	gap: 8px;
	align-items: center;
}

.copy-line code {
	min-width: 0;
	padding: 8px 9px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #f8fafc;
	color: var(--text);
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 12px;
	overflow-wrap: anywhere;
}

.health-grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
}

.trend-card {
	min-width: 0;
	padding: 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel-soft);
}

.trend-head {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	justify-content: space-between;
	margin-bottom: 8px;
}

.trend-head h3 {
	margin-bottom: 2px;
}

.trend-head p,
.chart-meta {
	margin: 0;
	color: var(--muted);
	font-size: 12px;
}

.trend-head strong {
	font-size: 18px;
	font-weight: 760;
	white-space: nowrap;
}

.chart-wrap {
	display: grid;
	gap: 6px;
}

.sparkline {
	width: 100%;
	height: 58px;
	overflow: visible;
}

.sparkline path {
	fill: none;
	stroke: var(--brand);
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 2.2;
}

.sparkline circle {
	fill: var(--brand);
}

.chart-meta {
	display: flex;
	justify-content: space-between;
}

.chart-empty {
	display: grid;
	min-height: 58px;
	place-items: center;
	border: 1px dashed var(--line-strong);
	border-radius: 8px;
	color: var(--muted);
	font-size: 12px;
}

.system-facts {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 10px;
}

.system-facts .compact-row {
	padding: 8px 10px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel-soft);
}

.compact-row {
	display: grid;
	grid-template-columns: 96px minmax(0, 1fr);
	gap: 8px;
	padding: 6px 0;
	border-top: 1px solid var(--line);
}

.compact-row span {
	color: var(--muted);
	font-size: 12px;
	font-weight: 650;
}

.compact-row strong {
	min-width: 0;
	font-weight: 500;
	overflow-wrap: anywhere;
}

.mini-list {
	display: grid;
	gap: 4px;
}

.mini-row {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	padding: 7px 0;
	border-top: 1px solid var(--line);
}

.mini-row div {
	min-width: 0;
	display: grid;
	gap: 3px;
}

.mini-row strong {
	font-weight: 650;
}

.mini-row span {
	color: var(--muted);
	font-size: 12px;
	overflow-wrap: anywhere;
}

.panel-head {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
	padding: 12px 14px;
	border-bottom: 1px solid var(--line);
}

.panel-body {
	padding: 14px;
}

.metric {
	padding: 12px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: var(--panel);
}

.metric-label {
	margin-bottom: 6px;
	color: var(--muted);
	font-size: 12px;
	font-weight: 650;
	text-transform: uppercase;
}

.metric-value {
	font-size: 18px;
	font-weight: 750;
	line-height: 1;
}

.table-wrap {
	overflow: auto;
}

table {
	width: 100%;
	border-collapse: collapse;
}

th,
td {
	padding: 10px;
	border-bottom: 1px solid var(--line);
	text-align: left;
	vertical-align: top;
}

th {
	color: #475569;
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	white-space: nowrap;
}

tr:hover td {
	background: #f8fafc;
}

.device-link {
	border: 0;
	background: transparent;
	color: var(--brand);
	font-weight: 700;
	text-align: left;
	overflow-wrap: anywhere;
}

.badge {
	display: inline-flex;
	align-items: center;
	min-height: 22px;
	padding: 3px 7px;
	border-radius: 999px;
	background: var(--brand-soft);
	color: var(--brand);
	font-size: 11px;
	font-weight: 750;
	text-transform: uppercase;
	white-space: nowrap;
}

.badge.ok {
	background: var(--ok-soft);
	color: var(--ok);
}

.badge.warn {
	background: var(--warn-soft);
	color: var(--warn);
}

.badge.bad {
	background: var(--bad-soft);
	color: var(--bad);
}

.split {
	display: grid;
	grid-template-columns: 1.05fr 0.95fr;
	gap: 12px;
}

.detail-list {
	display: grid;
	gap: 12px;
}

.detail-row {
	display: grid;
	grid-template-columns: 160px 1fr;
	gap: 8px;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.detail-label {
	color: var(--muted);
	font-weight: 650;
}

.service-list {
	display: grid;
	gap: 6px;
}

.service-row,
.event-row {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	padding: 7px 0;
	border-bottom: 1px solid var(--line);
}

.service-row:last-child,
.event-row:last-child {
	border-bottom: 0;
}

.service-row span,
.event-row strong {
	font-weight: 650;
}

.event-row {
	display: grid;
	align-items: start;
}

.event-row div {
	display: flex;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
}

.event-row span,
.event-row p {
	margin: 0;
	color: var(--muted);
	font-size: 13px;
}

.code {
	max-height: 320px;
	overflow: auto;
	padding: 14px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #0f172a;
	color: #dbeafe;
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
	font-size: 13px;
	line-height: 1.5;
	white-space: pre-wrap;
}

.empty {
	padding: 18px;
	border: 1px dashed var(--line-strong);
	border-radius: 8px;
	background: var(--panel-soft);
	color: var(--muted);
	text-align: center;
}

.toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	justify-content: space-between;
}

.filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.filters input,
.filters select {
	min-height: 42px;
	padding: 9px 12px;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: #ffffff;
}

.hidden {
	display: none !important;
}

@media (max-width: 980px) {
	.login-layout,
	.dashboard,
	.split,
	.health-grid,
	.system-facts,
	.license-form,
	.user-form,
	.channel-config-grid,
	.network-output-grid,
	.operation-mode-grid,
	.config-grid.two,
	.config-grid.four,
	.grid.two,
	.grid.three,
	.grid.four {
		grid-template-columns: 1fr;
	}

	.login-visual {
		min-height: 320px;
		order: -1;
	}

	.sidebar {
		position: static;
	}

	.main {
		padding: 18px;
	}
}

@media (max-width: 640px) {
	.login-panel,
	.login-visual {
		padding: 28px;
	}

	.topbar,
	.panel-head,
	.remote-screen-head,
	.toolbar {
		align-items: stretch;
		flex-direction: column;
	}

	.detail-row {
		grid-template-columns: 1fr;
	}
}
