/* ============================================================
   PCDANI · Portal de Reparaciones
   Hoja de estilos principal — v18 (2026-06-21)
   Paleta: industrial naranja (#ff5a1f) + negro (#0f0f10) + gris (#f2f2f3) + amber admin
   ============================================================ */

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

:root {
  --accent:        #ff5a1f;       /* industrial naranja */
  --accent-soft:   #ffe4d6;       /* tinte claro del naranja */
  --accent-hover:  #e64a14;       /* naranja oscuro para hover */
  --bg:            #f2f2f3;       /* gris industrial de fondo */
  --bg-card:       #ffffff;
  --text:          #0f0f10;       /* negro puro, alto contraste */
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;
  --ok:            #15803d;
  --warn:          #b45309;
  --err:           #b91c1c;
  --warn-bg:       #fff7ed;
  --err-bg:        #fef2f2;

  /* Paleta admin (técnico) — amber */
  --adm-bg:        #fffbeb;
  --adm-bg-2:      #fef3c7;
  --adm-bg-card:   #ffffff;
  --adm-border:    #fde68a;
  --adm-border-2:  #fcd34d;
  --adm-border-3:  #fbbf24;
  --adm-accent:    #f59e0b;
  --adm-accent-2:  #d97706;
  --adm-text:      #92400e;       /* admin usa paleta amber */
  --adm-text-2:    #0f0f10;       /* secundario pasa a negro */

  /* Estados de parte */
  --estado-Abierto-bg:               #ffedd5;       /* tinte naranja */
  --estado-Abierto-fg:               #9a3412;       /* texto naranja oscuro */
  --estado-En.Diagnostico-bg:        #fef9c3;
  --estado-En.Diagnostico-fg:        #854d0e;
  --estado-En.Reparacion-bg:         #fed7aa;
  --estado-En.Reparacion-fg:         #9a3412;
  --estado-Esperando.Material-bg:    #fed7aa;       /* mismo tono que En Reparación */
  --estado-Esperando.Material-fg:    #9a3412;
  --estado-Listo-bg:                 #d1fae5;
  --estado-Listo-fg:                 #065f46;
  --estado-Entregado-bg:             #e5e7eb;
  --estado-Entregado-fg:             #374151;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.muted  { color: var(--text-muted); font-size: 0.92em; }

/* ===================== TOPBAR ===================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

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

/* ===> REGLA DEL LOGO HEADER (definitiva) <=== */
.brand-logo,
.brand-logo img,
img.brand-logo {
  height: 42px !important;
  width: auto !important;
  max-width: 140px !important;
  display: block;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--text);
}
.brand small {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

#userbar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===================== MAIN / VIEWS ===================== */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.view {
  animation: fadein 0.2s ease;
}
@keyframes fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===================== CARD GENÉRICA ===================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

/* ===================== LOGIN ===================== */

.login-card {
  max-width: 420px;
  margin: 60px auto 0;
  text-align: left;
}

.login-head {
  text-align: center;
  margin-bottom: 20px;
}

/* ===> REGLA DEL LOGO LOGIN (definitiva) <=== */
.login-logo,
img.login-logo {
  display: block !important;
  margin: 0 auto 16px !important;
  height: 64px !important;
  width: auto !important;
  max-width: 240px !important;
  object-fit: contain !important;
}

.login-head h1 {
  font-size: 1.35rem;
  margin-bottom: 4px;
}

/* Formularios estándar (login, nuevo parte, etc.) */
form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

form input,
form select,
form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text);
  line-height: 1.5;
  min-height: 44px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
form textarea {
  min-height: 140px;
  resize: vertical;
}
form input:focus,
form select:focus,
form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.error {
  margin-top: 12px;
  padding: 8px 10px;
  background: var(--err-bg);
  border-left: 3px solid var(--err);
  color: var(--err);
  border-radius: 4px;
  font-size: 0.88rem;
}

/* ===================== BOTONES ===================== */

