/* MediaXT admin. Near-black surfaces with one lime accent; a light theme mirrors it.
   Linked after the Tailwind build, so these component classes win over its utilities. */

:root {
  color-scheme: light;
  --bg: #eef0ea;
  --surface: #ffffff;
  --surface-2: #f5f6f1;
  --surface-3: #eceee6;
  --surface-hover: #e4e7dc;
  --border: rgba(20, 28, 10, 0.08);
  --border-strong: rgba(20, 28, 10, 0.14);
  --text: #11150c;
  --muted: #5d6453;
  --soft: #8a917f;
  --accent: #b5ec2c;
  --accent-2: #86d42a;
  --accent-grad: linear-gradient(95deg, #d2f73d 0%, #a6e32e 55%, #7fcf2a 100%);
  --accent-ink: #0d1400;
  --accent-text: #4d7c0f;
  --accent-soft: rgba(132, 204, 22, 0.14);
  --glow-strength: 0.35;
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.1);
  --warn: #b45309;
  --warn-soft: rgba(245, 158, 11, 0.12);
  --info: #0369a1;
  --info-soft: rgba(14, 165, 233, 0.12);
  --shadow: 0 1px 2px rgba(17, 21, 12, 0.04), 0 8px 24px rgba(17, 21, 12, 0.05);
  --radius-lg: 1.5rem;
  --radius: 1.1rem;
  --radius-sm: 0.8rem;
  --sidebar-w: 17rem;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

.dark {
  color-scheme: dark;
  --bg: #0b0b0c;
  --surface: #141415;
  --surface-2: #1b1b1d;
  --surface-3: #232326;
  --surface-hover: #2b2b2f;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.11);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --soft: #71717a;
  --accent-text: #c4f042;
  --accent-soft: rgba(190, 242, 60, 0.12);
  --glow-strength: 0.6;
  --danger: #fb4a6b;
  --danger-soft: rgba(251, 74, 107, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --info: #7dd3fc;
  --info-soft: rgba(56, 189, 248, 0.14);
  --shadow: none;
}

html {
  background: var(--bg);
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: var(--bg);
}

[x-cloak] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

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

.surface-soft {
  color: var(--soft);
}

/* --- Shell ------------------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
}

.app-main {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.app-content {
  flex: 1 1 auto;
  width: 100%;
  max-width: 96rem;
  margin: 0 auto;
  padding: 0.5rem 1rem 2.5rem;
}

@media (min-width: 640px) {
  .app-content {
    padding: 0.5rem 1.5rem 3rem;
  }
}

@media (min-width: 1024px) {
  .app-main {
    padding-left: var(--sidebar-w);
  }

  .app-content {
    padding: 0.5rem 2rem 3rem;
  }
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: none;
  width: var(--sidebar-w);
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 1rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--accent-grad);
  color: var(--accent-ink);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand-sub {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--soft);
}

.nav {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.72rem 1rem;
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.nav-item:hover {
  background: var(--surface-3);
}

.nav-item .nav-chevron {
  margin-left: auto;
  color: var(--soft);
}

.nav-item.is-active {
  border-color: transparent;
  background: var(--accent-grad);
  color: var(--accent-ink);
  font-weight: 650;
  box-shadow: 0 8px 24px -10px rgba(163, 230, 53, 0.55);
}

.nav-item.is-active .nav-chevron {
  color: var(--accent-ink);
}

.sidebar-foot {
  display: grid;
  gap: 0.6rem;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border-radius: 1.25rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.65rem 0.75rem;
}

.user-card-text {
  min-width: 0;
}

.user-card-name {
  font-size: 0.86rem;
  font-weight: 650;
}

.user-card-mail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74rem;
  color: var(--soft);
}

.avatar {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: linear-gradient(135deg, #3f3f46, #18181b);
  color: #e4e4e7;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 2px solid var(--surface-3);
}

.version-tag {
  text-align: center;
  font-size: 0.7rem;
  color: var(--soft);
}

/* --- Top bar ----------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 96rem;
  margin: 0 auto;
  padding: 1rem 1rem 0.85rem;
}

@media (min-width: 640px) {
  .topbar-inner {
    padding: 1.1rem 1.5rem 0.9rem;
  }
}

@media (min-width: 1024px) {
  .topbar-inner {
    padding: 1.25rem 2rem 1rem;
  }
}

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

@media (min-width: 1024px) {
  .topbar-brand {
    display: none;
  }
}

.search-pill {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  max-width: 26rem;
  align-items: center;
}

.search-pill svg {
  position: absolute;
  left: 1rem;
  color: var(--muted);
  pointer-events: none;
}

.search-pill input {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.72rem 1rem 0.72rem 2.6rem;
  font-size: 0.88rem;
  color: var(--text);
}

.search-pill input::placeholder {
  color: var(--soft);
}

.search-pill input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  background: var(--surface-3);
}

.icon-button-sm {
  width: 2.1rem;
  height: 2.1rem;
}

@media (min-width: 1024px) {
  .topbar-avatar {
    display: none;
  }
}

.mobile-nav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  max-width: 96rem;
  margin: 0 auto;
  padding: 0 1rem 0.85rem;
  scrollbar-width: none;
}

.mobile-nav::-webkit-scrollbar {
  display: none;
}

/* Written here rather than as lg:hidden: this file loads after Tailwind, so a display
   rule on .mobile-nav used to win over the utility and put both navs on desktop. */
@media (min-width: 1024px) {
  .mobile-nav {
    display: none;
  }
}

.mobile-nav-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.mobile-nav-link-active {
  border-color: transparent;
  background: var(--accent-grad);
  color: var(--accent-ink);
}

/* --- Page structure ---------------------------------------------------------------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-subtitle {
  margin-top: 0.35rem;
  max-width: 46rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.section-head-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-head-link {
  font-size: 0.84rem;
  color: var(--muted);
}

.section-head-link:hover {
  color: var(--accent-text);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.6rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.breadcrumb a:hover {
  color: var(--accent-text);
}

/* The old small-caps label. Kept for the few places a card still wants a kicker. */
.eyebrow {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}

/* --- Cards ------------------------------------------------------------------------- */

.card,
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.card-pad {
  padding: 1.25rem;
}

@media (min-width: 640px) {
  .card-pad {
    padding: 1.5rem;
  }
}

.card-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-note {
  margin-top: 0.3rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

.section-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-note {
  margin-top: 0.3rem;
  max-width: 52rem;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--muted);
}

.section-block + .section-block {
  margin-top: 2rem;
}

/* --- KPI cards --------------------------------------------------------------------- */

.stat-card {
  --glow: 163, 230, 53;
  position: relative;
  overflow: hidden;
  display: flex;
  min-height: 10.5rem;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(90% 110% at 100% 100%, rgba(var(--glow), var(--glow-strength)) 0%, rgba(var(--glow), 0) 62%),
    var(--surface);
  padding: 1rem 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.stat-green { --glow: 74, 222, 128; }
.stat-emerald { --glow: 16, 185, 129; }
.stat-teal { --glow: 45, 212, 191; }

.stat-card-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgb(var(--glow));
  color: var(--accent-ink);
}

.stat-lime .stat-icon {
  background: var(--accent-grad);
}

.stat-label {
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-arrow {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  margin-left: auto;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text);
  transition: background 0.15s ease;
}

.stat-arrow:hover {
  background: var(--surface-3);
}

.stat-value {
  margin-top: auto;
  padding-top: 1.1rem;
  font-size: 2.15rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.stat-badge {
  border-radius: 999px;
  background: rgb(var(--glow));
  padding: 0.18rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--accent-ink);
}

.stat-lime .stat-badge {
  background: var(--accent-grad);
}

/* --- Stream tiles (the dashboard's "matches") --------------------------------------- */

.stream-tile {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease;
}

.stream-tile:hover {
  border-color: var(--border-strong);
}

.stream-tile-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stream-tile-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 600;
}

.stream-tile-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.stream-orb {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--soft);
  box-shadow: 0 0 0 5px var(--surface-2);
}

