:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212d;
  --border: #263244;
  --text: #e6edf6;
  --muted: #8ea0b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 12px; }
.mt-16 { margin-top: 16px; }
.full-width { width: 100%; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.brand-header h1 { margin: 0; font-size: 20px; }
.brand-header p { margin: 2px 0 0; font-size: 13px; }
.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #10b981);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
}
.brand-badge.sm { width: 32px; height: 32px; font-size: 13px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.field input, .field select, .field textarea, .input-search, .input-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus, .input-search:focus {
  border-color: var(--primary);
}
.login-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  text-align: center;
}
.error-text { color: var(--red); font-size: 13px; margin: 4px 0 0; }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-left > div:last-child {
  display: flex;
  flex-direction: column;
}

.main-wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi-value.small-val { font-size: 15px; padding-top: 6px; }
.accent-green { color: var(--green); }
.accent-amber { color: var(--amber); }
.accent-red { color: var(--red); }

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.input-search { min-width: 260px; flex: 1; max-width: 400px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 16px; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.span-2 { grid-column: span 2; }
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.checkbox-inline { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table tr:last-child td { border-bottom: none; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}
.pill-ok { background: rgba(34, 197, 94, 0.14); color: var(--green); border-color: rgba(34, 197, 94, 0.35); }
.pill-warn { background: rgba(245, 158, 11, 0.14); color: var(--amber); border-color: rgba(245, 158, 11, 0.35); }
.pill-bad { background: rgba(239, 68, 68, 0.14); color: var(--red); border-color: rgba(239, 68, 68, 0.35); }
.pill-info { background: rgba(59, 130, 246, 0.14); color: #60a5fa; border-color: rgba(59, 130, 246, 0.35); }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
}
.btn:hover { filter: brightness(1.1); }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger-ghost { background: transparent; border-color: rgba(239, 68, 68, 0.45); color: var(--red); }
.actions-row { display: flex; flex-wrap: wrap; gap: 6px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
}
.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-header h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.ok { border-color: rgba(34, 197, 94, 0.55); }
.toast.err { border-color: rgba(239, 68, 68, 0.55); color: #fca5a5; }

@media (max-width: 900px) {
  .grid-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .grid-form, .two-col { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

/* ===== Live Delta-Tile Streaming UI ===== */
.btn-live {
  background: linear-gradient(135deg, #dc2626, #ea580c);
  color: #fff;
  border-color: rgba(248, 113, 113, 0.4);
}
.lives-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--panel-2);
  color: var(--muted);
}
.lives-badge.is-live {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.45);
}
.lives-empty {
  text-align: center;
  padding: 28px 20px;
}
.lives-empty h3 { margin: 0 0 6px; }
.lives-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 16px;
}
.live-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.live-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}
.live-stage {
  position: relative;
  background: #06080c;
  aspect-ratio: 16 / 9;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.live-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.live-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(220, 38, 38, 0.88);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.live-pill.inline {
  position: static;
}
.live-pill.silent {
  background: rgba(99, 102, 241, 0.9);
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: livePulse 1.4s infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}
.live-expand-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(11, 15, 20, 0.78);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.live-stage:hover .live-expand-hint { opacity: 1; }
.live-info {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.live-info-top, .live-info-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.live-net-stats { color: #93c5fd; }
.live-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mini-bar {
  position: relative;
  height: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.mini-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}
.mini-bar.hp .mini-bar-fill { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.mini-bar.mp .mini-bar-fill { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }
.mini-bar-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.live-card-actions { display: flex; gap: 6px; }
.live-title-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.voc-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.voc-ek { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border-color: rgba(239, 68, 68, 0.45); }
.voc-rp { background: rgba(234, 179, 8, 0.16); color: #fde047; border-color: rgba(234, 179, 8, 0.45); }
.voc-ms { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border-color: rgba(168, 85, 247, 0.48); }
.voc-ed { background: rgba(6, 182, 212, 0.16); color: #67e8f9; border-color: rgba(6, 182, 212, 0.45); }
.voc-mk { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border-color: rgba(245, 158, 11, 0.48); }
.voc-other { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.35); }
.supplies-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sup-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.sup-hp { border-color: rgba(239, 68, 68, 0.35); color: #fca5a5; }
.sup-mp { border-color: rgba(59, 130, 246, 0.38); color: #93c5fd; }
.sup-cap { border-color: rgba(245, 158, 11, 0.35); color: #fde68a; }
.live-hunt-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.hunt-stat-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hunt-stat-box strong { font-size: 12px; }
.kills-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.kill-pill {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde68a;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}
.lives-clients-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 12px;
}
.live-client-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(24, 33, 45, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.live-modal-backdrop { padding: 14px; z-index: 55; }
.live-modal-card {
  width: min(96vw, 1520px);
  height: min(92vh, 920px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}
.live-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  flex-wrap: wrap;
}
.live-modal-title-wrap, .live-modal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.live-quality-select { padding: 4px 8px; font-size: 12px; }
.live-modal-stage {
  flex: 1;
  background: #05070a;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.live-modal-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}
@media (max-width: 600px) {
  .lives-grid { grid-template-columns: 1fr; }
}
