/* ============================================================================
 * LA SEMILLA OBRAS — SISTEMA DE DISEÑO MÓVIL MODERNO (iOS & Android Nativo)
 * Cero dependencias externas bloqueantes · Safe-Area iOS · 16px Inputs anti-zoom
 * ============================================================================ */
:root {
  --bg-app: #f2f5f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-soft: #e2e8f0;
  --border-strong: #cbd5e1;

  --brand: #059669;
  --brand-dark: #047857;
  --brand-soft: #ecfdf5;
  --brand-border: #a7f3d0;

  --blue: #0284c7;
  --blue-soft: #f0f9ff;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --rose: #e11d48;
  --rose-soft: #fff1f2;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius-xl: 20px;
  --radius-lg: 15px;
  --radius-md: 12px;
}

body.theme-dark {
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-elevated: #1f2937;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-soft: #1f2937;
  --border-strong: #334155;

  --brand-soft: rgba(16, 185, 129, 0.14);
  --brand-border: rgba(16, 185, 129, 0.35);
  --blue-soft: rgba(14, 165, 233, 0.14);
  --amber-soft: rgba(245, 158, 11, 0.14);
  --purple-soft: rgba(139, 92, 246, 0.15);
  --rose-soft: rgba(244, 63, 94, 0.15);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.5);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* En escritorio la centramos como teléfono moderno; en celular ocupa 100% real */
@media (min-width: 680px) {
  body.desktop-phone-preview {
    background: #060911;
    display: flex;
    justify-content: center;
    padding: 18px 0;
    min-height: 100vh;
  }
  body.desktop-phone-preview #app-shell {
    width: 100%;
    max-width: 440px;
    height: calc(100vh - 36px);
    border-radius: 34px;
    border: 5px solid #1e293b;
    box-shadow: 0 28px 70px rgba(0, 0, 0, 0.65);
    overflow: hidden;
  }
}

#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  background: var(--bg-app);
  color: var(--text-primary);
  position: relative;
}

/* Cabecera superior con soporte Safe Area iPhone (Notch / Dynamic Island) */
.app-topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-soft);
  padding: max(12px, calc(env(safe-area-inset-top, 0px) + 8px)) 16px 10px;
  z-index: 30;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
  flex-shrink: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 2px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-sync-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}
.app-sync-pill.is-online { background: var(--brand-soft); color: var(--brand); }
.app-sync-pill.is-syncing { background: var(--blue-soft); color: var(--blue); }
.app-sync-pill.is-local { background: var(--amber-soft); color: var(--amber); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease;
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn.amber {
  background: var(--amber-soft);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--amber);
}

/* Barra horizontal deslizable de Obras (Pills) */
.obra-pills-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.obra-pills-scroll::-webkit-scrollbar { display: none; }

.obra-pill {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.obra-pill.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.28);
}
.obra-pill .count {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.1);
}
.obra-pill.active .count {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

/* Área central scrolleable con momentum nativo iOS */
.app-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 96px;
}

.view-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.18s ease-out;
}
.view-section.hidden { display: none !important; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tarjetas modernas */
.m-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.hero-card {
  background: linear-gradient(140deg, #065f46 0%, #047857 55%, #0f766e 100%);
  color: #ffffff;
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 12px 28px rgba(4, 120, 87, 0.26);
  position: relative;
  overflow: hidden;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.hero-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.88;
}

.hero-obra-name {
  font-size: 18px;
  font-weight: 800;
  margin: 4px 0 0;
  line-height: 1.22;
  letter-spacing: -0.01em;
}

.hero-pct-badge {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 900;
  flex-shrink: 0;
}

.progress-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  margin: 13px 0 10px;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: #34d399;
  transition: width 0.35s ease;
}

.progress-track-light {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}
.progress-fill-brand {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width 0.35s ease;
}

/* Selector de usuario cómodo */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
}
.user-bar-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.user-select {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px; /* Evita auto-zoom en iPhone Safari */
  font-weight: 800;
  text-align: right;
  outline: none;
  cursor: pointer;
  min-width: 0;
}