.stream-orb.is-live {
  background: var(--accent-grad);
  color: var(--accent-ink);
  box-shadow: 0 0 0 5px var(--accent-soft);
}

.stream-io {
  display: grid;
  gap: 0.2rem;
  border-radius: 1rem;
  background: var(--surface-2);
  padding: 0.55rem 0.85rem;
  text-align: center;
}

.stream-io-label {
  font-size: 0.7rem;
  color: var(--soft);
}

.stream-io-value {
  font-size: 1rem;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.stream-tile-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* --- Rows: activity, quick actions ------------------------------------------------- */

.row-list {
  display: grid;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 0;
}

.row-item-stack {
  display: block;
}

.row-item + .row-item {
  border-top: 1px solid var(--border);
}

a.row-item:hover .row-title,
button.row-item:hover .row-title {
  color: var(--accent-text);
}

.row-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent-text);
}

.row-icon-danger {
  color: var(--danger);
}

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

.row-body {
  min-width: 0;
  flex: 1 1 auto;
  text-align: left;
}

.row-title {
  font-size: 0.9rem;
  font-weight: 600;
}

.row-sub {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.time-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

/* --- Badges and chips -------------------------------------------------------------- */

.status-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.28rem 0.65rem 0.28rem 0.55rem;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: currentColor;
}

