:root {
  --bg-base: #070a11;
  --bg-surface: #0d121f;
  --bg-elevated: #141c2e;
  --accent-gold: #fdc500;
  --accent-amber: #f59e0b;
  --accent-cyan: #38bdf8;
  --status-live: #10b981;
  --status-offline: #64748b;
  --status-error: #ef4444;
  --border-subtle: rgba(253, 197, 0, 0.12);
  --border-active: rgba(253, 197, 0, 0.40);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
}

.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.text-gold { color: var(--accent-gold); }
.text-amber { color: var(--accent-amber); }
.text-cyan { color: var(--accent-cyan); }
.text-live { color: var(--status-live); }
.text-error { color: var(--status-error); }
.muted { color: var(--text-secondary); }
.center { text-align: center; }
.w-full { width: 100%; }

code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

.ambient-glow {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(130px);
  z-index: 0;
  opacity: 0.22;
}
.ambient-glow-1 {
  width: 460px; height: 460px; top: -140px; left: -100px;
  background: radial-gradient(circle, var(--accent-gold), transparent 70%);
}
.ambient-glow-2 {
  width: 420px; height: 420px; bottom: -150px; right: -80px;
  background: radial-gradient(circle, var(--accent-cyan), transparent 70%);
}

.glass-panel {
  background: rgba(13, 18, 31, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

.glass-subcard {
  background: rgba(20, 28, 46, 0.72);
  border: 1px solid rgba(253, 197, 0, 0.14);
  border-radius: 12px;
  padding: 16px;
}

/* Topbar */
.topbar {
  position: sticky; top: 12px; z-index: 40;
  margin: 12px auto 0; max-width: 1400px; width: calc(100% - 32px);
  padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-amber));
  color: #070a11; display: grid; place-items: center;
  box-shadow: 0 0 20px rgba(253, 197, 0, 0.35);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-title span { color: var(--accent-gold); }
.brand-sub { font-size: 0.68rem; letter-spacing: 0.08em; color: var(--text-secondary); }

.nav-tabs {
  display: flex; gap: 6px;
  background: rgba(7, 10, 17, 0.65); padding: 4px;
  border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.06);
}
.nav-tab {
  background: transparent; border: none; color: var(--text-secondary);
  padding: 8px 14px; border-radius: 9px; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; transition: all 0.2s ease;
}
.nav-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.nav-tab.active {
  background: var(--bg-elevated); color: var(--accent-gold);
  box-shadow: inset 0 0 0 1px var(--border-active);
}

.ws-pill, .quota-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600;
  background: var(--bg-elevated); border: 1px solid rgba(255, 255, 255, 0.08);
}
.ws-pill.live { border-color: rgba(16, 185, 129, 0.45); color: var(--status-live); }
.ws-pill.offline { color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ws-pill.live .dot, .status-badge.live .dot { animation: pulseDot 1.6s infinite; }

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.45); opacity: 0.55; }
}

.auth-controls { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 10px;
  background: rgba(253, 197, 0, 0.08); border: 1px solid var(--border-subtle);
  font-size: 0.84rem; font-weight: 600;
}

/* Container & Headers */
.container {
  position: relative; z-index: 1;
  max-width: 1400px; width: calc(100% - 32px);
  margin: 22px auto 64px;
}

.hero-card {
  padding: 28px; display: grid;
  grid-template-columns: 1.5fr 1fr; gap: 24px;
  border-color: var(--border-active);
}
.hero-badge {
  display: inline-block; padding: 5px 11px; border-radius: 999px;
  background: rgba(253, 197, 0, 0.14); color: var(--accent-gold);
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.05em; margin-bottom: 12px;
}
.hero-card h1 { margin: 0 0 10px; font-size: 1.7rem; line-height: 1.25; }
.hero-card p { margin: 0 0 18px; color: var(--text-secondary); line-height: 1.6; }
.hero-actions, .header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero-metrics { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.metric-row {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06); padding-bottom: 8px; font-size: 0.86rem;
}
.metric-row:last-child { border-bottom: none; padding-bottom: 0; }

