:root {
  --bg: #0f1419;
  --bg-elev: #171d26;
  --bg-elev-2: #1e2631;
  --border: #2a3441;
  --text: #e4e9ef;
  --text-dim: #93a1b1;
  --accent: #3d8bfd;
  --green: #2ea043;
  --amber: #d29922;
  --red: #e5534b;
  --purple: #a371f7;
  --radius: 10px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/* A class selector with `display` beats the UA stylesheet's [hidden] rule, so
   `.login-wrap { display: grid }` would keep the login card visible after
   sign-in. Make the attribute win everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }

.muted { color: var(--text-dim); }
.small { font-size: 12px; }
.num { text-align: right; }
.error { color: var(--red); font-size: 13px; margin: 8px 0 0; }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  transition: filter .12s ease;
}
button:hover:not(:disabled) { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

.btn-danger { background: var(--red); }
.btn-small { padding: 4px 9px; font-size: 12px; }

input, select {
  font: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 6px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { margin-bottom: 4px; }
.login-card p { margin: 0 0 22px; }
.login-card label { margin-top: 14px; }
.login-card button { width: 100%; margin-top: 22px; }

/* ---------------- Chrome ---------------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.refresh-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); margin: 0; }
.refresh-toggle input { width: auto; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 10px 14px;
  border-radius: 0;
  white-space: nowrap;
}
.tab:hover { color: var(--text); filter: none; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

main { padding: 20px; max-width: 1800px; }
.panel { display: none; }
.panel.active { display: block; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 150px; font-size: 13px; padding: 5px 9px; }

/* ---------------- Summary tiles ---------------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.stat-value.good { color: var(--green); }
.stat-value.warn { color: var(--amber); }
.stat-value.bad { color: var(--red); }

/* ---------------- Tables ---------------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-dim);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-elev-2); }
.mono { font-family: var(--mono); font-size: 12px; }
.empty-row td { text-align: center; color: var(--text-dim); padding: 28px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { background: #4a5663; }

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid;
  white-space: nowrap;
}
.chip-available { color: var(--green); border-color: var(--green); background: rgba(46,160,67,.12); }
.chip-busy      { color: var(--amber); border-color: var(--amber); background: rgba(210,153,34,.12); }
.chip-paused    { color: var(--purple); border-color: var(--purple); background: rgba(163,113,247,.12); }
.chip-offline   { color: var(--text-dim); border-color: var(--border); }
.chip-disabled  { color: var(--red); border-color: var(--red); background: rgba(229,83,75,.12); }
.chip-active    { color: var(--accent); border-color: var(--accent); background: rgba(61,139,253,.12); }
.chip-failed    { color: var(--red); border-color: var(--red); background: rgba(229,83,75,.12); }

/* ---------------- Forms ---------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  padding: 16px;
}
.form-actions { display: flex; align-items: flex-end; }
.form-actions button { width: 100%; }

.credential-box {
  margin: 0 16px 16px;
  padding: 14px 16px;
  background: rgba(46,160,67,.08);
  border: 1px solid var(--green);
  border-radius: var(--radius);
}
.credential-box h3 { margin: 0 0 8px; font-size: 14px; color: var(--green); }
.credential-box dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 12px; }
.credential-box dt { color: var(--text-dim); font-size: 12px; }
.credential-box dd { margin: 0; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.credential-box pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0 0 10px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
}
.credential-warning { color: var(--amber); font-size: 12px; margin: 0 0 10px; }

/* ---------------- Diagnostics ---------------- */
.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.diag-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.diag-card h3 { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.diag-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; }
.diag-card dt { color: var(--text-dim); font-size: 12px; }
.diag-card dd { margin: 0; font-size: 12px; text-align: right; font-family: var(--mono); word-break: break-all; }

.log-box {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 11px 16px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.45);
  z-index: 100;
  max-width: 420px;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }

@media (max-width: 720px) {
  main { padding: 12px; }
  .tabs { padding: 0 8px; }
  .topbar { padding: 10px 12px; }
}
