
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #242836;
  --border: #2e3348;
  --text: #e4e6f0;
  --text-muted: #8b8fa3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.screen { min-height: 100vh; }

/* Auth screens */
.auth-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.auth-logo { text-align: center; margin-bottom: 32px; }
.logo-icon {
  width: 56px; height: 56px;
  background: var(--primary); color: #fff;
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; margin-bottom: 16px;
}
.auth-logo h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { color: var(--text-muted); font-size: 14px; }
.auth-form {
  width: 100%; max-width: 380px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 14px;
  transition: border-color 0.15s;
}
.form-group input:focus { outline: none; border-color: var(--primary); }
.auth-error { margin-top: 12px; font-size: 13px; color: var(--danger); min-height: 18px; }

/* Header */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-left h1 { font-size: 18px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 12px; }
.version-text { font-size: 11px; color: var(--text-muted); }
.user-text { font-size: 13px; color: var(--text-muted); }
.health-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); }
.health-dot.ok { background: var(--success); box-shadow: 0 0 6px var(--success); }
.health-dot.fail { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* Buttons */
.btn {
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-full { width: 100%; padding: 12px; font-size: 14px; margin-top: 8px; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Layout */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 24px; }
.section-title {
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.stat-value {
  font-size: 22px; font-weight: 700; line-height: 1.2;
}
.stat-bar {
  height: 4px; background: var(--bg); border-radius: 2px;
  margin-top: 10px; overflow: hidden;
}
.stat-bar-fill {
  height: 100%; border-radius: 2px; transition: width 0.5s ease;
  width: 0;
}
.bar-ok { background: var(--success); }
.bar-warning { background: var(--warning); }
.bar-danger { background: var(--danger); }

/* Add stream form */
.add-form {
  display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap;
}
.add-form input {
  flex: 1; min-width: 150px;
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 13px;
}
.add-form input:focus { outline: none; border-color: var(--primary); }

/* Streams table */
.table-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.table-search input {
  padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); font-size: 12px;
  width: 200px;
}
.table-search input:focus { outline: none; border-color: var(--primary); }
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
thead tr {
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
}
th {
  padding: 10px 12px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  text-align: left; white-space: nowrap;
  user-select: none;
}
th.sortable { cursor: pointer; }
th.sortable:hover { color: var(--text); }
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  white-space: nowrap;
}
tr:hover { background: var(--bg-hover); }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.empty-cell {
  text-align: center; padding: 32px 12px;
  color: var(--text-muted); font-size: 13px;
}

/* Stream name cell */
.stream-name {
  display: flex; align-items: center; gap: 8px;
}
.stream-name code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
}
.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.dot-online { background: var(--success); box-shadow: 0 0 4px var(--success); }
.dot-offline { background: var(--text-muted); }

/* Codec tag */
.codec-tag {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
}
.src-url {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
}

/* Links row (expanded) */
.links-row td { padding: 0 !important; }
.links-panel {
  background: var(--bg);
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.link-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0;
  font-size: 12px;
}
.link-row:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,0.04); }
.link-label { font-weight: 600; width: 110px; flex-shrink: 0; color: var(--text-muted); }
.link-url {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-muted); font-size: 11px;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.copied { color: var(--success) !important; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 16px; font-size: 13px;
  z-index: 200; animation: slideIn 0.3s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 12px; }
  .header { padding: 10px 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .add-form { flex-direction: column; }
  .auth-form { padding: 20px; }
  .table-search input { width: 140px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
