:root {
  --bg: #0b0f17;
  --surface: #131a26;
  --surface-2: #1a2333;
  --border: #263248;
  --text: #e5ecf6;
  --muted: #8b9bb4;
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.16);
  --red: #ef4444;
  --blue: #3b82f6;
  --gold: #f59e0b;
}

* {
  box-sizing: border-box;
}

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

.hidden {
  display: none !important;
}

.view {
  min-height: 100vh;
}

/* Login */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #17233a 0%, #0b0f17 65%);
}

.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.login-brand {
  text-align: center;
  margin-bottom: 22px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
  margin: 0 auto 10px;
  box-shadow: 0 0 14px var(--green);
}

.login-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.login-brand p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .search-input, .select-input, #global-search-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}

.field input:focus, .search-input:focus, #global-search-input:focus {
  border-color: var(--blue);
}

.error-box {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Buttons */
.btn {
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 14px;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-full {
  width: 100%;
  padding: 11px;
  font-size: 14px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-stream {
  background: var(--green);
  color: #042117;
  font-weight: 700;
}

.btn-stream-idle {
  background: #334155;
  color: #cbd5e1;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Topbar */
.topbar {
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  font-weight: 700;
  font-size: 15px;
}

.live-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
}

.live-indicator.online {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.badge-company {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

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

/* Main Dashboard */
.main-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.dash-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.dash-header h2 {
  margin: 0;
  font-size: 19px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.quick-search-wrap {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.row-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.2px;
}

.active-title {
  color: #6ee7b7;
}

.inactive-title {
  color: #94a3b8;
}

.dot-green, .dot-gray {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-green {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.dot-gray {
  background: #64748b;
}

/* Circles Row (Single Horizontal Row on Desktop, Responsive Wrap on Mobile) */
.circles-row {
  display: grid;
  grid-template-columns: repeat(10, minmax(90px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

@media (max-width: 1100px) {
  .circles-row {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
  }
}

@media (max-width: 600px) {
  .circles-row {
    grid-template-columns: repeat(3, minmax(84px, 1fr));
    gap: 10px;
  }
}

.circle-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: 12px;
  transition: background 0.15s, transform 0.15s;
}

.circle-item:hover {
  background: var(--surface-2);
  transform: translateY(-2px);
}

.circle-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 8px;
  transition: box-shadow 0.2s;
}

.circle-orb.orb-active {
  background: radial-gradient(circle at 30% 30%, rgba(16, 185, 129, 0.28), rgba(16, 185, 129, 0.08));
  border: 2px solid var(--green);
  color: #6ee7b7;
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.22);
}

.circle-orb.orb-active.zero {
  border-color: rgba(16, 185, 129, 0.35);
  color: #64748b;
  box-shadow: none;
}

.circle-orb.orb-inactive {
  background: radial-gradient(circle at 30% 30%, rgba(100, 116, 139, 0.22), rgba(30, 41, 59, 0.45));
  border: 2px solid #475569;
  color: #cbd5e1;
}

.circle-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}

.circle-sub {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

/* Table View */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-left h2 {
  margin: 0;
  font-size: 17px;
}

.toolbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.select-input {
  width: auto;
  min-width: 135px;
}

.search-input {
  width: 190px;
}

.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

.pill.active {
  background: var(--green-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.pill.inactive {
  background: rgba(100, 116, 139, 0.2);
  color: #cbd5e1;
  border: 1px solid #475569;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.users-table th, .users-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.users-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.users-table tr:last-child td {
  border-bottom: none;
}

.col-action {
  text-align: right !important;
  width: 120px;
}

.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 28px !important;
}

.uid-strong {
  font-weight: 700;
  color: #f8fafc;
}

.uid-name {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.portal-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.status-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-active {
  background: var(--green-soft);
  color: #6ee7b7;
}

.status-inactive {
  background: rgba(100, 116, 139, 0.22);
  color: #94a3b8;
}

.status-wait {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}

/* Player View */
.player-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 54px);
}

.player-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-bar-left, .player-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.target-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.path-label {
  font-size: 11px;
  color: var(--muted);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-viewport-outer {
  position: relative;
  flex: 1;
  background: #05070c;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12px;
}

.player-stage {
  position: relative;
  transform-origin: top center;
}

.player-stage .replayer-wrapper {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.65);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.player-stage iframe {
  border: none !important;
  pointer-events: none;
}

.player-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 23, 0.84);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 15;
  text-align: center;
  padding: 20px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(59, 130, 246, 0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
