:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --card: #1e293b;
  --card-hover: #263449;
  --surface-subtle: rgba(255, 255, 255, 0.04);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --foreground: #f8fafc;
  --muted-foreground: #94a3b8;
  --placeholder: #64748b;
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-soft: rgba(16, 185, 129, 0.14);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 4px 10px -2px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100dvh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* ==================== PANTALLA DE PIN ==================== */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at top, #132238 0%, var(--bg) 70%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 16px) + 28px) 24px calc(env(safe-area-inset-bottom, 16px) + 24px);
}

.pin-header {
  text-align: center;
  max-width: 320px;
}

.pin-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  margin: 0 auto 14px;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.25);
}

.pin-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pin-subtitle {
  margin: 0;
  font-size: 13px;
  color: var(--muted-foreground);
}

.pin-dots {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin: 24px 0 10px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: all 0.18s ease;
}

.pin-dot.filled {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.55);
  transform: scale(1.1);
}

.pin-dot.error {
  border-color: var(--danger);
  background: var(--danger);
}

.pin-error-msg {
  min-height: 20px;
  font-size: 13px;
  color: #f87171;
  font-weight: 500;
  text-align: center;
}

.pin-keypad {
  width: 100%;
  max-width: 310px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.pin-key {
  height: 64px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.75);
  color: var(--foreground);
  font-size: 24px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.1s ease, background 0.15s ease;
}

.pin-key:active {
  transform: scale(0.94);
  background: rgba(16, 185, 129, 0.25);
  border-color: var(--primary);
}

.pin-key.action-key {
  font-size: 16px;
  color: var(--muted-foreground);
  background: transparent;
  border-color: transparent;
}

/* ==================== LAYOUT PRINCIPAL ==================== */
.app-shell {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(env(safe-area-inset-bottom, 12px) + 84px);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(11, 17, 32, 0.86);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-pill {
  background: var(--gold-soft);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  transform: scale(0.95);
}

.main-content {
  padding: 16px;
}

/* ==================== TARJETA BOLETO / NÚMERO ==================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 18px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}

.ticket-card {
  background: linear-gradient(145deg, #1e293b 0%, #131c2e 100%);
  border: 1px solid rgba(245, 158, 11, 0.28);
  position: relative;
  overflow: hidden;
}

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

.ticket-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fbbf24;
}

.edit-mode-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.number-input-wrapper {
  position: relative;
  margin-bottom: 8px;
}

.decimo-input {
  width: 100%;
  height: 68px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-strong);
  background: #090e1a;
  color: #f8fafc;
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-align: center;
  padding-left: 0.25em;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.decimo-input::placeholder {
  color: rgba(148, 163, 184, 0.22);
}

.decimo-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
}

.clear-number-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.16);
  color: var(--muted-foreground);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.digit-helper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ==================== ALERTA DE DUPLICADO ==================== */
.duplicate-alert {
  background: linear-gradient(145deg, rgba(245, 158, 11, 0.16), rgba(30, 41, 59, 0.96));
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 16px;
  animation: fadeSlideIn 0.2s ease-out;
}

.duplicate-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.duplicate-icon {
  font-size: 22px;
  line-height: 1;
}

.duplicate-title {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: #fde68a;
}

.duplicate-subtitle {
  margin: 0;
  font-size: 12px;
  color: #cbd5e1;
}

.duplicate-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-item.full-width {
  grid-column: span 2;
}

.detail-label {
  font-size: 12px;
  color: var(--muted-foreground);
}

.detail-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

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

/* ==================== FORMULARIO DE DETALLES ==================== */
.field-block {
  margin-bottom: 18px;
}

.field-block:last-child {
  margin-bottom: 0;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  font-size: 12px;
  font-weight: 700;
}

.field-hint {
  font-size: 12px;
  color: var(--muted-foreground);
}

.chip-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.chip-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.choice-chip {
  height: 46px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: rgba(15, 23, 42, 0.65);
  color: var(--foreground);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.choice-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: #34d399;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.3);
}

.choice-chip:active {
  transform: scale(0.97);
}

.custom-input-wrap {
  margin-top: 10px;
  position: relative;
}

.text-input,
.textarea-input,
.select-input {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  background: #0f172a;
  color: var(--foreground);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
}

.text-input:focus,
.textarea-input:focus,
.select-input:focus {
  border-color: var(--primary);
}

.textarea-input {
  resize: none;
  min-height: 76px;
}

.input-suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-weight: 600;
  pointer-events: none;
}

