:root {
  --azul: #0e5aa7;
  --azul-osc: #0a3d73;
  --gris: #f4f6f8;
  --borde: #d9e0e6;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--gris);
  margin: 0;
  min-height: 100vh;
}
.topbanner {
  background: var(--azul);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbanner-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}
.topbanner-logo { height: 30px; width: 30px; display: block; }
.topbanner-text {
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 1.5px;
}
.topbanner-help {
  background: none;
  border: 1px solid rgba(255,255,255,0.6);
  color: white;
  width: auto;
  margin: 0;
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
}
.topbanner-help:active { background: rgba(255,255,255,0.15); }

.help-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 60, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.help-modal-box {
  background: white;
  border-radius: 5px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}
.help-modal-box h2 { color: var(--azul-osc); font-size: 1.1rem; margin: 0 0 16px; text-align: center; }
.help-modal-box ol { margin: 0; padding-left: 20px; }
.help-modal-box li { margin-bottom: 12px; font-size: 0.9rem; color: #333; line-height: 1.4; }
.help-modal-box li:last-child { margin-bottom: 0; }
.help-sublist { margin: 8px 0; padding-left: 18px; }
.help-sublist li { margin-bottom: 6px; font-size: 0.85rem; color: #444; }
.help-sublist li:last-child { margin-bottom: 8px; }
#help-modal-close { margin-top: 18px; }
.page-content {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
}
.card {
  background: white;
  border-radius: 5px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.08);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  margin-top: 24px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.card.wide { max-width: 640px; }
h1 {
  font-size: 1.15rem;
  color: var(--azul-osc);
  margin: 0 0 20px;
  text-align: center;
}
h1.subheading { margin-top: 24px; }
label {
  display: block;
  font-size: 0.85rem;
  color: #555;
  margin: 12px 0 4px;
}
input, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--borde);
  border-radius: 5px;
  font-size: 1.1rem;
  text-align: center;
  background: white;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--azul); border-color: var(--azul); }
button {
  width: 100%;
  padding: 12px;
  margin-top: 18px;
  background: var(--azul);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
button:active { background: var(--azul-osc); }
button:disabled { opacity: 0.6; cursor: default; }
.error {
  color: #b3261e;
  font-size: 0.9rem;
  margin-top: 6px;
  text-align: center;
}
.error:empty { margin-top: 0; }
.success {
  color: #1a7f37;
  font-size: 0.9rem;
  margin-top: 10px;
  text-align: center;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.sorteo-heading {
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  color: var(--azul-osc);
  margin-bottom: 16px;
  line-height: 1.3;
}
.sorteo-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
}
.sorteo-selector .chip.sorteo-chip {
  width: auto;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.topbar span { font-size: 0.85rem; color: #666; }
.topbar a { font-size: 0.85rem; color: var(--azul); cursor: pointer; text-decoration: none; }
.footer-link {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
}
.footer-link a { color: var(--azul); text-decoration: none; }
#qr-result { text-align: center; margin-top: 6px; display: none; }
#qr-result img { max-width: 100%; border: 1px solid var(--borde); border-radius: 5px; }
#qr-result .numero-grande { font-size: 2.4rem; font-weight: 700; color: var(--azul-osc); margin-bottom: 8px; letter-spacing: 2px; }
#qr-result .fracciones-disponibles { font-size: 0.9rem; color: #1a7f37; font-weight: 600; margin-bottom: 12px; }
.hidden { display: none !important; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { color: #666; font-weight: 600; font-size: 0.8rem; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { width: auto; margin: 0 4px 0 0; padding: 6px 12px; font-size: 0.85rem; }
button.reject { background: #b3261e; }
button.reject:active { background: #8c1e17; }
.empty-msg { color: #888; text-align: center; padding: 20px 0; }
.small-btn {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 0.85rem;
  background: white;
  color: var(--azul);
  border: 1px solid var(--azul);
}
.scroll-table { max-height: 500px; overflow-y: auto; }

.pdv-row { cursor: pointer; }
.pdv-row:active { background: var(--gris); }
.pdv-chevron { display: inline-block; color: #888; font-size: 0.75rem; width: 0.9em; }
.x-btn {
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  background: #b3261e;
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.x-btn:active { background: #8c1e17; }
.pdv-detail td { background: var(--gris); padding: 10px 8px; }
.pdv-detail-grid { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: #333; }
.pdv-detail-grid strong { color: #555; }

.adv-toggle {
  text-align: center;
  margin-top: 18px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--azul);
  color: white;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
}
.adv-toggle:active { background: var(--azul-osc); }
.adv-panel { margin-top: 6px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.chip {
  width: 100%;
  margin-top: 0;
  padding: 8px 4px;
  background: white;
  color: var(--azul-osc);
  border: 1px solid var(--borde);
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip.active { background: var(--azul); color: white; border-color: var(--azul); }
.suma-range { display: flex; align-items: center; gap: 8px; }
.suma-range input { text-align: center; }
.suma-range span { color: #888; font-size: 0.85rem; }
.adv-count { text-align: center; font-size: 0.85rem; color: #666; margin-top: 14px; min-height: 1.2em; }
.adv-results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
  max-height: 260px;
  overflow-y: auto;
}
.result-chip {
  width: 100%;
  margin-top: 0;
  padding: 6px 0;
  background: var(--gris);
  color: var(--azul-osc);
  border: 1px solid var(--borde);
  border-radius: 5px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-align: center;
}
.result-chip:active { background: var(--azul); color: white; }
#share-btn { background: white; color: var(--azul); border: 1px solid var(--azul); margin-top: 12px; }
.load-more-btn { background: white; color: var(--azul); border: 1px solid var(--azul); margin-top: 10px; }

.hint { font-size: 0.85rem; color: #666; margin: 0 0 4px; line-height: 1.4; }
#selae-sync-status { font-size: 0.9rem; margin-top: 10px; }
.ok { color: #1a7f37; font-weight: 600; }
.warn { color: #9a6700; margin-top: 6px; }