.status-online {
  color: var(--accent-text);
}

.status-online::before {
  box-shadow: 0 0 0 3px var(--accent-soft);
  animation: live-pulse 1.8s ease-in-out infinite;
}

.status-ready {
  color: var(--info);
}

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

.status-disabled {
  color: var(--danger);
}

@keyframes live-pulse {
  50% {
    box-shadow: 0 0 0 5px transparent;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-online::before {
    animation: none;
  }
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.28rem 0.65rem;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

code.pill,
code.chip {
  font-family: var(--mono);
  font-size: 0.76rem;
}

.chip-accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.chip-warn {
  border-color: transparent;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
}

.meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.18rem 0.55rem;
  font-size: 0.74rem;
  white-space: nowrap;
}

.meta-key {
  color: var(--soft);
}

/* --- Buttons ----------------------------------------------------------------------- */

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.66rem 1.15rem;
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, color 0.15s ease;
}

.primary-button {
  background: var(--accent-grad);
  color: var(--accent-ink);
  box-shadow: 0 10px 26px -12px rgba(132, 204, 22, 0.8);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px -12px rgba(132, 204, 22, 0.9);
}

.secondary-button {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  background: var(--surface-3);
}

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

.ghost-button:hover {
  background: var(--surface-3);
  color: var(--text);
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.danger-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8rem;
}

.copy-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 0.32rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s ease;
}

.copy-link:hover {
  background: var(--surface-3);
}

.copy-link.is-copied {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* --- Forms ------------------------------------------------------------------------- */

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.form-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--surface-2);
  padding: 0.72rem 0.95rem;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input::placeholder {
  color: var(--soft);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select.form-input {
  padding-right: 2.5rem;
}

.dark select.form-input {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%23a1a1aa' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
}

.form-help {
  margin-top: 0.4rem;
  display: block;
  font-size: 0.77rem;
  line-height: 1.5;
  color: var(--muted);
}

.form-error {
  margin-top: 0.4rem;
  display: block;
  font-size: 0.8rem;
  color: var(--danger);
}

.form-grid {
  display: grid;
  gap: 1.1rem;
}

@media (min-width: 768px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .span-full {
    grid-column: 1 / -1;
  }
}

/* A checkbox with its explanation beside it, as one clickable row. */
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.9rem 1rem;
}

.toggle-row:hover {
  border-color: var(--border-strong);
}

.toggle-row input[type="checkbox"] {
  margin-top: 0.15rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 0.35rem;
  border-color: var(--border-strong);
  background-color: var(--surface);
  color: var(--accent-2);
}

.toggle-row input[type="checkbox"]:checked {
  border-color: transparent;
  background-color: var(--accent-2);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%230d1400' viewBox='0 0 16 16'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0'/%3E%3C/svg%3E");
}

.toggle-row input[type="checkbox"]:focus {
  --tw-ring-color: var(--accent-2);
  --tw-ring-offset-color: var(--surface);
}

