:root {
  --bg: #000000;
  --card: #121212;
  --accent: #00ff41;
  --danger: #ff3b30;
  --text: #ffffff;
  --text-dim: #888;
}

body {
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- IMPORTANT: asegurar que [hidden] funcione en todos los navegadores --- */
[hidden] {
  display: none !important;
}

/* --- PANTALLAS --- */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 0px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}
.active { display: flex; }

/* --- UI CÁMARA CIRCULAR --- */
.camera-ring {
  width: 260px;
  height: 260px;
  border-radius: 0%;
  border: 4px solid var(--accent);
  overflow: hidden;
  margin: 0px 0;
  background: #000;
  position: relative;
}
video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- BOTONES --- */
.frst-screen--btn-cntnr {
  width: 100%;
  display: flex;          
  flex-direction: column;
  align-items: center;    
  gap: 15px;
  margin-top: 70px;
}
.frst-screen--btn {
  background: var(--accent);
  color: #000;
  border: none; 
  padding: 22px;
  border-radius: 50px;
  font-weight: 900;
  font-size: 18px;
  width: 90%;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 255, 65, 0.2);
}
.frst-screen--btn-2 {
  background: #787575;
  color: #000;
  border: none; 
  padding: 22px;
  border-radius: 50px;
  font-weight: 900;
  font-size: 18px;
  width: 90%;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 255, 65, 0.2);
}

.btn-scan-next {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 22px;
  border-radius: 50px;
  font-weight: 900;
  font-size: 18px;
  width: 90%;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 255, 65, 0.2);
  display: block;
  margin: 0 auto;
}

.btn-ghost {
    background: #7da989;
    color: #000;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 900;
    font-size: 14px;
    width: 90%;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 255, 65, 0.2);
    display: block;
    margin: 30px;
}

/* --- RESULTADOS --- */
.status-top {
  width: 100%;
  padding: 35px 20px;
  text-align: center;
  border-radius: 20px;
  font-size: 26px;
  font-weight: 900;
  margin-bottom: 20px;
  text-transform: uppercase;
}
.valid-bg { background: var(--accent); color: #000; }
.invalid-bg { background: var(--danger); color: #fff; }
.warning-bg { background: #ffcc00; color: #000; }

.data-list {
  background: var(--card);
  width: 100%;
  border-radius: 15px;
  padding: 10px 20px;
  border: 1px solid #222;
}
.data-item {
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid #222;
}
.data-item:last-child { border: none; }
.label {
  color: var(--text-dim);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* === ADDED: Historial (MODO CELULAR) === */
.history-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  background: var(--card);
  border: 1px solid #222;
  border-radius: 14px;
  margin-top: 15px;
  max-height: 55vh;
  overflow: hidden;
}

/* Fila de botones arriba */
.hist-actions-top {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: #1a1a1a;
  border-bottom: 1px solid #222;
}

.btn-tool {
  flex: 1;
  background: #7da989;
  color: #000;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.hist-summary-line {
  padding: 8px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 800;
  background: #000;
  border-bottom: 1px solid #222;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hist-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

/* Items */
.hist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid #222;
  border-radius: 10px;
  background: #0c0c0c;
  border-left: 4px solid #333;
}

.hist-left {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.hist-line {
  font-size: 14px;
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.run-sep {
  margin: 12px 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.valid { background: var(--accent); color: #000; }
.badge.denied { background: var(--danger); color: #fff; }
.run-sep { margin: 8px 0 4px; color: var(--text-dim); font-size: 11px; text-transform: uppercase; }

/* === ADDED: Gestor de sesiones (sin llaves) === */
.sessions { width: 100%; }
.sess-title { text-align: center; }
.sess-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.sess-item {
  background: var(--card);
  border: 1px solid #222;
  border-radius: 12px;
  padding: 12px;
}
.sess-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sess-name { font-weight: 800; }
.sess-sub { color: var(--text-dim); font-size: 14px; }
.sess-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.app-options { margin-top: 16px; color: var(--text-dim); font-size: 14px; }
.opt-line { display: flex; align-items: center; gap: 8px; }
.hint { margin-top: 6px; }

/* ===============================================
   ⚡ FIX PRINCIPAL: SESIÓN "VER" (MÓVIL / TABLET)
   =============================================== */

#session-view {
  display: flex;                   /* necesario */
  flex-direction: column;
  width: 100%;
  max-height: 100vh;               /* crítico en iPhone */
  overflow-y: auto;                /* scroll interno */
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;            /* aire al final */
}

/* contenedor donde se pintan los items del viewer */
#sess-view-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: var(--card);
  border-radius: 12px;
}

/* Ocultar encabezado y debug de la pantalla: Página no activada */
#scr-blocked > h2,
#scr-blocked > p,
#scr-blocked .data-list {
  display: none !important;
}
