:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Colores del tema claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #ea580c;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #ea580c;
  --primary-hover: #c2410c;
  --primary-subtle: rgba(234, 88, 12, 0.1);

  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --info: #2563eb;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.08);

  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #090d16;
    --bg-card: #131a29;
    --bg-subtle: #1e293b;
    --bg-input: #172133;
    --border-color: #27354a;
    --border-focus: #f97316;

    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --primary-subtle: rgba(234, 88, 12, 0.2);

    --success-bg: rgba(5, 150, 105, 0.15);
    --success-border: rgba(5, 150, 105, 0.35);

    --warning-bg: rgba(217, 119, 6, 0.15);
    --warning-border: rgba(217, 119, 6, 0.35);

    --danger-bg: rgba(220, 38, 38, 0.15);
    --danger-border: rgba(220, 38, 38, 0.35);

    --info-bg: rgba(37, 99, 235, 0.15);
    --info-border: rgba(37, 99, 235, 0.35);

    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  }
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  padding-bottom: 40px;
}

/* Envoltorio principal de aplicación */
.app-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 40px 16px;
}

/* Barra superior fija o superior */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(8px);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-main);
  text-decoration: none;
}

.brand-icon-wrap {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #ea580c, #f97316);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.3);
}

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

/* Tarjetas Principales */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-title svg {
  color: var(--primary);
  flex-shrink: 0;
}

/* Encabezado del Taller Comercial */
.workshop-header-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-subtle) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.workshop-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.workshop-logo {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--border-color);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}

.workshop-info h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}

.workshop-info p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.workshop-contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #25d366;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
  transition: var(--transition);
  cursor: pointer;
  border: none;
}

.workshop-contact-btn:hover {
  background: #1ebd5a;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.35);
}

/* Tarjeta Principal de Identificación y Estado */
.order-hero-card {
  position: relative;
  overflow: hidden;
}

.order-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.order-badge-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-number {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-copy-code {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--transition);
}

.btn-copy-code:hover {
  color: var(--text-main);
  background: var(--border-color);
}

/* Insignias de Estado Normativas */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.badge-recibido {
  background: #e0f2fe;
  color: #0369a1;
  border-color: #bae6fd;
}
.badge-en_diagnostico {
  background: #e0e7ff;
  color: #4338ca;
  border-color: #c7d2fe;
}
.badge-presupuesto_pendiente, .badge-presupuestado {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}
.badge-presupuesto_aprobado {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}
.badge-en_reparacion {
  background: #f3e8ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}
.badge-listo, .badge-listo_para_retiro {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
.badge-entregado {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}
.badge-cancelado {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fecaca;
}

/* Ficha Técnica del Equipo */
.device-spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 14px;
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spec-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.spec-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
}

/* Problema Reportado */
.problem-box {
  margin-top: 16px;
  padding: 12px 16px;
  background: rgba(234, 88, 12, 0.05);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.problem-box strong {
  color: var(--text-main);
}

/* Checklist de Ingreso */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.check-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.check-item .chk-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.check-item .chk-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Diagnóstico Técnico */
.diag-card {
  border-left: 4px solid #3b82f6;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.06), transparent);
}

.diag-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-line;
}

/* Galería de Evidencias Fotográficas */
.evidencias-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.evidencia-thumb-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  aspect-ratio: 1 / 1;
  background: #000000;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.evidencia-thumb-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.evidencia-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.evidencia-thumb-card:hover img {
  transform: scale(1.06);
}

.evidencia-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.evidencia-caption-peek {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
  color: #ffffff;
  font-size: 0.72rem;
  padding: 14px 6px 6px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Desglose de Presupuesto */
.quote-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.quote-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 12px;
}

.quote-item-desc {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  flex-wrap: wrap;
}

.type-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
}

.type-pill.repuesto {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.type-pill.mano-obra {
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.quote-item-qty {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.quote-item-sub {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.quote-totals-box {
  border-top: 2px dashed var(--border-color);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.total-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.total-line .val {
  font-family: var(--font-mono);
  font-weight: 600;
}

.total-line-highlight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  margin-top: 6px;
  border: 1px solid var(--border-color);
}

.total-line-highlight .label {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.total-line-highlight .amount {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}

.warranty-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 0.85rem;
  color: #047857;
  font-weight: 600;
}

/* Módulo de Decisión Digital */
.decision-card {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.05) 0%, rgba(16, 185, 129, 0.08) 100%);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(234, 88, 12, 0.12);
  text-align: center;
}

.decision-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.decision-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  max-width: 540px;
  margin: 0 auto 18px auto;
}

.decision-total-prompt {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 18px;
}

.decision-total-prompt span {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  color: var(--primary);
}

.decision-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-decision {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  min-width: 200px;
}

.btn-approve {
  background: #059669;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.btn-approve:hover {
  background: #047857;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(5, 150, 105, 0.45);
}

.btn-reject {
  background: var(--bg-card);
  color: #dc2626;
  border: 1px solid var(--danger-border);
}

.btn-reject:hover {
  background: var(--danger-bg);
  border-color: #dc2626;
  transform: translateY(-2px);
}

.decision-status-alert {
  margin-top: 16px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.95rem;
  display: none;
}

/* Lightbox Modal Profesional */
.lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  z-index: 9999;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.lightbox-header {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  z-index: 10;
}

.lightbox-title-wrap {
  display: flex;
  flex-direction: column;
}

.lightbox-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.lightbox-subtitle {
  font-size: 0.75rem;
  color: #94a3b8;
}

.lightbox-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-tool-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.lightbox-tool-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.lightbox-stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: none;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  transition: transform 0.2s ease-out;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
  border-radius: var(--radius-sm);
}

.lightbox-caption-bar {
  width: 100%;
  max-width: 800px;
  text-align: center;
  color: #cbd5e1;
  font-size: 0.85rem;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.7);
  border-radius: var(--radius-md);
  margin-top: 10px;
}

/* Pie de Página y QR de Consulta */
.footer-card {
  text-align: center;
  padding: 24px 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.qr-box-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.qr-box {
  background: #ffffff;
  padding: 10px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: inline-block;
  margin-bottom: 8px;
}

.qr-box img, .qr-box canvas {
  display: block;
  width: 120px;
  height: 120px;
}

/* Estado Vacío / Sin Hash */
.empty-hero {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px auto;
  color: var(--text-muted);
}

.empty-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-main);
}

.empty-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  max-width: 460px;
  margin: 0 auto 24px auto;
}

/* Toast flotante */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Ajustes responsivos */
@media (max-width: 640px) {
  .app-container {
    padding: 12px 12px 40px 12px;
  }
  .workshop-header-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .workshop-contact-btn {
    width: 100%;
    justify-content: center;
  }
  .order-hero-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .btn-decision {
    width: 100%;
  }
}
