/* ══════════════════════════════════════════
   CARPINTERÍA 360 – Components
   ══════════════════════════════════════════ */

/* ── HEADER ── */
.app-header {
  background: var(--dark);
  padding: 14px 18px 12px;
  /* CORREGIDO (reporte iPhone/PWA): al instalar como PWA, viewport-fit=cover
     + status bar "black-translucent" hacen que el contenido se dibuje POR
     DEBAJO del notch/Dynamic Island. Sin este padding, el encabezado (y los
     botones de acción que contiene) quedaban parcialmente tapados/fuera del
     área visible en iPhones con notch. env(...) devuelve 0 en navegadores
     sin notch, así que no afecta a los demás dispositivos. */
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.app-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 80% at 20% 50%, rgba(245,130,10,.12), transparent);
  pointer-events: none;
}
.header-logo { position: relative; z-index: 1; }
.header-brand {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: 2px;
  color: #fff;
  line-height: 1;
}
.header-brand span { color: var(--orange); }
.header-brand-img {
  display: block;
  height: 30px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
  padding: 3px 6px;
}
.header-tagline {
  font-size: .62rem;
  color: rgba(255,255,255,.6);
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-top: 2px;
}
.header-actions { display: flex; gap: 8px; align-items: center; position: relative; z-index: 1; }
.header-icon-btn {
  background: rgba(255,255,255,.1);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  cursor: pointer;
  position: relative;
  transition: background .2s;
}
.header-icon-btn:active { background: rgba(255,255,255,.2); }
.notif-badge {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--orange);
  border-radius: 50%;
  border: 1.5px solid var(--dark);
}

/* ── PAGE HEADER ── */
.page-header {
  background: var(--card);
  padding: 14px 18px;
  /* Mismo motivo que .app-header: evita que el botón "←" quede tapado por
     el notch/Dynamic Island al instalar la app como PWA en iPhone. */
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.page-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 1.5px;
}
.back-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  transition: background .15s;
}
.back-btn:active { background: var(--border); }
.page-header-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── BOTTOM NAV ──
   Antes: position:fixed + bottom:0 (auditoría, Carpintero #4). En iOS Safari,
   un elemento fixed anclado a bottom:0 se posiciona detrás de la barra de
   navegación del navegador (que se superpone al "viewport visual" pero no
   al "viewport de layout"), tapando los últimos ~15-20px del nav — por eso
   las etiquetas de los botones se veían cortadas. #app-shell ya usa 100dvh
   y flex-direction:column, así que basta con dejar que el nav viva en el
   flujo normal (último hijo flex, flex-shrink:0) para que siempre quede
   justo encima del borde real de la pantalla visible, en cualquier
   dispositivo. Se agrega además el padding para no invadir el área del
   home indicator / gestos en iPhones con notch. */
.bottom-nav {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  color: var(--muted);
  font-size: .52rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  transition: color .15s;
  position: relative;
}
.nav-item.active { color: var(--orange); }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--orange);
  border-radius: 0 0 4px 4px;
}
.nav-icon { font-size: 1.2rem; line-height: 1; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: var(--r-sm);
  border: none;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: .4px;
  cursor: pointer;
  transition: background .2s, transform .1s, opacity .2s;
  width: 100%;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-orange  { background: var(--orange); color: #fff; }
.btn-orange:hover { background: var(--orange-dark); }
.btn-dark    { background: var(--dark); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--orange); color: var(--orange); }
.btn-ghost   { background: var(--border); color: var(--text); }
.btn-green   { background: #25D366; color: #fff; }
.btn-sm      { padding: 8px 16px; font-size: .78rem; width: auto; border-radius: 8px; }

/* ── CTA BIG ── */
.cta-big {
  margin: 12px 14px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 17px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245,130,10,.35);
  transition: background .2s, transform .1s;
  width: calc(100% - 28px);
}
.cta-big:active { transform: scale(.98); background: var(--orange-dark); }
.cta-arrow { font-size: 1.5rem; }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 5px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

input[type=text],
input[type=number],
input[type=email],
input[type=tel],
input[type=password],
select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: .88rem;
  color: var(--text);
  background: var(--card);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245,130,10,.12);
}
textarea { min-height: 90px; resize: vertical; }

