:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-2: #eaf1f8;
  --text: #12263a;
  --muted: #4d6478;
  --line: #d7e0ea;
  --primary: #1570ef;
  --primary-hover: #0b5fdb;
  --primary-soft: #dcebff;
  --ok: #0f8a5f;
  --ok-soft: #d8f3e8;
  --stop: #b42318;
  --stop-soft: #fde4e1;
  --warn: #b54708;
  --warn-soft: #feeed6;
  --shadow: 0 12px 32px rgba(18, 38, 58, 0.08);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0c1520;
  --surface: #15202c;
  --surface-2: #1c2b3a;
  --text: #e8eef4;
  --muted: #9db0c2;
  --line: #2a3c4e;
  --primary: #3b8cf0;
  --primary-hover: #62a4f5;
  --primary-soft: #16345a;
  --ok: #3dce95;
  --ok-soft: #143528;
  --stop: #f97066;
  --stop-soft: #3a1b1b;
  --warn: #f6b14a;
  --warn-soft: #3a2a12;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  background:
    radial-gradient(1200px 400px at 10% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.content { width: min(1200px, calc(100% - 40px)); margin: 28px auto 48px; }
.content.narrow { width: min(480px, calc(100% - 32px)); }
.content.medium { width: min(760px, calc(100% - 32px)); }
.content.console-page { width: min(1280px, calc(100% - 24px)); }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand-logo {
  height: 36px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
  display: block;
}
.lang-btn {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.logo-specs {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.logo-specs h2 { margin: 0 0 8px; font-size: 16px; }
.logo-specs ul { margin: 0; padding-left: 18px; color: var(--muted); }
.logo-preview { margin-bottom: 16px; }
.logo-preview img { height: 48px; width: auto; max-width: 240px; object-fit: contain; }
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, var(--primary), #0ea5a4 70%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px 7px 8px;
  border-radius: 999px;
  border: 2px solid white;
  border-left-color: transparent;
  transform: rotate(-20deg);
}
.brand-copy { display: flex; flex-direction: column; }
.brand-copy strong { font-size: 14px; letter-spacing: -0.02em; line-height: 1.2; }
.brand-copy small { color: var(--muted); font-size: 11px; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; flex: 0 0 auto; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.nav-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav { display: flex; gap: 6px; flex: 1; }
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}
.nav a.is-active,
.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }

.page-head, .card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head.compact { align-items: center; }
.page-head h1, .auth-card h1 { margin: 4px 0 8px; font-size: 30px; letter-spacing: -0.03em; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
}
.lede, .quiet, .hint { color: var(--muted); }
.lede { margin-top: 0; }
.hint { display: block; font-size: 12px; margin-top: 6px; }
.strong { font-weight: 700; }
.mono { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.auth-card, .table-card, .surface-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { padding: 32px; }
.auth-card.wide { padding: 32px; }
.surface-card { padding: 20px 22px; }
.table-card { overflow: auto; }

.stack { display: grid; gap: 16px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}
.check-row input { width: auto; }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="file"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
input:focus {
  outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
  border-color: var(--primary);
}

.primary-btn, .ghost-btn, .tiny-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}
.primary-btn {
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 11px 16px;
}
.primary-btn:hover { background: var(--primary-hover); }
.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}
.tiny-btn {
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
}
.tiny-btn-primary { background: var(--primary); color: #fff; }
.tiny-btn-danger { background: var(--stop-soft); color: var(--stop); }

.secret-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.secret-row input {
  flex: 1 1 220px;
}
.secret-row .tiny-btn {
  flex: 0 0 auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  margin: 2px 4px 2px 0;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-stopped { background: var(--stop-soft); color: var(--stop); }
.pill-busy { background: var(--warn-soft); color: var(--warn); }
.pill-quiet { background: var(--surface-2); color: var(--muted); }
.os-cell { width: 52px; text-align: center; }
.os-icon { width: 22px; height: 22px; display: block; margin: 0 auto; }
.os-linux { color: #2b6cb0; }
.os-windows { color: #1570ef; }
html[data-theme="dark"] .os-linux { color: #7dd3fc; }
html[data-theme="dark"] .os-windows { color: #60a5fa; }

.action-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.action-row .power-btn { width: 36px; height: 36px; border-radius: 10px; }
.action-row .power-btn .icon { width: 18px; height: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.endpoint-list { list-style: none; padding: 0; margin: 12px 0 16px; }
.endpoint-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; color: var(--text); }
.endpoint-list small { color: var(--muted); }

.access-fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.access-group h2 { margin: 0 0 10px; font-size: 16px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.endpoint-rows { display: grid; gap: 8px; margin-bottom: 12px; }
.endpoint-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; }

.flash-stack { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--stop-soft); color: var(--stop); }
.flash-warning { background: var(--warn-soft); color: var(--warn); }
.field-error { color: var(--stop); font-size: 12px; font-weight: 600; }

.console-stage {
  position: relative;
  background: #071018;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.novnc-screen {
  height: calc(100vh - 210px);
  min-height: 420px;
  background: #071018;
}
.console-stage-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  gap: 8px;
}
.console-fs-btn {
  background: color-mix(in srgb, #071018 70%, white);
  color: #fff;
}
.console-stage:fullscreen,
.console-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
}
.console-stage:fullscreen .novnc-screen,
.console-stage:-webkit-full-screen .novnc-screen {
  height: 100vh;
  min-height: 100vh;
}
.console-power {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0 8px;
}
.power-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
}
.power-btn .icon { width: 22px; height: 22px; }
.power-stop .icon,
.power-reset .icon { fill: currentColor; stroke: none; }
.power-start { background: #14804a; }
.power-start:hover { background: #0f6b3d; }
.power-shutdown { background: #c47b0a; }
.power-shutdown:hover { background: #a66708; }
.power-stop { background: #c4312a; }
.power-stop:hover { background: #a52822; }
.power-reboot { background: #1570ef; }
.power-reboot:hover { background: #0b5fdb; }
.power-reset { background: #d35400; }
.power-reset:hover { background: #b34700; }
.power-cad { background: #5b4b8a; }
.power-cad:hover { background: #4a3c72; }
.console-hint { color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; }
  .split, .endpoint-row { grid-template-columns: 1fr; }
}
