:root {
  color-scheme: light dark;
  --bg: light-dark(#f3f5f6, #101416);
  --surface: light-dark(#ffffff, #191e21);
  --surface-soft: light-dark(#f7f9fa, #20272b);
  --sidebar: #152129;
  --sidebar-muted: #94a4ad;
  --text: light-dark(#172127, #eef2f4);
  --muted: light-dark(#687780, #a5b0b6);
  --border: light-dark(#dae1e4, #333c41);
  --accent: light-dark(#087e78, #39b8ac);
  --accent-hover: light-dark(#076c67, #55cabe);
  --danger: light-dark(#b63a3a, #e26969);
  --success: light-dark(#16855b, #3bbb82);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
h1 { font-size: 1.05rem; font-weight: 600; letter-spacing: 0; }
h2 { margin: 0; font-size: .95rem; font-weight: 600; letter-spacing: 0; }
label { display: grid; gap: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
}
textarea { resize: vertical; font-family: "Cascadia Code", Consolas, monospace; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.primary, .secondary, .icon-button {
  min-height: 36px;
  border-radius: 5px;
  border: 1px solid var(--border);
  padding: 7px 12px;
}
.primary { color: #fff; border-color: var(--accent); background: var(--accent); }
.primary:hover { background: var(--accent-hover); }
.secondary { color: var(--text); background: var(--surface-soft); }
.icon-button { width: 34px; padding: 0; color: var(--muted); background: transparent; font-size: 1.25rem; }
button:disabled { cursor: not-allowed; opacity: .5; }
.block { width: 100%; }
.error { min-height: 1.25rem; color: var(--danger); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: #071513; background: #35b9ad; font-weight: 700; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-panel { width: min(390px, 100%); display: grid; gap: 16px; padding: 28px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.login-panel h1 { margin: 12px 0 0; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 18px 14px; color: #eef4f6; background: var(--sidebar); }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav button { width: 100%; border: 0; border-radius: 5px; padding: 10px 12px; text-align: left; color: var(--sidebar-muted); background: transparent; }
.sidebar nav button.active { color: #fff; background: #253640; }
.account { margin-top: auto; display: grid; gap: 2px; padding: 14px 8px 0; border-top: 1px solid #2d3b43; }
.account strong { font-weight: 600; }
.account span { color: var(--sidebar-muted); }
.main-column { min-width: 0; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar h1 { margin: 0; }
.page { display: grid; gap: 18px; padding: 20px 24px 28px; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.panel-heading { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.metrics { display: grid; grid-template-columns: 1.3fr repeat(4, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--border); border-radius: 7px; background: var(--border); }
.metrics > div { min-width: 0; padding: 14px 16px; background: var(--surface); }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); }
.metrics strong { margin-top: 5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-grid { display: grid; grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); gap: 18px; align-items: start; }
.form-grid { display: grid; gap: 14px; padding: 16px; }
.form-grid .panel-heading { margin: -16px -16px 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 88px; gap: 10px; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 6px; color: var(--muted); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); }
.segmented label { display: flex; justify-content: center; padding: 6px; color: var(--text); cursor: pointer; }
.segmented input { width: auto; min-height: 0; margin-right: 7px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; color: var(--text); }
.switch-row input { width: 42px; min-height: 22px; accent-color: var(--accent); }
.result-column { min-width: 0; display: grid; gap: 18px; }
.chart-panel { min-height: 310px; }
#speed-chart { width: 100%; height: auto; display: block; padding: 12px; }
#chart-grid line { stroke: var(--border); stroke-width: 1; }
#chart-axis text { fill: var(--muted); font-size: 11px; }
#chart-axis .axis-unit { font-size: 10px; letter-spacing: .04em; }
#chart-axis .axis-line { stroke: var(--muted); stroke-width: 1; }
#chart-axis .legend-send { stroke: var(--accent); stroke-width: 3; }
#chart-axis .legend-recv { stroke: light-dark(#2379bd, #70b5e8); stroke-width: 2; }
#send-line { fill: none; stroke: var(--accent); stroke-width: 3; }
#recv-line { fill: none; stroke: light-dark(#2379bd, #70b5e8); stroke-width: 2; }
pre { min-height: 190px; max-height: 310px; margin: 0; padding: 15px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: #c9d5da; background: #0c1216; font: .8rem/1.55 "Cascadia Code", Consolas, monospace; }
.status { padding: 4px 8px; border-radius: 999px; color: var(--accent); background: light-dark(#dff3f0, #143d39); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; background: var(--surface-soft); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.online, .offline, .busy { display: inline-flex; align-items: center; gap: 6px; }
.online::before, .offline::before, .busy::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.offline::before { background: var(--muted); }
.busy::before { background: light-dark(#a85f08, #e5a64b); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions button, .role-select { min-height: 32px; padding: 5px 8px; }
.install-content { display: grid; gap: 12px; padding: 16px; }
.install-content p { margin-bottom: 0; color: var(--muted); }
dialog { width: min(440px, calc(100% - 32px)); padding: 0; color: var(--text); border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
dialog::backdrop { background: #08101599; }
dialog form { display: grid; gap: 14px; padding: 16px; }
.dialog-heading { min-height: 48px; display: flex; align-items: center; justify-content: space-between; margin: -16px -16px 0; padding: 0 16px; border-bottom: 1px solid var(--border); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
#toast { position: fixed; right: 18px; bottom: 18px; z-index: 20; max-width: min(380px, calc(100% - 36px)); padding: 10px 14px; border-radius: 5px; color: #fff; background: #162229; opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
#toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding: 16px 10px; }
  .sidebar .brand strong, .sidebar nav button, .account { font-size: 0; }
  .sidebar nav button { min-height: 38px; padding: 0; text-align: center; }
  .sidebar nav button::first-letter { font-size: 1rem; }
  .test-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics > div:first-child { grid-column: 1 / -1; }
  table { min-width: 680px; }
}
@media (max-width: 560px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; }
  .sidebar .brand strong { display: inline; font-size: 1rem; }
  .sidebar nav { margin-left: auto; display: flex; }
  .sidebar nav button { width: auto; min-width: 42px; padding: 0 8px; font-size: .8rem; }
  .sidebar nav button::first-letter { font-size: inherit; }
  .topbar { height: 56px; padding: 0 14px; }
  .page { padding: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: minmax(0, 1fr) 82px; }
}
