:root {
  color-scheme: dark;
  --bg: #0f1216;
  --surface: #171c22;
  --surface-2: #1f262e;
  --border: #2b333d;
  --text: #e6ebf1;
  --muted: #97a3b1;
  --accent: #4f9cf9;
  --accent-strong: #2f7fe0;
  --danger: #e2604f;
  --ok: #47b881;
  --warn: #e0a94a;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

/*
 * Author rules that set `display` (for example `.grid { display: grid }`) beat
 * the browser's own `[hidden] { display: none }`, which would leave the signed
 * out dashboard on screen. This restores the attribute's meaning globally.
 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-mark {
  color: var(--accent);
}

.brand-name {
  font-weight: 650;
  letter-spacing: 0.02em;
}

.brand-tag {
  color: var(--muted);
  font-size: 12px;
}

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 22px 64px;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/*
 * Grid items default to `min-width: auto`, so a card cannot shrink below the
 * min-content width of whatever it contains. A five-column table then pushes
 * the card out of its track and the table spills over the neighbouring card.
 * Allowing the items to shrink keeps every table inside its own card.
 */
.grid > * {
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card-narrow {
  max-width: 420px;
  margin: 48px auto;
}

.card-wide {
  grid-column: 1 / -1;
}

h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

h2 {
  font-size: 17px;
  margin: 0 0 6px;
}

h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 20px 0 8px;
}

p {
  margin: 0 0 14px;
}

.muted {
  color: var(--muted);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 0;
  padding: 0;
  margin: 0;
}

.field > span,
.field > legend {
  font-size: 13px;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}

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

.button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
}

.button-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.button-ghost {
  background: transparent;
}

.button-small {
  padding: 4px 10px;
  font-size: 13px;
}

.row-start,
.row-end {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.row-end {
  justify-content: flex-end;
  margin-top: 12px;
}

.cred-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.cred {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.cred-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cred code {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}

.cred-actions {
  display: flex;
  gap: 8px;
}

/*
 * Last-resort fallback for very narrow cards: if the columns still cannot fit,
 * the table scrolls inside the card instead of overflowing it.
 */
.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  /* Long destination names and ids wrap instead of forcing the card wider. */
  overflow-wrap: anywhere;
}

.table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 13px;
}

.status-list {
  margin: 0;
  padding-left: 18px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
}

.badge-ready,
.badge-live,
.badge-ok {
  color: var(--ok);
  border-color: var(--ok);
}

.badge-pending_review,
.badge-blocked,
.badge-unknown,
.badge-starting {
  color: var(--warn);
  border-color: var(--warn);
}

.badge-not_eligible,
.badge-needs_reconnect,
.badge-error {
  color: var(--danger);
  border-color: var(--danger);
}

.badge-offline,
.badge-ended {
  color: var(--muted);
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-success {
  border-left-color: var(--ok);
}