.input-group { position: relative; }
.input-prefix {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .85rem;
  pointer-events: none;
}
.input-group input { padding-left: 30px; }

/* ── SEARCH BAR ── */
.search-wrap {
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.search-icon {
  position: absolute;
  left: 26px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1rem;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: .85rem;
  background: var(--bg);
  outline: none;
  transition: border-color .2s;
}
.search-input:focus { border-color: var(--orange); }

/* ── CHIPS / FILTERS ── */
.chips {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--card);
  color: var(--muted);
  transition: all .15s;
  white-space: nowrap;
  letter-spacing: .3px;
}
.chip.active, .chip:active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
}
.card-body { padding: 16px; }
.card-img  { width: 100%; height: 150px; object-fit: cover; background: #ddd; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-green   { background: var(--green-bg);  color: var(--green);  }
.badge-red     { background: var(--red-bg);    color: var(--red);    }
.badge-blue    { background: var(--blue-bg);   color: var(--blue);   }
.badge-orange  { background: rgba(245,130,10,.15); color: var(--orange); }
.badge-purple  { background: var(--purple-bg); color: var(--purple); }

/* ── STATUS PILLS (proyectos) ── */
.status-pill {
  font-size: .62rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .4px;
  flex-shrink: 0;
}
.st-produccion  { background: #FFF3E0; color: #E65100; }
.st-pendiente   { background: var(--blue-bg);   color: var(--blue);   }
.st-finalizado  { background: var(--green-bg);  color: var(--green);  }
.st-instalacion { background: var(--purple-bg); color: var(--purple); }
.st-cancelado   { background: var(--red-bg);    color: var(--red);    }
.st-aprobado    { background: #E8F5E9; color: #1B5E20; }

/* ── RESULT BOX ── */
.result-box {
  background: #FFF8F0;
  border: 2px solid var(--orange);
  border-radius: var(--r);
  padding: 18px;
  margin-top: 16px;
}
.result-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 1.5px;
  color: var(--orange);
  margin-bottom: 12px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(245,130,10,.15);
}
.result-row:last-child { border: none; }
.result-label { font-size: .78rem; color: var(--muted); }
.result-value { font-size: .88rem; font-weight: 700; color: var(--text); }
.result-total { font-size: 1.25rem; font-weight: 800; color: var(--orange); }

/* ── FÓRMULAS (Calculadora rápida) ── */
.formulas-search {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  font-size: .85rem;
  background: var(--bg);
  outline: none;
  margin-bottom: 12px;
  transition: border-color .2s;
}
.formulas-search:focus { border-color: var(--orange); }

.formulas-cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
}
.formulas-cats::-webkit-scrollbar { display: none; }

.formulas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (min-width: 480px) {
  .formulas-grid { grid-template-columns: 1fr 1fr; }
}

.formula-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 12px;
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.formula-card:active { transform: scale(.97); }
.formula-card:hover {
  border-color: var(--orange);
  box-shadow: 0 4px 14px rgba(245,130,10,.14);
}
.formula-card-icon { font-size: 1.5rem; line-height: 1; }
.formula-card-title { font-size: .82rem; font-weight: 800; color: var(--text); }
.formula-card-desc { font-size: .68rem; color: var(--muted); line-height: 1.3; }

.formula-detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.formula-back-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bone);
  border: none;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.formula-back-btn:active { background: var(--border); }
.formula-detail-title { font-family: var(--font-display); font-size: 1.05rem; letter-spacing: .5px; }

.formula-expr {
  background: var(--wood-pale);
  border: 1.5px dashed var(--wood-light);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-family: 'Courier New', monospace;
  font-size: .92rem;
  font-weight: 700;
  color: var(--wood);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: .3px;
}

.formula-help {
  font-size: .76rem;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 16px;
  padding-left: 2px;
}

