/* ── Base ──────────────────────────────────────────────── */
:root {
  --bg:        #f6f4f1;
  --surface:   #ffffff;
  --surface-2: #faf8f6;
  --border:    #e6e1da;
  --border-2:  #d6cfc5;
  --text:      #211e1b;
  --muted:     #7c756c;
  --faint:     #a49c92;

  --tomate:    #c8452f;
  --tomate-d:  #a2331f;
  --albahaca:  #2f6b4f;
  --masa:      #e5a445;
  --peligro:   #b3261e;

  --ok-bg:     #e8f3ec;
  --warn-bg:   #fdf3e3;
  --err-bg:    #fdeceb;

  --sidebar:   #1e1b18;
  --radio:     12px;
  --sombra:    0 1px 2px rgba(28,24,20,.05), 0 4px 14px rgba(28,24,20,.05);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p  { margin: 0; }

/* ── Layout ────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: var(--sidebar);
  color: #ddd6cd;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

/* El logo viene con fondo blanco sólido, así que sobre la barra oscura va
   montado en una placa clara en vez de recortado. */
.marca { padding: 0 4px 20px; }
.placa-logo {
  display: block; background: #fff; border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.placa-logo img { display: block; width: 100%; height: auto; }
.marca-tag {
  display: block; text-align: center; margin-top: 10px;
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #8e857b;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  color: #b6ada2; font-size: 14.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: #2b2723; color: #f0e9e1; }
.nav a.activo { background: #322d28; color: #fff; }
.nav a .ico { width: 18px; text-align: center; font-size: 15px; opacity: .95; }
.nav .cuenta {
  margin-left: auto; background: var(--tomate); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
}
.nav .cuenta.suave { background: #4a423a; color: #d8cec2; }

.nav-sep { margin: 16px 11px 8px; font-size: 10.5px; letter-spacing: .09em;
           text-transform: uppercase; color: #6b625a; }

.motor-box {
  margin-top: auto; padding: 11px; border-radius: 10px;
  background: #262220; font-size: 12px; color: #9b9289; line-height: 1.45;
}
.motor-box .punto { width: 7px; height: 7px; border-radius: 99px; display: inline-block; margin-right: 6px; }
.motor-box .punto.on  { background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.16); }
.motor-box .punto.off { background: var(--masa); box-shadow: 0 0 0 3px rgba(229,164,69,.16); }
.motor-box b { color: #ded6cc; font-weight: 600; }

.main { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1420px; }

.encabezado { display: flex; align-items: flex-end; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.encabezado .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.encabezado .acciones { margin-left: auto; display: flex; gap: 9px; align-items: center; }

/* ── Botones ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border-2); background: var(--surface);
  font-size: 14px; font-weight: 550; color: var(--text);
  cursor: pointer; font-family: inherit;
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn.primario { background: var(--tomate); border-color: var(--tomate); color: #fff; }
.btn.primario:hover { background: var(--tomate-d); border-color: var(--tomate-d); }
.btn.verde { background: var(--albahaca); border-color: var(--albahaca); color: #fff; }
.btn.verde:hover { filter: brightness(1.08); }
.btn.chico { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.fantasma { background: transparent; border-color: transparent; color: var(--muted); }
.btn.fantasma:hover { background: #ece7e0; color: var(--text); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ── Tarjetas ──────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radio); box-shadow: var(--sombra);
}
.card > header {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card > header .der { margin-left: auto; font-size: 13px; color: var(--muted); }
.card .cuerpo { padding: 18px; }
.card .cuerpo.sin-pad { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1, .g-1-2, .g3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .g2, .g4 { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; } .main { padding: 18px; } }

/* ── KPI ───────────────────────────────────────────────── */
.kpi { padding: 16px 18px; }
.kpi .rotulo { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .valor { font-size: 28px; font-weight: 680; letter-spacing: -0.02em; margin-top: 7px; font-variant-numeric: tabular-nums; }
.kpi .nota { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi.acento .valor { color: var(--tomate); }
.kpi.verde .valor { color: var(--albahaca); }

/* ── Semáforo de liquidez ──────────────────────────────── */
.semaforo { border-left: 5px solid var(--border-2); }
.semaforo.ok       { border-left-color: var(--albahaca); }
.semaforo.atencion { border-left-color: var(--masa); }
.semaforo.critico  { border-left-color: var(--peligro); }

.barra { height: 9px; border-radius: 99px; background: #ece7e0; overflow: hidden; display: flex; }
.barra i { display: block; height: 100%; }
.barra i.transf { background: #3b6ea5; }
.barra i.efvo   { background: var(--albahaca); }
.barra i.indef  { background: var(--faint); }
.barra i.lleno  { background: var(--tomate); }

.leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 10px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* ── Etiquetas ─────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; padding: 2.5px 9px; border-radius: 99px;
  background: #efece7; color: #5c554d; white-space: nowrap;
}
.badge.ok      { background: var(--ok-bg);  color: #1f5c40; }
.badge.warn    { background: var(--warn-bg); color: #8a5c07; }
.badge.err     { background: var(--err-bg);  color: #9b2019; }
.badge.info    { background: #e9eff7; color: #2c5480; }
.badge.ia      { background: #efe9f7; color: #56409a; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border-2);
  color: var(--muted); background: var(--surface);
}

/* ── Tablas ────────────────────────────────────────────── */
.tabla-wrap { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tabla th {
  text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; padding: 11px 14px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.tabla td { padding: 11px 14px; border-bottom: 1px solid #f0ece6; vertical-align: middle; }
table.tabla tbody tr:hover { background: #fbf9f6; }
table.tabla tbody tr.vencida { background: #fdf5f4; }
table.tabla tbody tr.vencida:hover { background: #fcefee; }
table.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tabla .fuerte { font-weight: 620; }
table.tabla tfoot td { padding: 13px 14px; font-weight: 680; border-top: 2px solid var(--border); }

.prov { display: flex; flex-direction: column; gap: 1px; }
.prov b { font-weight: 600; }
.prov small { color: var(--faint); font-size: 12px; }

/* ── Formularios ───────────────────────────────────────── */
label.campo { display: block; }
label.campo > span {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em;
}
input[type=text], input[type=date], input[type=number], input[type=search],
input[type=password], input[type=file], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: 9px;
  border: 1px solid var(--border-2); background: var(--surface);
  font-family: inherit; font-size: 14px; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--tomate); box-shadow: 0 0 0 3px rgba(200,69,47,.12);
}
textarea { resize: vertical; min-height: 70px; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filtros label.campo { min-width: 138px; }
.filtros .crece { flex: 1; min-width: 200px; }

/* ── Bandeja tipo WhatsApp ─────────────────────────────── */
.hilo { display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 12px; align-items: flex-start; }
.avatar {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 99px;
  background: #ded7cd; color: #6b625a; display: grid; place-items: center;
  font-weight: 650; font-size: 14px;
}
.burbuja {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px; box-shadow: var(--sombra);
  padding: 13px 15px; flex: 1; min-width: 0;
}
.burbuja .quien { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.burbuja .quien b { font-size: 14px; }
.burbuja .quien small { color: var(--faint); font-size: 12px; }
.burbuja .texto { margin: 7px 0 12px; color: #4a443d; font-size: 14.5px; }

.adjunto { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.adjunto .miniatura {
  width: 132px; height: 132px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border-2); background: #f1ede7; flex: 0 0 132px;
}
.adjunto .miniatura img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.adjunto .lado { flex: 1; min-width: 210px; }

.resultado {
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); padding: 13px 15px; margin-top: 12px;
}
.resultado.pendiente { display: none; }
.resultado .titulo { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; font-size: 13.5px; font-weight: 620; }
.campos { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px 18px; }
.campos div span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; }
.campos div b { font-size: 14px; font-weight: 600; }

/* Animación de "leyendo con IA" */
.leyendo { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.escaner {
  width: 34px; height: 34px; border-radius: 8px; position: relative; overflow: hidden;
  background: linear-gradient(#efe9f7, #efe9f7); flex: 0 0 34px;
  border: 1px solid #ddd2f0;
}
.escaner::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px;
  background: #7c5cd6; box-shadow: 0 0 9px 2px rgba(124,92,214,.5);
  animation: barrer 1.05s ease-in-out infinite;
}
@keyframes barrer { 0% { top: 2px; } 50% { top: 27px; } 100% { top: 2px; } }
.puntos::after { content: ""; animation: puntitos 1.2s steps(4, end) infinite; }
@keyframes puntitos { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ── Vista día por día ─────────────────────────────────── */
.dias {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(64px, 1fr);
  gap: 6px; overflow-x: auto; padding-bottom: 4px;
}
.dia {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 5px;
  background: var(--surface); text-align: center; position: relative;
}
.dia.finde { background: var(--surface-2); }
.dia.hoy { border-color: var(--tomate); box-shadow: 0 0 0 2px rgba(200,69,47,.13); }
.dia.vacio { opacity: .5; }
.dia .dow { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; }
.dia .num { font-size: 21px; font-weight: 680; line-height: 1.15; }
.dia .monto { font-size: 12.5px; font-weight: 620; color: var(--tomate); margin-top: 4px; font-variant-numeric: tabular-nums; }
.dia .cant { font-size: 11px; color: var(--faint); }
.dia .col { height: 42px; display: flex; align-items: flex-end; justify-content: center; gap: 2px; margin-top: 7px; }
.dia .col i { width: 10px; border-radius: 2px 2px 0 0; display: block; min-height: 2px; }
.dia .col i.transf { background: #3b6ea5; }
.dia .col i.efvo { background: var(--albahaca); }
.dia .col i.indef { background: var(--faint); }

/* ── Varios ────────────────────────────────────────────── */
.vacio { text-align: center; padding: 46px 20px; color: var(--muted); }
.vacio .emoji { font-size: 34px; display: block; margin-bottom: 10px; }

.aviso {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px;
  border-radius: 10px; font-size: 14px; border: 1px solid transparent;
}
.aviso.info { background: #eef3f9; border-color: #d6e2f0; color: #2c4f77; }
.aviso.warn { background: var(--warn-bg); border-color: #f0dfbe; color: #7d5406; }
.aviso.err  { background: var(--err-bg); border-color: #f4d3d0; color: #8f211b; }
.aviso.ok   { background: var(--ok-bg); border-color: #cfe6d9; color: #1f5c40; }

.lista-limpia { list-style: none; margin: 0; padding: 0; }
.lista-limpia li { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid #f2eee8; }
.lista-limpia li:last-child { border-bottom: none; }
.lista-limpia .crece { flex: 1; min-width: 0; }
.lista-limpia .monto { font-variant-numeric: tabular-nums; font-weight: 620; white-space: nowrap; }

.mini { font-size: 12.5px; color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.truncar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.der { text-align: right; }
.fila { display: flex; align-items: center; gap: 10px; }
.fila.wrap { flex-wrap: wrap; }
.pila { display: flex; flex-direction: column; gap: 14px; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }

.previsualizacion img { width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; }

/* ── Login ─────────────────────────────────────────────── */
.pantalla-login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1100px 620px at 50% -10%, #efe7dd 0%, var(--bg) 62%);
}
.caja-login { width: 100%; max-width: 380px; }
/* Dentro de la tarjeta blanca: el fondo blanco del logo se funde con ella
   y no queda el recuadro que se ve sobre el crema del fondo. */
.marca-login {
  text-align: center; padding: 26px 20px 4px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.marca-login img { display: block; margin: 0 auto; width: 190px; max-width: 78%; height: auto; }
.marca-login span {
  display: block; margin: 8px 0 18px; font-size: 10.5px; color: var(--faint);
  letter-spacing: .11em; text-transform: uppercase;
}

.usuario-box {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid #322d28;
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: #9b9289;
}
.usuario-box form { margin-left: auto; }
.usuario-box button {
  background: none; border: none; color: #9b9289; cursor: pointer;
  font-family: inherit; font-size: 12.5px; padding: 2px 4px; border-radius: 6px;
}
.usuario-box button:hover { color: #f0e9e1; background: #322d28; }
