:root {
  /* Colores de marca FacilPres (guía de imagen v1, julio 2026) */
  --terracota: #e0603a;
  --terracota-deep: #c94f27;
  --crema: #f7f4ee;
  --tinta: #2b2a27;
  --tinta-soft: #6b6862;

  /* Neutros derivados */
  --card: #ffffff;
  --line: # e9e4da;
  --line: #e9e4da;
  --line-soft: #f0ebe2;

  /* Colores de categoría (capítulos de obra) */
  --ok: #3f7a54;
  --warn: #c0392b;
  --info: #45568a;

  /* Estados de presupuesto */
  --estado-borrador: #6b6862;
  --estado-enviado: #45568a;
  --estado-aceptado: #3f7a54;
  --estado-rechazado: #c0392b;
  --estado-caducado: #c94f27;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(43,42,39,0.08), 0 4px 12px rgba(43,42,39,0.04);
  --shadow-lg: 0 2px 6px rgba(43,42,39,0.10), 0 8px 24px rgba(43,42,39,0.06);

  --font-display: 'Poppins', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'Plus Jakarta Sans', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--crema);
  color: var(--tinta);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--crema);
  display: flex;
  flex-direction: column;
}

/* Cabecera limpia sobre crema */
.header {
  background: var(--crema);
  color: var(--tinta);
  padding: 20px 20px 14px;
  position: relative;
}

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

.brand-top svg {
  flex-shrink: 0;
  /* align-items:center centra el simbolo contra la altura real de la linea
     "facilpres" (h1), porque el lema ya no vive dentro de esta fila - es un
     bloque aparte debajo, asi que no afecta a este calculo de centrado. */
}

.brand .tagline {
  /* Flush con el borde izquierdo del logo (mismo alineado que .brand-top),
     no sangrado bajo el texto: crea un bloque unico mas limpio y le da mas
     ancho disponible al lema antes de necesitar partirse en 2 lineas. */
  margin-left: 0;
}

/* Wordmark: "facil" en tinta, "pres" en terracota */
.brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.3px;
  margin: 0;
  line-height: 1;
  text-transform: none;
  color: var(--tinta);
}
.brand h1 .pres { color: var(--terracota); }

.brand .tagline::before { content: '\201C'; }
.brand .tagline::after { content: '\201D'; }
.brand .tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12px;
  font-weight: 500;
  color: var(--tinta-soft);
  margin-top: 5px;
  letter-spacing: 0;
  line-height: 1.35;
  /* Hasta 2 lineas (algunos lemas, sobre todo los de refranes, no caben en
     una sola a este ancho). min-height reserva siempre el alto de 2 lineas,
     tanto si el lema del momento ocupa 1 como 2, para que el logo no salte
     de sitio al rotar entre lemas cortos y largos. */
  white-space: normal;
  max-width: none;
  min-height: calc(12px * 1.35 * 2);
}

.main {
  flex: 1;
  padding: 8px 18px 100px;
}

.screen { display: none; }
.screen.active { display: block; }

/* Lista de presupuestos */
.list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.list-toolbar h2 {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: none;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.2px;
}

.ticket {
  background: var(--card);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .12s ease;
}
.ticket:active { transform: scale(0.985); box-shadow: var(--shadow-lg); }

.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.ticket-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--tinta-soft);
}

.ticket-title {
  font-weight: 600;
  font-size: 15px;
  margin: 4px 0 8px;
}

.ticket-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ticket-cliente {
  font-size: 13px;
  color: var(--tinta-soft);
}

.ticket-total {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--terracota);
}

.badge {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.badge-borrador { background: #eeeae2; color: var(--tinta-soft); }
.badge-enviado { background: #e3e6ed; color: var(--info); }
.badge-aceptado { background: #e3ede6; color: var(--ok); }
.badge-rechazado { background: #f7e4e1; color: var(--warn); }
.badge-caducado { background: #fbe9df; color: var(--terracota-deep); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--tinta-soft);
}
.empty-state svg { margin-bottom: 14px; opacity: 0.5; }
.empty-state p { font-size: 14px; margin: 4px 0; }

/* Formularios */
.step-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  color: var(--terracota);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: none;
  font-size: 20px;
  margin: 0 0 16px;
  letter-spacing: -0.2px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--tinta-soft);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  background: var(--card);
  color: var(--tinta);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--terracota);
  outline-offset: 1px;
  border-color: var(--terracota);
}

.field textarea { resize: vertical; min-height: 60px; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Partidas */
.item-row {
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
}

.item-row .row-2 { margin-top: 8px; }

.item-remove {
  background: none;
  border: none;
  color: var(--warn);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 0;
}

.item-importe {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--tinta-soft);
  margin-top: 6px;
}

.suggestions {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-top: 4px;
  margin-bottom: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.suggestions div {
  padding: 10px 13px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.suggestions div:last-child { border-bottom: none; }
.suggestions div:active { background: var(--crema); }

.btn-add-item {
  width: 100%;
  padding: 12px;
  border: 1.5px dashed var(--terracota);
  background: none;
  border-radius: var(--radius-sm);
  color: var(--terracota);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 16px;
}

.totales {
  background: var(--tinta);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin: 6px 0 20px;
}
.totales .fila {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 3px 0;
  color: #d8d4cc;
}
.totales .fila.total {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  border-top: 1px solid rgba(255,255,255,0.18);
  margin-top: 8px;
  padding-top: 12px;
}
.totales .fila.total span:last-child { color: var(--terracota); }

/* Botones */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--terracota); color: #fff; }
.btn-primary:active { background: var(--terracota-deep); }
.btn-secondary { background: var(--card); color: var(--tinta); border: 1.5px solid var(--line); margin-top: 10px; }
.btn-danger { background: none; color: var(--warn); }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* Nav inferior fija */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  display: flex;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 3px rgba(43,42,39,0.06), 0 -4px 16px rgba(43,42,39,0.05);
  border-top: 1px solid var(--line-soft);
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--tinta-soft);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.tab.active { color: var(--terracota); background: #fbe9df; }

/* Detalle de presupuesto */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.detail-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--tinta-soft);
}
.detail-title {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: none;
  font-size: 24px;
  letter-spacing: -0.3px;
  margin: 2px 0 0;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.info-box {
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.info-box .k {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--tinta-soft);
  margin-bottom: 3px;
}
.info-box .v { font-size: 14px; font-weight: 600; }

.detail-items {
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
  margin-bottom: 16px;
}
.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  gap: 8px;
}
.detail-item:last-child { border-bottom: none; }
.detail-item .desc { flex: 1; }
.detail-item .imp { font-family: var(--font-mono); font-weight: 600; white-space: nowrap; }

/* Firma */
.signature-box {
  background: var(--card);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  touch-action: none;
  box-shadow: var(--shadow);
}
canvas#firmaCanvas { display: block; width: 100%; height: 180px; }

.spark-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 0 14px;
  color: var(--terracota);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.spark-divider .line { flex: 1; height: 1px; background: var(--line); }

.toast {
  position: fixed;
  bottom: 78px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--tinta);
  color: #fff;
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Paso 2: estado actual (fotos) y objetivo (audio) */
.paso-ayuda {
  font-size: 12px;
  color: var(--tinta-soft);
  margin: -6px 0 12px;
  line-height: 1.45;
}

.subseccion {
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.subseccion-titulo {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}

.fotos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0;
}

.foto-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--crema);
}
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-thumb .foto-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(43,42,39,0.85);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.foto-thumb .foto-analisis {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(43,42,39,0.75);
  color: #fff;
  font-size: 9px;
  padding: 3px 4px;
  max-height: 40%;
  overflow: hidden;
}