.formula-live-result {
  /* CORREGIDO: antes tenía "background: #FFF8F0" fijo (un crema claro que
     no cambia con el tema). En modo oscuro, --text se invierte a un color
     claro (ver variables.css), así que el resultado quedaba con letras
     claras sobre ese mismo fondo claro fijo -- prácticamente invisible.
     Con var(--card) el fondo sí se oscurece junto con el texto. */
  background: var(--card);
  border: 2px solid var(--orange);
  border-radius: var(--r);
  padding: 16px;
  margin-top: 14px;
  text-align: center;
}
.formula-live-empty {
  background: var(--bone);
  border: 1.5px dashed var(--border);
  border-radius: var(--r);
  padding: 18px;
  margin-top: 14px;
  text-align: center;
  font-size: .78rem;
  color: var(--muted);
}
.formula-live-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--orange);
  margin-bottom: 4px;
}
.formula-live-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--text);
  letter-spacing: .5px;
  word-break: break-word;
}
.formula-live-unit { font-size: 1rem; color: var(--muted); font-weight: 700; margin-left: 4px; }
.formula-live-extra { margin-top: 10px; text-align: left; }

.formula-copy-btn {
  margin-top: 12px;
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, transform .1s;
}
.formula-copy-btn:active { transform: scale(.97); background: var(--orange-dark); }

/* ── FÓRMULAS: cabecera de detalle con acción "limpiar" ── */
.formula-detail-title-wrap { flex: 1; min-width: 0; }
.formula-detail-hint {
  font-size: .68rem;
  color: var(--muted);
  margin-top: 2px;
}
.formula-clear-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bone);
  border: none;
  font-size: .95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.formula-clear-btn:active { background: var(--red-bg); transform: scale(.93); }

/* ── FÓRMULAS: validación de campos ── */
.form-group input.input-error {
  border-color: var(--red);
  background: var(--red-bg);
}
.field-error {
  display: none;
  font-size: .68rem;
  font-weight: 600;
  color: var(--red);
  margin-top: -2px;
}

.formula-live-error {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
  font-weight: 600;
}

/* ── FÓRMULAS: procedimiento paso a paso ── */
.formula-steps {
  background: var(--bone);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-top: 14px;
}
.formula-steps-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 8px;
}
.formula-steps-list {
  margin: 0;
  padding-left: 18px;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.7;
  font-family: 'Courier New', monospace;
}

/* ── FÓRMULAS: acciones del resultado ── */
.formula-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.formula-action-btn {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: var(--r-sm);
  background: var(--dark);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .15s, transform .1s;
}
.formula-action-btn:active { transform: scale(.97); background: var(--orange-dark); }