.btn-primary,
.btn-ghost,
.btn-ghost-dark,
.btn-warn,
.btn-danger,
.btn-pause,
.btn-camera,
.btn-files,
.btn-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
  line-height: 1.3;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--text-muted); cursor: not-allowed; }

.btn-secondary {
  background: #475569;
  color: #fff;
  border: 1px solid #334155;
}
.btn-secondary:hover { background: #334155; }
.btn-secondary:disabled { background: var(--text-muted); cursor: not-allowed; }

/* Botón rojo de cámara (PCDANI) — acción destructiva / captura activa */
.btn-camera {
  background: #dc2626;
  color: #fff;
  border: 1px solid #b91c1c;
}
.btn-camera:hover { background: #b91c1c; }
.btn-camera:disabled { background: var(--text-muted); cursor: not-allowed; }

/* Botón naranja para exportar PDF en cada tarjeta de parte */
.btn-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid #c2410c;
  background: #ea580c;
  color: #fff;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  line-height: 1.3;
}
.btn-pdf:hover { background: #c2410c; }
.btn-pdf:disabled { background: var(--text-muted); cursor: not-allowed; }
.btn-pdf:active { transform: translateY(1px); }

.card-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Botón azul para archivos/galería (PCDANI) */
.btn-files {
  background: #2563eb;
  color: #fff;
  border: 1px solid #1d4ed8;
}
.btn-files:hover { background: #1d4ed8; }
.btn-files:disabled { background: var(--text-muted); cursor: not-allowed; }

/* Inputs nativos <input type="file"> en Android WebView no se pueden estilizar.
   Los ocultamos visualmente y los botones .btn-camera / .btn-files los disparan.
   IMPORTANTE: NO usar `pointer-events: none` ni `display: none` ni `left: -9999px`
   ni `z-index: -1` porque eso IMPIDE que .click() programatico funcione en
   Android WebView. Usamos position fixed en esquina, tamaño real, opacity 0,
   pointer-events auto. Asi el WebView lo trata como clickeable cuando se hace
   input.click() desde JS. */
.upload-native {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  z-index: 9999;
  pointer-events: auto;
  cursor: pointer;
}

.upload-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}
.upload-status {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--accent-soft); }

/* Variante oscura del ghost — para acciones secundarias del panel técnico */
.btn-ghost-dark {
  background: transparent;
  color: var(--adm-text);
  border-color: #fde68a;
}
.btn-ghost-dark:hover {
  background: var(--adm-bg-2);
  border-color: var(--adm-accent);
}

.btn-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #fed7aa;
}
.btn-warn:hover { background: #ffedd5; }

.btn-danger {
  background: transparent;
  color: var(--err);
  border-color: #fecaca;
  font-size: 0.8rem;
  padding: 4px 10px;
}
.btn-danger:hover { background: var(--err-bg); }

/* Variante sólida y grande del danger, para acciones destructivas importantes */
.btn-danger.btn-danger-lg {
  background: #b91c1c;
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger.btn-danger-lg:hover { background: #991b1b; }
.btn-danger.btn-danger-lg:disabled { background: #6b7280; cursor: not-allowed; }

/* Zona peligrosa en el panel admin */
.admin-danger-zone {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px dashed #fecaca;
}

/* ===================== MODAL GENÉRICO (confirmaciones) ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 16, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  animation: modal-fade-in 0.18s ease-out;
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.5rem 1.25rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: modal-pop 0.18s ease-out;
}
@keyframes modal-pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.modal-danger {
  border-top: 4px solid #b91c1c;
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #b91c1c;
  margin: 0 0 0.75rem 0;
}
.modal-msg {
  font-size: 0.95rem;
  color: #0f0f10;
  margin: 0.5rem 0;
  line-height: 1.5;
}
.modal-msg.muted {
  color: #6b7280;
  font-size: 0.88rem;
}
.modal-msg code {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
}
#modalBorrarInput {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  margin-top: 0.5rem;
  font-size: 1.05rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  letter-spacing: 0.04em;
  border: 2px solid #d1d5db;
  border-radius: 8px;
  background: #f9fafb;
  color: #0f0f10;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#modalBorrarInput:focus {
  border-color: #ff5a1f;
  background: #fff;
}
#modalBorrarInput.invalid {
  border-color: #b91c1c;
  background: #fef2f2;
}
.modal-error {
  font-size: 0.85rem;
  color: #b91c1c;
  font-weight: 600;
  margin: 0.5rem 0 0 0;
}
.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.modal-buttons button {
  flex: 1;
  min-width: 130px;
}

/* ===================== PANEL (lista de partes) ===================== */

/* Banner con el nombre de la empresa del usuario (encima del título "Mis partes") */
.empresa-banner {
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  color: #fff;
  padding: 14px 18px;
  margin-bottom: 14px;
  border-radius: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}
.empresa-banner:empty { display: none; }

/* Panel debug flotante (PCDANI) */
.panel-debug {
  background: #1e293b;
  color: #e2e8f0;
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.panel-debug.hidden { display: none; }
.panel-debug pre {
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
  margin: 8px 0 0 0;
  font-size: 0.78rem;
  line-height: 1.4;
}
.panel-debug-btn {
  background: #475569;
  color: #fff;
  border: 0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  margin-top: 6px;
  cursor: pointer;
}

/* Botón flotante para mostrar/ocultar debug */
.debug-fab {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #1e293b;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}
.panel-head h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.parte-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.parte-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.parte-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.parte-card .parte-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ===================== BADGES DE ESTADO ===================== */

.badge-estado {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.estado-Abierto          { background: var(--estado-Abierto-bg);          color: var(--estado-Abierto-fg); }
.estado-En.Diagnostico   { background: var(--estado-En.Diagnostico-bg);   color: var(--estado-En.Diagnostico-fg); }
.estado-En.Reparacion    { background: var(--estado-En.Reparacion-bg);    color: var(--estado-En.Reparacion-fg); }
.estado-Esperando.Material { background: var(--estado-Esperando.Material-bg); color: var(--estado-Esperando.Material-fg); }
.estado-Listo            { background: var(--estado-Listo-bg);            color: var(--estado-Listo-fg); }
.estado-Entregado        { background: var(--estado-Entregado-bg);        color: var(--estado-Entregado-fg); }

/* ===================== DETALLE ===================== */

.detalle-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.detalle-head h1 {
  font-size: 1.6rem;
  font-weight: 600;
}
.detalle-head .sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.detalle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.detalle-grid .field {
  font-size: 0.9rem;
}
.detalle-grid .field .label {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.detalle-grid .field .value {
  font-weight: 500;
  word-break: break-word;
}

.seccion {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.seccion h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 10px;
}

/* ===================== PANEL ADMIN (técnico) =====================
   Diseño "amber" que distingue al técnico del resto.
   Reglas con !important SOLO donde una regla genérica previa (form input, etc.)
   podría pisarlas. El reset anti-cascada al final protege también contra
   cualquier .admin-row heredado. */

.admin-panel {
  margin-top: 24px;
  padding: 24px;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border: 1px solid #fcd34d;
  border-left: 4px solid #f59e0b;
  border-radius: 10px;
}

.admin-panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #92400e;
  margin: 0 0 20px 0;
  padding-bottom: 12px;
  border-bottom: 2px solid #fcd34d;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-panel-title::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25);
}

.admin-section {
  background: #ffffff;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid #fde68a;
}
.admin-section:last-child {
  margin-bottom: 0;
}

.admin-section-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #92400e;
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Cada campo en su propia fila. !important en display:block y en el label
   para evitar que ninguna regla anterior gane por cascada. */
.admin-field {
  display: block !important;
  margin-bottom: 16px;
}
.admin-field:last-child {
  margin-bottom: 0;
}
.admin-field > label {
  display: block !important;
  font-size: 0.88rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}
.admin-field input,
.admin-field select,
.admin-field textarea,
.admin-field input[type="file"] {
  display: block !important;
  width: 100% !important;
  padding: 11px 13px !important;
  border: 1.5px solid #fde68a !important;
  border-radius: 6px;
  font-size: 0.96rem !important;
  font-family: inherit !important;
  background: #fffbeb !important;
  color: #1f2937 !important;
  line-height: 1.5;
  min-height: 44px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
/* file inputs nativos de Android son feos, los ocultamos y ponemos botones encima */
.file-input-hidden {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  /* pointer-events: none IMPIDE el click programático en Android WebView.
     Lo dejamos auto (default) para que JS pueda disparar .click() sobre él. */
}
.file-input-wrapper {
  display: flex !important;
  align-items: center !important;
  gap: 0.6rem !important;
  flex-wrap: wrap !important;
}
.file-input-btn {
  display: inline-block !important;
  padding: 11px 16px !important;
  font-size: 0.96rem !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  border: 1.5px solid transparent !important;
  font-family: inherit !important;
  min-height: 44px;
  box-sizing: border-box;
  width: auto !important;
  text-align: center !important;
}
.file-input-btn.btn-primary {
  background: #ea580c !important;
  color: #fff !important;
  border-color: #c2410c !important;
}
.file-input-btn.btn-primary:hover { background: #c2410c !important; }
.file-input-btn.btn-camera {
  background: #dc2626 !important;
  color: #fff !important;
  border-color: #b91c1c !important;
}
.file-input-btn.btn-camera:hover { background: #b91c1c !important; }
.file-input-name {
  font-size: 0.88rem !important;
  color: #6b7280 !important;
  font-style: italic;
  flex: 1;
  min-width: 120px;
  word-break: break-all;
}
.file-input-name.has-file {
  color: #059669 !important;
  font-style: normal;
  font-weight: 600;
}
.admin-field textarea {
  min-height: 130px;
  resize: vertical;
}
.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
  outline: none !important;
  border-color: #f59e0b !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important;
}
/* El input[type=file] no debe perder el icono nativo "Examinar…" */
.admin-field input[type="file"]:focus { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important; }

/* Select nativo del campo Estado: mantener aspecto consistente */
.admin-field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2392400e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px !important;
}

.admin-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.admin-buttons-end {
  justify-content: flex-end;
}

.admin-shortcut {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  background: #fef3c7;
  border: 1px dashed #fbbf24;
  border-radius: 6px;
}
.admin-shortcut-label {
  font-size: 0.88rem;
  color: #92400e;
  font-weight: 500;
}

.btn-pause {
  background: #f59e0b;
  color: #ffffff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-pause:hover {
  background: #d97706;
}

.admin-msg {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Input de fecha con icono personalizado */
.date-input-wrap {
  position: relative;
  display: block;
}
.date-input-wrap input[type="date"] {
  width: 100%;
  padding: 11px 44px 11px 13px;
  border: 1.5px solid #fde68a;
  border-radius: 6px;
  font-size: 0.96rem;
  font-family: inherit;
  background: #fffbeb;
  color: #1f2937;
  line-height: 1.5;
  min-height: 44px;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.date-input-wrap input[type="date"]:focus {
  outline: none;
  border-color: #f59e0b;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}
.date-input-wrap .date-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #92400e;
  pointer-events: none;
  display: flex;
  align-items: center;
}
/* Ocultar icono nativo del navegador para que se vea el nuestro (Chrome/Edge) */
.date-input-wrap input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
/* Firefox */
.date-input-wrap input[type="date"]::-moz-calendar-picker-indicator {
  opacity: 0;
  cursor: pointer;
}

/* Selector de estado (legacy / vista cliente) */
.state-selector {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.state-selector select {
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 0.92rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text);
  min-width: 180px;
}

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

/* ===================== FOTOS / THUMBS ===================== */

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.thumb-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 1;
}
.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-wrap .thumb-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 0.7rem;
  line-height: 1.2;
}
.thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(185, 28, 28, 0.92);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-del:hover { background: var(--err); }

.thumb-empty {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-style: italic;
}

/* ===================== UPLOAD ===================== */

.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone input[type=file] { display: none; }
.upload-zone p { color: var(--text-muted); font-size: 0.88rem; }

/* ===================== FORM NUEVO PARTE ===================== */

form fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px 16px;
  margin-bottom: 16px;
}
form legend {
  padding: 0 8px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--accent);
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

/* ===================== ACTIVIDAD ===================== */

.actividad-list {
  list-style: none;
}
.actividad-list li {
  padding: 6px 0;
  font-size: 0.86rem;
  border-bottom: 1px dashed var(--border);
  color: var(--text-muted);
}
.actividad-list li:last-child { border-bottom: none; }
.actividad-list li strong { color: var(--text); }

/* ===================== UTILIDADES ===================== */

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.spacer { flex: 1; }
hr.thin { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ===================== RESPONSIVE ===================== */

@media (max-width: 640px) {
  main { padding: 18px 14px 40px; }
  .login-card { margin-top: 30px; }
  .detalle-head h1 { font-size: 1.3rem; }
  .topbar {
    padding: 10px 14px;
    display: grid !important;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "brand userinfo logout"
      "btns  btns    btns";
    align-items: center;
    column-gap: 10px;
    row-gap: 6px;
  }
  .topbar .brand {
    grid-area: brand;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }
  .topbar .brand-logo {
    height: 32px !important;
    max-width: 36px !important;
    flex-shrink: 0;
  }
  .topbar .brand > div {
    min-width: 0;
  }
  .topbar .brand strong {
    font-size: 0.92rem;
    line-height: 1.1;
  }
  .topbar .brand small {
    font-size: 0.68rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }
  /* email en el centro, alineado a la derecha */
  .topbar nav#userbar {
    display: contents !important;
  }
  .topbar nav#userbar #userinfo {
    grid-area: userinfo;
    text-align: right;
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  /* botón salir a la derecha */
  .topbar nav#userbar #btnLogout {
    grid-area: logout;
    font-size: 0.82rem;
    padding: 6px 12px;
    white-space: nowrap;
  }
  /* botón Empresas en segunda fila, alineado a la derecha */
  .topbar nav#userbar #btnEmpresas {
    grid-area: btns;
    justify-self: end;
    font-size: 0.82rem;
    padding: 6px 12px;
  }
  .admin-panel { padding: 16px; }
  .admin-section { padding: 14px; }
}

/* ===== BARRA DE FILTROS (Diseño B · Bold & Modern) ===== */
.filtros-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 28px 0 28px;
  flex-wrap: wrap;
}
.filtros-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s ease,
              border-color 0.22s ease,
              background 0.22s ease;
  font-family: inherit;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}
.chip:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
  border-color: #fbbf24;
}
.chip.active {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
}
.chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 8px;
  background: #f1f5f9;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  transition: background 0.22s ease, color 0.22s ease;
}
.chip.active .chip-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Labels de campos en vista de detalle del parte (Técnico, Empresa, Equipo, etc.) */
.row > .label,
.row .label {
  font-weight: 800;
  color: #0f172a;
  font-size: 14px;
  letter-spacing: 0.01em;
  text-transform: none;
}

.filtros-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 280px;
  max-width: 400px;
  flex: 1 1 auto;
  margin-left: auto;
}
.filtros-search .search-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  font-size: 18px;
  pointer-events: none;
}
.filtros-search input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 2px solid #e2e8f0;
  background: #ffffff;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  color: #0f172a;
  font-family: inherit;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}
