:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2030;
  --line: #262d3d;
  --text: #e6eaf2;
  --muted: #8b95ab;
  --accent: #4d9fff;
  --ok: #35d07f;
  --warn: #f5a623;
  --bad: #ff5f56;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #182034 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 18px 64px; }

header.top {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 18px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
header.top h1 { font-size: 19px; margin: 0; letter-spacing: .3px; }
header.top .spacer { flex: 1; }
.tag {
  font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}

button {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 14px;
  transition: background .15s, border-color .15s, opacity .15s;
}
button:hover:not(:disabled) { background: #232a3c; border-color: #34405a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #04121f; font-weight: 600; }
button.primary:hover:not(:disabled) { background: #6bb0ff; border-color: #6bb0ff; }
button.danger { border-color: #4a2626; color: #ffb1ad; }
button.danger:hover:not(:disabled) { background: #381f1f; border-color: #6b3232; }
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

select, input[type=password] {
  font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; max-width: 100%;
}
select:focus, input:focus { outline: 2px solid #2c5b96; outline-offset: 0; }

.card {
  background: linear-gradient(180deg, var(--panel) 0%, #11151d 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}

.host-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.host-head h2 { margin: 0; font-size: 17px; }
.host-head .sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(53,208,127,.7); }
.dot.off { background: #3a4152; }
.dot.warn { background: var(--warn); box-shadow: 0 0 10px rgba(245,166,35,.6); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.grid {
  display: grid; gap: 12px; margin-top: 16px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.metric {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.metric .label {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; gap: 8px;
}
.metric .value { font-size: 22px; font-weight: 600; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.metric .foot { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.bar { height: 6px; border-radius: 999px; background: #0d111a; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.bar > i.ok { background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.section-title {
  font-size: 12px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 20px 0 10px;
}

.svc {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-2); margin-bottom: 8px;
}
.svc .name { font-weight: 600; }
.svc .state { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.svc .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.offline-note { color: var(--muted); margin-top: 12px; font-size: 14px; }
.err { color: #ffb1ad; font-size: 13px; margin-top: 10px; word-break: break-word; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #0f1520; border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 16px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { border-color: #6b3232; }

.login {
  max-width: 380px; margin: 14vh auto; text-align: center;
}
.login .card { padding: 26px; }
.login h1 { font-size: 20px; margin: 0 0 6px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login input { width: 100%; margin-bottom: 12px; text-align: center; }
.login button { width: 100%; }
.login .msg { color: #ffb1ad; font-size: 13px; min-height: 18px; margin-top: 10px; }

@media (max-width: 620px) {
  .actions { width: 100%; margin-left: 0; }
  .actions button { flex: 1; }
}

/* ---- remote screen viewer ---- */
#screen-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: none; flex-direction: column;
  background: #05070b;
}
#screen-overlay.open { display: flex; }
#screen-overlay .screen-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
  background: var(--panel); flex: 0 0 auto;
}
#screen-overlay .screen-title { font-weight: 600; font-size: 14px; }
#screen-overlay .spacer { flex: 1; }
#screen-overlay .screen-frame {
  flex: 1 1 auto; width: 100%; border: 0; background: #05070b;
}
