/* PZTec Server Admin — "control room" identity.
   Deep blue-ink ground, steel-cyan accent, status colors carry the meaning.
   Mono-caps labels give the ops/terminal character; body text stays humane. */

:root {
  --bg: #0d131d;
  --panel: #141c2a;
  --panel-2: #182234;
  --border: #243149;
  --text: #e6ecf5;
  --dim: #8c9ab0;
  --accent: #58b7c9;
  --ok: #40b67c;
  --warn: #e3a63c;
  --crit: #e2585a;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SF Mono", ui-monospace, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }

/* Links must stay readable on the dark ground — no browser default blue/violet */
a { color: var(--accent); text-decoration-color: rgba(88, 183, 201, 0.5); }
a:visited { color: var(--accent); }
a:hover { color: #8ad4e4; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.rail {
  width: 208px; flex: none;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 12px;
  position: sticky; top: 0; height: 100vh;
}
.rail-brand { display: flex; gap: 10px; align-items: flex-start; margin: 0 8px 26px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-top: 5px; flex: none;
  box-shadow: 0 0 10px var(--accent);
}
.brand-name {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  color: var(--text); line-height: 1.5;
}
.rail-link {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; color: var(--dim);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.rail-link:hover { color: var(--text); background: var(--panel-2); }
.rail-link.active { color: var(--accent); background: var(--panel-2); }
.rail-link:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.rail-footer { margin-top: auto; padding: 8px 12px; display: grid; gap: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border);
}
.menu-btn {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 36px; padding: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; flex: none;
}
.menu-btn span { display: block; height: 2px; background: var(--text); border-radius: 1px; }
.rail-backdrop {
  position: fixed; inset: 0; background: rgba(6, 10, 16, 0.65); z-index: 65;
}
.topbar-status { display: flex; align-items: center; gap: 14px; }
.topbar-meta { display: flex; gap: 18px; font-family: var(--mono); font-size: 12px; }
.content { padding: 22px 24px 40px; }

/* ---------- fleet strip (signature) ---------- */
.fleet-strip {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 10px 24px; border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.fleet-cell {
  width: 22px; height: 8px; border-radius: 2px;
  background: var(--border); cursor: default;
}
.fleet-cell.ok { background: var(--ok); }
.fleet-cell.warn { background: var(--warn); }
.fleet-cell.crit { background: var(--crit); }

/* ---------- cards + grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.span4 { grid-column: span 4; }
.span6 { grid-column: span 6; }
.span12 { grid-column: span 12; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px 18px;
}
.card-eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--dim); margin-bottom: 12px;
}
.card-hint { color: var(--dim); font-size: 13px; margin: 0 0 12px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }

/* ---------- metrics ---------- */
.gauge {
  height: 10px; background: var(--panel-2); border-radius: 5px;
  overflow: hidden; margin-bottom: 10px;
}
.gauge-fill { height: 100%; width: 0; background: var(--ok); border-radius: 5px;
  transition: width .6s ease, background-color .6s ease; }
.gauge-fill.warn { background: var(--warn); }
.gauge-fill.crit { background: var(--crit); }
.metric-line { display: flex; align-items: baseline; gap: 10px; }
.metric-big { font-family: var(--mono); font-size: 26px; }
.disk-row { margin-bottom: 10px; }
.disk-label { display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 12px; color: var(--dim); margin-bottom: 4px; }

.chart { width: 100%; height: 160px; display: block; touch-action: pan-y; cursor: crosshair; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart-fill { fill: rgba(88, 183, 201, 0.12); stroke: none; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--dim); font-family: var(--mono); font-size: 10px; }
.cross-line { stroke: var(--dim); stroke-width: 1; stroke-dasharray: 4 3; }
.cross-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 1.5; }
.cross-box { fill: var(--panel-2); stroke: var(--border); }
.cross-label { fill: var(--text); font-family: var(--mono); font-size: 11px; }

/* ---------- status ---------- */
.status-badge {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
  padding: 5px 12px; border-radius: 6px; border: 1px solid;
}
.status-ok { color: var(--ok); border-color: var(--ok); }
.status-warning { color: var(--warn); border-color: var(--warn); }
.status-critical { color: var(--crit); border-color: var(--crit); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }

/* ---------- tables / lists ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.10em; text-transform: uppercase; color: var(--dim);
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--accent); }
th.sortable.active { color: var(--accent); }
.sort-arrow { font-size: 9px; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.mono { font-family: var(--mono); }
.mono-dim { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.kv-list div { display: flex; justify-content: space-between; padding: 5px 0;
  border-bottom: 1px solid var(--border); font-size: 13px; }
.kv-list div:last-child { border-bottom: 0; }
.issue-list .issue {
  border-left: 3px solid var(--warn); background: var(--panel-2);
  border-radius: 0 8px 8px 0; padding: 10px 12px; margin-bottom: 8px;
}
.issue.crit { border-left-color: var(--crit); }
.issue-title { font-weight: 600; font-size: 14px; }
.issue-detail { color: var(--dim); font-size: 13px; }
.empty-note { color: var(--dim); font-size: 13px; padding: 6px 0; }

/* ---------- controls ---------- */
.btn {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1016; }
.btn-primary:hover { color: #0b1016; filter: brightness(1.1); }
.btn-danger { border-color: var(--crit); color: var(--crit); }
.btn-danger:hover { background: var(--crit); color: #0b1016; border-color: var(--crit); }
.btn-ghost { background: none; }
.btn-small { padding: 5px 10px; font-size: 11px; }
.btn-block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.10em; text-transform: uppercase; color: var(--dim);
  margin-bottom: 6px;
}
input[type="text"], input[type="password"], input[type="number"], .select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: var(--sans);
}
/* Selects size to their longest option (container names get long) — never
   let them push past the card on small screens. */
.select { width: auto; max-width: 100%; min-width: 0; }
.input-inline { width: 130px !important; font-family: var(--mono); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.log-box {
  background: #0a0f17; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  padding: 12px; max-height: 480px; overflow: auto; white-space: pre-wrap;
  word-break: break-word; margin: 12px 0 0;
}
.totp-qr { width: 190px; height: 190px; background: #fff; border-radius: 8px; padding: 8px; }

/* ---------- resource bars ---------- */
.usebar {
  height: 8px; min-width: 70px; background: var(--panel-2);
  border-radius: 4px; overflow: hidden;
}
.usebar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 4px; }
.usebar-fill.warn { background: var(--warn); }
.usebar-fill.crit { background: var(--crit); }
.res-sub { color: var(--dim); font-size: 12px; font-family: var(--mono); }

/* ---------- dialogs / toast ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(6, 10, 16, 0.7);
  display: flex; align-items: center; justify-content: center; z-index: 40;
}
.dialog {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  max-width: 440px; width: calc(100% - 40px); padding: 22px;
}
.dialog h2 { margin: 0 0 10px; font-size: 17px; }
.dialog p { color: var(--dim); }
.toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 50;
  background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; font-size: 13px; max-width: 380px;
}
.toast.error { border-color: var(--crit); }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; padding: 30px;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-title { font-size: 20px; margin: 0 0 4px; }
.login-sub { color: var(--dim); font-size: 13px; margin: 0 0 22px; }
.login-error { color: var(--crit); font-size: 13px; min-height: 18px; margin: 12px 0 0; }
.login-note { color: var(--dim); font-size: 12px; margin-top: 18px; }

/* ---------- responsive: rail becomes a hamburger drawer ---------- */
@media (max-width: 980px) {
  .span4, .span6 { grid-column: span 12; }
  .menu-btn { display: flex; }
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100vh;
    width: 240px; z-index: 70;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  }
  .rail.open { transform: none; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .topbar-meta { order: 3; width: 100%; justify-content: space-between; }
  .fleet-strip { padding: 10px 16px; }
  .content { padding: 16px 12px 40px; }
  .card { padding: 14px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