/* Grilla 2x2 de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.kpi-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease;
}
.kpi-tile:active { transform: scale(0.97); }
.kpi-icon-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
}
.kpi-num {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-top: 2px;
}
.kpi-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}
.kpi-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Botonera 2x2 de Acciones Rápidas de 1 Pulgar */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.quick-action-btn {
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 14px 12px;
  background: var(--bg-surface);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.quick-action-btn:active { transform: scale(0.96); }
.quick-action-btn .qa-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.quick-action-btn .qa-txt {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}
.quick-action-btn .qa-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Secciones y encabezados */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.sec-title {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
}
.sec-link {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--brand);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
}

/* Chips de filtro horizontales */
.chips-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chips-row::-webkit-scrollbar { display: none; }

.filter-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.filter-chip.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-surface);
}

/* Tonos suaves claros para tarjetas de Etapa */
.stage-card {
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  padding: 15px;
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
}
body:not(.theme-dark) .stage-card[data-tono="menta"]   { background: #f0fdf4; border-color: #bbf7d0; }
body:not(.theme-dark) .stage-card[data-tono="celeste"] { background: #f0f9ff; border-color: #bae6fd; }
body:not(.theme-dark) .stage-card[data-tono="crema"]   { background: #fffbeb; border-color: #fde68a; }
body:not(.theme-dark) .stage-card[data-tono="lavanda"] { background: #f5f3ff; border-color: #ddd6fe; }
body:not(.theme-dark) .stage-card[data-tono="durazno"] { background: #fff7ed; border-color: #fed7aa; }
body:not(.theme-dark) .stage-card[data-tono="rosa"]    { background: #fdf2f8; border-color: #fbcfe8; }

.task-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.task-title {
  font-size: 14.5px;
  font-weight: 800;
  line-height: 1.32;
  margin: 0;
  color: var(--text-primary);
}
.task-title.done {
  text-decoration: line-through;
  opacity: 0.62;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Badges legibles */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-green  { background: var(--brand-soft); color: var(--brand); }
.badge-amber  { background: var(--amber-soft); color: var(--amber); }
.badge-blue   { background: var(--blue-soft); color: var(--blue); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-rose   { background: var(--rose-soft); color: var(--rose); }

/* Botones táctiles grandes */
.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 13px;
  border: none;
  font-size: 13.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: 12.5px; border-radius: 11px; }

.btn-primary { background: var(--brand); color: #ffffff; box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25); }
.btn-blue    { background: var(--blue); color: #ffffff; }
.btn-amber   { background: #f59e0b; color: #0f172a; }
.btn-purple  { background: var(--purple); color: #ffffff; }
.btn-dark    { background: #0f172a; color: #ffffff; }
body.theme-dark .btn-dark { background: #334155; }
.btn-outline {
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

/* Stepper de 3 pasos para Pedidos de Luciano */
.order-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 8px 0 4px;
}
.order-step {
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}
.order-step.done {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand);
}
.order-step.current {
  background: var(--amber-soft);
  border-color: rgba(217, 119, 6, 0.45);
  color: var(--amber);
}

/* Galería de miniaturas */
.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.thumb-item {
  width: 68px;
  height: 54px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--brand);
  cursor: pointer;
  padding: 0;
  background: #000;
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Barra inferior de 5 pestañas + Safe Area Home Bar de iPhone */
.app-tabbar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-soft);
  padding: 6px 8px max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  z-index: 35;
  box-shadow: 0 -4px 18px rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

.tab-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 2px;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}
.tab-btn .t-ico { font-size: 19px; line-height: 1; }
.tab-btn .t-lbl { font-size: 10.5px; font-weight: 700; }
.tab-btn.active {
  color: var(--brand);
  background: var(--brand-soft);
}
.tab-btn.active .t-lbl { font-weight: 800; }

.tab-badge {
  position: absolute;
  top: 2px;
  right: 10%;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Botón flotante (+) de Acción Rápida */
.fab-plus {
  position: fixed;
  right: 18px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #ffffff;
  font-size: 28px;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(5, 150, 105, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 36;
}
@media (min-width: 680px) {
  body.desktop-phone-preview .fab-plus {
    position: absolute;
    bottom: 78px;
  }
}
.fab-plus:active { transform: scale(0.93); }

/* Bottom Sheet Modal estilo iOS nativo */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.sheet-backdrop.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideSheet { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-panel {
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28);
  animation: slideSheet 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 2px auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.sheet-title {
  font-size: 16px;
  font-weight: 800;
  margin: 0;
}

/* Formularios cómodos con 16px para que iPhone no haga auto-zoom */
.f-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 13px;
}
.f-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}
.f-input, .f-select, .f-textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border-radius: 13px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 16px; /* Crítico en iOS Safari */
  font-weight: 600;
  font-family: inherit;
  outline: none;
}
.f-input:focus, .f-select:focus, .f-textarea:focus {
  border-color: var(--brand);
  background: var(--bg-surface);
}
.f-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.preset-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.preset-chip:active {
  transform: scale(0.95);
}

/* Constructor multi-ítem para Pedidos de Materiales y Facturas */
.mat-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.mat-item-card {
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-strong);
  border-radius: 15px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mat-item-card .f-input,
.mat-item-card .f-select {
  background: var(--bg-surface);
  min-height: 43px;
  padding: 8px 11px;
}
.mat-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mat-item-num {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
}
.mat-remove-btn {
  border: 1px solid rgba(225, 29, 72, 0.25);
  background: var(--rose-soft);
  color: var(--rose);
  border-radius: 9px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}
.btn-add-mat-row {
  width: 100%;
  min-height: 44px;
  border-radius: 13px;
  border: 1.5px dashed var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 13.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  margin-bottom: 13px;
}
.btn-add-mat-row:active {
  transform: scale(0.98);
}

/* Lista desglosada de ítems dentro de la tarjeta de Pedido */
.order-items-box {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
}
.order-item-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.3;
}
.order-item-name {
  font-weight: 700;
  color: var(--text-primary);
}
.order-item-qty {
  font-weight: 800;
  font-size: 12.5px;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Buscador */
.search-box {
  position: relative;
}
.search-box input {
  padding-left: 38px;
}
.search-box .s-ico {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  pointer-events: none;
}

/* Toasts flotantes arriba */
#toast-container {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 410px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#toast-container > div {
  padding: 12px 16px;
  border-radius: 15px;
  background: #0f172a;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  border-left: 4px solid #10b981;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}
#toast-container > div.bg-amber-600 { border-left-color: #f59e0b; }
#toast-container > div.bg-sky-600   { border-left-color: #38bdf8; }

/* Lightbox de fotos */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.lightbox-backdrop.hidden { display: none !important; }
.lightbox-backdrop img {
  max-width: 100%;
  max-height: 78dvh;
  border-radius: 14px;
  object-fit: contain;
}

/* ============================================================================
 * ZOMAX v14 — LOGO, BARRA DINÁMICA MODO ADMIN, ESCALA LETRA CAD 2D Y PERMISOS
 * ============================================================================ */
.brand-logo {
  padding: 0;
  overflow: hidden;
  background: #0d1424;
  border: 1px solid rgba(56, 189, 248, 0.35);
}
.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mode-indicator-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--brand-soft);
  color: var(--brand);
  border: 1px solid var(--brand-border);
}
.mode-indicator-pill.is-admin {
  background: #1e1b4b;
  color: #a5b4fc;
  border-color: #6366f1;
}

.app-tabbar.is-admin-mode {
  background: linear-gradient(180deg, #0f172a 0%, #090d16 100%);
  border-top: 2px solid #6366f1;
  box-shadow: 0 -6px 24px rgba(79, 70, 229, 0.22);
}
.app-tabbar.is-admin-mode .tab-btn {
  color: #94a3b8;
}
.app-tabbar.is-admin-mode .tab-btn.active {
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
}
.app-tabbar.is-admin-mode .tab-btn-back-obra {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.tab-btn-admin-entry {
  color: #6366f1;
}
body.theme-dark .tab-btn-admin-entry {
  color: #818cf8;
}

/* Nitidez y 3 opciones rápidas de tamaño de letra dentro del Plano CAD 2D */
.dxf-crisp-txt {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: calc(var(--dxf-fs, 4px) * var(--cad-text-scale, 1));
  font-weight: 800;
  paint-order: stroke fill;
  stroke: rgba(13, 17, 23, 0.92);
  stroke-width: 2.2px;
  stroke-linejoin: round;
  letter-spacing: 0.01em;
  pointer-events: none;
}

.cad-txt-scale-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #161f30;
  padding: 2px;
  border-radius: 9px;
  border: 1px solid #334155;
}
.cad-txt-scale-pill {
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 10.5px;
  font-weight: 800;
  padding: 4px 7px;
  border-radius: 7px;
  cursor: pointer;
}
.cad-txt-scale-pill.active {
  background: #10b981;
  color: #052e16;
}

/* Píldoras táctiles para activar/quitar capas del modelo 3D */
.m3d-layer-bar {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 8px 10px;
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  scrollbar-width: none;
}
.m3d-layer-bar::-webkit-scrollbar { display: none; }
.m3d-layer-pill {
  border: 1px solid #334155;
  background: #1e293b;
  color: #94a3b8;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.m3d-layer-pill.active {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #6ee7b7;
}
.m3d-layer-pill.preset-amber {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  color: #fde68a;
}

/* Permisos granulares por persona */
.perm-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  font-size: 13px;
  font-weight: 700;
}
.perm-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--brand);
  cursor: pointer;
}

.icon-mini-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 10px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-mini-btn:active { transform: scale(0.94); }
.icon-mini-btn.danger {
  border-color: rgba(225, 29, 72, 0.3);
  background: var(--rose-soft);
  color: var(--rose);
}

/* ============================================================================
 * ZOMAX v20 — REFINAMIENTO VISUAL, ANIMACIÓN CINEMATOGRÁFICA ZM,
 * CHECKLIST INTERACTIVO (☑) Y CARRITO INTELIGENTE VINCULADO (🛒)
 * ============================================================================ */

/* 1. Intro Cinematográfica Rápida ZM (Zoe & Máximo) */
.zm-intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 50% 42%, #132038 0%, #09101E 62%, #050912 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1), transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
.zm-intro-overlay.is-leaving {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}
.zm-intro-overlay.is-gone {
  display: none !important;
}
.zm-intro-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, rgba(0,0,0,0.85) 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at center, rgba(0,0,0,0.85) 20%, transparent 75%);
}
.zm-intro-glow {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.22) 0%, rgba(16, 185, 129, 0.18) 45%, transparent 72%);
  filter: blur(22px);
  animation: zmPulseGlow 1.6s ease-out forwards;
}
.zm-intro-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
}
.zm-emblem-frame {
  position: relative;
  width: 146px;
  height: 112px;
  border-radius: 28px;
  background: linear-gradient(155deg, rgba(30, 41, 59, 0.72), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(251, 191, 36, 0.28);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: zmEmblemPop 0.65s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.zm-monogram-svg {
  width: 126px;
  height: 92px;
}
.zm-stroke-z {
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: zmDrawStroke 0.72s cubic-bezier(0.33, 1, 0.68, 1) 0.08s forwards;
}
.zm-stroke-m {
  stroke-dasharray: 380;
  stroke-dashoffset: 380;
  animation: zmDrawStroke 0.78s cubic-bezier(0.33, 1, 0.68, 1) 0.24s forwards;
}
.zm-sheen {
  position: absolute;
  inset: -40% -120%;
  background: linear-gradient(112deg, transparent 42%, rgba(255, 255, 255, 0.36) 50%, transparent 58%);
  transform: translateX(-60%);
  animation: zmSheenGlide 0.95s ease-in-out 0.52s forwards;
  pointer-events: none;
}
.zm-wordmark {
  margin-top: 16px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #fde68a;
  opacity: 0;
  transform: translateY(8px);
  animation: zmFadeRise 0.48s ease-out 0.38s forwards;
}
.zm-wordmark span {
  color: #34d399;
}
.zm-tagline {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  opacity: 0;
  transform: translateY(6px);
  animation: zmFadeRise 0.48s ease-out 0.52s forwards;
}

@keyframes zmDrawStroke {
  to { stroke-dashoffset: 0; }
}
@keyframes zmSheenGlide {
  from { transform: translateX(-55%); }
  to { transform: translateX(65%); }
}
@keyframes zmEmblemPop {
  0% { opacity: 0; transform: scale(0.84) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes zmFadeRise {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes zmPulseGlow {
  0% { opacity: 0.2; transform: scale(0.75); }
  60% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 0.85; transform: scale(1); }
}

/* 2. Cabecera refinada con Switcher Obra | Administración y Carrito */
.brand-logo {
  border: 1.5px solid rgba(251, 191, 36, 0.45);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
  cursor: pointer;
  padding: 0;
  transition: transform 0.16s ease;
}
.brand-logo:active { transform: scale(0.92); }

.app-topbar {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.93);
}
body.theme-dark .app-topbar {
  background: rgba(17, 24, 39, 0.92);
}

.topbar-subrow {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 9px;
}

.mode-seg-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  border-radius: 13px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
}
.mode-seg-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 800;
  padding: 7px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.mode-seg-btn.active[data-top-mode="obra"] {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(5, 150, 105, 0.28);
}
.mode-seg-btn.active[data-top-mode="admin"] {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.32);
}

.cart-top-btn.has-items {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #f59e0b;
  color: #92400e;
  animation: zmCheckPop 0.3s ease;
}
body.theme-dark .cart-top-btn.has-items {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  color: #fde68a;
}

/* 3. Efectos visuales suaves en tarjetas y barras de progreso */
.hero-card {
  background: linear-gradient(135deg, #0b192c 0%, #065f46 58%, #047857 100%);
  border: 1px solid rgba(52, 211, 153, 0.28);
}
.hero-card::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.progress-fill, .progress-fill-brand {
  position: relative;
  overflow: hidden;
}
.progress-fill::after, .progress-fill-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.32), transparent);
  animation: zmProgressShimmer 2.4s infinite;
}
@keyframes zmProgressShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.stage-card, .task-item, .m-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.task-item {
  padding: 15px;
  gap: 11px;
  border-radius: 17px;
}
.task-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.38;
  letter-spacing: -0.01em;
}