/* ── MATERIAL CARD ── */
.mat-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  transition: box-shadow .2s;
}
.mat-card:active { box-shadow: var(--shadow-lg); }
.mat-swatch {
  width: 54px;
  height: 54px;
  border-radius: 9px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.mat-info { flex: 1; min-width: 0; }
.mat-name  { font-weight: 700; font-size: .88rem; }
.mat-brand { font-size: .7rem; color: var(--muted); margin-top: 1px; }
.mat-desc  { font-size: .7rem; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.mat-footer{ display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.mat-price { font-weight: 800; color: var(--orange); font-size: .95rem; }

/* ── PROJECT CARD ── */
.proj-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: box-shadow .2s;
}
.proj-card:active { box-shadow: var(--shadow-lg); }
.proj-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 8px; }
.proj-name   { font-weight: 700; font-size: .92rem; }
.proj-sub    { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.proj-progress { background: var(--border); border-radius: 50px; height: 6px; margin-bottom: 8px; overflow: hidden; }
.proj-bar { height: 100%; background: var(--orange); border-radius: 50px; transition: width .6s ease; }
.proj-meta { display: flex; justify-content: space-between; font-size: .7rem; color: var(--muted); }

/* ── DIRECTORIO CARD ── */
.dir-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.dir-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
}
.dir-body { flex: 1; }
.dir-name  { font-weight: 700; font-size: .9rem; }
.dir-spec  { font-size: .72rem; color: var(--muted); margin-top: 1px; }
.dir-city  { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.dir-rating { display: flex; align-items: center; gap: 5px; margin-top: 5px; }
.stars     { color: var(--orange); font-size: .75rem; letter-spacing: 1px; }
.dir-reviews { font-size: .68rem; color: var(--muted); }
.dir-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.dir-btn { padding: 8px; border-radius: 8px; border: none; font-size: .72rem; font-weight: 700; cursor: pointer; text-align: center; transition: opacity .15s; }
.dir-btn:active { opacity: .8; }
.dir-btn-call { background: var(--orange); color: #fff; }
.dir-btn-wa   { background: #25D366; color: #fff; }

/* ── FORUM CARD ── */
.forum-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.forum-card:active { box-shadow: var(--shadow-lg); }
.forum-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.forum-title { font-weight: 700; font-size: .88rem; line-height: 1.3; margin-bottom: 6px; }
.forum-meta  { display: flex; gap: 12px; font-size: .68rem; color: var(--muted); flex-wrap: wrap; }
.forum-hot   { font-size: .65rem; font-weight: 700; color: var(--orange); }

/* ── CURSO CARD ── */
.curso-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
  cursor: pointer;
}
.curso-thumb {
  height: 100px;
  background: linear-gradient(135deg, #1a0800, #3d1800);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.8rem;
  position: relative;
}
.curso-thumb .curso-badge-free {
  position: absolute; top: 10px; right: 10px;
}
.curso-body { padding: 14px; }
.curso-title { font-weight: 700; font-size: .9rem; margin-bottom: 5px; line-height: 1.3; }
.curso-desc  { font-size: .72rem; color: var(--muted); margin-bottom: 10px; line-height: 1.4; }
.curso-meta  { display: flex; gap: 10px; font-size: .68rem; color: var(--muted); margin-bottom: 4px; }
.curso-instructor { font-size: .7rem; color: var(--muted); }
.curso-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.curso-price { font-weight: 800; font-size: 1rem; color: var(--orange); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 30px;
}
.empty-icon  { font-size: 3.5rem; margin-bottom: 14px; }
.empty-title { font-family: var(--font-display); font-size: 1.5rem; letter-spacing: 1px; margin-bottom: 8px; }
.empty-sub   { font-size: .82rem; color: var(--muted); line-height: 1.6; }

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%; transform: translateX(-50%);
  background: var(--dark);
  color: #fff;
  padding: 10px 22px;
  border-radius: 50px;
  font-size: .82rem;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90%;
}
.toast.show { opacity: 1; }

/* ── MODAL OVERLAY ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 22px 18px 36px;
  width: 100%;
  max-width: 480px;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 4px;
  margin: 0 auto 18px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
}

/* ── PROFILE ── */
.profile-header {
  background: var(--dark);
  padding: 28px 18px 24px;
  text-align: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.profile-header::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 30%, rgba(245,130,10,.18), transparent);
}
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  color: #fff;
  margin: 0 auto 12px;
  position: relative; z-index: 1;
  border: 3px solid rgba(255,255,255,.2);
}
.profile-name { font-weight: 700; font-size: 1.1rem; color: #fff; position: relative; z-index: 1; }
.profile-role { font-size: .72rem; color: rgba(255,255,255,.6); margin-top: 3px; position: relative; z-index: 1; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--card);
  border-radius: var(--r);
  overflow: hidden;
  margin: 14px;
  box-shadow: var(--shadow);
}
.profile-stat { padding: 14px 8px; text-align: center; border-right: 1px solid var(--border); }
.profile-stat:last-child { border-right: none; }
.profile-stat-num {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--orange);
  line-height: 1;
}
.profile-stat-lbl { font-size: .6rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 3px; }