.toggle-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.toggle-note {
  margin-top: 0.2rem;
  display: block;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

/* A radio rendered as a card. */
.choice {
  display: block;
  cursor: pointer;
}

.choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.choice-card {
  position: relative;
  display: block;
  height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.95rem 2.6rem 0.95rem 1rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice-card::after {
  content: "";
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
}

.choice:hover .choice-card {
  border-color: var(--border-strong);
}

.choice input:checked + .choice-card {
  border-color: var(--accent-2);
  background: var(--accent-soft);
}

.choice input:checked + .choice-card::after {
  border: 0;
  background: var(--accent-grad);
  box-shadow: inset 0 0 0 3.5px var(--surface);
}

.choice input:focus-visible + .choice-card {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.choice-title {
  display: block;
  font-size: 0.9rem;
  font-weight: 650;
}

.choice-note {
  margin-top: 0.35rem;
  display: block;
  font-size: 0.79rem;
  line-height: 1.5;
  color: var(--muted);
}

/* --- Tables ------------------------------------------------------------------------ */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-head th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--soft);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table-row td {
  padding: 0.9rem 1rem;
  vertical-align: middle;
  font-size: 0.88rem;
  color: var(--text);
}

.table-row + .table-row td {
  border-top: 1px solid var(--border);
}

.table-row:hover td {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

.table-row td:first-child {
  border-top-left-radius: 0.9rem;
  border-bottom-left-radius: 0.9rem;
}

.table-row td:last-child {
  border-top-right-radius: 0.9rem;
  border-bottom-right-radius: 0.9rem;
}

.table-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
}

.stream-cell {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.stream-cell-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.stream-cell-name:hover {
  color: var(--accent-text);
}

.stream-cell-path {
  display: block;
  margin-top: 0.1rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--soft);
}

.stream-cell .stream-orb {
  width: 2.35rem;
  height: 2.35rem;
  box-shadow: none;
}

/* The dashboard and streams list used to wrap tables in these. Kept for the usage page. */
.table-shell {
  position: relative;
}

/* --- Menus ------------------------------------------------------------------------- */

.menu {
  position: relative;
  display: inline-flex;
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  z-index: 40;
  width: 17rem;
  border-radius: 1.1rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 0.4rem;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.45);
  text-align: left;
}

.menu-panel-up {
  top: auto;
  bottom: calc(100% + 0.45rem);
}

.menu-label {
  padding: 0.55rem 0.65rem 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--soft);
}

.menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.65rem;
  border-radius: 0.75rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
}

.menu-item svg {
  flex: 0 0 auto;
  color: var(--muted);
}

.menu-item:hover {
  background: var(--surface-3);
}

.menu-item-danger,
.menu-item-danger svg {
  color: var(--danger);
}

.menu-item-danger:hover {
  background: var(--danger-soft);
}

.menu-item-note {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.menu-divider {
  margin: 0.35rem 0.25rem;
  border-top: 1px solid var(--border);
}

/* --- Tabs: a segmented pill control ------------------------------------------------ */

.tab-bar {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.3rem;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--accent-grad);
  color: var(--accent-ink);
}

/* Panels behind a tab bar. Hidden, never removed; see tabPanels() in app.js. */
.tab-panel {
  scroll-margin-top: 6rem;
}

/* --- Settings: a section list beside the form ------------------------------------- */

.settings-layout {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .settings-layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    align-items: start;
  }
}

.settings-menu {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-menu::-webkit-scrollbar {
  display: none;
}

@media (min-width: 1024px) {
  .settings-menu {
    position: sticky;
    top: 6rem;
    flex-direction: column;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
    padding: 0.6rem;
  }
}

.settings-menu-item {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.55rem 0.9rem;
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
  text-align: left;
}

@media (min-width: 1024px) {
  .settings-menu-item {
    border-color: transparent;
    background: transparent;
    padding: 0.62rem 0.85rem;
  }
}

.settings-menu-item:hover {
  background: var(--surface-3);
  color: var(--text);
}

.settings-menu-item.is-active {
  border-color: transparent;
  background: var(--accent-grad);
  color: var(--accent-ink);
}

.settings-section {
  scroll-margin-top: 6rem;
}

.settings-section-head {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  margin-bottom: 1.35rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

/* Save has to be reachable without scrolling past thirty fields to find it. */
.save-bar {
  position: sticky;
  bottom: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 0.5rem 0.5rem 0.5rem 1.25rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.5);
}

.save-state {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.save-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--accent-2);
}

.save-dot.is-dirty {
  background: var(--warn);
}

/* --- Callouts ---------------------------------------------------------------------- */

.note-callout {
  display: flex;
  gap: 0.7rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--warn-soft);
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  line-height: 1.55;
}

.note-callout svg {
  flex: 0 0 auto;
  margin-top: 0.1rem;
  color: var(--warn);
}

.alert {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-size: 0.86rem;
  line-height: 1.5;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.alert-info {
  background: var(--surface-2);
  color: var(--text);
}

.state-banner {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid;
  padding: 1rem 1.15rem 1rem 1.4rem;
  overflow: hidden;
}

.state-banner::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: currentColor;
}

.state-banner-title {
  font-size: 0.98rem;
  font-weight: 650;
  color: var(--text);
}

