/* Limflow — Design System "Cítrico Fresco"
   Claro, moderno, con movimiento. Contrastes WCAG 2.1 AA. Mobile-first.
   Todo en rem/em para soportar zoom 200% y reflow 400%. */

:root {
  /* Superficies */
  --crema: #FBFBF3;
  --crema-200: #F2F2E4;
  --blanco: #FFFFFF;

  /* Bordes (control >=3:1, decorativo claro) */
  --borde-control: #B8B8A0;
  --borde: #E4E4D2;

  /* Tinta (texto) */
  --tinta: #3A3A2E;     /* 11:1  cuerpo */
  --tinta-2: #6B6B57;   /* 5.2:1 labels/secundario a 16px */
  --tinta-3: #8A8A72;   /* solo >=18.66px bold / >=24px o iconos decorativos */

  /* Acentos cítricos */
  --hoja: #4F7A1F;
  --hoja-dark: #3E6318;
  --hoja-light: #6FA02E;
  --lima: #E3F25C;
  --lima-30: #F4F9CE;
  --lima-texto: #5E7314;
  --citrico: #FFD23F;   /* SOLO decoración (aria-hidden) */

  /* Estados (siempre icono + texto, nunca solo color) */
  --ok: #15803D;
  --atencion: #92400E;
  --vencido: #B83C28;
  --borrador: #5E7314;
  --neutro: #6B6B57;

  /* Tipografía */
  --font-head: "Poppins", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Escala de espaciado */
  --sp-1: 0.25rem; --sp-2: 0.5rem; --sp-3: 0.75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem;

  /* Radios y sombras (verde oliva translúcido) */
  --r-sm: 0.5rem; --r-md: 0.875rem; --r-lg: 1.25rem; --r-full: 999px;
  --sh-soft: 0 1px 2px rgba(62, 99, 24, .06), 0 2px 8px rgba(62, 99, 24, .06);
  --sh-card: 0 2px 6px rgba(62, 99, 24, .08), 0 8px 24px rgba(62, 99, 24, .07);
  --sh-float: 0 10px 30px rgba(62, 99, 24, .14);

  --sidebar-w: 16rem;
  --bottomnav-h: 4.25rem;
}

* { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--tinta);
  background: var(--crema);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--tinta); line-height: 1.2; margin: 0 0 var(--sp-3); font-weight: 600; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.075rem; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--hoja-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--tinta-2); }
.small { font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Foco accesible (>=2px, offset, 3:1) */
:focus-visible {
  outline: 3px solid var(--hoja);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Skip link */
.skip-link {
  position: absolute; left: var(--sp-3); top: -3rem;
  background: var(--hoja-dark); color: #fff; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-sm); z-index: 1000; transition: top .15s ease;
}
.skip-link:focus { top: var(--sp-3); }

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }

.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  background: rgba(251, 251, 243, .85); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--borde);
}
.brand { display: inline-flex; align-items: center; gap: .5rem; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; color: var(--tinta); }
.brand .lemon { font-size: 1.35rem; line-height: 1; }
.brand:hover { text-decoration: none; }

.usermenu { display: flex; align-items: center; gap: var(--sp-3); }
.usermenu .uname { font-size: .9rem; color: var(--tinta-2); max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { padding: var(--sp-4); padding-bottom: calc(var(--bottomnav-h) + var(--sp-5)); max-width: 1200px; margin: 0 auto; width: 100%; }

/* ---------- Bottom nav (móvil) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: var(--bottomnav-h);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--blanco); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(62,99,24,.06);
}
.bottom-nav a, .bottom-nav span {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: .7rem; color: var(--tinta-2); text-decoration: none;
}
.bottom-nav .ic { font-size: 1.25rem; line-height: 1; }
.bottom-nav a.active { color: var(--hoja-dark); font-weight: 600; }
.bottom-nav .is-disabled { color: #B6B6A2; pointer-events: none; }

/* ---------- Cards ---------- */
.card {
  background: var(--blanco); border: 1px solid var(--borde);
  border-radius: var(--r-lg); box-shadow: var(--sh-card);
  padding: var(--sp-5);
}
.card + .card { margin-top: var(--sp-4); }
.grid { display: grid; gap: var(--sp-4); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); }

