:root {
  --bg: #0c0e12;
  --panel: #14171e;
  --panel-2: #1b1f28;
  --line: #262b36;
  --text: #e7ebf1;
  --muted: #8a93a3;
  --accent: #4f8cff;
  --up: #33d17a;
  --down: #ff5b5b;
  --partial: #f2b134;
  --host: #a5a8c9;
  --radius: 14px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #161b26 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.muted { color: var(--muted); }
.error { color: var(--down); font-size: 0.85rem; margin: 6px 0 0; }

.brand {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.5px;
}
.brand .w {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(79, 140, 255, 0.5);
}
.brand--lg { font-size: 2.4rem; margin-bottom: 4px; }

/* login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}
.login-card input {
  width: 100%;
  margin-top: 18px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-card button {
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}
.login-card button:hover { filter: brightness(1.08); }
.btn-oidc {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  text-align: center;
  box-sizing: border-box;
}
.btn-oidc:hover { filter: brightness(1.08); }
.btn-oidc:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(12, 14, 18, 0.82);
  backdrop-filter: blur(10px);
  z-index: 5;
}
.topbar .brand { flex: none; }
.filter {
  flex: 0 1 200px;
  min-width: 80px;
  padding: 7px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 0.85rem;
}
.filter::placeholder { color: var(--muted); }
.filter:focus { outline: 2px solid var(--accent); border-color: transparent; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}
.summary {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ghost {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  flex: none;
  font-size: 1rem;
  cursor: pointer;
}
.ghost:hover { border-color: var(--accent); }

/* board + groups */
.board {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 22px 30px;
}
.grp + .grp { margin-top: 26px; }
.grp-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 16px 2px 8px;
  border-bottom: 1px solid var(--line);
}
.grp-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text);
}
.grp-count {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 4px;
  gap: 10px;
}
.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.03);
}
.dot.up { background: var(--up); box-shadow: 0 0 12px var(--up); }
.dot.down { background: var(--down); }
.dot.partial { background: var(--partial); box-shadow: 0 0 12px var(--partial); }
.card-title { font-weight: 700; font-size: 1.05rem; }
.card-sub { font-size: 0.78rem; color: var(--muted); margin-left: auto; text-align: right; }
.card-path {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: -4px;
}

.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 0.75rem;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip:hover { border-color: var(--accent); }
.chip .pdot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.chip .pdot.live { background: var(--up); }
.chip .pdot.dead { background: var(--down); }
.chip.domain { color: var(--accent); }

/* source tag — typographic label, not a chip: weight + tracking + an
   underline rule carry the distinction, no fill, no border. */
.tag {
  flex: none;
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  line-height: 1;
  padding-bottom: 3px;
  border-bottom: 1.5px solid currentColor;
  white-space: nowrap;
}
.tag--docker { color: var(--accent); }
/* A dedicated neutral, not --partial: that amber is reserved for the
   degraded-status dot, and Host being fully up shouldn't borrow it. */
.tag--host { color: var(--host); }

.services { display: flex; flex-direction: column; gap: 4px; }
.svc {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.svc .s-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--down); flex: none; }
.svc .s-dot.running { background: var(--up); }
.svc .s-name { color: var(--text); }

.hint { font-size: 0.68rem; color: var(--muted); line-height: 1.4; }

.actions { display: flex; gap: 8px; margin-top: 2px; }
.btn {
  flex: 1;
  padding: 9px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.up { color: var(--up); }
.btn.down { color: var(--down); }

.btn:focus-visible,
.ghost:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.foot { padding: 14px 22px 30px; text-align: center; font-size: 0.78rem; }

@media (max-width: 520px) {
  .board { padding: 8px 14px 24px; }
  .grid { gap: 12px; }
  .topbar { padding: 14px 16px; flex-wrap: wrap; }
  .filter { order: 3; flex-basis: 100%; }
}

.empty {
  padding: 40px 12px;
  text-align: center;
  font-size: 0.85rem;
}

/* tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 2px;
  flex: none;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--panel); color: var(--text); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* residents tab — its own palette (brass/amber on the same dark ground),
   scoped under .residents-board so it doesn't bleed into the Apps board's
   blue accent. Reuses the standalone roster page's identity, by request. */
.residents-board {
  --r-accent: #dba848;
  --r-accent-soft: #35291a;
  --r-live: #58b68e;
  --r-live-soft: #17332a;
  --r-restarting: #e0a23f;
  --r-restarting-soft: #332813;
  --r-font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 22px 40px;
}
.residents-board.hidden { display: none; }

.r-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.r-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: start;
  transition: border-color 0.15s ease;
}
.r-card:hover { border-color: var(--r-accent); }

.r-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  flex-wrap: wrap;
  grid-column: 1;
}
.r-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  align-self: center;
  background: var(--r-live);
  box-shadow: 0 0 0 3px var(--r-live-soft);
}
.r-dot.restarting {
  background: var(--r-restarting);
  box-shadow: 0 0 0 3px var(--r-restarting-soft);
}
.r-name {
  font-family: 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  font-weight: 620;
}
.r-title { color: var(--muted); font-size: 13.5px; }
.r-title.pending { font-style: italic; }

.r-open {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  text-decoration: none;
  font-family: var(--r-font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--r-accent);
  background: var(--r-accent-soft);
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  white-space: nowrap;
}
.r-open:hover { border-color: var(--r-accent); }
.r-open::after { content: " ↗"; }
.r-open[aria-disabled="true"] {
  color: var(--muted);
  background: var(--panel-2);
  pointer-events: none;
}

.r-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.r-folder::before { content: "📁 "; opacity: 0.6; }
.r-sep { color: var(--line); }
.r-url { overflow-wrap: anywhere; }
.r-copy {
  font-family: var(--r-font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 7px;
  cursor: pointer;
  flex: none;
}
.r-copy:hover { color: var(--text); border-color: var(--muted); }
.r-copy:focus-visible, .r-open:focus-visible { outline: 2px solid var(--r-accent); outline-offset: 2px; }

@media (max-width: 480px) {
  .r-card { grid-template-columns: 1fr; }
  .r-open { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 6px; }
}
