/* =========================================================
   PictoScore · Dashboard Styles
   Dark observer theme, auto-refresh read-only view
   ========================================================= */

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

:root {
  --bg: #0d0f14;
  --surface: #161920;
  --surface2: #1e2230;
  --border: #2a2e3d;
  --text: #e0e4f0;
  --muted: #6e7490;
  --accent: #6c63ff;
  --accent-lt: rgba(108, 99, 255, 0.18);
  --ok: #2ec27e;
  --warn: #e0902e;
  --danger: #e05555;
  --radius: 6px;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== TOP BAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.app-title em {
  font-style: normal;
  color: var(--accent);
}
.session-label {
  font-size: 11px;
  color: var(--muted);
}

/* ===== CONNECTION DOT ===== */
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot-idle {
  background: var(--muted);
}
.dot-ok {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}
.dot-warn {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
}
.dot-err {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #564bcc;
}
.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}
.btn-wide {
  width: 100%;
}

/* ===== JOIN PANEL ===== */
.join-panel {
  max-width: 360px;
  margin: 60px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.join-panel h2 {
  font-size: 17px;
}
.join-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.join-panel input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}
.join-panel input:focus {
  border-color: var(--accent);
}
.error-msg {
  font-size: 11px;
  color: var(--danger);
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  gap: 14px;
}

/* ===== KPI ROW ===== */
.kpi-row {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.kpi-card {
  flex: 1;
  min-width: 90px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.kpi-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

/* ===== DETAIL ROW ===== */
.detail-row {
  display: flex;
  gap: 14px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.detail-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-header h3 {
  font-size: 12px;
  font-weight: 700;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  background: var(--accent-lt);
  color: var(--accent);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 4px;
  margin-left: 4px;
}
.muted-sm {
  font-size: 10px;
  color: var(--muted);
}

/* ===== PRESENCE LIST ===== */
.presence-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.presence-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  background: var(--surface2);
  font-size: 12px;
}
.presence-row.online {
  border-left: 3px solid var(--ok);
}
.presence-row.offline {
  border-left: 3px solid var(--muted);
  opacity: 0.6;
}
.pr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.pr-dot.online {
  background: var(--ok);
}
.pr-dot.offline {
  background: var(--muted);
}
.pr-name {
  flex: 1;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pr-role {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.pr-room {
  font-size: 10px;
  color: var(--muted);
}

/* ===== ACTIVITY FEED ===== */
.activity-feed {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.activity-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--surface2);
  font-size: 11px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
  }
}
.act-time {
  color: var(--muted);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.act-type {
  flex-shrink: 0;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  min-width: 80px;
}
.act-body {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.type-join .act-type {
  color: var(--ok);
}
.type-submission .act-type {
  color: #60c2f7;
}
.type-round_open .act-type {
  color: var(--accent);
}
.type-round_close .act-type {
  color: var(--warn);
}
.type-route_assign .act-type {
  color: #c2a0f7;
}
.type-route_revoke .act-type {
  color: var(--danger);
}
.type-route_empty .act-type {
  color: var(--muted);
}

/* ===== EMPTY HINT ===== */
.empty-hint {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 2px;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .detail-row {
    flex-direction: column;
  }
  .kpi-card {
    min-width: 80px;
  }
}

/* ===== QR CODES BAR ===== */
.qr-bar {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 20px 16px 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.qr-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px 12px;
}
.qr-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
}
.qr-canvas {
  background: #fff;
  border-radius: 4px;
  line-height: 0;
}
/* override the QRCode lib's inline table styles if canvas fallback not available */
.qr-canvas table {
  margin: 0 !important;
}
.qr-url {
  font-size: 10px;
  color: var(--muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