.btn-record {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--tinta);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
.btn-record.recording { background: var(--warn); }
.rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--warn);
  display: inline-block;
}
.btn-record.recording .rec-dot {
  background: #fff;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.analisis-ia-box {
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--terracota);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.analisis-ia-box .k {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--terracota);
  margin-bottom: 4px;
  letter-spacing: 0.4px;
}
.analisis-ia-box .v {
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.detail-fotos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 6px;
}
.detail-fotos-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

/* Aviso de partidas sugeridas por IA */
.aviso-ia {
  background: #fbe9df;
  border: 1px solid var(--terracota);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tinta);
  margin-bottom: 14px;
}

.item-origen {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 20px;
  margin-left: 6px;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.item-origen-estimacion { background: #fbe9df; color: var(--terracota-deep); }
.item-origen-catalogo { background: #e3ede6; color: var(--ok); }
.item-origen-tarifa { background: #e3e6ed; color: var(--info); }

/* Perfil de empresa */
.logo-preview {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview.vacio {
  color: var(--tinta-soft);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}

.catalogo-item {
  background: var(--card);
  border: none;
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.catalogo-item .nombre { font-size: 13px; font-weight: 600; }
.catalogo-item .detalle { font-family: var(--font-mono); font-size: 11px; color: var(--tinta-soft); }
.catalogo-item .catalogo-borrar {
  background: none;
  border: none;
  color: var(--warn);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}


/* Agrupado de partidas por categoria (capitulo de obra): el icono y el nombre
   de la categoria se pintan UNA vez por grupo, no una vez por partida. */
.cat-group {
  margin-bottom: 18px;
}
.cat-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.cat-group-header i { font-size: 15px; }

/* Control discreto para corregir la categoria de una partida concreta */
.item-row-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  gap: 8px;
}
.cat-select-mini {
  border: none;
  background: none;
  color: var(--tinta-soft);
  font-family: var(--font-body);
  font-size: 11px;
  padding: 2px 0;
  cursor: pointer;
  max-width: 60%;
}
.cat-select-mini:focus { outline: none; color: var(--terracota); }

.detail-item { display: flex; justify-content: space-between; }

/* ---------- Dashboard (pantalla inicial) ---------- */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.dash-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  cursor: default;
}
.dash-card-label {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--tinta-soft);
  margin-bottom: 2px;
}
.dash-card-valor {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--tinta);
}
.dash-card-dark {
  background: var(--tinta);
  cursor: pointer;
}
.dash-card-dark .dash-card-label { color: #cfc9bd; }
.dash-card-dark .dash-card-valor { color: #ffffff; }
.dash-card-dark:active { transform: scale(0.985); }
.dash-card-proximamente {
  opacity: 0.6;
}
.dash-card-proximamente .dash-card-valor { color: var(--tinta-soft); }
.dash-nota-proximamente {
  font-size: 10px;
  color: var(--tinta-soft);
  margin: -4px 0 14px 2px;
}

/* Bloque de seguimiento: presupuestos enviados sin respuesta hace 10+ dias */
.seg-bloque {
  background: #fbf1de;
  border: 1px solid #f0d9a8;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.seg-cabecera {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #6b4a15;
  margin-bottom: 8px;
}
.seg-cabecera i { font-size: 16px; }
.seg-fila {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
.seg-fila:last-child { margin-bottom: 0; }
.seg-titulo { font-size: 12px; font-weight: 500; color: var(--tinta); }
.seg-meta { font-size: 10px; color: var(--tinta-soft); }
.seg-whatsapp {
  background: #25d366;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.seg-whatsapp i { color: #ffffff; font-size: 15px; }