.state-banner-note {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--muted);
}

.state-ok {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-2);
}

.state-warn {
  border-color: transparent;
  background: var(--warn-soft);
  color: var(--warn);
}

.state-bad {
  border-color: transparent;
  background: var(--danger-soft);
  color: var(--danger);
}

/* --- Toasts ------------------------------------------------------------------------ */

.toast-stack {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 0.6rem 0.75rem 0.6rem 0.65rem;
  font-size: 0.86rem;
  box-shadow: var(--shadow);
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-3);
}

.toast-success .toast-icon {
  background: var(--accent-grad);
  color: var(--accent-ink);
}

.toast-error .toast-icon {
  background: var(--danger);
  color: #fff;
}

.toast-close {
  margin-left: auto;
  color: var(--soft);
}

/* --- Modal ------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 2rem;
  }
}

.modal-panel {
  width: min(100%, 60rem);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  border-radius: 1.75rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 1.5rem;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  color: var(--text);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* --- Copy fields ------------------------------------------------------------------- */

.copy-field {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.85rem 0.95rem;
}

.copy-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.copy-field-value {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
  word-break: break-all;
}

.copy-field-mono {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.copy-field-hint {
  margin-top: 0.45rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}

/* URL previews on the stream form. */
.preview-grid {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.preview-item {
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.7rem 0.85rem;
}

.preview-value {
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.5;
  word-break: break-all;
}

/* --- Runtime and usage figures ----------------------------------------------------- */

.runtime-strip {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}

.runtime-stat {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 0.85rem 1rem;
}

.runtime-stat-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 550;
  color: var(--muted);
}

.runtime-stat-value {
  margin-top: 0.4rem;
  font-size: 1.35rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.usage-headline {
  --glow: 163, 230, 53;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(80% 120% at 100% 100%, rgba(var(--glow), calc(var(--glow-strength) * 0.7)) 0%, rgba(var(--glow), 0) 60%),
    var(--surface-2);
  padding: 1.15rem 1.25rem;
}

.usage-headline.tone-teal {
  --glow: 45, 212, 191;
}

.usage-headline-value {
  margin-top: 0.6rem;
  font-size: 1.9rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.usage-headline-note {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* A usage figure with its share of the largest one as a bar underneath. */
.meter {
  height: 0.45rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
  transition: width 0.3s ease;
}

.meter-fill-teal {
  background: linear-gradient(90deg, #5eead4, #14b8a6);
}

/* --- Facts, logs ------------------------------------------------------------------- */

.fact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
}

.fact-row + .fact-row {
  border-top: 1px solid var(--border);
}

.fact-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.fact-value {
  font-size: 0.86rem;
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.fact-value-muted {
  font-weight: 400;
  color: var(--muted);
}

.log-action {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.log-target-link {
  font-size: 0.86rem;
  color: var(--accent-text);
}

.log-target-link:hover {
  text-decoration: underline;
}

/* Endpoints most people should never need. */
.advanced-toggle {
  cursor: pointer;
  list-style: none;
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--accent-text);
}

.advanced-toggle::-webkit-details-marker {
  display: none;
}

/* --- Streams page ------------------------------------------------------------------ */

.filter-bar {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .filter-bar {
    grid-template-columns: minmax(0, 1fr) 11rem 11rem auto;
    align-items: center;
  }
}

.filter-search {
  position: relative;
}

.filter-search svg {
  position: absolute;
  top: 50%;
  left: 0.95rem;
  transform: translateY(-50%);
  color: var(--soft);
  pointer-events: none;
}

.filter-search .form-input {
  padding-left: 2.5rem;
}

.filter-bar .form-input {
  border-radius: 999px;
}

.stream-card-list {
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .stream-card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.viewport-fill {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
}

/* --- Login and standalone pages ---------------------------------------------------- */

.login-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.login-shell::before {
  content: "";
  position: absolute;
  right: -12rem;
  bottom: -14rem;
  width: 40rem;
  height: 40rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(163, 230, 53, 0.35), transparent 65%);
  pointer-events: none;
}

.login-shell::after {
  content: "";
  position: absolute;
  left: -14rem;
  top: -16rem;
  width: 36rem;
  height: 36rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(45, 212, 191, 0.16), transparent 65%);
  pointer-events: none;
}

.login-panel {
  position: relative;
  z-index: 1;
  border-radius: 1.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.5);
}