.filtros-search input:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15),
              0 4px 12px rgba(245, 158, 11, 0.1);
}
.filtros-search input::placeholder { color: #94a3b8; }
.search-clear {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  display: none;
  transition: background 0.15s ease;
}
.search-clear:hover { background: #f1f5f9; }
.search-clear.visible { display: block; }
.filtros-empty {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
  font-size: 15px;
  font-weight: 500;
  background: #ffffff;
  border: 2px dashed #e2e8f0;
  border-radius: 14px;
  margin: 20px 0;
}

/* ===== CARDS (Diseño B · Bold & Modern) ===== */
.parte-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 22px;
  border: 2px solid transparent;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  margin-bottom: 16px;
}
.parte-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #f59e0b 0%, #ea580c 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.parte-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.1);
  border-color: #fde68a;
}
.parte-card:hover::before { opacity: 1; }
.parte-card .info strong {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}
.parte-card .meta {
  font-size: 13px;
  color: #64748b;
  line-height: 1.55;
  margin-top: 6px;
}
.parte-card .meta strong { color: #0f172a; font-weight: 700; }
.parte-card .badge {
  margin-top: 16px;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  display: inline-block;
}

/* ===== BADGES de estado (Diseño B · Bold & Modern) ===== */
.estado-Abierto { background: #ffedd5; color: #9a3412; }
.estado-En.Diagnostico { background: #fef3c7; color: #92400e; }
.estado-En.Reparacion { background: #fed7aa; color: #9a3412; }
.estado-Esperando.Material { background: #fed7aa; color: #9a3412; }
.estado-Listo { background: #d1fae5; color: #065f46; }
.estado-Entregado { background: #e5e7eb; color: #374151; }

@media (max-width: 768px) {
  .filtros-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filtros-search {
    max-width: 100%;
    min-width: 100%;
    margin-left: 0;
  }
}

/* ===================== GESTIÓN DE EMPRESAS (admin) ===================== */

/* Input con ojito + botón copiar a la derecha */
.pwd-input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
  margin-top: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.pwd-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.pwd-input-wrap input {
  flex: 1;
  border: 0 !important;
  background: transparent !important;
  padding: 11px 13px;
  font-size: 1rem;
  font-family: inherit;
  outline: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  min-height: 44px;
}
.pwd-toggle,
.pwd-copy {
  border: 0;
  background: transparent;
  padding: 0 12px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
  min-width: 44px;
  transition: background 0.15s, color 0.15s;
}
.pwd-toggle:hover,
.pwd-copy:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.pwd-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}
.pwd-hint.pwd-ok  { color: var(--ok); }
.pwd-hint.pwd-bad { color: var(--err); }

/* Checkbox alineado horizontalmente */
.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  margin: 0.5rem 0 1rem;
}
.checkbox-row input[type="checkbox"] {
  width: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  display: inline-block !important;
}
.checkbox-row span {
  font-size: 0.88rem;
  color: var(--text);
}

/* Caja de éxito (verde) — análoga a .error pero OK */
.success {
  margin-top: 12px;
  padding: 8px 10px;
  background: #ecfdf5;
  border-left: 3px solid var(--ok);
  color: var(--ok);
  border-radius: 4px;
  font-size: 0.88rem;
}

/* Tabla de empresas */
.empresas-table-wrap {
  width: 100%;
  overflow-x: auto;
}
.empresas-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.empresas-table th,
.empresas-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.empresas-table th {
  background: #f3f4f6;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-strong);
}
.empresas-table tbody tr:hover {
  background: #f2f2f3;
}
.empresas-table .email-texto {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86rem;
  display: block;
  margin-bottom: 4px;
  word-break: break-all;
}

/* Chip genérico (estado / vinculación) */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.chip-ok  { background: #d1fae5; color: #065f46; }
.chip-bad { background: #fee2e2; color: #991b1b; }

/* Botón pequeño (para acciones inline en la tabla) */
.btn-sm {
  padding: 6px 12px !important;
  font-size: 0.82rem !important;
}

/* Modal inline (reset de contraseña) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
  animation: fadein 0.15s ease;
}
.modal-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* Mobile: la tabla de empresas se convierte en cards apiladas */
@media (max-width: 768px) {
  .empresas-table thead { display: none; }
  .empresas-table,
  .empresas-table tbody,
  .empresas-table tr,
  .empresas-table td {
    display: block;
    width: 100%;
  }
  .empresas-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 12px;
  }
  .empresas-table td {
    border-bottom: 1px dashed var(--border);
    padding: 8px 0;
  }
  .empresas-table td:last-child { border-bottom: 0; }
  .empresas-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 600;
  }
}

/* ===================== LIGHTBOX DE FOTOS (PCDANI) ===================== */
img.zoomable {
  cursor: zoom-in;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
/* Thumbnails en preview: imagen pequeña, no la foto entera */
.thumbs img.zoomable {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
.lightbox[hidden] { display: none !important; }
.lightbox {
  position: fixed !important;
  inset: 0 !important;
  z-index: 99999 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.lightbox-backdrop {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.85) !important;
}
.lightbox-inner {
  position: relative !important;
  z-index: 2 !important;
  max-width: 95vw !important;
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
}
.lightbox-inner img {
  display: block !important;
  max-width: 95vw !important;
  max-height: 80vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  background: #000 !important;
  border-radius: 4px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}
.lightbox-close {
  position: fixed !important;
  top: max(env(safe-area-inset-top, 0px), 16px) !important;
  right: max(env(safe-area-inset-right, 0px), 16px) !important;
  z-index: 100000 !important;
  background: rgba(220, 38, 38, 0.95) !important;
  color: #fff !important;
  border: 2px solid #fff !important;
  border-radius: 50% !important;
  width: 56px !important;
  height: 56px !important;
  font-size: 32px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
}
.lightbox-close:hover { background: rgba(185, 28, 28, 1) !important; }
.lightbox-hint {
  position: fixed !important;
  bottom: max(env(safe-area-inset-bottom, 0px), 16px) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: rgba(0,0,0,0.6) !important;
  color: #fff !important;
  font-size: 0.85rem !important;
  padding: 8px 16px !important;
  border-radius: 20px !important;
  z-index: 100000 !important;
  text-align: center !important;
  max-width: 90vw !important;
}

/* ============================================================
   Modal de selección Cámara / Galería
   Solo se muestra cuando el bridge PCDANIBridge está disponible
   (cuando estamos dentro de la APK nativa).
   ============================================================ */
.pcdani-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: inherit;
}
.pcdani-modal.hidden { display: none; }
.pcdani-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  animation: pcdaniFade 0.2s ease;
}
@keyframes pcdaniFade { from { opacity: 0; } to { opacity: 1; } }
.pcdani-modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  padding: 20px 18px 28px;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.18);
  animation: pcdaniSlide 0.25s cubic-bezier(0.16,1,0.3,1);
}
@keyframes pcdaniSlide { from { transform: translateY(100%);} to {transform: translateY(0);} }
.pcdani-modal-sheet h3 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  color: #001391;
  font-weight: 700;
}
.pcdani-modal-sheet p.muted {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: #5a5a73;
}
.pcdani-modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.pcdani-modal-opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #f5f7fb;
  border: 1px solid #e2e6f1;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: #001391;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.pcdani-modal-opt:active {
  background: #e6ecf7;
  transform: scale(0.98);
}
.pcdani-modal-icon {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 10px;
  flex-shrink: 0;
}
.pcdani-modal-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pcdani-modal-label strong {
  font-size: 1rem;
  font-weight: 600;
  color: #001391;
}
.pcdani-modal-label small {
  font-size: 0.8rem;
  color: #6a6a85;
  font-weight: 400;
}
.pcdani-modal-cancel {
  width: 100%;
  background: transparent;
  border: 1px solid #cbd0e0;
  color: #5a5a73;
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
.pcdani-modal-cancel:active { background: #f0f1f5; }