.menu-list {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 0 14px 14px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.menu-item:last-child { border: none; }
.menu-item:active { background: var(--bg); }
.menu-icon  { font-size: 1.25rem; width: 28px; text-align: center; }
.menu-label { flex: 1; font-size: .88rem; font-weight: 500; }
.menu-arrow { color: var(--muted); font-size: .9rem; }

/* ── NOTIFICATION ITEMS ── */
.notif-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.notif-item.unread { background: #FFF8F0; }
.notif-item:active { background: var(--bg); }
.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  margin-top: 6px;
}
.notif-dot.read { background: transparent; border: 1.5px solid var(--border); }
.notif-text { font-size: .82rem; line-height: 1.5; }
.notif-time { font-size: .68rem; color: var(--muted); margin-top: 3px; }

/* ── COTIZACION RESULTADO ── */
.quote-summary {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 16px;
}
.quote-header {
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 1.5px;
  color: var(--orange);
  margin-bottom: 4px;
}
.quote-date { font-size: .7rem; color: var(--muted); margin-bottom: 14px; }
.quote-line {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.quote-line:last-child { border: none; font-weight: 800; font-size: 1rem; color: var(--orange); }
.quote-desc { color: var(--muted); }

/* ── CHECKLIST (instalador) ── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.checklist-item:active { background: var(--bg); }
.check-box {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
  font-size: .85rem;
}
.check-box.done { background: var(--orange); border-color: var(--orange); }
.check-label { font-size: .85rem; font-weight: 500; }
.check-label.done { text-decoration: line-through; color: var(--muted); }

/* ── LOADING SPINNER ── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   ERP COMPONENTS – v2
   ══════════════════════════════════════════ */

/* ── KPI CARDS ── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}
.kpi-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--orange);
  position: relative;
  overflow: hidden;
}
.kpi-card.kpi-green  { border-left-color: var(--green); }
.kpi-card.kpi-blue   { border-left-color: var(--blue); }
.kpi-card.kpi-purple { border-left-color: var(--purple); }
.kpi-card.kpi-teal   { border-left-color: var(--teal); }
.kpi-card.kpi-amber  { border-left-color: var(--amber); }
.kpi-label {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 4px;
}
.kpi-value {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: 1px;
  color: var(--text);
  line-height: 1;
}
.kpi-sub {
  font-size: .65rem;
  color: var(--muted);
  margin-top: 4px;
}
.kpi-trend {
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  position: absolute;
  top: 10px; right: 10px;
}
.kpi-trend.up   { background: var(--green-bg); color: var(--green); }
.kpi-trend.down { background: var(--red-bg);   color: var(--red); }

/* ── SECTION HEADER ── */
.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
}
.sec-title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1.5px;
  color: var(--text);
}
.sec-link {
  font-size: .72rem;
  font-weight: 700;
  color: var(--orange);
  cursor: pointer;
}

