:root {
  --bg: #0a0e13;
  --bg-raised: #121821;
  --panel: #101720;
  --border: #1f2a36;
  --border-soft: #182029;
  --text: #e6edf3;
  --text-muted: #7c8b9b;
  --text-dim: #4b5a68;
  --signal: #00e08f;
  --signal-dim: #0a3d2c;
  --amber: #ffb454;
  --red: #ff5c5c;
  --red-dim: #3a1414;
  --cyan: #4fd1ff;
  --font-ui: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(0, 224, 143, 0.06), transparent),
    radial-gradient(ellipse 700px 500px at 100% 0%, rgba(79, 209, 255, 0.05), transparent);
}

.scanline-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.012) 0px,
    rgba(255,255,255,0.012) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.5;
}

/* Áp dụng cho toàn bộ trang */
::-webkit-scrollbar {
  width: 6px; /* Độ mỏng của thanh cuộn */
}

::-webkit-scrollbar-track {
  background: #121212; /* Màu nền track, phù hợp với nền tối */
}

::-webkit-scrollbar-thumb {
  background-color: #2e2e2e; /* Màu thanh cuộn */
  border-radius: 10px; /* Bo tròn mịn */
  border: 1px solid #1a1a1a; /* Viền nhẹ để tạo chiều sâu */
}

::-webkit-scrollbar-thumb:hover {
  background-color: #3a3a3a; /* Hiệu ứng hover nhẹ */
}

/* Cho Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #2e2e2e #0a1015;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  font-size: 22px;
  color: var(--signal);
  text-shadow: 0 0 12px rgba(0,224,143,0.6);
}

.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.stat-strip { display: flex; gap: 28px; }

.stat { display: flex; align-items: baseline; gap: 7px; }

.stat-value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
}

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

.stat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}

.stat-dot.live-dot.active {
  background: var(--signal);
  box-shadow: 0 0 8px var(--signal);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.75); }
}

/* ---------- layout ---------- */
.layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 32px 48px;
  max-width: 900px;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.panel-head h2 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 9px;
}

.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--bg);
  background: var(--signal);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

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

/* ---------- single-stream form ---------- */
.single-form { padding: 18px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.single-form .field span em,
.modal-col h3 em { font-style: normal; color: var(--text-dim); font-weight: 400; }

.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 11px;
}

select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 32px 9px 11px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}
select:focus { outline: none; border-color: var(--signal); }

.btn-block {
  width: 100%;
  padding: 13px;
  font-size: 13.5px;
  border-radius: 8px;
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--text-dim); background: #182230; }

.btn-outline { background: transparent; }

.btn-signal {
  background: var(--signal);
  color: #052014;
  border-color: var(--signal);
}
.btn-signal:hover { background: #1cf5a4; }

.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-dim); }

.btn-sm { padding: 5px 9px; font-size: 11.5px; border-radius: 6px; }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- dropzone / upload ---------- */
.dropzone {
  margin: 14px 18px 4px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  transition: border-color 0.15s;
}
.dropzone.drag-over { border-color: var(--signal); background: rgba(0,224,143,0.04); }
.dropzone p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.upload-progress {
  margin-top: 10px;
  height: 6px;
  background: var(--bg-raised);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--signal);
  transition: width 0.2s;
}
.upload-progress span {
  position: absolute;
  top: 8px; left: 0; right: 0;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* ---------- video list ---------- */
.video-list, .stream-list {
  padding: 6px 12px 16px;
  max-height: 620px;
  overflow-y: auto;
}

.empty-hint {
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 24px 12px;
  text-align: center;
}

.video-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.video-row:hover { background: rgba(255,255,255,0.02); }

.video-icon { font-size: 15px; color: var(--text-dim); flex-shrink: 0; }

.video-info { flex: 1; min-width: 0; }
.video-name {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-meta { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

.video-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- stream list ---------- */
.stream-card {
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: linear-gradient(180deg, rgba(0,224,143,0.03), transparent);
}

.stream-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.on-air {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 6px var(--signal);
  animation: pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

.stream-file {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.stream-id {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.stream-rtmp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
  cursor: pointer;
  border-radius: 5px;
  padding: 2px 4px;
  margin-left: -4px;
  transition: background 0.12s;
}
.stream-rtmp:hover {
  background: rgba(79, 209, 255, 0.08);
}
.copy-hint {
  color: var(--text-dim);
  font-size: 9.5px;
  opacity: 0;
  transition: opacity 0.12s;
}
.stream-rtmp:hover .copy-hint { opacity: 1; }

.stream-progress-track {
  height: 4px;
  border-radius: 3px;
  background: var(--bg-raised);
  overflow: hidden;
  margin-bottom: 8px;
}
.stream-progress-fill {
  height: 100%;
  background: var(--signal);
  transition: width 1s linear;
}
.stream-progress-fill.infinite {
  background: repeating-linear-gradient(90deg, var(--amber) 0 10px, transparent 10px 20px);
  width: 100% !important;
  animation: scroll-stripes 1s linear infinite;
}
@keyframes scroll-stripes { from { background-position: 0 0; } to { background-position: 20px 0; } }

.stream-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stream-timer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.stream-timer b { color: var(--text); }

.batch-chip {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--amber);
  border: 1px solid rgba(255,180,84,0.3);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4,7,10,0.72);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-sm { max-width: 380px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 15px; }

.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer;
}
.modal-close:hover { color: var(--text); }

.modal-config {
  display: flex; gap: 14px;
  margin-bottom: 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field span { font-size: 11.5px; color: var(--text-muted); }
.field input {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
}
.field input:focus { outline: none; border-color: var(--signal); }

.modal-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) { .modal-columns { grid-template-columns: 1fr; } }

.modal-col h3 {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
  font-weight: 600;
}
.modal-col h3 em { font-style: normal; color: var(--text-dim); font-weight: 400; }

#rtmpUrls {
  width: 100%;
  height: 180px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 10px;
  resize: vertical;
}
#rtmpUrls:focus { outline: none; border-color: var(--signal); }

.checkbox-list {
  height: 180px;
  overflow-y: auto;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono);
}
.checkbox-row:hover { background: rgba(255,255,255,0.03); }
.checkbox-row input { accent-color: var(--signal); }

.hint-row {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.modal-preview {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  max-height: 120px;
  overflow-y: auto;
}
.modal-preview div { margin-bottom: 3px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- toast ---------- */
.toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1100;
}
.toast {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--signal);
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toast-in 0.2s ease;
}
.toast.error { border-left-color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}