.kpi {
  background: var(--blanco); border: 1px solid var(--borde);
  border-radius: var(--r-lg); box-shadow: var(--sh-card);
  padding: var(--sp-5); position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -1.5rem; top: -1.5rem;
  width: 5rem; height: 5rem; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--lima), transparent 70%);
  opacity: .5;
}
.kpi .k-label { font-size: .9rem; color: var(--tinta-2); margin-bottom: var(--sp-2); }
.kpi .k-value { font-family: var(--font-head); font-weight: 700; font-size: 1.9rem; color: var(--tinta); }
.kpi .k-hint { font-size: .8rem; color: var(--tinta-2); margin-top: var(--sp-2); }
.kpi .k-ic { font-size: 1.25rem; }

/* ---------- Hero ---------- */
.hero {
  border-radius: var(--r-lg); padding: var(--sp-6);
  background: linear-gradient(120deg, var(--hoja) 0%, var(--hoja-light) 100%);
  color: #fff; box-shadow: var(--sh-card); position: relative; overflow: hidden;
  margin-bottom: var(--sp-5);
}
.hero h1 { color: #fff; margin-bottom: var(--sp-2); }
.hero .sub { color: rgba(255,255,255,.92); }
.hero .citrus {
  position: absolute; right: -1rem; bottom: -2rem; font-size: 8rem; line-height: 1;
  opacity: .22; transform: rotate(-12deg); pointer-events: none;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  font-family: var(--font-head); font-weight: 600; font-size: .95rem;
  padding: .7rem 1.15rem; border-radius: var(--r-full); border: 1px solid transparent;
  min-height: 2.5rem;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--hoja); color: #fff; box-shadow: var(--sh-soft); }
.btn-primary:hover { background: var(--hoja-dark); }
.btn-ghost { background: var(--crema-200); color: var(--tinta); border-color: var(--borde-control); }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .78rem; font-weight: 600; padding: .2rem .6rem; border-radius: var(--r-full);
}
.badge .ic { font-size: .85em; }
.badge-ok { background: #DCFCE7; color: var(--ok); }
.badge-aten { background: #FEF3C7; color: var(--atencion); }
.badge-venc { background: #FEE2E2; color: var(--vencido); }
.badge-borrador { background: var(--lima-30); color: var(--borrador); }
.badge-neutro { background: var(--crema-200); color: var(--neutro); }
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--crema-200); color: var(--tinta-2); border-radius: var(--r-full); padding: .15rem .55rem; font-size: .75rem; }

/* ---------- Formularios ---------- */
.field { margin-bottom: var(--sp-4); }
.field label { display: block; font-size: .9rem; color: var(--tinta-2); margin-bottom: var(--sp-2); font-weight: 600; }
.input, input[type="text"], input[type="password"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; font: inherit; color: var(--tinta);
  background: var(--blanco); border: 1px solid var(--borde-control);
  border-radius: var(--r-md); padding: .7rem .85rem; min-height: 2.75rem;
}
.input:focus, input:focus, select:focus, textarea:focus { outline: 3px solid var(--hoja); outline-offset: 1px; border-color: var(--hoja); }
.input[aria-invalid="true"] { border-color: var(--vencido); }
.field-error { color: var(--vencido); font-size: .82rem; margin-top: var(--sp-2); }

/* ---------- Alertas / banners ---------- */
.alert { border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); font-size: .92rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert .ic { flex: none; }
.alert-info { background: var(--lima-30); color: var(--borrador); border: 1px solid #E3EBA8; }
.alert-error { background: #FEE2E2; color: var(--vencido); border: 1px solid #F6C9C9; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--borde); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { text-align: left; padding: .7rem .8rem; border-bottom: 1px solid var(--borde); }
table.data th { background: var(--crema-200); color: var(--tinta-2); font-weight: 600; position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: none; }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; padding: var(--sp-7) var(--sp-4); color: var(--tinta-2); }
.empty .em { font-size: 2.5rem; display: block; margin-bottom: var(--sp-3); }

/* ---------- Secciones ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.chart-box { position: relative; height: 18rem; }

/* ---------- Animaciones ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.animate-in { opacity: 0; }
.animate-in.is-visible { animation: fadeUp .55s cubic-bezier(.22,.61,.36,1) forwards; animation-delay: calc(var(--i, 0) * 70ms); }

@media (prefers-reduced-motion: reduce) {
  .animate-in, .animate-in.is-visible { opacity: 1 !important; animation: none !important; }
  .btn, .skip-link { transition: none !important; }
}

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
  .app-shell { grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: var(--sp-2);
    background: var(--blanco); border-right: 1px solid var(--borde);
    padding: var(--sp-4); position: sticky; top: 0; height: 100vh;
  }
  .sidebar .brand { margin-bottom: var(--sp-4); font-size: 1.3rem; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-item {
    display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem;
    border-radius: var(--r-md); color: var(--tinta-2); font-weight: 600; font-size: .95rem;
  }
  .nav-item .ic { font-size: 1.15rem; width: 1.4rem; text-align: center; }
  .nav-item:hover { background: var(--crema-200); text-decoration: none; color: var(--tinta); }
  .nav-item.active { background: var(--lima-30); color: var(--hoja-dark); }
  .nav-item.is-disabled { color: #B6B6A2; pointer-events: none; }
  .nav-item.is-disabled .pronto { margin-left: auto; font-size: .65rem; background: var(--crema-200); color: var(--tinta-2); padding: .05rem .4rem; border-radius: var(--r-full); }
  .bottom-nav { display: none; }
  .content { padding: var(--sp-6); padding-bottom: var(--sp-6); }
  h1 { font-size: 1.9rem; }
}

/* ---------- Login (página de entrada) ---------- */
.login-body { margin: 0; }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr; }

.login-brand {
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(135deg, var(--hoja-dark) 0%, var(--hoja) 45%, var(--hoja-light) 100%);
  padding: var(--sp-6); display: flex; align-items: center; min-height: 36vh;
}
.login-brand-inner { position: relative; z-index: 2; max-width: 32rem; }
.login-brand .brand-lg { font-family: var(--font-head); font-weight: 700; font-size: 2.1rem; display: flex; align-items: center; gap: .55rem; }
.login-brand .tagline { font-size: 1.08rem; color: rgba(255,255,255,.93); margin-top: var(--sp-3); line-height: 1.5; }
.brand-points { list-style: none; padding: 0; margin: var(--sp-5) 0 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.brand-points li { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25); border-radius: var(--r-full); padding: .35rem .85rem; font-size: .85rem; font-weight: 600; }

.login-deco { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.login-deco span { position: absolute; opacity: .16; animation: floaty 9s ease-in-out infinite; }
.login-deco span:nth-child(1) { top: 9%;  left: 9%;   font-size: 5rem;   animation-delay: 0s; }
.login-deco span:nth-child(2) { top: 64%; left: 20%;  font-size: 3.4rem; animation-delay: 1.2s; }
.login-deco span:nth-child(3) { top: 22%; right: 12%; font-size: 4.2rem; animation-delay: .6s; }
.login-deco span:nth-child(4) { bottom: 8%; right: 24%; font-size: 3rem;  animation-delay: 2s; }
.login-deco span:nth-child(5) { top: 46%; right: 42%; font-size: 2.3rem; animation-delay: 1.6s; }
.login-deco span:nth-child(6) { bottom: 26%; left: 44%; font-size: 2.7rem; animation-delay: 2.6s; }
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-18px) rotate(7deg); } }

.login-form-side { display: flex; align-items: center; justify-content: center; padding: var(--sp-5); background: var(--crema); }
.login-card { width: 100%; max-width: 24rem; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--r-lg); box-shadow: var(--sh-float); padding: var(--sp-6); }
.login-card h2 { margin: 0 0 var(--sp-1); }
.login-card .hello { color: var(--tinta-2); margin-bottom: var(--sp-5); }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); font-size: 1.05rem; opacity: .55; pointer-events: none; }
.input-icon input { padding-left: 2.5rem; }

@media (min-width: 900px) {
  .login-wrap { grid-template-columns: 1.05fr .95fr; }
  .login-brand { min-height: 100vh; padding: var(--sp-7); }
  .login-brand .brand-lg { font-size: 2.7rem; }
  .login-brand .tagline { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) {
  .login-deco span { animation: none; }
}
