/*
 * One dark theme, deliberately: this is an operations console read at 3 a.m.
 * on whatever device is closest, so contrast and touch-target size outrank
 * matching anybody's OS theme.
 */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2330;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4493f8;
  --ok: #3fb950;
  --bad: #f85149;
  --warn: #d29922;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 0.5rem 0 0; }
.ok-text { color: var(--ok); }

/* --- login ---------------------------------------------------------------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(24rem, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.login-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }
.login-card p { margin-top: 0; }

label { display: block; margin: 1rem 0 0; font-size: 0.9rem; color: var(--muted); }

input, select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button {
  margin-top: 1.25rem;
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: default; }

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  margin: 0;
}

button.danger { background: var(--bad); }
button.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; margin: 0; }

/* --- shell ---------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 1.05rem; letter-spacing: 0.02em; }
.brand b { color: var(--accent); }
#who { flex: 1; text-align: right; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  overflow-x: auto;
}

.tabs a {
  padding: 0.5rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
}

.tabs a.active { color: var(--text); background: var(--bg); border: 1px solid var(--border); border-bottom-color: var(--bg); margin-bottom: -1px; }

.view { padding: 1rem; max-width: 72rem; margin: 0 auto; }

h2 { font-size: 1.1rem; margin: 1.5rem 0 0.75rem; }
h2:first-child { margin-top: 0.25rem; }

/* --- panels, stats, tables ------------------------------------------------ */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.6rem; }

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}

.stat .n { font-size: 1.5rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 0.8rem; }

.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.6rem; }

.tile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}

.tile .dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: none; }
.tile.up .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.tile.down .dot { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.tile.down { border-color: var(--bad); }
.tile .name { font-weight: 600; font-size: 0.9rem; }
.tile .lat { margin-left: auto; color: var(--muted); font-size: 0.8rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }

table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; background: var(--panel); position: sticky; top: 0; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.clickable { cursor: pointer; }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.badge.active, .badge.up, .badge.ACTIVE { color: var(--ok); border-color: var(--ok); }
.badge.suspended, .badge.down, .badge.BANNED, .badge.blocked { color: var(--bad); border-color: var(--bad); }
.badge.PENDING, .badge.paused, .badge.unknown { color: var(--warn); border-color: var(--warn); }

.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; }
.row label { margin: 0; flex: 1 1 10rem; }
.row button { margin-top: 0; align-self: end; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }

.crumbs { margin-bottom: 0.75rem; font-size: 0.9rem; }
.crumbs a { color: var(--accent); text-decoration: none; cursor: pointer; }

.small { font-size: 0.85rem; }

/* Reasons are sentences, not identifiers, so this column wraps while the
   rest of the table stays on one line. */
td.wrap { white-space: normal; min-width: 18rem; }

a.evidence { color: var(--accent); cursor: pointer; text-decoration: underline; }

.evidence-dump {
  margin: 0;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
  max-height: 22rem;
  overflow: auto;
}

/* Secrets and recovery codes: monospace and selectable, since the whole point
   is copying them accurately. */
.secret {
  display: inline-block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  user-select: all;
  word-break: break-all;
  line-height: 1.8;
}

details summary { cursor: pointer; }

.note {
  border-inline-start: 3px solid var(--warn);
  background: var(--panel);
  padding: 0.6rem 0.9rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9rem;
  margin: 0.75rem 0;
}

.toast {
  position: fixed;
  inset-block-end: 1rem;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  z-index: 100;
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.5);
}
.toast.bad { border-color: var(--bad); }

@media (max-width: 640px) {
  .view { padding: 0.75rem; }
  th, td { padding: 0.5rem 0.6rem; }
}
