:root {
  --ink: #0f1115;
  --paper: #f6f7f9;
  --surface: #ffffff;
  --muted: rgba(15, 17, 21, 0.55);
  --faint: rgba(15, 17, 21, 0.4);
  --border: rgba(15, 17, 21, 0.1);
  --border-strong: rgba(15, 17, 21, 0.16);
  --accent: #0ec27b;
  --accent-strong: #099b62;
  --bad: #e0335c;
  --warn: #c98a00;
  --shadow: 0 1px 2px rgba(15, 17, 21, 0.04), 0 8px 24px rgba(15, 17, 21, 0.06);
  font-family: "Space Grotesk", "IBM Plex Sans", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
}

input,
button {
  font: inherit;
  color: inherit;
}

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

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: min(340px, 90vw);
  padding: 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.login-card h1::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  display: inline-block;
}

/* --- inputs / buttons (shared) --- */

input[type="text"],
input[type="url"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 194, 123, 0.15);
}

.btn {
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 80ms ease, background 120ms ease, border-color 120ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--ink);
  color: var(--surface);
}

.btn-primary:hover {
  background: #262a33;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.field-error {
  color: var(--bad);
  font-size: 0.85rem;
  margin: 0.6rem 0 0;
}

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

.shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-strong));
  box-shadow: 0 6px 16px rgba(14, 194, 123, 0.35);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.2;
}

.brand-sub {
  margin: 0;
  font-size: 0.75rem;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--faint);
  display: inline-block;
}

.live-dot.is-live {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 194, 123, 0.18);
}

.live-dot.is-error {
  background: var(--bad);
  box-shadow: 0 0 0 3px rgba(224, 51, 92, 0.18);
}

.live-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

/* --- flash banner --- */

.flash {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  border: 1px solid transparent;
}

.flash-success {
  background: rgba(14, 194, 123, 0.1);
  color: var(--accent-strong);
  border-color: rgba(14, 194, 123, 0.25);
}

.flash-error {
  background: rgba(224, 51, 92, 0.08);
  color: var(--bad);
  border-color: rgba(224, 51, 92, 0.2);
}

/* --- cards --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
}

.card-hint {
  margin: 0 0 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 60ch;
}

/* --- register form --- */

#register-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto auto;
  gap: 0.7rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.optional {
  font-weight: 400;
  color: var(--faint);
  text-transform: none;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  padding-bottom: 0.65rem;
}

.checkbox-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

@media (max-width: 720px) {
  #register-form {
    grid-template-columns: 1fr;
  }
}

/* --- instances table --- */

.instances-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.instances-count {
  font-size: 0.8rem;
  color: var(--faint);
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td.title-cell,
td.channel-cell {
  white-space: normal;
}

th {
  color: var(--faint);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

tbody tr:hover {
  background: rgba(15, 17, 21, 0.02);
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty {
  color: var(--faint);
  text-align: center;
  padding: 2rem 0.6rem;
  white-space: normal;
}

.status-badge {
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.status-live {
  background: rgba(14, 194, 123, 0.12);
  color: var(--accent-strong);
}

.status-backfilling {
  background: rgba(201, 138, 0, 0.14);
  color: var(--warn);
}

.status-error {
  background: rgba(224, 51, 92, 0.1);
  color: var(--bad);
}

.canvas-link {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
}

.canvas-link:hover {
  border-color: var(--ink);
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.row-actions button {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
}

.row-actions button:hover {
  border-color: var(--ink);
}

.row-actions .delete-btn {
  color: var(--bad);
  border-color: rgba(224, 51, 92, 0.3);
}

.row-actions .delete-btn:hover {
  border-color: var(--bad);
  background: rgba(224, 51, 92, 0.06);
}

/* --- toasts --- */

.toast-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 50;
}

.toast {
  padding: 0.65rem 0.95rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease;
}

.toast.toast-error {
  background: var(--bad);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