/* 4. Sub-Checklist Interactivo con Tilde (☑) dentro de cada Tarea */
.subtasks-panel {
  background: var(--bg-subtle);
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.subtasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-secondary);
}
.subtasks-mini-bar {
  width: 64px;
  height: 6px;
  border-radius: 999px;
  background: var(--border-strong);
  overflow: hidden;
  flex-shrink: 0;
}
.subtasks-mini-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.28s ease;
}
.subtask-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 6px 7px;
  border-radius: 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.subtask-row.is-checked {
  background: var(--brand-soft);
  border-color: var(--brand-border);
}
.subtask-check {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}
.subtask-row.is-checked .subtask-check {
  animation: zmCheckPop 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.subtask-txt {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-primary);
}
.subtask-row.is-checked .subtask-txt {
  text-decoration: line-through;
  opacity: 0.72;
}
.subtask-del-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0.65;
}
.subtask-add-inline {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.subtask-add-inline input {
  flex: 1;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 16px;
}
.subtask-add-inline button {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--brand-border);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

@keyframes zmCheckPop {
  0% { transform: scale(0.8); }
  65% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* 5. Botón +Carrito en tarea y Barra Flotante Glassmórfica del Carrito */
.btn-task-cart {
  background: var(--amber-soft);
  border: 1px solid rgba(217, 119, 6, 0.38);
  color: var(--amber);
  min-height: 38px;
  padding: 7px 11px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}
.btn-task-cart:active { transform: scale(0.96); }

.origin-link-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--blue-soft);
  color: var(--blue);
  border: 1px solid rgba(2, 132, 199, 0.24);
  max-width: 100%;
}

.floating-cart-bar {
  position: fixed;
  left: 12px;
  right: 76px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 37;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  border: 1px solid rgba(251, 191, 36, 0.48);
  border-radius: 16px;
  padding: 10px 13px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  animation: zmCartSlideUp 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.floating-cart-bar.hidden { display: none !important; }
@media (min-width: 680px) {
  body.desktop-phone-preview .floating-cart-bar {
    position: absolute;
    bottom: 78px;
  }
}
@keyframes zmCartSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.cart-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 2px 5px;
}
.cart-stepper button {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}