/* ── ENTITY CARDS (CRM / Clientes) ── */
.entity-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  transition: box-shadow .2s;
}
.entity-card:active { box-shadow: var(--shadow-lg); }
.entity-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--orange-glow);
  border: 2px solid var(--orange);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--orange);
  flex-shrink: 0;
}
.entity-info { flex: 1; min-width: 0; }
.entity-name { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entity-sub  { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.entity-meta { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ── TAGS / BADGES ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .3px;
}
.tag-orange  { background: var(--orange-glow);  color: var(--orange-dark); }
.tag-green   { background: var(--green-bg);   color: var(--green); }
.tag-blue    { background: var(--blue-bg);    color: var(--blue); }
.tag-red     { background: var(--red-bg);     color: var(--red); }
.tag-purple  { background: var(--purple-bg);  color: var(--purple); }
.tag-amber   { background: var(--amber-bg);   color: var(--amber); }
.tag-teal    { background: var(--teal-bg);    color: var(--teal); }
.tag-indigo  { background: var(--indigo-bg);  color: var(--indigo); }
.tag-muted   { background: var(--border);     color: var(--muted); }
.tag-wood    { background: var(--wood-pale);  color: var(--wood); }

/* ── AGENDA ITEMS ── */
.agenda-item {
  background: var(--card);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}
.agenda-time-block {
  text-align: center;
  min-width: 46px;
  flex-shrink: 0;
}
.agenda-time { font-family: var(--font-display); font-size: 1rem; letter-spacing: 1px; color: var(--orange); }
.agenda-ampm { font-size: .6rem; color: var(--muted); text-transform: uppercase; }
.agenda-dot  {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--orange); flex-shrink: 0;
}
.agenda-dot.green  { background: var(--green); }
.agenda-dot.blue   { background: var(--blue); }
.agenda-dot.purple { background: var(--purple); }
.agenda-content { flex: 1; min-width: 0; }
.agenda-title   { font-weight: 700; font-size: .88rem; }
.agenda-sub     { font-size: .7rem; color: var(--muted); margin-top: 2px; }

/* ── TIMELINE ── */
.timeline { padding: 4px 14px; }
.timeline-item { display: flex; gap: 14px; margin-bottom: 16px; }
.timeline-left { display: flex; flex-direction: column; align-items: center; }
.timeline-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--orange); flex-shrink: 0;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 2px var(--orange);
}
.timeline-dot.done  { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.timeline-dot.todo  { background: var(--border); box-shadow: 0 0 0 2px var(--muted); }
.timeline-line {
  width: 2px; flex: 1; background: var(--border);
  margin: 4px 0; min-height: 20px;
}
.timeline-content { flex: 1; padding-top: 0; }
.timeline-date  { font-size: .62rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.timeline-title { font-weight: 700; font-size: .88rem; margin-top: 2px; }
.timeline-desc  { font-size: .75rem; color: var(--muted); margin-top: 3px; }

/* ── PROGRESS BAR ── */
.prog-wrap { background: var(--border); border-radius: 50px; height: 6px; overflow: hidden; }
.prog-bar  { height: 100%; background: var(--orange); border-radius: 50px; transition: width .5s ease; }
.prog-bar.green  { background: var(--green); }
.prog-bar.blue   { background: var(--blue); }

/* ── STAT ROW ── */
.stat-row {
  display: flex;
  background: var(--card);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 0 14px 10px;
}
.stat-col {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
}
.stat-col:last-child { border-right: none; }
.stat-col-num {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 1px;
  color: var(--orange);
}
.stat-col-label { font-size: .58rem; color: var(--muted); font-weight: 600; text-transform: uppercase; margin-top: 2px; }

/* ── PIEZAS / DESPIECE ── */
.pieza-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.pieza-num {
  width: 24px; height: 24px;
  background: var(--orange);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.pieza-info { flex: 1; }
.pieza-name { font-size: .82rem; font-weight: 700; }
.pieza-dims { font-size: .68rem; color: var(--muted); }
.pieza-qty  { font-family: var(--font-display); font-size: 1.1rem; color: var(--orange); }

/* ── CHECKLIST ── */
.check-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.check-item:active { background: var(--bone); }
.check-box {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
  transition: all .2s;
}
.check-item.done .check-box {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.check-text { font-size: .85rem; }
.check-item.done .check-text { text-decoration: line-through; color: var(--muted); }

/* ── INVEOTRY ITEMS ── */
.inv-item {
  background: var(--card);
  border-radius: var(--r);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: var(--shadow);
}
.inv-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--wood-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.inv-info { flex: 1; min-width: 0; }
.inv-name { font-weight: 700; font-size: .85rem; }
.inv-sku  { font-size: .65rem; color: var(--muted); }
.inv-stock-wrap { text-align: right; }
.inv-stock { font-family: var(--font-display); font-size: 1.3rem; letter-spacing: 1px; }
.inv-unit  { font-size: .62rem; color: var(--muted); }
.inv-alert { color: var(--red); }
.inv-ok    { color: var(--green); }

/* ── MARKETPLACE CARDS ── */
.mkt-card {
  background: var(--card);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.mkt-card-img {
  height: 100px;
  background: linear-gradient(135deg, var(--wood-pale), var(--bone));
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.mkt-card-body { padding: 12px 14px; }
.mkt-name { font-weight: 700; font-size: .9rem; }
.mkt-price { color: var(--orange); font-weight: 800; font-size: 1rem; margin-top: 4px; }
.mkt-meta { font-size: .68rem; color: var(--muted); margin-top: 4px; }
.mkt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

/* ── CHART MINI ── */
.mini-chart-wrap {
  background: var(--card);
  border-radius: var(--r);
  margin: 0 14px 10px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.mini-chart-title {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 10px;
}
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 60px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar { width: 100%; background: var(--orange); border-radius: 4px 4px 0 0; transition: height .4s ease; }
.bar.dim { background: var(--border); }
.bar-lbl { font-size: .55rem; color: var(--muted); }

/* ── RENDER PREVIEW ── */
.render-card {
  background: var(--dark);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: var(--shadow-lg);
}
.render-canvas {
  height: 180px;
  background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  position: relative;
}
.render-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.7), transparent);
}
.render-label {
  position: absolute;
  bottom: 10px; left: 14px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 1.5px;
  z-index: 1;
}
.render-body { padding: 12px 14px; background: #1E1E1E; color: #fff; }

/* ── REPORTE CARD ── */
.report-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.report-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--orange-glow);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.report-info { flex: 1; }
.report-name { font-weight: 700; font-size: .88rem; }
.report-desc { font-size: .7rem; color: var(--muted); margin-top: 2px; }

/* ── BIBLIOTECA ── */
.bib-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
}
.bib-icon { font-size: 1.6rem; flex-shrink: 0; }
.bib-title { font-weight: 700; font-size: .88rem; }
.bib-desc  { font-size: .7rem; color: var(--muted); margin-top: 3px; }

/* ── TABS HORIZONTAL ── */
.htabs {
  display: flex;
  gap: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.htab {
  padding: 10px 14px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
  transition: all .2s;
  flex-shrink: 0;
}
.htab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  gap: 12px;
}
.empty-icon { font-size: 3rem; opacity: .4; }
.empty-title { font-family: var(--font-display); font-size: 1.1rem; letter-spacing: 1px; color: var(--muted); }
.empty-sub   { font-size: .78rem; color: var(--muted); max-width: 220px; }

/* ── FORM FIELD INLINE ── */
.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.field-row label {
  flex: 1;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
}
.field-row .field-val {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  text-align: right;
}

/* ── ORF - Ordenes de Fabricacion ── */
.of-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--blue);
}
.of-card.priority-alta   { border-top-color: var(--red); }
.of-card.priority-media  { border-top-color: var(--amber); }
.of-card.priority-normal { border-top-color: var(--blue); }
.of-code   { font-family: var(--font-display); font-size: .9rem; letter-spacing: 2px; color: var(--muted); }
.of-title  { font-weight: 700; font-size: .92rem; margin-top: 4px; }
.of-meta   { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.of-progress { margin-top: 10px; }
.of-prog-labels { display: flex; justify-content: space-between; font-size: .62rem; color: var(--muted); margin-bottom: 4px; }

/* ── CRONO ── */
.gantt-wrap {
  background: var(--card);
  border-radius: var(--r);
  margin: 0 14px 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.gantt-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.gantt-label { font-size: .72rem; font-weight: 600; width: 90px; flex-shrink: 0; }
.gantt-track { flex: 1; height: 16px; background: var(--border); border-radius: 4px; overflow: hidden; position: relative; }
.gantt-bar   { height: 100%; border-radius: 4px; position: absolute; background: var(--orange); }
.gantt-dates { font-size: .58rem; color: var(--muted); width: 60px; text-align: right; flex-shrink: 0; }

/* ── TOGGLE SWITCH (Notificaciones, preferencias) ── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: var(--border); border-radius: 24px;
  transition: background-color .2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 18px; width: 18px;
  left: 3px; bottom: 3px; background-color: #fff; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.switch input:checked + .slider { background-color: var(--orange); }
.switch input:checked + .slider::before { transform: translateX(18px); }
