/* Agenda comercial — tinta azul noche con acento ámbar (el color de las tintas de codificación). */
:root {
  --fondo: #f4f3ef;
  --papel: #ffffff;
  --tinta: #14213d;
  --texto: #1f2430;
  --suave: #5f6676;
  --linea: #e2e0d8;
  --acento: #e09f1f;
  --acento-texto: #6b4500;
  --acento-fondo: #fdf3dc;
  --peligro: #b3261e;
  --peligro-fondo: #fbe9e7;
  --ok: #2e7d4f;
  --ok-fondo: #e6f4ea;
  --sombra: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
  --radio: 12px;
  /* Colores por tipo de actividad */
  --t-llamada: #2f6fd6; --t-correo: #7a4fd0; --t-whatsapp: #1f9d55; --t-visita: #d9480f;
  --t-reunion: #0b7285; --t-demo: #c2255c; --t-cotizacion: #a87400; --t-otro: #6c757d; --t-recordatorio: #868e96;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0f1420; --papel: #171e2e; --tinta: #e8ecf5; --texto: #e3e6ee; --suave: #9aa3b5; --linea: #283149;
    --acento: #f0b440; --acento-texto: #f6cf7d; --acento-fondo: #3a2e14;
    --peligro: #ff8a80; --peligro-fondo: #3b1d1b; --ok: #6fcf97; --ok-fondo: #173226;
    --sombra: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fondo); color: var(--texto);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, h3 { color: var(--tinta); line-height: 1.2; margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .95rem; }

/* ---------- Marca y barra ---------- */
.marca { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--tinta); letter-spacing: -.01em; }
.marca.grande { font-size: 1.35rem; justify-content: center; margin-bottom: 1.2rem; }
.marca-punto { width: 12px; height: 12px; border-radius: 3px; background: var(--acento); box-shadow: 5px 5px 0 var(--tinta); margin-right: 6px; }
.barra {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  padding: .7rem max(16px, env(safe-area-inset-left)); background: var(--papel); border-bottom: 1px solid var(--linea);
}
.pestanas { display: flex; gap: .2rem; margin-left: 1rem; }
.pestanas a { text-decoration: none; padding: .45rem .8rem; border-radius: 8px; color: var(--suave); font-weight: 600; }
.pestanas a:hover { background: var(--fondo); color: var(--texto); }
.pestanas a.activa { background: var(--tinta); color: var(--papel); }
.barra-der { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.cola { background: var(--acento-fondo); color: var(--acento-texto); font-size: .8rem; font-weight: 600; padding: .2rem .55rem; border-radius: 99px; }

.vista { max-width: 1100px; margin: 0 auto; padding: 1.4rem 16px 7rem; }
.cabecera { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .8rem; justify-content: space-between; margin-bottom: 1rem; }
.cabecera .sub { color: var(--suave); margin-top: .25rem; }

/* ---------- Botones y formularios ---------- */
.btn {
  appearance: none; border: 1px solid var(--linea); background: var(--papel); color: var(--texto);
  font: inherit; font-weight: 600; padding: .55rem .95rem; border-radius: 9px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap;
}
.btn:hover { border-color: var(--suave); }
.btn.primario { background: var(--tinta); border-color: var(--tinta); color: var(--papel); }
.btn.acento { background: var(--acento); border-color: var(--acento); color: #2b1d00; }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--suave); }
.btn.fantasma:hover { color: var(--texto); background: var(--fondo); }
.btn.peligro { color: var(--peligro); }
.btn.pequeno { padding: .3rem .6rem; font-size: .85rem; }
.btn.ancho { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.botones { display: flex; flex-wrap: wrap; gap: .5rem; }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--suave); }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem; font: inherit; color: var(--texto); background: var(--papel);
  border: 1px solid var(--linea); border-radius: 9px; padding: .55rem .7rem;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--acento); outline-offset: 1px; border-color: var(--acento); }
textarea { min-height: 4.5rem; resize: vertical; }
.campos { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.campos .todo { grid-column: 1 / -1; }
.filtros { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end;
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: .8rem; margin-bottom: 1rem; }
.error { color: var(--peligro); font-size: .9rem; margin: .4rem 0 0; }

/* ---------- Tarjetas y listas ---------- */
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .7rem; }
.cifra { padding: .9rem 1rem; }
.cifra b { display: block; font-size: 1.7rem; color: var(--tinta); font-variant-numeric: tabular-nums; }
.cifra span { color: var(--suave); font-size: .85rem; }
.cifra.alerta b { color: var(--peligro); }