.section-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.section-header h2, .section-header h3 { margin: 0 0 4px; }
.section-header p { margin: 0; font-size: 0.9rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 11px; font-weight: 700; font-size: 0.88rem;
  cursor: pointer; border: 1px solid transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-sm { padding: 7px 12px; font-size: 0.79rem; border-radius: 9px; }
.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-amber));
  color: #070a11; box-shadow: 0 0 25px rgba(253, 197, 0, 0.30);
}
.btn-gold:hover { box-shadow: 0 0 32px rgba(253, 197, 0, 0.50); }
.btn-ghost {
  background: rgba(20, 28, 46, 0.78); color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.12);
}
.btn-ghost:hover { border-color: var(--border-active); }
.btn-stop:hover {
  border-color: var(--status-error); color: var(--status-error);
  background: rgba(239, 68, 68, 0.10);
}
.icon-btn {
  background: transparent; border: none; color: var(--text-secondary);
  cursor: pointer; font-size: 1.05rem; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.06); }

/* Streamloop Studio Shell */
.studio-shell {
  padding: 22px;
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 22px;
  border-color: var(--border-active);
}
.studio-left, .studio-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.studio-stage-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap;
}
.studio-slot-bar {
  display: flex; gap: 10px; align-items: flex-end;
}
.studio-cta-grid {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px;
}

.console-box {
  background: #05080f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
}
.console-head {
  padding: 8px 12px;
  background: rgba(20, 28, 46, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; justify-content: space-between; font-size: 0.74rem;
}
.console-log {
  margin: 0;
  padding: 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #cbd5e1;
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Badges & Stage */
.badge-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.04em;
}
.status-badge.live { background: rgba(16, 185, 129, 0.15); color: var(--status-live); border: 1px solid rgba(16, 185, 129, 0.45); }
.status-badge.reconnecting, .status-badge.starting { background: rgba(245, 158, 11, 0.16); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.45); }
.status-badge.offline { background: rgba(100, 116, 139, 0.16); color: var(--text-secondary); border: 1px solid rgba(100, 116, 139, 0.35); }
.status-badge.error { background: rgba(239, 68, 68, 0.16); color: var(--status-error); border: 1px solid rgba(239, 68, 68, 0.45); }

.pill-tag {
  font-size: 0.73rem; padding: 4px 9px; border-radius: 999px;
  background: var(--bg-elevated); color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.pill-tag.gold {
  color: var(--accent-gold); border-color: var(--border-active);
  background: rgba(253, 197, 0, 0.10);
}

.preview-stage { display: grid; gap: 12px; }
.preview-stage.dual { grid-template-columns: 2fr 1fr; }
.canvas-box {
  position: relative; border-radius: 12px; overflow: hidden;
  background: radial-gradient(circle at center, rgba(253, 197, 0, 0.10), #05080f 75%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  aspect-ratio: 16 / 9;
}
.canvas-box.vertical {
  aspect-ratio: 9 / 16; max-height: 270px;
  justify-self: center; width: 100%; max-width: 160px;
}
.canvas-box img, .canvas-box video {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.canvas-overlay {
  position: absolute; inset: auto 8px 8px 8px; padding: 5px 9px;
  border-radius: 8px; background: rgba(7, 10, 17, 0.82);
  backdrop-filter: blur(8px); font-size: 0.72rem;
  display: flex; justify-content: space-between; align-items: center; gap: 6px;
  pointer-events: none;
}

.telemetry-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  background: rgba(7, 10, 17, 0.72); border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px; padding: 12px;
}
.tele-cell { display: flex; flex-direction: column; gap: 4px; }
.tele-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.tele-val { font-size: 0.88rem; font-weight: 700; }

.dual-substrip {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  background: rgba(56, 189, 248, 0.08); border: 1px solid rgba(56, 189, 248, 0.24);
  font-size: 0.78rem;
}

/* Stream Cards Grid */
.streams-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 18px;
}
.stream-card {
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.25s ease;
}
.stream-card.is-live { border-color: rgba(16, 185, 129, 0.45); }
.stream-card.is-dual { border-color: var(--border-active); }
.stream-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.stream-title-input {
  background: transparent; border: 1px solid transparent; color: var(--text-primary);
  font-size: 1.06rem; font-weight: 700; padding: 3px 6px; margin-left: -6px;
  border-radius: 8px; width: 100%;
}
.stream-title-input:hover, .stream-title-input:focus {
  outline: none; background: rgba(20, 28, 46, 0.8); border-color: var(--border-active);
}
.key-strip {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--bg-elevated); font-size: 0.78rem;
}
.stream-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Media Library */
.upload-dropzone {
  padding: 28px 20px; text-align: center;
  border: 1.5px dashed var(--border-active); margin-bottom: 22px;
}
.upload-dropzone.dragover { background: rgba(253, 197, 0, 0.08); border-color: var(--accent-gold); }
.dropzone-icon { font-size: 2rem; margin-bottom: 8px; }
.link-like { text-decoration: underline; cursor: pointer; }
.upload-progress { max-width: 620px; margin: 16px auto 0; text-align: left; }
.progress-meta { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 6px; }
.progress-track { height: 10px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent-gold), var(--accent-cyan)); transition: width 0.2s ease; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(305px, 1fr)); gap: 18px; }
.media-card { overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { position: relative; aspect-ratio: 16 / 9; background: #05080f; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-select-check {
  position: absolute; top: 10px; left: 10px;
  width: 20px; height: 20px; accent-color: var(--accent-gold); cursor: pointer;
}
.media-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.media-name { font-weight: 700; font-size: 0.94rem; word-break: break-word; }
.media-meta { font-size: 0.78rem; color: var(--text-secondary); }
.media-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* API Panel */
.api-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.api-card { padding: 20px; }
.api-card h3 { margin-top: 0; }
.rtmp-list { display: flex; flex-direction: column; gap: 10px; }
.rtmp-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: 10px; background: var(--bg-base);
  border: 1px solid rgba(255, 255, 255, 0.06); font-size: 0.84rem;
}