.net-play-banner {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.09);
  border: 1px solid rgba(16, 185, 129, 0.24);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.net-play-banner strong {
  color: #34d399;
  font-size: 14px;
}

.people-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.person-tag-btn {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.person-tag-btn:active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* ==================== BOTONES DE ACCIÓN ==================== */
.btn-primary {
  width: 100%;
  height: 52px;
  border-radius: var(--radius-lg);
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #042f2e;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px -4px rgba(16, 185, 129, 0.45);
  transition: transform 0.12s ease, opacity 0.15s ease;
}

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

.btn-secondary {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-amber {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: none;
  background: #f59e0b;
  color: #1e1b4b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
}

.btn-danger-outline {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: var(--danger-soft);
  color: #fca5a5;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.edit-cancel-row {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.edit-cancel-row button {
  flex: 1;
}

/* ==================== SECCIÓN 2: TABLA, FILTROS Y EXCEL ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 10px;
  text-align: center;
}

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

.kpi-val {
  font-size: 17px;
  font-weight: 800;
  color: var(--foreground);
}

.kpi-val.emerald {
  color: #34d399;
}

.kpi-val.gold {
  color: #fbbf24;
}

.filters-card {
  padding: 14px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
}

.search-input-wrap .text-input {
  padding-left: 36px;
  height: 42px;
  font-size: 14px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  font-size: 14px;
}

.excel-btn {
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.excel-btn:active {
  transform: scale(0.96);
}

.filter-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.filter-controls-grid .select-input {
  height: 38px;
  padding: 0 8px;
  font-size: 12px;
}

/* Tabla responsive optimizada para móvil */
.table-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.numbers-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

.numbers-table th {
  background: rgba(15, 23, 42, 0.8);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.numbers-table th:hover {
  color: var(--foreground);
}

.numbers-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}

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

.numbers-table tbody tr {
  transition: background 0.15s ease;
  cursor: pointer;
}

.numbers-table tbody tr:active,
.numbers-table tbody tr.highlight-row {
  background: rgba(245, 158, 11, 0.14);
}

.num-badge {
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  font-size: 15px;
  font-weight: 800;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 3px 8px;
  border-radius: 7px;
  letter-spacing: 0.06em;
}

.pct-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
}

.pct-pill.shared {
  background: rgba(59, 130, 246, 0.16);
  color: #93c5fd;
}

.comment-cell {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted-foreground);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.mini-action-btn {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--foreground);
  font-size: 12px;
  cursor: pointer;
}

.empty-state {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted-foreground);
}

/* ==================== MODAL DE DETALLE ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 540px;
  background: var(--card);
  border-top: 1px solid var(--border-strong);
  border-radius: 22px 22px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom, 16px) + 20px);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  animation: slideUp 0.2s ease-out;
}

.modal-num-hero {
  text-align: center;
  padding: 14px;
  background: #090e1a;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg);
  margin: 12px 0 16px;
}

.modal-num-digits {
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: #fbbf24;
}

/* ==================== BOTTOM NAVIGATION BAR ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding: 6px 16px calc(env(safe-area-inset-bottom, 8px) + 6px);
}

.bottom-nav-inner {
  max-width: 540px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.nav-tab {
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab.active {
  background: var(--primary-soft);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.nav-badge {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
}

/* ==================== TOAST DE NOTIFICACIÓN ==================== */
.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 12px) + 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: #065f46;
  color: #ecfdf5;
  border: 1px solid #10b981;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.toast.error {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fef2f2;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