.lista { list-style: none; margin: 0; padding: 0; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
.lista > li { padding: .75rem 1rem; border-top: 1px solid var(--linea); display: flex; gap: .8rem; align-items: flex-start; }
.lista > li:first-child { border-top: 0; }
.lista > li.clic { cursor: pointer; }
.lista > li.clic:hover { background: var(--fondo); }
.lista .vacio { color: var(--suave); justify-content: center; }
.item-cuerpo { flex: 1; min-width: 0; }
.item-titulo { font-weight: 600; color: var(--tinta); }
.item-meta { color: var(--suave); font-size: .85rem; }
.item-nota { margin-top: .25rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.item-acciones { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.dia { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); margin: 1.2rem 0 .4rem; }

.tipo { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; padding: .15rem .5rem; border-radius: 99px;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; }
.tipo::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.etiqueta { font-size: .75rem; font-weight: 700; padding: .12rem .45rem; border-radius: 6px; background: var(--fondo); color: var(--suave); border: 1px solid var(--linea); }
.etiqueta.rojo { background: var(--peligro-fondo); color: var(--peligro); border-color: transparent; }
.etiqueta.verde { background: var(--ok-fondo); color: var(--ok); border-color: transparent; }
.etiqueta.ambar { background: var(--acento-fondo); color: var(--acento-texto); border-color: transparent; }
.proxima { margin-top: .35rem; font-size: .88rem; padding: .3rem .55rem; border-left: 3px solid var(--acento); background: var(--acento-fondo); color: var(--acento-texto); border-radius: 0 6px 6px 0; }
.proxima.hecha { border-color: var(--ok); background: var(--ok-fondo); color: var(--ok); text-decoration: line-through; }

/* Ficha de cliente */
.ficha-datos { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; color: var(--suave); margin-top: .35rem; }
.resumen { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.resumen .tarjeta { padding: .55rem .8rem; box-shadow: none; }
.resumen b { font-size: 1.1rem; color: var(--tinta); }
.resumen small { display: block; color: var(--suave); }
.columnas { display: grid; grid-template-columns: 1fr 340px; gap: 1.4rem; align-items: start; }
.contacto-enlaces a { margin-right: .6rem; font-size: .85rem; color: var(--tinta); }

/* Etapas de proyecto */
.etapas { display: flex; gap: 3px; margin-top: .4rem; }
.etapas i { flex: 1; height: 5px; border-radius: 3px; background: var(--linea); }
.etapas i.si { background: var(--acento); }
.pipeline { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.columna-etapa h3 { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .45rem; }
.columna-etapa h3 span { color: var(--suave); }

/* Estadísticas */
.barras { display: grid; gap: .4rem; }
.barra-fila { display: grid; grid-template-columns: 110px 1fr 44px; gap: .6rem; align-items: center; font-size: .88rem; }
.barra-fila .pista { height: 14px; background: var(--fondo); border-radius: 4px; overflow: hidden; }
.barra-fila .relleno { height: 100%; background: var(--c, var(--tinta)); border-radius: 4px; }
.barra-fila b { text-align: right; font-variant-numeric: tabular-nums; }
.apiladas { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: .5rem; overflow-x: auto; }
.apilada { flex: 1 0 28px; display: flex; flex-direction: column-reverse; height: 100%; position: relative; }
.apilada .seg { width: 100%; background: var(--c); }
.apilada .seg:last-child { border-radius: 4px 4px 0 0; }
.ejes { display: flex; gap: 6px; font-size: .72rem; color: var(--suave); overflow-x: hidden; }
.ejes span { flex: 1 0 28px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leyenda { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.tabla-env { overflow-x: auto; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--linea); white-space: nowrap; }
th { color: var(--suave); font-weight: 600; font-size: .8rem; background: var(--fondo); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--fondo); }
.segmentado { display: inline-flex; border: 1px solid var(--linea); border-radius: 9px; overflow: hidden; background: var(--papel); }
.segmentado button { border: 0; background: none; font: inherit; font-size: .85rem; font-weight: 600; padding: .45rem .75rem; color: var(--suave); cursor: pointer; }
.segmentado button.si { background: var(--tinta); color: var(--papel); }

/* ---------- Botón flotante, diálogo y aviso ---------- */
.fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20;
  border: 0; border-radius: 99px; padding: .85rem 1.25rem; font: inherit; font-weight: 700; cursor: pointer;
  background: var(--acento); color: #2b1d00; box-shadow: 0 6px 20px rgba(224, 159, 31, .45); display: flex; align-items: center; gap: .4rem;
}
.fab span { font-size: 1.35rem; line-height: 1; }
.dialogo { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--papel); color: var(--texto); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.dialogo::backdrop { background: rgba(10, 15, 30, .45); }
.dialogo form { padding: 1.2rem; display: grid; gap: .9rem; }
.dialogo .pie { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--papel); padding-top: .4rem; }
.dialogo .pie .izq { margin-right: auto; }
.tipos { display: flex; flex-wrap: wrap; gap: .35rem; }
.tipos input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; margin: 0; }
.tipos label { position: relative; }
.tipos label { margin: 0; cursor: pointer; padding: .4rem .7rem; border-radius: 99px; border: 1px solid var(--linea); color: var(--texto); font-weight: 600; }
.tipos input:checked + span { color: var(--c); }
.tipos label:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c); }
.tipos label:has(input:focus-visible) { outline: 2px solid var(--acento); }
.atajos { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.ayuda { color: var(--suave); font-size: .82rem; margin: .25rem 0 0; font-weight: 400; }
.aviso { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--tinta); color: var(--papel); padding: .65rem 1rem; border-radius: 10px; box-shadow: var(--sombra); font-weight: 600; max-width: calc(100vw - 32px); }

/* ---------- Acceso ---------- */
.acceso { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.acceso-caja { width: min(360px, 100%); background: var(--papel); border: 1px solid var(--linea); border-radius: 16px; padding: 1.6rem; box-shadow: var(--sombra); display: grid; gap: 1rem; }

/* ---------- Móvil ---------- */
.nav-movil { display: none; }
@media (max-width: 760px) {
  .pestanas { display: none; }
  .vista { padding-top: 1rem; padding-bottom: 9rem; }
  .nav-movil {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--papel); border-top: 1px solid var(--linea);
    padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .nav-movil a { flex: 1; text-align: center; text-decoration: none; font-size: .7rem; font-weight: 600; color: var(--suave); padding: .25rem 0; border-radius: 8px; }
  .nav-movil a b { display: block; font-size: 1.15rem; line-height: 1.3; }
  .nav-movil a.activa { color: var(--tinta); background: var(--fondo); }
  .fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .columnas { grid-template-columns: 1fr; }
  .lista > li { flex-wrap: wrap; }
  .item-acciones { width: 100%; justify-content: flex-start; }
  .barra-fila { grid-template-columns: 84px 1fr 36px; }
  .dialogo { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; }
}