/* Pricing & Admin */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 24px; }
.plan-card { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.plan-card.popular { border-color: var(--accent-gold); box-shadow: 0 0 36px rgba(253, 197, 0, 0.16); }
.plan-price { font-size: 1.9rem; font-weight: 800; color: var(--accent-gold); }
.plan-features { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem; color: var(--text-secondary); }

.admin-meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.meter-card { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.meter-card strong { font-size: 1.45rem; }
.tx-panel { padding: 20px; }
.tx-panel h3 { margin-top: 0; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.data-table th { color: var(--text-secondary); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* Modals & Inputs */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 6, 12, 0.80);
  backdrop-filter: blur(8px); z-index: 80;
  display: grid; place-items: center; padding: 16px;
}
.modal { width: 100%; max-width: 460px; padding: 24px; max-height: 92vh; overflow-y: auto; }
.modal-lg { max-width: 720px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; }

.auth-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.switch-btn {
  padding: 8px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--bg-base); color: var(--text-secondary); font-weight: 600; cursor: pointer;
}
.switch-btn.active { background: var(--bg-elevated); color: var(--accent-gold); border-color: var(--border-active); }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; }
input[type="text"], input[type="password"], input[type="email"], select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-base); border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary); font-family: inherit; font-size: 0.88rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent-gold); }
.input-with-eye, .input-with-action { position: relative; display: flex; align-items: center; gap: 8px; }
.eye-btn {
  position: absolute; right: 8px; background: transparent; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 1rem;
}

.dual-toggle-box { padding: 12px; border-radius: 12px; background: rgba(253, 197, 0, 0.07); border: 1px solid var(--border-active); }
.dual-fields {
  padding: 14px; border-radius: 12px; background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.25); display: flex; flex-direction: column; gap: 12px;
}
.toggle-row { flex-direction: row; align-items: center; gap: 10px; color: var(--text-primary); cursor: pointer; }
.toggle-row input { width: 16px; height: 16px; accent-color: var(--accent-gold); }
.form-error {
  padding: 10px 12px; border-radius: 10px;
  background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca; font-size: 0.84rem;
}
.empty-state { grid-column: 1 / -1; padding: 34px 24px; text-align: center; }

.toast-stack { position: fixed; right: 18px; bottom: 18px; z-index: 95; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 16px; border-radius: 12px; background: var(--bg-elevated);
  border: 1px solid var(--border-active); color: var(--text-primary);
  font-size: 0.86rem; font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.toast.error { border-color: var(--status-error); }

@media (max-width: 980px) {
  .hero-card, .studio-shell, .streams-grid, .form-grid-2, .preview-stage.dual {
    grid-template-columns: 1fr;
  }
  .telemetry-strip { grid-template-columns: repeat(2, 1fr); }
}
