* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
#app { width: 90%; max-width: 600px; }
.screen { width: 100%; padding: 30px; background: linear-gradient(160deg, #fafafa 0%, #f5f5f5 50%, #f0f0f0 100%); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.15); border-top: 4px solid #667eea; }
h1 { color: #2d3748; margin-bottom: 8px; font-size: 1.6em; }
h2 { color: #4a5568; margin-bottom: 15px; font-size: 1.2em; }
input { width: 100%; padding: 12px 14px; margin: 8px 0; border: 2px solid #e2e8f0; border-radius: 8px; font-size: 16px; transition: border-color 0.2s; outline: none; }
input:focus { border-color: #667eea; }
button { width: 100%; padding: 12px; margin: 8px 0; border: none; border-radius: 8px; font-size: 16px; cursor: pointer; font-weight: 600; transition: transform 0.1s, box-shadow 0.2s; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.btn-secondary { background: linear-gradient(135deg, #4a5568, #2d3748); color: white; }
.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px solid #f0f0f0; }
.header button { width: auto; padding: 8px 18px; background: #e53e3e; color: white; border-radius: 6px; font-size: 14px; }
.header button:hover { background: #c53030; }
.upload-area { text-align: center; }
#preview { margin: 15px 0; padding: 12px; background: #f7fafc; border: 1px dashed #cbd5e0; border-radius: 8px; }
.success { color: #276749; font-weight: 600; padding: 12px; background: #c6f6d5; border-radius: 8px; margin: 10px 0; border-left: 4px solid #38a169; }
.warning { color: #975a16; font-weight: 600; padding: 12px; background: #fefcbf; border-radius: 8px; margin: 10px 0; border-left: 4px solid #d69e2e; }
.error { color: #9b2c2c; font-weight: 600; padding: 12px; background: #fed7d7; border-radius: 8px; margin: 10px 0; border-left: 4px solid #e53e3e; }
p { text-align: center; margin: 10px 0; color: #718096; }
a { color: #667eea; text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; color: #764ba2; }
#forgot-message, #reset-message, #register-message { margin-top: 15px; }
#upload-btn { background: linear-gradient(135deg, #38a169, #2f855a); color: white; margin-top: 15px; }

/* Camera overlay */
#camera-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 1000; display: flex; flex-direction: column; }
.camera-top-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,0.7); color: #fff; font-size: 14px; font-weight: 600; }
.camera-close-btn { width: auto; background: none; color: #fff; font-size: 28px; padding: 0 8px; margin: 0; line-height: 1; }
.camera-viewfinder { flex: 1; position: relative; overflow: hidden; }
#camera-video { width: 100%; height: 100%; object-fit: cover; }
.camera-guide { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 92%; height: 82%; border: 2px solid rgba(255,255,255,0.6); border-radius: 8px; pointer-events: none; }
.guide-corner { position: absolute; width: 24px; height: 24px; border-color: #fff; border-style: solid; }
.guide-corner.tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-radius: 6px 0 0 0; }
.guide-corner.tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-radius: 0 6px 0 0; }
.guide-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-radius: 0 0 0 6px; }
.guide-corner.br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-radius: 0 0 6px 0; }
.btn-capture { width: auto; margin: 16px auto; padding: 16px 48px; background: #fff; color: #000; border-radius: 50px; font-size: 18px; font-weight: 700; display: block; }

/* ── Modal confirmación — fixes iOS Safari / Android Chrome ────────────── */
#confirm-modal {
  /* Scroll nativo iOS con momentum */
  -webkit-overflow-scrolling: touch;
  overflow-y: scroll;
}
#confirm-modal > div {
  /* Safe area para iPhone con notch (iOS 11+) */
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
/* Evitar zoom automático en iOS al enfocar inputs (requiere font-size ≥16px) */
#confirm-modal input {
  font-size: 16px !important;
  /* Eliminar delay de 300ms en tap (iOS y Android) */
  touch-action: manipulation;
}
#confirm-modal button {
  touch-action: manipulation;
  /* Evitar highlight azul en tap móvil */
  -webkit-tap-highlight-color: transparent;
}
/* Botones principales — eliminar highlight en móvil */
button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Identidad de empresa en header ─────────────────────────────────────── */
/* header-top: fila superior idéntica a la original (h1 + botón Salir) */
.header { flex-direction: column; align-items: stretch; gap: 0; }
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Pill de empresa: segunda fila del header, solo visible tras login */
.company-chip {
  display: none;
  margin-top: 10px;
  padding: 6px 16px;
  border-radius: 20px;
  width: fit-content;
  max-width: 100%;
  animation: chipFadeUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.company-chip.visible { display: flex; align-items: center; flex-wrap: nowrap; }

.company-name-chip {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
  flex: 0 1 auto;
  min-width: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
  letter-spacing: 0.02em;
}

/* Aviso visual cuando el CIF guardado no pasa el algoritmo AEAT.
   Se renderiza al lado del nombre, sin romper el ellipsis del nombre. */
.company-cif-warning {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 6px;
  font-size: 13px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.85);
  color: #b7791f;
  border-radius: 999px;
  cursor: help;
  vertical-align: middle;
  text-shadow: none;
}

@keyframes chipFadeUp {
  from { opacity: 0; transform: translateY(6px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

/* ── Logo SETEX: SE naranja + TEX blanco sobre badge oscuro ─────────────── */
.setex-badge {
  display: inline-block;
  background: #2d3748;
  padding: 2px 10px 3px;
  border-radius: 7px;
  font-weight: 900;
  letter-spacing: 0.05em;
  vertical-align: middle;
  line-height: 1.4;
}
.setex-badge .se { color: #FF6600; }
.setex-badge .tex { color: #ffffff; }
