:root {
  color-scheme: light;
  --bg: #f2eee4;
  --surface: #fffdf7;
  --surface-2: #f6f1e6;
  --surface-strong: #e9f0e5;
  --line: #e5ded1;
  --line-strong: #d4cbb8;
  --hairline: #ece6d8;
  --text: #1b221c;
  --text-2: #54605a;
  --muted: #69716a;
  --faint: #737a72;
  --green: #21503a;
  --green-2: #2d6a49;
  --green-bright: #3d8a5f;
  --wheat: #c39b45;
  --wheat-tint: rgba(195, 155, 69, 0.14);
  --amber: #b0721f;
  --blue: #2f5d7c;
  --red: #a8402f;
  /* Colores semánticos de plata (ganancia/pérdida), unificados en toda la app. */
  --money-pos: #15803d;
  --money-neg: #c0392b;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(28, 38, 30, 0.05);
  --shadow: 0 1px 2px rgba(28, 38, 30, 0.04), 0 10px 26px rgba(28, 38, 30, 0.06);
  --shadow-lg: 0 2px 4px rgba(28, 38, 30, 0.05), 0 18px 44px rgba(28, 38, 30, 0.10);
  --focus: 0 0 0 3px rgba(195, 155, 69, 0.35);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #203428;
  color: #f7f3eb;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto; /* que el menú + el pie (toggle compacto) sean alcanzables en pantallas bajas */
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  align-items: center;
  background: #d9c28f;
  border-radius: 8px;
  color: #203428;
  display: inline-flex;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

/* El brand-mark con el logo: chip claro para que la hoja resalte sobre el verde. */
.brand-mark-logo {
  background: #fffdf8;
  padding: 4px;
  overflow: hidden;
}

.brand-mark-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #c9d1c8;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 10px;
}

/* Grupos del menu (Campo / Plata / Datos): ordenan las 12 paginas por tema. */
.nav-group {
  display: grid;
  gap: 3px;
}

.nav-group-label {
  color: rgba(247, 243, 235, 0.5);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 6px 12px 3px;
  text-transform: uppercase;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #f7f3eb;
  padding: 11px 12px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

/* Sub-secciones de la pagina activa, desplegadas dentro del menu (acordeon). */
.nav-sub {
  display: grid;
  gap: 2px;
  margin: 2px 0 6px 12px;
  padding-left: 10px;
  border-left: 2px solid rgba(255, 255, 255, 0.16);
}

.nav-sub-item {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: rgba(247, 243, 235, 0.82);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 6px 10px;
  text-align: left;
}

.nav-sub-item:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}

/* Boton hamburguesa (topbar) para plegar/mostrar el menu. */
.topbar-left {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.nav-toggle {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  cursor: pointer;
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
  padding: 8px 11px;
}

.nav-toggle:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Boton para volver a FIJAR el menu (solo visible cuando esta flotando). */
.nav-dock {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #f7f3eb;
  cursor: pointer;
  display: none;
  font-size: 0.72rem;
  margin-left: auto;
  padding: 5px 9px;
  white-space: nowrap;
}

body.nav-collapsed .nav-dock {
  display: inline-block;
}

.nav-backdrop {
  display: none;
}

/* Zona de borde izquierdo: al pasar el cursor revela el menu flotante (solo mouse;
   en tablet/tactil no aplica hover, se usa el boton ☰). */
.nav-edge {
  display: none;
}

/* Pestanas de la vista Stock. */
.stock-tabs {
  border-bottom: 1px solid var(--line, #e0e4dc);
  padding-bottom: 0;
  gap: 4px;
}
.stock-tab {
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
}
#view-stock .stock-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* Pestanas de la vista Aportes (mismo patron que Stock). */
.aportes-tabs {
  border-bottom: 1px solid var(--line);
  gap: 4px;
}
.aportes-tab {
  border-radius: 8px 8px 0 0;
  margin-bottom: -1px;
}
#view-aportes .aportes-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* Tablero "de un vistazo" del cierre (elemento de presentacion). */
.cierre-score {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 6px 0 20px;
}
.cs-main {
  flex: 1 1 300px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #f6f4ee;
  box-shadow: 0 12px 30px rgba(36, 82, 58, 0.22);
}
.cs-pct {
  font-size: 3.1rem;
  font-weight: 700;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cs-pct span {
  font-size: 1.15rem;
  font-weight: 600;
  opacity: 0.75;
  margin-left: 2px;
}
.cs-meta {
  flex: 1;
  min-width: 0;
}
.cs-label {
  font-size: 0.98rem;
  font-weight: 600;
}
.cs-bar {
  height: 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.25);
  margin: 9px 0;
  overflow: hidden;
}
.cs-bar > i {
  display: block;
  height: 100%;
  background: #f6f4ee;
  border-radius: 5px;
  transition: width 0.45s ease;
}
.cs-sub {
  font-size: 0.8rem;
  opacity: 0.92;
}
.cs-chips {
  flex: 1 1 300px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  min-width: 0;
}
.cs-chip {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.cs-chip b {
  font-size: 1.55rem;
  font-variant-numeric: tabular-nums;
  color: var(--green);
  min-width: 1.2em;
  text-align: right;
}
.cs-chip span {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.2;
}
.cs-chip-ok {
  background: var(--surface-strong);
}
.cs-chip-ok b {
  color: var(--green-2);
  opacity: 0.55;
}

.hint-inline-warn {
  color: var(--amber);
  font-weight: 600;
}
.iva-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.iva-input input {
  width: 4.5em;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.alias-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin: 6px 0 14px;
}
.alias-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1 1 220px;
}
.alias-form input,
.alias-form select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.alias-form button {
  flex: 0 0 auto;
}

/* Ayuda contextual: "?" chico por cuadro. */
.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  margin-left: 8px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  opacity: 0.75;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.help-btn:hover {
  opacity: 1;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 22, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1350;
  padding: 16px;
}
.help-overlay.hidden {
  display: none;
}
.help-modal {
  background: var(--surface);
  border-radius: 14px;
  width: min(520px, 96vw);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.help-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #f6f4ee;
}
.help-head .link {
  color: #f6f4ee;
}
.help-body {
  padding: 16px 18px;
  overflow-y: auto;
  line-height: 1.55;
}
.help-body p {
  margin: 0;
}

/* Onboarding / bienvenida (usuarios nuevos). */
.ob-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 22, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1400;
  padding: 16px;
}
.ob-overlay.hidden {
  display: none;
}
.ob-modal {
  background: var(--surface);
  border-radius: 18px;
  width: min(560px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.ob-hero {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #f6f4ee;
  padding: 26px 26px 22px;
  border-radius: 18px 18px 0 0;
}
.ob-brand {
  font-size: 1.7rem;
  font-weight: 700;
}
.ob-tag {
  opacity: 0.92;
  margin-top: 4px;
  font-size: 0.95rem;
}
.ob-body {
  padding: 18px 22px 6px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ob-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.ob-ico {
  font-size: 1.4rem;
  flex: 0 0 auto;
  line-height: 1.3;
}
.ob-step b {
  display: block;
  font-size: 0.98rem;
}
.ob-step span {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.4;
}
.ob-foot {
  padding: 8px 22px 22px;
  display: flex;
  justify-content: flex-end;
}

/* Resolucion con IA (labores <-> facturas). */
.ai-btn {
  margin-left: 8px;
  white-space: nowrap;
}
.ai-match-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 22, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
  padding: 16px;
}
.ai-match-overlay.hidden {
  display: none;
}
.ai-match-modal {
  background: var(--surface);
  border-radius: 16px;
  width: min(680px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ai-match-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #f6f4ee;
}
.ai-match-head strong {
  font-size: 1.05rem;
}
.ai-match-head .link {
  color: #f6f4ee;
}
#aiMatchBody {
  padding: 14px 20px;
  overflow-y: auto;
}
.ai-match-foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.ai-sug {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.ai-sug input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.ai-sug-main {
  flex: 1;
  min-width: 0;
  font-size: 0.9rem;
}
.ai-sug-conf {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* Cockpit / checklist de cierre de campana. */
.cierre-check {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 6px 16px 14px;
  margin-bottom: 20px;
}
.ck-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--line);
}
.ck-head b {
  font-size: 1.02rem;
  color: var(--green);
}
.ck-head span {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ck-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.ck-ico {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.ck-done .ck-ico {
  background: var(--surface-strong);
  color: var(--green);
}
.ck-todo .ck-ico {
  background: #f6ecd6;
  color: var(--amber);
}
.ck-main {
  flex: 1;
  min-width: 0;
}
.ck-main b {
  display: block;
  font-size: 0.94rem;
}
.ck-main span {
  font-size: 0.8rem;
  color: var(--muted);
}
.ck-act {
  flex: 0 0 auto;
}
.ck-foot {
  padding-top: 14px;
}

/* Hero de bienvenida de Inicio (primera impresion / presentacion). */
.inicio-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 20px 24px;
  margin-bottom: 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: #f6f4ee;
  box-shadow: 0 12px 30px rgba(36, 82, 58, 0.22);
}
.ih-brand {
  min-width: 0;
}
.ih-title {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}
.ih-sub {
  font-size: 0.86rem;
  opacity: 0.9;
  margin-top: 4px;
}
.ih-pulse {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ih-metric {
  min-width: 132px;
}
.ih-metric > b {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ih-metric > b i {
  font-size: 1rem;
  font-weight: 600;
  font-style: normal;
  opacity: 0.75;
  margin-left: 1px;
}
.ih-metric > span {
  display: block;
  font-size: 0.78rem;
  opacity: 0.9;
  margin-top: 2px;
}
.ih-bar {
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.25);
  margin-top: 7px;
  overflow: hidden;
}
.ih-bar > em {
  display: block;
  height: 100%;
  background: #f6f4ee;
  border-radius: 4px;
  transition: width 0.45s ease;
}
.ih-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f6f4ee;
  text-align: left;
}
.ih-chip b {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ih-chip span {
  font-size: 0.74rem;
  opacity: 0.9;
  margin-top: 3px;
}
.ih-chip:hover {
  background: rgba(255, 255, 255, 0.22);
}
.ih-chip.ih-warn b {
  color: #ffd9b0;
}

/* Clima / pronostico. */
.hint-box.hint-ok {
  border-color: var(--green);
  background: var(--surface-strong);
  color: var(--green);
}
.hint-box.hint-danger {
  border-color: var(--red);
  background: #f7e6e2;
  color: var(--red);
}
.wx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.wx-day {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  background: var(--surface);
}
.wx-date {
  font-size: 0.74rem;
  text-transform: capitalize;
  color: var(--muted);
  font-weight: 600;
}
.wx-temp {
  margin: 6px 0 8px;
  font-variant-numeric: tabular-nums;
}
.wx-temp b {
  font-size: 1.5rem;
  color: var(--text);
}
.wx-temp span {
  font-size: 0.95rem;
  color: var(--muted);
  margin-left: 4px;
}
.wx-rain,
.wx-wind {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 3px;
}
.wx-rain.on {
  color: var(--blue);
  font-weight: 600;
}

/* Accion de auto-vinculo en el panel de cierre. */
.cierre-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 6px 0 16px;
}
.cierre-actions .subcopy {
  margin: 0;
  flex: 1 1 220px;
}

/* Barra del modo estricto de stock (Fase 1: flujo forzado). */
.strict-stock-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--green-2, #2f6b4a);
  border-radius: 10px;
  background: rgba(47, 107, 74, 0.08);
  cursor: pointer;
  font-size: 0.86rem;
  line-height: 1.35;
}
.strict-stock-bar input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  cursor: pointer;
}
.strict-stock-bar strong {
  color: var(--green, #24523a);
}
@media (hover: hover) and (pointer: fine) {
  body.nav-collapsed .nav-edge {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    width: 18px;
    height: 100vh;
    z-index: 1150;
    cursor: pointer;
  }
  body.nav-collapsed .nav-edge::after {
    content: "›";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: 2px;
    border-radius: 0 6px 6px 0;
    background: var(--green, #24523a);
    color: #f7f3eb;
    font-size: 0.9rem;
    opacity: 0.55;
    transition: opacity 0.2s ease, width 0.2s ease;
  }
  body.nav-collapsed .nav-edge:hover::after {
    opacity: 0.95;
    width: 12px;
  }
  body.nav-collapsed.nav-open .nav-edge::after {
    opacity: 0;
  }
}

/* Menu FLOTANTE: sale del layout (main a todo el ancho) y aparece por encima. */
body.nav-collapsed .shell {
  grid-template-columns: 1fr;
}

body.nav-collapsed .sidebar {
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
  height: 100vh;
  left: 0;
  position: fixed;
  top: 0;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  width: 250px;
  z-index: 1200;
}

body.nav-collapsed.nav-open .sidebar {
  transform: translateX(0);
}

body.nav-collapsed.nav-open .nav-backdrop {
  background: rgba(10, 18, 12, 0.4);
  display: block;
  inset: 0;
  position: fixed;
  z-index: 1100;
}

/* Previsualizacion de remito en Stock. */
.stock-remito-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 10px;
}
.stock-remito-head label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 4px;
}
#srpRows input {
  width: 100%;
}
#srpRows .srp-unit {
  width: 80px;
}

/* Reparto entre socios (despachos). */
.partner-split-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 12px;
}
.partner-split-filters label {
  color: #2d4738;
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  font-weight: 700;
  gap: 4px;
}
.partner-split-filters select {
  border: 1px solid #c8cfc1;
  border-radius: 8px;
  font-size: 0.95rem;
  min-width: 190px;
  padding: 8px 10px;
}

.partner-split-config {
  align-items: center;
  background: #f3f6f1;
  border: 1px solid #dde3d7;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 14px;
  padding: 10px 12px;
}
.partner-split-config .psplit-input {
  align-items: center;
  display: flex;
  font-size: 0.82rem;
  font-weight: 600;
  gap: 6px;
}
.partner-split-config .psplit-input input {
  border: 1px solid #c8cfc1;
  border-radius: 7px;
  font-size: 0.92rem;
  padding: 5px 7px;
  text-align: right;
  width: 82px;
}
.partner-split-config .psplit-sum {
  font-weight: 700;
  margin-left: auto;
}
.partner-split-crop {
  margin-bottom: 16px;
}
.partner-split-crop h3 {
  font-size: 15px;
  margin: 4px 0 8px;
}
.partner-split-crop .split-pos {
  color: var(--money-pos);
  font-weight: 700;
}
.partner-split-crop .split-neg {
  color: var(--money-neg);
  font-weight: 700;
}
.partner-split-crop .split-otro td {
  color: #69736b;
  font-style: italic;
}

/* Desplegable de seccion: solo se usa en telefono (ver @media). */
.mobile-nav {
  display: none;
}

.main {
  min-width: 0;
  padding: 28px;
  padding-bottom: 92px; /* aire para que el FAB (+) y el buscador flotante no tapen la última tarjeta */
}

.topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.05;
  margin-bottom: 0;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 0;
}

h3 {
  font-size: 0.98rem;
  margin-bottom: 0;
}

.top-actions,
.section-head,
.section-actions,
.button-stack {
  align-items: center;
  display: flex;
  gap: 10px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 10px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.cloud-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  min-width: 150px;
}

.section-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compact-action {
  min-height: 34px;
  padding: 7px 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel,
.kpi,
.lot-card,
.order-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.warning-panel {
  border-color: #d39b2f;
  box-shadow: 0 10px 28px rgba(114, 76, 16, 0.12);
}

.kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.kpi {
  padding: 16px;
}

.kpi small {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.kpi strong {
  display: block;
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
}

.compact-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 12px;
}
/* Grillas de KPI con cantidad variable (ganadería): que no quede una tarjeta
   huérfana a 1/4 de ancho; se acomodan solas. */
#ganaderiaKpis.kpi-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.compact-kpis .kpi {
  box-shadow: none;
  min-height: 104px;
}

.compact-kpis .kpi strong {
  font-size: 1.42rem;
}

.margin-filter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.margin-visual-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: 10px;
}

.margin-visual-grid h3 {
  margin: 0 0 10px;
}

.bar-chart {
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-height: 170px;
  padding: 12px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(92px, 0.9fr) minmax(120px, 1.6fr) minmax(82px, 0.7fr);
}

.bar-label {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: #e9e5dc;
  border-radius: 999px;
  height: 13px;
  overflow: hidden;
}

.bar-fill {
  background: linear-gradient(90deg, var(--green), var(--green-2));
  border-radius: inherit;
  height: 100%;
  min-width: 3px;
}

.bar-fill.negative {
  background: linear-gradient(90deg, #bf6b43, var(--red));
}

.bar-value {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.quick-actions {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 16px;
}

.quick-card {
  background: linear-gradient(180deg, #fffdfa 0%, #f2f6ef 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(35, 45, 36, 0.08);
  color: var(--text);
  display: grid;
  gap: 5px;
  min-height: 88px;
  padding: 14px;
  text-align: left;
}

.quick-card:hover {
  border-color: #b8c9b6;
  transform: translateY(-1px);
}

.quick-card strong {
  color: var(--green);
  font-size: 1rem;
}

.quick-card span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

/* Desglose por marca de una droga (fila expandible en la conciliacion). */
.droga-toggle {
  font-weight: 700;
  padding: 0 4px;
  min-width: 18px;
}
tr.droga-member td {
  background: #f5faf3;
  color: var(--muted);
  font-size: 0.9rem;
}
.droga-member-name {
  padding-left: 22px !important;
}
.droga-assign {
  font-size: 0.82rem;
  white-space: nowrap;
}
.droga-assign-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.droga-assign-form .da-droga {
  min-width: 170px;
}
.droga-assign-form .da-conc {
  width: 90px;
}

/* Facturas de labor sin contratista: lista accionable (asignar contratista). */
.fsc-panel {
  margin-top: 12px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.fsc-head {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.fsc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.fsc-info {
  min-width: 0;
}
.fsc-act {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.fsc-sel {
  min-width: 180px;
}

/* Cargar rapido (modo campo): capturas por voz/foto desde el Inicio. */
.quick-capture {
  margin-bottom: 16px;
}
.qc-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.qc-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
}
.cap-btn {
  align-items: center;
  background: linear-gradient(180deg, #f3f8f1 0%, #e6f0e4 100%);
  border: 1px solid #cfe0cb;
  border-radius: 10px;
  color: var(--green);
  cursor: pointer;
  display: flex;
  font-weight: 700;
  gap: 10px;
  min-height: 62px;
  padding: 12px 14px;
  text-align: left;
}
.cap-btn:hover {
  border-color: var(--green-2);
  transform: translateY(-1px);
}
.cap-ic {
  font-size: 1.5rem;
  line-height: 1;
}
.cap-tx {
  font-size: 0.98rem;
}
.cap-photo {
  background: linear-gradient(180deg, #eef4fb 0%, #e2edf8 100%);
  border-color: #c3d6ea;
  color: var(--blue);
}

.split,
.two-col,
.report-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.master-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.form {
  display: grid;
  gap: 13px;
}

.form.is-editing {
  border-color: #d1a35d;
  box-shadow: 0 0 0 3px rgba(182, 118, 34, 0.12), var(--shadow);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.inline-form {
  align-items: end;
  grid-template-columns: minmax(160px, 1.2fr) minmax(110px, 0.7fr) minmax(150px, 1fr) auto;
  margin-bottom: 14px;
}

.history-toolbar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 420px) minmax(150px, 1fr);
  margin-bottom: 14px;
}

.history-toolbar .hint-box {
  margin: 0;
  min-height: 48px;
}

.inline-edit-form {
  box-shadow: none;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 14px;
}

.inline-edit-form .section-head {
  grid-column: 1 / -1;
}

.wide-field {
  grid-column: 1 / -1;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.82rem;
  font-weight: 700;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

/* Checkboxes y radios: tamaño normal (la regla de arriba los agrandaba como cuadros
   gigantes). Acento verde de la marca. */
input[type="checkbox"],
input[type="radio"] {
  width: 18px !important;
  height: 18px !important;
  min-height: 0 !important;
  max-width: 18px !important;
  flex: 0 0 auto !important;
  padding: 0 !important;
  margin: 0;
  border-radius: 4px;
  accent-color: var(--green);
  vertical-align: middle;
  cursor: pointer;
}
input[type="radio"] { border-radius: 50%; }

input.is-estimated {
  border-color: #c0392b;
  color: #9d2419;
  font-weight: 800;
}

textarea {
  resize: vertical;
}

.primary,
.secondary,
.ghost,
.link {
  border-radius: 7px;
  min-height: 40px;
  padding: 9px 13px;
}

.primary {
  background: var(--green);
  border: 1px solid var(--green);
  color: white;
  font-weight: 800;
}

.primary:hover {
  background: var(--green-2);
}

.secondary {
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  font-weight: 700;
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.link {
  background: transparent;
  border: 0;
  color: var(--blue);
  font-weight: 800;
  padding-left: 6px;
  padding-right: 6px;
}

.link.danger {
  color: var(--red);
}

.file-action {
  align-items: center;
  background: #fff;
  border: 1px solid #cfc8bd;
  border-radius: 7px;
  color: var(--green);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 800;
  min-height: 40px;
  padding: 9px 13px;
}

.file-action input {
  display: none;
}

.wide {
  width: 100%;
}

.form-block {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.lot-picker {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-height: 260px;
  overflow: auto;
}

.group-selector {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1fr) auto auto;
  margin-bottom: 12px;
}

.lot-option {
  align-items: start;
  background: #fff;
  border: 1px solid #d7d1c9;
  border-radius: 8px;
  display: grid;
  gap: 2px;
  grid-template-columns: 20px 1fr;
  min-height: 58px;
  padding: 8px;
}

.lot-option input {
  min-height: auto;
  width: auto;
}

.lot-option strong {
  font-size: 0.9rem;
}

.lot-option small {
  color: var(--muted);
  display: block;
}

.product-rows {
  display: grid;
  gap: 10px;
}

.product-row {
  background: #fff;
  border: 1px solid #d7d1c9;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(160px, 2fr) 90px 88px 88px 36px;
  padding: 10px;
}

.icon-btn {
  align-self: end;
  background: #f8e7e2;
  border: 1px solid #efc2b8;
  border-radius: 7px;
  color: var(--red);
  font-weight: 900;
  min-height: 42px;
}

.list {
  display: grid;
  gap: 10px;
}

.recent-list {
  display: grid;
  gap: 8px;
}
/* El atributo hidden DEBE ganarle al display:grid, si no la sabana de
   "ultimas cargas" queda expandida y gigante en el Inicio. */
.recent-list[hidden] { display: none !important; }

.recent-entry {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(110px, 0.55fr) minmax(0, 1.4fr) minmax(150px, 0.8fr) auto;
  padding: 10px 12px;
}

.recent-entry strong,
.recent-entry span {
  display: block;
}

.recent-entry small {
  color: var(--muted);
}

.recent-type {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.recent-detail {
  min-width: 0;
}

.recent-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.edit-note {
  background: #eef4eb;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green);
  font-weight: 700;
  padding: 10px 12px;
}

.order-card {
  padding: 14px;
}

.order-top {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.muted,
.subcopy {
  color: var(--muted);
}

.subcopy {
  margin-bottom: 0;
}

.pill {
  background: #dcece3;
  border-radius: 999px;
  color: var(--green);
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 850;
  padding: 5px 9px;
}

.pill.amber {
  background: #faebd2;
  color: #8b520e;
}

.pill.red {
  background: #f9ded8;
  color: var(--red);
}

.ha-fill-btn {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 0.78rem;
  padding: 0;
}

.lot-summary-total td {
  font-weight: 800;
  background: #eef5ee;
  border-top: 2px solid #c9d8c9;
}

.margin-stock-toggle {
  display: block;
  background: #f3f7f0;
  border: 1px solid #d6e3cf;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: #234;
  cursor: pointer;
}

.margin-stock-toggle input {
  margin-right: 8px;
}

.margin-stock-toggle .field-hint {
  font-weight: 500;
}

.field-hint {
  color: #7a8a7a;
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 2px;
}

/* Indice de secciones (chips) para navegar dentro de una pagina larga. */
.page-index {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.page-index .chip {
  background: #eaf1e6;
  border: 1px solid #cfe0c4;
  color: #234;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.page-index .chip:hover {
  background: #dcebd2;
}

/* Patrón de página densa (Fase 4): resumen + pestañas PEGAJOSOS arriba, para no
   perder los totales ni el navegador de secciones al scrollear el detalle. */
.report-stickywrap { position: sticky; top: 0; z-index: 25; background: var(--paper); padding-top: 8px; margin-bottom: 14px; }
.report-stickywrap .report-tabs { margin-bottom: 8px; }
.report-sticky { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; padding: 9px 15px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); }
.report-sticky:empty { display: none; }
.report-sticky .rs-item { display: flex; flex-direction: column; }
.report-sticky .rs-k { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; }
.report-sticky .rs-v { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 1.02rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
/* En teléfono el desplegable de sección ya es sticky (91px): no pegamos el resumen
   para no taparlo ni comer pantalla. Queda arriba de las pestañas, normal. */
@media (max-width: 760px){ .report-stickywrap { position: static; } }

/* Panel plegable (form oculto detras de un titulo clickeable). */
.collapse-panel > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.collapse-panel > summary::-webkit-details-marker {
  display: none;
}

.collapse-panel > summary strong {
  color: var(--green);
  font-size: 1.05rem;
}

.collapse-panel[open] > summary {
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.dispatch-split-panel {
  background: #f3f7f0;
  border: 1px solid #d6e3cf;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 4px 0;
}

.dispatch-split-panel .split-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.dispatch-split-panel .split-row {
  display: grid;
  grid-template-columns: 1fr 86px 86px auto;
  gap: 6px;
  margin-bottom: 6px;
}

.dispatch-split-panel .split-row select,
.dispatch-split-panel .split-row input {
  width: 100%;
  min-width: 0;
}

.dispatch-split-panel .split-total {
  font-size: 0.8rem;
  font-weight: 700;
  color: #2f6b4a;
}

.estado-pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  white-space: nowrap;
}

.estado-pill.estado-cierra {
  background: #d6f0dd;
  color: #14532d;
}

.estado-pill.estado-parcial {
  background: #f3f1e2;
  color: #6b6320;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  /* Recuadro con scroll propio: los datos suben dentro de la caja y la barra
     horizontal queda a mano abajo (como inmovilizar paneles en Excel). */
  max-height: 70vh;
}

/* Los items de grid/flex tienen min-width:auto (= min-content) por defecto, asi
   que una tabla ancha adentro estira el panel y hace que TODA la pagina scrollee
   de costado (feo en el telefono). Con min-width:0 el panel puede achicarse y la
   barra de scroll horizontal queda DENTRO de la caja de la tabla, como debe ser. */
.table-wrap,
.view.active > *,
.split > *,
.two-col > *,
.report-grid > *,
.margin-visual-grid > *,
.master-grid > *,
.lot-grid > * {
  min-width: 0;
}

/* Encabezado y fila de filtros fijos arriba al hacer scroll (freeze panes). */
.table-wrap thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

.table-wrap thead th {
  box-shadow: inset 0 -1px 0 var(--line);
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-strong);
  color: #34453a;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.filter-row th {
  background: var(--surface-2);
  padding: 6px;
}

.filter-row select {
  border-radius: 6px;
  font-size: 0.78rem;
  min-height: 30px;
  padding: 5px 7px;
}

/* Autofiltro tipo Excel: la flechita va DENTRO del encabezado, pegada a la
   derecha. El <th> es relative (no rompe el freeze: el sticky esta en el thead). */
th.has-col-filter {
  position: relative;
  padding-right: 28px;
}

.col-filter {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 5px;
  display: flex;
  align-items: center;
}

.col-filter-btn {
  background: rgba(255, 255, 255, 0.92)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232d4738' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat center center;
  background-size: 10px 10px;
  border: 1px solid #c8cfc1;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0;
  height: 18px;
  line-height: 0;
  padding: 0;
  width: 18px;
}

.col-filter-btn:hover {
  background-color: #eef4ec;
  border-color: var(--green);
}

/* Filtrada: embudo celeste (como el indicador de filtro de Excel). */
.col-filter-btn.cf-active {
  background-color: #229ed9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M3 4h18l-7 8v7l-4-2v-5z'/%3E%3C/svg%3E");
  background-size: 11px 11px;
  border-color: #1c7ab0;
}

.col-filter-menu {
  background: #fff;
  border: 1px solid #cdd3c6;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  max-height: 320px;
  overflow: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}
/* El menu oculto debe seguir oculto (display:flex pisaba el [hidden]). */
.col-filter-menu[hidden] {
  display: none;
}
/* La lista de valores scrollea sola; buscar, "seleccionar todo" y los botones
   quedan fijos. Asi se ve y se desplaza bien aunque haya muchas opciones. */
.col-filter-menu .cf-sort,
.col-filter-menu .cf-search,
.col-filter-menu .cf-all,
.col-filter-menu .cf-actions,
.col-filter-menu .cf-clearall {
  flex: 0 0 auto;
}

.col-filter-menu .cf-clearall {
  margin-top: 4px;
  width: 100%;
  border: none;
  background: transparent;
  color: #8b520e;
  border-top: 1px solid #ece3d2;
  border-radius: 0;
  padding: 5px 4px 2px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.col-filter-menu .cf-list {
  flex: 1 1 auto;
  min-height: 96px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.col-filter-menu .cf-search {
  border: 1px solid #cdd3c6;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 6px;
  padding: 6px 8px;
  width: 100%;
}

.col-filter-menu .cf-row {
  align-items: center;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  font-size: 0.85rem;
  font-weight: 400;
  gap: 8px;
  padding: 5px 5px;
  text-transform: none;
}

.col-filter-menu .cf-row:hover {
  background: #f1f5ef;
}

.col-filter-menu .cf-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-filter-menu .cf-row input {
  flex: 0 0 auto;
  height: 16px;
  width: 16px;
}

.col-filter-menu .cf-all {
  border-bottom: 1px solid #e3e7df;
  font-weight: 700;
  margin-bottom: 4px;
  padding-bottom: 7px;
}

.col-filter-menu .cf-actions {
  border-top: 1px solid #e3e7df;
  display: flex;
  gap: 8px;
  margin-top: 6px;
  padding-top: 8px;
  position: sticky;
  bottom: 0;
  background: #fff;
}
.col-filter-menu .cf-actions button {
  border-radius: 7px;
  cursor: pointer;
  flex: 1;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 8px 6px;
}
.col-filter-menu .cf-apply {
  background: var(--green);
  border: 1px solid var(--green);
  color: #fff;
}
.col-filter-menu .cf-cancel {
  background: #fff;
  border: 1px solid #c8cfc1;
  color: #2d4738;
}

.table-filtered-out {
  display: none;
}

/* Fila de subtotal (suma de filas visibles, estilo Excel). */
tfoot.subtotal-foot td {
  background: #eef4ec;
  border-top: 2px solid var(--green);
  color: #1d3b29;
  font-weight: 800;
  position: sticky;
  bottom: 0;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Mini-barra de rinde (Rendimiento por lote): rinde del lote vs el mejor del cultivo,
   con el mismo semáforo del número. Se lee de un vistazo qué lote rinde y cuál no. */
.rinde-cell { line-height: 1.2; }
.rinde-bar { height: 4px; border-radius: 2px; background: var(--surface-strong); margin-top: 3px; overflow: hidden; }
.rinde-bar em { display: block; height: 100%; border-radius: 2px; transition: width .3s; }

/* Chips de estado / severidad con color semantico. */
.sev-pill {
  border-radius: 999px;
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 9px;
  white-space: nowrap;
}
.sev-alta {
  background: #f6d9d3;
  color: #a5382b;
}
.sev-media {
  background: #f6ecd0;
  color: #8a5a12;
}
.sev-baja {
  background: #e6efe1;
  color: #2e6b3c;
}

/* Pantalla ANALISIS: grilla de tarjetas + graficos de barras propios. */
:root {
  --an-pos: #2e6b3c;
  --an-neg: #b23a2e;
  --an-accent: #2f6db0;
  --an-amber: #b0801f;
}
.an-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.an-bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 6px;
}
.an-bar-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 120px 1fr auto;
}
.an-bar-label {
  color: var(--ink);
  font-size: 0.82rem;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.an-bar-track {
  background: var(--surface-2, #f3f6ef);
  border: 1px solid var(--line);
  border-radius: 7px;
  height: 22px;
  overflow: hidden;
}
.an-bar-fill {
  border-radius: 6px 0 0 6px;
  height: 100%;
  min-width: 3px;
  transition: width 0.5s ease;
}
.an-bar-val {
  color: var(--an-pos);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}
.an-bar-val.neg {
  color: var(--an-neg);
}

/* Chips de cultivo en la hoja Datos (doble cultivo). */
.crop-chip {
  align-items: center;
  background: #eef5ea;
  border: 1px solid #cfe0c4;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.82rem;
  gap: 4px;
  padding: 2px 6px 2px 10px;
  white-space: nowrap;
}
.crop-chip small {
  color: #56624e;
}
.crop-x {
  background: transparent;
  border: 0;
  color: #a5382b;
  cursor: pointer;
  font-size: 0.72rem;
  line-height: 1;
  padding: 2px 3px;
}
.crop-x:hover {
  color: #7a2a20;
}

/* Puntos de atencion (panel de Margen). */
.attention-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attn-item {
  align-items: center;
  background: #fafcf7;
  border: 1px solid #e0e6d8;
  border-left: 4px solid #cbd4c0;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
}
.attn-item.attn-crit {
  border-left-color: #a5382b;
  background: #fbf1ef;
}
.attn-item.attn-warn {
  border-left-color: #b0801f;
  background: #fbf6ea;
}
.attn-item.attn-info {
  border-left-color: #2e6b3c;
  background: #eef5ea;
}
.attn-tag {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
.attn-crit .attn-tag {
  color: #a5382b;
}
.attn-warn .attn-tag {
  color: #8a5a12;
}
.attn-info .attn-tag {
  color: #2e6b3c;
}
.attn-detail {
  flex: 1;
  min-width: 180px;
  font-size: 0.9rem;
}
.attn-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

/* Formato (Fase 4): numeros alineados en todos lados y resalte de fila al pasar
   el mouse, para leer mas facil las tablas anchas. */
.kpi strong,
.money-pos,
.money-neg {
  font-variant-numeric: tabular-nums;
}

tbody tr:hover {
  background: #f5faf3;
}

tfoot.subtotal-foot td {
  font-variant-numeric: tabular-nums;
}

/* Un respiro entre el titulo de cada seccion y su tabla. */
.panel > .table-wrap,
.detail-panel > .table-wrap {
  margin-top: 4px;
}

.estimated-value {
  color: #c0392b;
  font-weight: 850;
}

.estimated-tag {
  color: #c0392b;
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 850;
  margin-left: 4px;
  text-transform: uppercase;
}

.click-row {
  cursor: pointer;
}

.click-row:hover td {
  background: #f3f7ef;
}

.detail-panel {
  margin-top: 16px;
}

.row-actions {
  white-space: nowrap;
}

.row-actions .link {
  min-height: 28px;
  padding-bottom: 2px;
  padding-top: 2px;
}

.stock-aporte-actions {
  min-width: 360px;
}

.stock-aporte-actions select {
  display: block;
  margin-bottom: 6px;
  max-width: 520px;
  width: 100%;
}

.inline-link-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 320px;
}

.inline-link-picker select {
  flex: 1 1 220px;
  min-width: 180px;
}

.gasto-reparto {
  border-top: 1px solid var(--border, #d9d9d9);
  margin-top: 10px;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gasto-reparto-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.gasto-reparto-row input[data-grow-name] {
  flex: 1 1 160px;
  min-width: 120px;
}

.gasto-reparto-row input[data-grow-pct] {
  width: 80px;
}

.pill.pill-warn {
  background: #b3261e;
  color: #fff;
}

.inline-percent-input {
  max-width: 84px;
  min-height: 32px;
  padding: 4px 6px;
  text-align: right;
}

.compact-table table {
  min-width: 620px;
}

.lot-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.lot-card {
  padding: 14px;
}

.lot-card strong {
  display: block;
  font-size: 1.05rem;
}

.lot-card dl {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
  margin: 12px 0 0;
}

.lot-card dt {
  color: var(--muted);
  font-size: 0.76rem;
}

.lot-card dd {
  margin: 0;
  text-align: right;
}

.search {
  max-width: 320px;
}

.check-list {
  margin: 14px 0 0;
  padding-left: 18px;
}

.check-list li {
  margin-bottom: 8px;
}

.button-stack {
  align-items: stretch;
  flex-direction: column;
  margin-top: 18px;
}

.stock-split-panel,
.stock-link-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  grid-column: 1 / -1;
  padding: 12px;
}

.stock-link-panel {
  background: #f4f7ef;
}

.split-rows {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.split-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1fr) 120px auto;
}

.pill.warn {
  background: #f7d9d4;
  color: #7d2619;
}

.correction-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 1fr) minmax(180px, 1fr) auto;
  margin-bottom: 16px;
}

.correction-form button {
  align-self: end;
}

.query-form {
  margin-top: 18px;
}

.ai-intake-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(180px, 0.7fr) minmax(220px, 0.9fr);
}

.ai-text-field {
  grid-column: 1 / -1;
}

.draft-panel {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 14px;
}

.inline-draft {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
}

.inline-draft h3 {
  color: #102019;
  font-size: 20px;
  margin: 0;
}

.answer-box {
  background: #f7f4ee;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 180px;
  padding: 14px;
  white-space: pre-wrap;
}

.hint-box {
  background: #eef5ee;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin-top: 12px;
  padding: 10px 12px;
}

.map-panel {
  overflow: hidden;
  padding: 0;
}

.map-filter {
  margin-top: 12px;
}

.map-tabs {
  background: #f6f4ed;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
  -webkit-overflow-scrolling: touch;
}

.map-tab {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #183122;
  cursor: pointer;
  flex: 0 0 auto;
  font-weight: 800;
  min-height: 36px;
  padding: 8px 12px;
}

.map-tab.active {
  background: #1f573b;
  border-color: #1f573b;
  color: #fff;
}

.map-toolbar {
  background: #faf8f3;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
}

.map-toolbar button {
  min-height: 38px;
}

.map-canvas {
  background: #eef3ec;
  cursor: grab;
  display: block;
  height: min(62vh, 560px);
  touch-action: none;
  width: 100%;
}

.map-canvas.dragging {
  cursor: grabbing;
}

.map-lot {
  cursor: pointer;
  fill: #d7c78e;
  fill-opacity: 0.54;
  stroke: #17472e;
  stroke-width: 2;
}

.map-lot.linked {
  fill: #8ab57c;
  fill-opacity: 0.64;
}

.map-lot.selected {
  fill-opacity: 0.86;
  stroke: #082719;
  stroke-width: 4;
}

.map-label {
  fill: #102019;
  font-size: 18px;
  font-weight: 800;
  pointer-events: none;
  stroke: rgba(255, 255, 255, 0.78);
  stroke-width: 3px;
  paint-order: stroke;
  text-anchor: middle;
}

.map-empty {
  fill: var(--muted);
  font-size: 20px;
}

.map-legend {
  background: #fffdf9;
  border-top: 1px solid var(--line);
  padding: 12px;
}

.map-legend-title {
  color: #183122;
  font-weight: 900;
  margin-bottom: 8px;
}

.map-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.map-legend-item {
  align-items: center;
  background: #f6f4ed;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  padding: 8px 10px;
}

.map-legend-item small {
  color: var(--muted);
}

.map-swatch {
  border: 1px solid rgba(16, 32, 25, 0.28);
  border-radius: 999px;
  display: inline-block;
  height: 16px;
  width: 16px;
}

.map-detail {
  align-items: center;
  background: #faf8f3;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  padding: 12px;
}

.map-detail > div {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.map-detail strong {
  color: #123021;
}

.voice-panel,
.ticket-panel {
  align-items: center;
  background: rgba(24, 33, 26, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.ticket-panel {
  background: rgba(24, 33, 26, 0.5);
  z-index: 60;
}

.voice-card,
.ticket-card-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 680px;
  padding: 18px;
  width: min(680px, 100%);
}

.ticket-card-wrap {
  max-height: 94vh;
  overflow: auto;
}

.ticket-card {
  background: #fff;
  border: 1px solid #cfc8bd;
  border-radius: 8px;
  color: #17231b;
  margin: 14px auto;
  max-width: 520px;
  padding: 22px;
}

.ticket-head {
  border-bottom: 2px solid #203428;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.ticket-head h3 {
  font-size: 1.25rem;
  margin: 0 0 4px;
}

.ticket-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.ticket-row {
  border-bottom: 1px solid #e5ded3;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 8px 0;
}

.ticket-row strong {
  text-align: right;
}

.ticket-weight {
  background: #eef4eb;
  border-radius: 8px;
  margin: 14px 0;
  padding: 10px 14px;
}

.ticket-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.ticket-text {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.voice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.voice-matches {
  margin-top: 12px;
}

.hidden {
  display: none;
}

@media print {
  body.printing-ticket .shell,
  body.printing-ticket .toast,
  body.printing-ticket .ticket-card-wrap > .section-head,
  body.printing-ticket .ticket-actions,
  body.printing-ticket .ticket-text {
    display: none !important;
  }

  body.printing-ticket {
    background: #fff;
  }

  body.printing-ticket .ticket-panel {
    background: #fff;
    display: block !important;
    inset: 0;
    padding: 0;
    position: static;
  }

  body.printing-ticket .ticket-card-wrap {
    border: 0;
    box-shadow: none;
    max-height: none;
    max-width: none;
    padding: 0;
    width: auto;
  }

  body.printing-ticket .ticket-card {
    border: 0;
    max-width: none;
  }
}

#view-reportes.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* El orden del HTML ya es el correcto (Tablero -> detalles -> Control/Historial
   -> Exportar). Se quitaron unas reglas order:nth-of-type viejas que lo
   desordenaban (dejaban el Tablero al fondo y Exportar arriba). */
#view-reportes .detail-panel {
  margin-top: 0;
}

/* Regla comun de orden (Fase 1): en cada pagina primero se CARGA, despues la
   tabla EDITABLE, y al final los resumenes de SOLO LECTURA. Igual que Margen,
   usamos flex + order para no depender del orden del HTML. */
#view-siembra.active,
#view-cosecha.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#view-siembra .detail-panel,
#view-cosecha .detail-panel {
  margin-top: 0;
}

#view-siembra > .kpi-grid,
#view-cosecha > .kpi-grid,
#view-siembra > .page-index,
#view-cosecha > .page-index {
  margin-bottom: 0;
}

#view-siembra > .kpi-grid,
#view-cosecha > .kpi-grid {
  order: 0;
}

#view-siembra > .page-index,
#view-cosecha > .page-index {
  order: 1;
}

#siemCargar,
#cosCargar {
  order: 2;
}

#siemAvance,
#cosAvance {
  order: 3;
}

#siemResumen,
#cosResumen {
  order: 4;
}

#cosRinde {
  order: 5;
}

#siemTrabajo {
  order: 5;
}

#cosTrabajo {
  order: 6;
}

/* Despachos: misma regla. Form (cargar) -> tabla editable -> resumenes. */
#view-despachos.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#view-despachos .detail-panel {
  margin-top: 0;
}

#view-despachos > .kpi-grid,
#view-despachos > .page-index {
  margin-bottom: 0;
}

#view-despachos > .kpi-grid {
  order: 0;
}

#view-despachos > .page-index {
  order: 1;
}

#despCargar {
  order: 2;
}

#despTabla {
  order: 3;
}

#despVsCosecha {
  order: 4;
}

#despReparto {
  order: 5;
}

.toast {
  background: #1f3027;
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: #fff;
  left: 50%;
  max-width: calc(100vw - 32px);
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.ai-float {
  align-items: center;
  background: var(--green);
  border: 2px solid #d9c28f;
  border-radius: 999px;
  bottom: 22px;
  box-shadow: 0 18px 42px rgba(20, 45, 30, 0.28);
  color: #fffdfa;
  display: inline-flex;
  font-weight: 900;
  height: 62px;
  justify-content: center;
  position: fixed;
  right: 22px;
  width: 62px;
  z-index: 35;
  touch-action: none; /* para poder arrastrarlo en el celu sin scrollear la página */
}
.float-dragging { cursor: grabbing !important; opacity: .92; transition: none !important; }

.ai-float:hover {
  background: var(--green-2);
}

.ai-float-panel {
  background: rgba(23, 35, 27, 0.36);
  bottom: 0;
  left: 0;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 34;
}

.ai-float-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-left: auto;
  max-height: calc(100vh - 36px);
  max-width: 640px;
  overflow: auto;
  padding: 22px;
}

.ai-float-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ai-float-text,
.ai-float-file {
  grid-column: 1 / -1;
}

.ai-float-panel .answer-box {
  margin-top: 12px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

/* Hilo conversacional de la IA (chat con burbujas). */
.ai-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 2px 6px;
}
.ai-msg {
  border-radius: 13px;
  font-size: 0.9rem;
  line-height: 1.45;
  max-width: 88%;
  padding: 9px 12px;
  word-wrap: break-word;
}
.ai-msg-user {
  align-self: flex-end;
  background: var(--green, #2e6b3c);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.ai-msg-ai {
  align-self: flex-start;
  background: #eef3ea;
  border-bottom-left-radius: 4px;
  color: #1f2d22;
}

@media (max-width: 1080px) {
  .kpi-grid,
  .lot-grid,
  .master-grid,
  .quick-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col,
  .split,
  .report-grid,
  .margin-visual-grid {
    grid-template-columns: 1fr;
  }

  .compact-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    display: block;
    padding-bottom: 0;
  }

  /* En telefono no usamos la barra inferior (era dificil de tocar): la ocultamos
     y navegamos con el desplegable fijo de arriba. */
  .sidebar {
    display: none;
  }

  /* En telefono se navega con el desplegable, no con el menu flotante. */
  .nav-toggle,
  .nav-dock {
    display: none;
  }

  .mobile-nav {
    display: block;
    position: sticky;
    top: 0;
    z-index: 20;
    margin: -18px -14px 14px;
    padding: 10px 14px 12px;
    background: var(--green);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
  }

  .mobile-nav label {
    color: rgba(255, 255, 255, 0.8);
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    margin-bottom: 5px;
    text-transform: uppercase;
  }

  .mobile-nav select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2324523a' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    border: 1px solid #d6dccf;
    border-radius: 10px;
    color: #17231b;
    font-size: 17px;
    font-weight: 700;
    padding: 14px 40px 14px 14px;
    width: 100%;
  }

  .main {
    padding: 18px 14px;
    padding-bottom: 84px;
  }

  .ai-float {
    bottom: 18px;
    height: 58px;
    right: 14px;
    width: 58px;
  }

  .ai-float-panel {
    padding: 12px;
  }

  .ai-float-card {
    max-height: calc(100vh - 98px);
    padding: 16px;
  }

  .ai-float-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }
  /* El "Todo guardado ✓" ocupaba una fila entera y es redundante (auto-guarda). */
  .top-actions .cloud-status { display: none; }
  /* Papelera / Campaña / backup: chicos, en una sola fila, sin comer pantalla. */
  .top-actions .secondary { min-height: 34px; padding: 6px 11px; font-size: 0.82rem; flex: 0 0 auto; }

  .section-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .kpi-grid,
  .compact-kpis,
  .margin-filter-grid,
  .lot-grid,
  .master-grid,
  .lot-picker {
    grid-template-columns: 1fr;
  }

  /* MODO CAMPO (movil): tap grande y menos scroll. */
  .quick-actions {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .quick-card {
    min-height: 76px;
    align-content: center;
  }
  .quick-card strong {
    font-size: 1.02rem;
  }
  .quick-card span {
    font-size: 0.76rem;
  }
  /* Objetivos de toque mas grandes para usar con dedo en el campo. */
  .section-actions button,
  .form-actions button,
  .compact-action,
  .help-btn,
  .link {
    min-height: 44px;
  }
  .mobile-nav select {
    min-height: 50px;
    font-size: 1.02rem;
  }
  /* Campos de carga comodos con el dedo y sin el zoom automatico de iOS
     (se dispara cuando la letra del campo es menor a 16px). */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 46px;
    font-size: 16px;
  }
  .ai-float {
    width: 60px;
    height: 60px;
  }

  .bar-row {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .bar-value {
    text-align: left;
  }

  .group-selector {
    grid-template-columns: 1fr 1fr;
  }

  .group-selector button {
    width: 100%;
  }

  .product-row {
    grid-template-columns: 1fr 1fr;
  }

  .recent-entry {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .correction-form {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .history-toolbar {
    grid-template-columns: 1fr;
  }

  .inline-edit-form {
    grid-template-columns: 1fr;
  }

  .product-row label:first-child {
    grid-column: 1 / -1;
  }

  .icon-btn {
    grid-column: 1 / -1;
  }
}

/* Pantalla de login (Etapa 2: candado real) */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 520px at 50% -8%, rgba(46, 125, 79, 0.38), transparent 62%),
    linear-gradient(180deg, #16281e 0%, #101a14 100%);
  backdrop-filter: blur(3px);
}

.auth-overlay[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 384px;
  background: #fffdf8;
  border: 1px solid rgba(40, 60, 45, 0.08);
  border-radius: 20px;
  padding: 34px 30px 24px;
  box-shadow: 0 26px 64px rgba(0, 0, 0, 0.42);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--green);
}

.auth-logo {
  height: 58px;
  width: auto;
  max-width: 100%;
  display: block;
}

.auth-tagline {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #2e7d4f;
}

.auth-lead {
  margin: 0 0 4px;
  text-align: center;
  color: #5a655e;
  font-size: 13.5px;
  line-height: 1.45;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: #3a443e;
}

.auth-field span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6a746d;
}

.auth-field input {
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid #d5dcd4;
  border-radius: 11px;
  font-size: 15px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  outline: none;
  border-color: #2e7d4f;
  box-shadow: 0 0 0 3px rgba(46, 125, 79, 0.15);
}

.auth-card .primary {
  margin-top: 8px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
}

.auth-status {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  text-align: center;
  color: #b03030;
}

.auth-status.ok {
  color: #2c7a4b;
}

.auth-foot {
  margin: 6px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: #9aa39c;
}

.auth-logout {
  margin-top: 4px;
  padding: 0;
  font-size: 12px;
  text-align: left;
}

/* Formulario de consumo real de una orden */
.real-consumption-card {
  background: #fffdf8;
  border: 1px solid #d8d2c4;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 620px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rc-date {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #3a443e;
}

.rc-date input,
.rc-date select {
  padding: 9px 11px;
  border: 1px solid #cbd2cb;
  border-radius: 9px;
  font-size: 15px;
  background: #fff;
}

.rc-help {
  font-size: 12px;
  margin: 0;
}

.rc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #e7e3d8;
}

.rc-prod {
  display: flex;
  flex-direction: column;
}

.rc-prod small {
  color: #6b756e;
  font-size: 12px;
}

.rc-real {
  width: 130px;
  padding: 9px 10px;
  border: 1px solid #cbd2cb;
  border-radius: 9px;
  font-size: 15px;
  text-align: right;
}

/* Cerrar orden con el parte del aplicador (Fase 0 pulverización) */
.close-order-card { max-width: 640px; }
.co-input { display: flex; flex-direction: column; gap: 8px; }
.co-input textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd2cb; border-radius: 9px;
  font-size: 14px; font-family: inherit; resize: vertical; background: #fff;
}
.co-input-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.co-input-actions .primary { margin-left: auto; }
.co-photo-btn { cursor: pointer; display: inline-flex; align-items: center; }
.co-status { font-size: 12.5px; margin: 2px 0 0; min-height: 1.2em; }
#closeOrderDiff:empty { display: none; }
.co-meta { font-size: 12.5px; color: #5c6660; margin: 4px 0 8px; }
.co-tally {
  font-size: 13px; color: #3a443e; background: #f4f1e9; border: 1px solid #e4ddcd;
  border-radius: 9px; padding: 8px 12px; margin: 0 0 10px;
}
.co-tally b { font-variant-numeric: tabular-nums; }
.co-lotes { display: flex; flex-direction: column; gap: 6px; }
.co-row {
  display: grid; grid-template-columns: 5px 1.4fr 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid #e7e3d8; border-radius: 9px; font-size: 13px; background: #fffdf8;
}
.co-row .co-stripe { width: 5px; align-self: stretch; border-radius: 3px; min-height: 30px; }
.co-row.ok .co-stripe { background: #2e7d4f; }
.co-row.warn .co-stripe { background: #a9720a; }
.co-row.stop .co-stripe { background: #a8492f; }
.co-lote { font-weight: 600; }
.co-lote small { display: block; font-weight: 400; color: #8a938c; font-size: 11.5px; margin-top: 1px; }
.co-ha { font-size: 12.5px; color: #5c6660; font-variant-numeric: tabular-nums; }
.co-ha .co-plan { color: #8a938c; }
.co-ha .co-real { color: #2b6d8c; font-weight: 600; }
.co-pill {
  justify-self: end; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.co-pill.ok { background: rgba(46,125,79,.12); color: #1f5c39; }
.co-pill.warn { background: rgba(169,114,10,.13); color: #a9720a; }
.co-pill.stop { background: rgba(168,73,47,.12); color: #a8492f; }
.co-prods-title { font-size: 12px; font-weight: 700; color: #5c6660; text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px; }
.co-prods { display: flex; flex-direction: column; gap: 5px; }
.co-prod {
  display: flex; justify-content: space-between; gap: 10px; font-size: 13px;
  padding: 7px 10px; border-radius: 8px; background: #f8f5ec; border: 1px solid #eee6d5;
}
.co-prod.warn { background: rgba(169,114,10,.08); border-color: rgba(169,114,10,.25); }
.co-prod-v { font-family: "JetBrains Mono", ui-monospace, monospace; color: #3a443e; font-variant-numeric: tabular-nums; }
.co-prod-v small { color: #8a938c; }
.co-obs { font-size: 12.5px; color: #5c6660; font-style: italic; margin: 10px 0 0; }
.co-exceptions {
  background: rgba(169,114,10,.09); border: 1px solid rgba(169,114,10,.3); border-radius: 9px;
  padding: 10px 12px; font-size: 13px; color: #3a443e; margin-bottom: 4px;
}
.co-exceptions ul { margin: 6px 0 0; padding-left: 18px; }
.co-exceptions li { margin: 2px 0; }

/* Maquinaria y partes de trabajo (Fase 1) */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 520px) {
  .form-row-2 { grid-template-columns: 1fr; }
}
.maq-item, .parte-item {
  border: 1px solid #e4ddcd;
  border-radius: 10px;
  padding: 11px 13px;
  background: #fffdf8;
  margin-bottom: 8px;
}
.maq-item .maq-head, .parte-item .parte-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.maq-item .maq-name, .parte-item .parte-title { font-weight: 700; }
.maq-item .maq-type {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: #5c6660; background: #f4f1e9; border-radius: 999px; padding: 2px 8px;
}
.maq-item .maq-cost, .parte-item .parte-cost {
  margin-left: auto; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 700; color: #1f5c39;
}
.maq-item .maq-meta, .parte-item .parte-meta {
  font-size: 12.5px; color: #5c6660; margin-top: 3px;
}
.parte-item .parte-cost-breakdown {
  font-size: 12px; color: #8a938c; margin-top: 4px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.maq-actions, .parte-actions {
  display: flex; gap: 12px; margin-top: 8px;
}
.parte-cost-live {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.parte-cost-live b { color: #1f5c39; font-size: 15px; }
.parte-tankada {
  margin-top: 6px;
  font-size: 12.5px;
  color: #3a443e;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.parte-tankada b { color: #2b6d8c; }

/* Quién paga cada gasto (cash flow por socio) */
#gastoPagosDetails summary { cursor: pointer; font-weight: 700; font-size: 15px; }
.gp-top { display: flex; align-items: center; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.gp-search { flex: 1; min-width: 180px; padding: 8px 11px; border: 1px solid #cbd2cb; border-radius: 9px; font-size: 14px; }
.gp-count { font-size: 12.5px; color: #6b756e; font-variant-numeric: tabular-nums; }
.gp-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; }
.gp-row { display: flex; flex-direction: column; gap: 7px; padding: 8px 10px; border: 1px solid #e7e3d8; border-radius: 9px; background: #fffdf8; }
.gp-line { display: flex; align-items: center; gap: 10px; }
.gp-desc { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gp-desc b { font-family: ui-monospace, monospace; font-size: 13px; }
.gp-desc span { font-size: 12px; color: #6b756e; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-sel { flex: 0 0 auto; max-width: 48%; padding: 7px 9px; border: 1px solid #cbd2cb; border-radius: 8px; font-size: 13px; background: #fff; }
.gp-payers { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.gp-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: #3a443e; background: #f4f1e9; border: 1px solid #e4ddcd; border-radius: 999px; padding: 4px 10px; cursor: pointer; user-select: none; }
.gp-chk.on { background: rgba(44,110,73,.12); border-color: rgba(44,110,73,.4); color: #1e5236; font-weight: 600; }
.gp-chk input { margin: 0; }
.gp-custom-edit { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; padding: 8px 10px; background: #f4f1e9; border-radius: 8px; }
.gp-pct-l { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: #5c6660; }
.gp-pct { width: 74px; padding: 6px 8px; border: 1px solid #cbd2cb; border-radius: 7px; font-size: 14px; text-align: right; }
.gp-sum { font-family: ui-monospace, monospace; font-size: 13px; color: #2c6e49; font-weight: 700; align-self: center; }
.gp-sum-warn { color: #a9720a; }

/* Quién paga cada rubro (cash flow del Presupuesto) */
.presu-pagobtn { color: var(--green-2); border-color: rgba(45, 106, 73, 0.35) !important; }
.presu-pagobtn.open { background: rgba(45, 106, 73, 0.1); }
.presu-pago-box { margin-top: 10px; padding-top: 9px; border-top: 1px dashed #d5cdba; display: flex; flex-direction: column; gap: 7px; }
.presu-pago-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.presu-pago-done { border: 1px solid var(--green-2); background: var(--green); color: #fff; border-radius: 999px; padding: 5px 14px; font-size: 0.78rem; font-weight: 700; cursor: pointer; min-height: 30px; }
.presu-pago-done:hover { background: var(--green-2); }
.presu-asig { border-left: 3px solid var(--wheat); }
.pa-dif-warn { color: var(--amber); font-weight: 700; }
.presu-pago-lbl { font-size: 12px; font-weight: 700; color: #3a443e; }
.presu-pago-chks { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.presu-pago-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: #3a443e; background: #fff; border: 1px solid #d5cdba; border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.presu-pago-chk.on { background: rgba(46,125,79,.12); border-color: rgba(46,125,79,.45); color: #215c3a; font-weight: 600; }
.presu-pago-chk input { margin: 0; }
.presu-pago-pcts { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.presu-pago-pcts label { font-size: 12px; color: #5c6660; display: inline-flex; align-items: center; gap: 4px; }
.presu-cc-extras { margin-top: 9px; padding-top: 8px; border-top: 1px dashed #d5cdba; display: flex; flex-direction: column; gap: 8px; }
.presu-cc-flags { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.presu-cc-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: #3a443e; }
.presu-cc-chk input { margin: 0; }
.presu-cc-extras .presu-pago-box { margin-top: 0; padding-top: 0; border-top: 0; }

/* Resumen de tarjetas arriba de cada pantalla */
.screen-summary {
  margin-bottom: 14px;
}

/* Indice verde del mapa (rinde) */
.map-index-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #3a443e;
  margin-top: 8px;
}

.map-index-toggle input {
  width: 16px;
  height: 16px;
}

.map-yield-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.map-yield-bar {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(0, 65%, 45%), hsl(60, 65%, 45%), hsl(120, 65%, 45%));
}

.map-yield-scale {
  display: flex;
  justify-content: space-between;
  color: #4a5650;
}

.map-ndvi-bar {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(25, 70%, 45%), hsl(70, 70%, 45%), hsl(125, 70%, 38%));
}

.map-ndvi-detail {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  max-width: 220px;
}

.map-ndvi-detail strong {
  color: #1c4b32;
}

.map-ndvi-thumb {
  margin-top: 6px;
  width: 100%;
  max-width: 200px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #eef1ec;
}

.map-legend-note {
  color: #6b756e;
  font-size: 11px;
}

/* Edicion directa de celdas (tipo Excel) */
td.cell-edit {
  cursor: cell;
  position: relative;
}

td.cell-edit:hover {
  background: #f3f6f1;
  box-shadow: inset 0 0 0 1px #cdd8cf;
}

.cell-edit-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #2c7a4b;
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}

td.cell-edit.num .cell-edit-input {
  text-align: right;
}

/* Lista de labores para vincular a una factura */
.factura-labores-list {
  max-height: min(58vh, 560px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid #e4ded2;
  border-radius: 8px;
}

.factura-labor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-bottom: 1px solid #efeadf;
  font-size: 13px;
  cursor: pointer;
}

.factura-labor-row input {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

/* Factura vinculada a una orden/labor */
.order-factura {
  display: inline-block;
  font-size: 13px;
  background: #eef3ec;
  border-radius: 8px;
  padding: 3px 8px;
}

.order-factura.muted {
  background: #f3efe6;
}

/* Aviso de auditoria de stock */
.hint-warn {
  background: #fdeceb;
  border-left: 4px solid #b03030;
  color: #7a2222;
}

/* Analisis financiero del margen */
.margin-analysis {
  margin-top: 16px;
  border-top: 1px solid #e7e3d8;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.analysis-headline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.analysis-result {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
}

.analysis-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.analysis-card {
  background: #fffdf8;
  border: 1px solid #e2ddd0;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.analysis-card small {
  color: #6b756e;
  font-size: 12px;
}

.analysis-card strong {
  font-size: 15px;
}

.analysis-card span {
  font-size: 12px;
  color: #4a5650;
}

.analysis-cost h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.cost-bar-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 13px;
}

.cost-bar-label {
  color: #3a443e;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cost-bar-track {
  background: #ece8dc;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.cost-bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green-2), var(--green));
  border-radius: 999px;
}

.cost-bar-val {
  color: #4a5650;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.analysis-note {
  margin: 0;
  background: #f3f6f1;
  border-left: 4px solid #2c7a4b;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px;
  font-size: 14px;
  color: #2f3a33;
}

.margin-detail > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.margin-detail > summary::-webkit-details-marker {
  display: none;
}

.margin-detail > summary strong::before {
  content: "▸ ";
}

.margin-detail[open] > summary strong::before {
  content: "▾ ";
}

/* Plata coloreada: verde positivo, rojo negativo (margenes) */
.money-pos {
  color: var(--money-pos);
  font-weight: 700;
}

.money-neg {
  color: var(--money-neg);
  font-weight: 700;
}

/* Ordenar columnas tipo Excel: encabezados clickeables con flechita */
th.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.sortable-th:hover {
  text-decoration: underline;
}

th.sortable-th.sort-asc::after {
  content: " \2191";
  opacity: 0.85;
}

th.sortable-th.sort-desc::after {
  content: " \2193";
  opacity: 0.85;
}

/* ===== Modo solo lectura (inversores) ===== */
/* Esconde todo lo que sea editar/crear/borrar. Los export y la navegacion
   quedan visibles. El candado real es el RLS de la base. */
body.viewer-mode .row-actions,
body.viewer-mode .section-actions,
body.viewer-mode form.form,
body.viewer-mode #aporteForm,
body.viewer-mode #orderForm,
body.viewer-mode .product-row-add,
body.viewer-mode [data-edit-harvest],
body.viewer-mode [data-edit-seeding],
body.viewer-mode [data-delete-order-labor] {
  display: none !important;
}
body.viewer-mode .cell-edit {
  pointer-events: none !important;
}
body.viewer-mode .cell-edit::after {
  content: none !important;
}
#viewerBadge {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 9999;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  opacity: 0.92;
}
/* Cartel de MODO DEMO: centrado abajo (no pisa los flotantes de las esquinas). */
#demoBadge {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  z-index: 9997;
  background: #b0721f;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  max-width: calc(100vw - 24px);
  text-align: center;
}

/* ===== Sugerencias (proponer / aprobar) ===== */
.suggest-float {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 9998;
  background: #2f6b4a;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.suggest-inbox-float {
  position: fixed;
  right: 22px;
  bottom: 150px;
  z-index: 9998;
  background: #b9842b;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.suggest-count {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  background: #fff;
  color: #b9842b;
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 4px;
  font-size: 12px;
}
/* Bandeja de Telegram: boton flotante (centro de recepcion de cargas del bot). */
.telegram-float {
  position: fixed;
  right: 22px;
  bottom: 204px;
  z-index: 9998;
  background: #229ed9;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}
.telegram-float .suggest-count {
  color: #1c7ab0;
}
.suggest-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
}
.suggest-item {
  border: 1px solid #d9d2c8;
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.6);
}
.suggest-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
}
.suggest-item-body {
  margin: 6px 0;
  font-size: 14px;
  white-space: pre-wrap;
}
.suggest-item-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
/* El boton Sugerir queda visible tambien en modo solo lectura (es lo unico que el inversor puede hacer). */
body.viewer-mode .suggest-float {
  display: inline-block !important;
}

/* El menu lateral ahora scrollea si no entran todos los items. */
.sidebar {
  overflow-y: auto;
}
/* En mobile (sidebar oculto) los flotantes quedan arriba del boton IA, a la derecha. */
@media (max-width: 1080px) {
  .suggest-float {
    right: 14px;
    bottom: 84px;
  }
  .suggest-inbox-float {
    right: 14px;
    bottom: 134px;
  }
  .telegram-float {
    right: 14px;
    bottom: 184px;
  }
}

/* Modo solo lectura: ocultar tambien los botones peligrosos de la barra de arriba. */
body.viewer-mode #quickCloudSaveBtn,
body.viewer-mode #campaignBtn,
body.viewer-mode #papeleraBtn,
body.viewer-mode #resetDemoBtn,
body.viewer-mode #clearAllBtn,
body.viewer-mode .top-actions [data-view-jump="ordenes"],
body.viewer-mode [data-view-jump="ordenes"] {
  display: none !important;
}
.campaign-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.campaign-active {
  margin: 6px 0 10px;
}
.campaign-advanced {
  margin-top: 14px;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
}
.campaign-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}
.campaign-advanced button {
  margin-right: 8px;
  margin-top: 8px;
}

/* Botones de orden dentro del autofiltro */
.cf-sort {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.cf-sort button {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
}
.cf-sort button:hover {
  background: #e4ece1;
}

/* Resaltar en verde la labor ya tildada (vinculada) en el panel de vincular. */
.factura-labor-row:has(input:checked) {
  background: #e7f3ea;
  border-radius: 6px;
  font-weight: 600;
}

/* Alertas clickeables del Inicio: llevan a la pantalla donde estan los registros. */
.alert-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(128, 128, 128, 0.3);
  background: transparent;
  color: inherit;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
}
.alert-card + .alert-card { margin-top: 8px; }
.alert-card:hover { border-color: rgba(128, 128, 128, 0.6); background: rgba(128, 128, 128, 0.08); }
.alert-card .alert-text { flex: 1; }
.alert-card .alert-go { opacity: 0.55; white-space: nowrap; font-size: 0.85em; }
.alert-card.sev-alta { border-left: 3px solid #e5484d; }
.alert-card.sev-media { border-left: 3px solid #f5a623; }
.alert-card.sev-baja { border-left: 3px solid #4caf7d; }
.alert-card { cursor: default; }
.alert-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
}
.alert-ignore {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0.55;
}
.alert-ignore:hover { opacity: 1; background: var(--surface-strong); color: var(--text); }
.alert-mute {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.5;
}
.alert-mute:hover { opacity: 1; background: var(--surface-strong); }
.alert-chip.alert-muted { color: var(--muted); border-style: dashed; }
.alerts-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.alert-chip {
  font-size: 0.74rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.alert-chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.alert-chip.alert-restore { margin-left: auto; color: var(--green); }

/* Panel de Alertas del Inicio: scrollea para ver todas sin ocupar toda la pantalla. */
.alerts-scroll {
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scatter "fecha de siembra vs rinde" (SVG a mano, sin librerias). */
.scatter-svg { width: 100%; height: auto; display: block; color: inherit; overflow: visible; }
.an-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 12px; opacity: 0.9; }
.an-leg { display: inline-flex; align-items: center; gap: 6px; }
.an-leg i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.inline-select { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.inline-select select { padding: 4px 8px; }

/* Aviso preventivo de dosis de herbicida excesiva en el formulario de orden. */
.product-row .dose-warn {
  grid-column: 1 / -1;
  color: #c0392b;
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}
.row-dose.input-warn {
  border-color: #e5484d !important;
  box-shadow: 0 0 0 1px #e5484d;
}

/* ===== Presupuesto de arrendamiento ===== */
.presu-topbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.presu-sel { display: flex; flex-direction: column; gap: 4px; font-weight: 600; min-width: 0; flex: 1 1 240px; }
.presu-sel select { min-height: 40px; }
.presu-topbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.presu-meta-head { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-start; }
.presu-campo input { min-height: 34px; margin-left: 6px; }
.presu-actions { margin-top: 10px; }
.presu-fuente { display: block; margin: 10px 0 2px; font-weight: 600; font-size: 13px; }
.presu-fuente select { min-height: 38px; margin-left: 6px; max-width: 100%; }
.presu-arr-actions { margin: 8px 0; }
.presu-flete { margin-top: 10px; font-size: 13px; font-weight: 600; }
.presu-flete input { max-width: 90px; margin: 0 4px; }
.presu-flete .muted { font-weight: 400; }
.presu-almac { margin-top: 12px; border-top: 1px dashed rgba(127,127,127,0.25); padding-top: 8px; }
.presu-almac h5 { margin: 0 0 6px; font-size: 13px; }
.presu-almac h5 .muted { font-weight: 400; font-size: 12px; }
.presu-almac-table { width: 100%; border-collapse: collapse; }
.presu-almac-table td { padding: 3px 4px; border-bottom: 1px solid rgba(127,127,127,0.12); vertical-align: middle; }
.presu-almac-table td:first-child { width: 55%; }
.presu-almac-table td:nth-child(2) { white-space: nowrap; text-align: right; }
.presu-almac-table td:last-child { width: 26px; text-align: center; }
.presu-almac-table input[type="text"] { width: 100%; box-sizing: border-box; font-size: 13px; }
.presu-almac-table input[type="number"] { max-width: 62px; }
.presu-unit { font-size: 11px; color: var(--muted, #777); margin-left: 3px; }
.presu-totals { display: flex; flex-wrap: wrap; gap: 14px; }
.presu-totals > div { display: flex; flex-direction: column; min-width: 120px; }
.presu-totals span { font-size: 12px; opacity: 0.7; }
.presu-totals b { font-size: 18px; }
.presu-addcul { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.presu-addcul select { min-height: 40px; flex: 1 1 200px; min-width: 0; }
.presu-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.presu-card-head h3 { margin: 0; }
.presu-inputs { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.presu-inputs label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; flex: 1 1 140px; min-width: 0; }
.presu-num { min-height: 40px; font-size: 16px; padding: 6px 8px; width: 100%; box-sizing: border-box; }
.presu-num-sm { max-width: 110px; }
.presu-cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.presu-box { flex: 1 1 280px; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; background: rgba(127,127,127,0.05); border-radius: 10px; padding: 12px; }
/* Topamos el ancho de la caja de costos: sin esto, en pantallas anchas la columna
   RUBRO (la única flexible) se estira al pedo y queda gigante. Con el tope, RUBRO
   queda justo para el nombre más largo ("PULVERIZACION TERRESTRE") y el panel de
   margen ocupa el resto del ancho. */
.presu-cols > .presu-box:first-child { flex: 1 1 340px; max-width: 700px; }
.presu-cols > .presu-box:nth-child(2) { flex: 1 1 300px; }
.presu-box h4 { margin: 0 0 6px; }
.presu-hint { font-size: 12px; opacity: 0.7; margin: 2px 0 8px; }
.presu-costos-table, .presu-kv, .presu-esc-table { width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed; }
.presu-costos-table td, .presu-kv td { padding: 4px 6px; border-bottom: 1px solid rgba(127,127,127,0.15); vertical-align: middle; }
.presu-costos-table .presu-rubro-name { font-size: 13px; word-break: break-word; }
/* 8 columnas: Rubro | US$/ha | Categoría | Riesgo | Fin | Mes(es) | Quién paga | ✕
   Con table-layout:fixed manda la PRIMERA fila (el <thead> th). Igual defino los
   MISMOS anchos en th Y en td para que nunca se contradigan entre sí (así la tabla
   sale idéntica en todos los campos). La col 1 (Rubro) queda flexible y absorbe el resto. */
.presu-costos-head th:nth-child(2), .presu-costos-table td:nth-child(2) { width: 62px; }
/* Input de US$/ha compacto para que el número (ej. 396) se vea entero en su columna. */
.presu-costos-table td:nth-child(2) input.presu-num { font-size: 14px; padding: 6px 4px; text-align: right; }
.presu-costos-table td:nth-child(2) input::-webkit-outer-spin-button,
.presu-costos-table td:nth-child(2) input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.presu-costos-head th:nth-child(3), .presu-costos-table td:nth-child(3) { width: 104px; }
.presu-costos-head th:nth-child(4), .presu-costos-table td:nth-child(4) { width: 30px; text-align: center; }
.presu-costos-head th:nth-child(5), .presu-costos-table td:nth-child(5) { width: 30px; text-align: center; }
.presu-costos-head th:nth-child(6), .presu-costos-table td:nth-child(6) { width: 110px; }
.presu-costos-head th:nth-child(7), .presu-costos-table td:nth-child(7) { width: 100px; }
.presu-costos-head th:nth-child(8), .presu-costos-table td:nth-child(8) { width: 22px; text-align: center; }
/* El botón de mes/quién-paga NO desborda la celda: se queda en su ancho y recorta
   con "…"; al hacer clic se abren todos los meses/socios. */
.presu-costos-table .presu-mesbtn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }
.presu-costos-table input, .presu-catsel { max-width: 100%; width: 100%; box-sizing: border-box; }
.presu-catsel { font-size: 12px; padding: 2px 4px; }
.presu-mes { font-size: 12px; padding: 2px 4px; max-width: 100%; box-sizing: border-box; }
.presu-cuotas { font-size: 11px; padding: 2px 3px; max-width: 100%; box-sizing: border-box; }
.presu-mescuo { display: inline-flex; gap: 3px; align-items: center; }
.presu-costos-table td.presu-mescuo { display: table-cell; }
.presu-costos-table td.presu-mescuo .presu-mes { display: block; margin-bottom: 2px; width: 100%; }
.presu-costos-table td.presu-mescuo .presu-cuotas { display: block; width: 100%; }
.presu-mes-lbl { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted, #777); flex-wrap: wrap; }
.presu-cuota-row td { background: rgba(47,125,79,0.05); padding: 6px 8px !important; }
/* Detalle "labor por labor" de un rubro (ítems editables que suman al total) */
.presu-detbtn { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--green-2, var(--green)); cursor: pointer; white-space: nowrap; }
.presu-detbtn.on { background: var(--surface-strong); border-color: var(--green); font-weight: 600; }
.presu-det-total { text-align: right; font-variant-numeric: tabular-nums; }
.presu-det-total small { color: var(--muted); font-size: 10px; display: block; }
.presu-det-box { display: flex; flex-direction: column; gap: 8px; }
.presu-det-lbl { font-size: 12px; color: var(--text-2, var(--muted)); }
.presu-det-list { display: flex; flex-direction: column; gap: 6px; }
.presu-det-item { display: flex; align-items: center; gap: 8px; }
.presu-det-name { flex: 1 1 auto; min-width: 0; min-height: 38px; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
.presu-det-item .presu-num-sm { max-width: 92px; text-align: right; }
.presu-det-u { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.presu-det-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.presu-additem { font-size: 12px; padding: 6px 12px; }
.presu-cuota-lbl { font-size: 11.5px; color: var(--muted, #777); margin-right: 6px; }
.presu-cuota-i { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; margin-right: 8px; }
.presu-cuota-i input { max-width: 52px; }
.presu-cuota-sum { font-size: 12px; font-weight: 600; }
.presu-cuota-warn { color: #c0392b; }
.presu-mesbtn { width: 100%; box-sizing: border-box; font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.presu-mesbtn.open { border-color: var(--green); }
.presu-mesbtn-car { opacity: .5; font-size: 10px; }
.presu-meschips-lbl { font-size: 11.5px; color: var(--muted, #777); margin-bottom: 4px; }
.presu-meschips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.presu-meschip { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.presu-meschip.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.presu-cuota-pcts { margin-top: 4px; }
.presu-tabs { display: flex; gap: 6px; margin: 12px 0; }
.presu-tab { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-weight: 600; }
.presu-tab.active { background: var(--green); border-color: var(--green); color: #fff; }
.presu-cf h3 { margin: 0 0 4px; }
.presu-cf-inicio { margin: 4px 0 8px; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.presu-cf-inicio select, .presu-cf-socio select { font-size: 13px; padding: 2px 6px; }
.presu-cf-inicio .presu-hint, .presu-cf-socio .presu-hint { margin: 0; }
.presu-cf-socio { margin: 4px 0 8px; font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px; background: rgba(47,125,79,0.06); border-radius: 8px; }
.presu-cf-actions { margin-top: 8px; }
.presu-socios-ed { margin: 6px 0 4px; padding: 8px 10px; border: 1px dashed rgba(127,127,127,0.35); border-radius: 8px; background: var(--surface); }
.presu-socio-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.presu-socio-row input[type="text"] { flex: 1 1 160px; min-width: 0; }
.presu-socio-row input[type="number"] { max-width: 70px; }
.presu-socio-foot { margin-top: 6px; display: flex; gap: 12px; align-items: center; }
.presu-socios-box { margin-top: 12px; padding: 10px 12px; border: 1px solid rgba(47,125,79,0.28); border-radius: 10px; background: var(--surface); }
.presu-socios-title { font-weight: 600; margin-bottom: 6px; }
.presu-socios-title .presu-hint { font-weight: 400; }
.presu-socios-rows { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.presu-socios-rows .presu-socio-row { flex: 0 1 260px; }
.presu-analisis { margin-top: 14px; border-top: 2px solid rgba(47,125,79,0.2); padding-top: 10px; }
.presu-analisis h4 { margin: 0 0 8px; color: var(--green); }
.pa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.pa-item { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
.pa-item span { display: block; font-size: 12px; color: var(--muted, #777); }
.pa-item b { font-size: 15px; }
.pa-item.hi { background: rgba(47,125,79,0.08); border-color: var(--green); }
.pa-ratios { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.pa-ratio { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pa-ratio span { font-size: 12px; color: var(--muted, #777); }
.pa-ratio span small { font-size: 10.5px; opacity: 0.85; }
.pa-ratio b { font-size: 20px; white-space: nowrap; }
.pa-ratio.hi { background: rgba(47,125,79,0.1); border-color: var(--green); }
.presu-fin-cell input { margin: 0; }
/* --- Control / auditoría margen bruto <-> cash flow --- */
.pa-audit-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin: 8px 0; }
.pa-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.pa-card span { display: block; font-size: 12px; color: var(--muted, #777); }
.pa-card b { font-size: 17px; }
.pa-card-warn { background: rgba(192,57,43,0.08); border-color: #c0392b; }
.pa-card-ok { background: rgba(47,125,79,0.08); border-color: var(--green); }
.pa-alert { background: rgba(230,160,0,0.12); border-left: 3px solid #e0a000; border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 13.5px; }
.pa-okbox { background: rgba(47,125,79,0.08); border-left: 3px solid var(--green); border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 13.5px; }
.presu-audit-table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.presu-audit-table th, .presu-audit-table td { border: 1px solid rgba(127,127,127,0.18); padding: 5px 8px; text-align: left; }
.presu-audit-table td.n, .presu-audit-table th.n { text-align: right; white-space: nowrap; }
.presu-audit-table thead th { background: rgba(127,127,127,0.08); font-weight: 600; }
.presu-audit-table tr.pa-sec td { background: rgba(47,125,79,0.1); font-weight: 700; font-size: 12px; letter-spacing: 0.3px; }
.presu-audit-table tr.pa-cult td { background: rgba(127,127,127,0.05); font-weight: 600; }
.presu-audit-table tr.pa-tot td { font-weight: 700; background: rgba(127,127,127,0.04); }
.presu-audit-table tr.pa-row-warn td { background: rgba(230,160,0,0.12); }
.pa-cat { font-size: 11px; color: var(--muted, #777); margin-left: 4px; }
.pa-ok { color: var(--green); font-weight: 600; }
.pa-warn { color: #c07a00; font-weight: 600; }
.pa-bad { color: #c0392b; font-weight: 700; }
.cf-pico-note { background: rgba(47,125,79,0.08); border-left: 3px solid var(--green); border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 13.5px; }
.presu-cf-table { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.presu-cf-table th, .presu-cf-table td { border: 1px solid rgba(127,127,127,0.18); padding: 4px 7px; text-align: right; white-space: nowrap; }
.presu-cf-table th.cf-concepto, .presu-cf-table td:first-child { text-align: left; }
.presu-cf-table thead th, .presu-cf-table th { background: rgba(127,127,127,0.08); font-weight: 600; }
.presu-cf-table .cf-zero { color: rgba(127,127,127,0.4); text-align: center; }
.presu-cf-table .cf-strong td, .presu-cf-table tr.cf-strong td { font-weight: 700; background: rgba(127,127,127,0.04); }
.presu-cf-table .cf-ing td { color: var(--green); }
.presu-cf-table .cf-acum td { font-weight: 700; border-top: 2px solid rgba(127,127,127,0.3); }
.presu-cf-table .cf-pico { outline: 2px solid #d21; outline-offset: -2px; }
/* Columna CONCEPTO congelada: al scrollear los meses en el celular, los nombres de
   fila (Labores, Insumos, Saldo…) quedan visibles. Fondo SÓLIDO y opaco (el sticky
   sobre fondos semi-transparentes dejaría ver las celdas de atrás). Alta especificidad
   para ganarle a `.presu-cf-table tr.cf-strong td` (que trae un fondo semi-transparente). */
.presu-cf-table tbody tr td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface) !important; }
.presu-cf-table thead th:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface-strong) !important; }
.presu-costos-head th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; opacity: .6; text-align: left; padding: 2px 6px; font-weight: 600; }
.presu-costos-head th:nth-child(2) { text-align: right; }
.presu-kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.presu-strong td { font-weight: 700; }
/* Cascada de margen bruto (vista app): 3 columnas concepto | US$/ha | total */
.presu-casc td:nth-child(2), .presu-casc td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 82px; }
.presu-casc-head td { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; opacity: .6; font-weight: 600; }
.presu-casc .presu-sub2 td:first-child { padding-left: 16px; opacity: .8; }
.presu-casc .presu-line td { border-top: 1px solid rgba(127,127,127,0.25); }
.presu-casc .presu-strong.money-pos td:not(:first-child) { color: var(--money-pos, #1e7a4d); }
.presu-casc .presu-strong.money-neg td:not(:first-child) { color: var(--money-neg, #c0392b); }
.presu-vtag { font-size: 10px; background: rgba(127,127,127,0.15); padding: 1px 5px; border-radius: 8px; vertical-align: middle; }
.presu-plata { margin-top: 8px; }
.presu-plata td { border-bottom: none; }
.presu-plata .presu-strong td { background: rgba(47,125,79,0.10); }
.presu-plata td:last-child { color: var(--money-pos, #1e7a4d); font-weight: 700; }
.presu-totals > div.hi { background: var(--accent, #2f7d4f); color: #fff; border-radius: 8px; padding: 6px 10px; }
.presu-totals > div.hi span { opacity: .9; }
.presu-resumen { margin-top: 10px; border-top: 1px solid rgba(127,127,127,0.2); padding-top: 8px; }
.presu-resumen .prg { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.presu-resumen .prg b { font-variant-numeric: tabular-nums; }
.presu-resumen .prf { margin-top: 6px; font-size: 12.5px; opacity: .85; }
.presu-costo-total { margin-top: 8px; text-align: right; }
.presu-x { background: none; border: none; color: #c0392b; cursor: pointer; font-size: 14px; padding: 0 4px; }
.presu-arriendo { margin-top: 16px; }
.presu-arr-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.presu-arr-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13px; flex: 1 1 150px; min-width: 0; }
.presu-arr-grid select.presu-num { min-height: 40px; }
.presu-check { display: inline-flex; align-items: center; gap: 6px; margin: 10px 0; font-weight: 600; }
.presu-esc-table td { padding: 4px 6px; }
.presu-arr-out { margin-top: 10px; }
.presu-grid-box { margin-top: 16px; }
.presu-grid-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.presu-grid-tabs .chip { cursor: pointer; }
.presu-grid-tabs .chip.active { background: var(--accent, #2f7d4f); color: #fff; }
.presu-grid-table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
.presu-grid-table th, .presu-grid-table td { border: 1px solid rgba(127,127,127,0.2); padding: 5px 8px; text-align: right; white-space: nowrap; }
.presu-grid-table thead th, .presu-grid-table th { background: rgba(127,127,127,0.08); font-weight: 600; }
.presu-grid-corner { text-align: left !important; opacity: 0.6; font-weight: 500 !important; }
.presu-col-exp { outline: 2px solid var(--accent, #2f7d4f); }
.presu-cell-exp { outline: 2px solid #1d1d1d; font-weight: 800; }
@media (max-width: 700px) {
  .presu-cols, .presu-arr-grid { flex-direction: column; }
  .presu-totals b { font-size: 16px; }
  .presu-grid-table { font-size: 12px; }
  .presu-grid-table th, .presu-grid-table td { padding: 4px 5px; }
}
/* --- Fila de backup en nube (indicador + botón 💾) --- */
.backup-nube-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-strong); }
.backup-nube-info { font-size: 13px; color: var(--muted, #777); }
.backup-nube-btn { margin-left: auto; }
.export-group-title { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
/* Checklist de primeros pasos (Inicio) */
.ih-onboarding { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ih-ob-title { font-weight: 700; margin-bottom: 6px; }
.ih-ob-title span { color: var(--muted); font-weight: 600; font-size: 13px; }
.ih-ob-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ih-ob-list li { font-size: 14px; }
.ih-ob-list li.done s { color: var(--muted); }
.ih-ob-list li .linklike { font-size: 14px; }
.top-save-btn { padding: 6px 10px; font-size: 16px; line-height: 1; }
.top-save-btn.saved-flash { background: var(--green, #2f7d4f); color: #fff; border-color: var(--green, #2f7d4f); }

/* --- Vista "tarjeta apilada" en celular para tablas anchas (Despachos, Acciones) --- */
@media (max-width: 760px) {
  .mob-cards thead { position: absolute; left: -9999px; top: -9999px; }
  .mob-cards, .mob-cards tbody, .mob-cards tr, .mob-cards td { display: block; width: 100%; }
  .mob-cards tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; padding: 4px 12px; background: var(--surface); box-shadow: var(--shadow); }
  .mob-cards td { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; border: none; border-bottom: 1px solid rgba(127,127,127,0.12); padding: 6px 0; white-space: normal; min-height: 34px; }
  .mob-cards td:last-child { border-bottom: none; }
  .mob-cards td::before { font-weight: 600; color: var(--muted); text-align: left; flex: 0 0 auto; }
  .mob-cards td input, .mob-cards td select { max-width: 58%; }
  .mob-cards-desp td:nth-child(1)::before { content: "Fecha"; }
  .mob-cards-desp td:nth-child(2)::before { content: "Remitente"; }
  .mob-cards-desp td:nth-child(3)::before { content: "CPE"; }
  .mob-cards-desp td:nth-child(4)::before { content: "Campo"; }
  .mob-cards-desp td:nth-child(5)::before { content: "Cultivo"; }
  .mob-cards-desp td:nth-child(6)::before { content: "Destino"; }
  .mob-cards-desp td:nth-child(7)::before { content: "Lote"; }
  .mob-cards-desp td:nth-child(8)::before { content: "Kg carta porte"; }
  .mob-cards-desp td:nth-child(9)::before { content: "Kg origen"; }
  .mob-cards-desp td:nth-child(10)::before { content: "Kg destino"; }
  .mob-cards-desp td:nth-child(11)::before { content: "Bruto"; }
  .mob-cards-desp td:nth-child(12)::before { content: "Tara"; }
  .mob-cards-desp td:nth-child(13)::before { content: "Dif"; }
  .mob-cards-desp td:nth-child(14)::before { content: "Humedad"; }
  .mob-cards-desp td:nth-child(15)::before { content: "Factor %"; }
  .mob-cards-desp td:nth-child(16)::before { content: "Transporte"; }
  .mob-cards-desp td:nth-child(17)::before { content: "Chofer"; }
  .mob-cards-desp td:nth-child(18)::before { content: "Chasis"; }
  .mob-cards-desp td:nth-child(19)::before { content: "Acoplado"; }
  .mob-cards-desp td:nth-child(20)::before { content: "Kg limpios"; }
  .mob-cards-desp td:nth-child(21)::before { content: "USD/TN"; }
  .mob-cards-desp td:nth-child(22)::before { content: "Ingreso USD"; }
  .mob-cards-desp td:nth-child(23)::before { content: "Acciones"; }
  .mob-cards-acc td:nth-child(1)::before { content: "Fecha"; }
  .mob-cards-acc td:nth-child(2)::before { content: "Campo"; }
  .mob-cards-acc td:nth-child(3)::before { content: "Lote"; }
  .mob-cards-acc td:nth-child(4)::before { content: "Ha"; }
  .mob-cards-acc td:nth-child(5)::before { content: "Cultivo"; }
  .mob-cards-acc td:nth-child(6)::before { content: "Labor/Insumo"; }
  .mob-cards-acc td:nth-child(7)::before { content: "Tipo producto"; }
  .mob-cards-acc td:nth-child(8)::before { content: "Producto"; }
  .mob-cards-acc td:nth-child(9)::before { content: "Unidad"; }
  .mob-cards-acc td:nth-child(10)::before { content: "Dosis"; }
  .mob-cards-acc td:nth-child(11)::before { content: "Cantidad"; }
  .mob-cards-acc td:nth-child(12)::before { content: "USD total"; }
  .mob-cards-acc td:nth-child(13)::before { content: "USD/ha"; }
  .mob-cards-acc td:nth-child(14)::before { content: "Contratista"; }
  .mob-cards-acc td:nth-child(15)::before { content: "O.T"; }
  .mob-cards-acc td:nth-child(16)::before { content: "Detalle"; }
  .mob-cards-acc td:nth-child(17)::before { content: "Acciones"; }
}

/* Fila con saldo negativo (stock/reparto) y fila TOTAL de tablas */
tr.neg-row td { background: rgba(192, 57, 43, 0.07); }
tr.tot-row td { font-weight: 700; background: rgba(127, 127, 127, 0.06); border-top: 2px solid rgba(127, 127, 127, 0.25); }
.tag-bajo { display: inline-block; font-size: 10px; font-weight: 700; color: #fff; background: #c0392b; border-radius: 6px; padding: 1px 6px; vertical-align: middle; }

/* FAB "＋ Cargar" flotante (modo campo) — abajo a la izquierda */
.fab-wrap { position: fixed; left: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.fab-btn { width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--green); color: #fff; font-size: 26px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,0.22); cursor: pointer; transition: transform .15s ease; }
.fab-wrap.open .fab-btn { transform: rotate(45deg); }
.fab-menu { display: flex; flex-direction: column; gap: 6px; align-items: stretch; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 10px; box-shadow: var(--shadow-lg, var(--shadow)); width: min(310px, calc(100vw - 32px)); }
.fab-menu-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; padding: 2px 6px 4px; }
.fab-item { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; cursor: pointer; white-space: normal; transition: border-color .12s, transform .12s; }
.fab-item:hover { background: var(--surface-strong); border-color: var(--green); transform: translateX(2px); }
.fab-item .btn-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-strong); display: grid; place-items: center; flex: 0 0 auto; color: var(--green); }
.fab-item .btn-ic svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.fab-item[data-fab-do="ia"] .btn-ic svg { fill: currentColor; stroke: none; }
.fab-item-tx b { display: block; font-size: 0.9rem; color: var(--text); }
.fab-item-tx small { display: block; color: var(--muted); font-size: 0.76rem; line-height: 1.25; margin-top: 1px; }
.fab-menu[hidden] { display: none !important; }
.order-cost-est { display: block; margin-top: 4px; font-size: 13px; font-weight: 600; color: var(--green); }
.pct-lo { color: #c07a00; font-weight: 600; }
.map-label-val { font-size: 8.5px; font-weight: 700; }
/* Barras de estado de campaña (Inicio hero) */
.ih-progress { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin-top: 10px; }
.ih-pg { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.ih-pg > span { flex: 0 0 78px; color: rgba(255,255,255,0.85); }
.ih-pg-bar { flex: 1; height: 9px; border-radius: 5px; background: rgba(255,255,255,0.18); overflow: hidden; box-shadow: inset 0 1px 2px rgba(0,0,0,0.12); }
.ih-pg-bar em { display: block; height: 100%; background: linear-gradient(90deg, #e7d5a0, var(--wheat)); border-radius: 5px; box-shadow: 0 0 6px rgba(195,155,69,0.4); }
.ih-pg > b { flex: 0 0 34px; text-align: right; color: #fff; }

/* ===== Legibilidad y "dedo" en el telefono (a pleno sol / con guantes) =====
   Sube el piso de las letras mas chicas y agranda los controles que se tocan.
   Solo afecta <=760px; no cambia la vista de escritorio ni toca datos. */
@media (max-width: 760px) {
  /* Piso de tipografia: nada por debajo de 12px en las etiquetas/tags densos. */
  .presu-unit, .presu-cuotas, .pa-cat, .presu-vtag,
  .presu-costos-head th, .presu-casc-head td { font-size: 12px; }
  .presu-mesbtn-car, .map-label-val { font-size: 11px; }
  .tag-bajo { font-size: 11px; padding: 2px 7px; }
  /* Objetivos tactiles: los controles de carga a >=44px de alto. */
  input, select, textarea, button { min-height: 44px; }
  /* ...menos los que son chips/iconos chicos, que no deben inflar la fila. */
  .fab-btn, .tag, .chip, .badge, .pill,
  .mob-cards td button, td button, th button { min-height: 0; }
  /* Celdas editables de las tarjetas apiladas: comodas para el dedo. */
  .mob-cards td input, .mob-cards td select { min-height: 40px; }
}

/* Cockpit "Plata para mirar" (Inicio): lo accionable con plata, arriba de todo. */
.money-cockpit { margin: 4px 0 14px; }
.mc-title { font-size: 13px; font-weight: 700; color: var(--muted, #777); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 8px; }
.mc-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.mc-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); border-left: 4px solid var(--green, #2e7d4f); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.mc-card:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); }
.mc-val { font-size: 20px; font-weight: 800; color: var(--green, #2e7d4f); line-height: 1.1; }
.mc-label { font-size: 13.5px; font-weight: 700; }
.mc-hint { font-size: 11.5px; color: var(--muted, #777); }

/* Sugerencia de "Crear orden" desde el historial (menos tipeo). */
.labor-hint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 10px; padding: 8px 12px; border-radius: 10px; background: rgba(46,125,79,0.08); border: 1px solid rgba(46,125,79,0.22); }
.labor-hint .lh-txt { font-size: 12.5px; color: var(--text, #333); }
.labor-hint .lh-apply { flex: 0 0 auto; background: var(--green, #2e7d4f); color: #fff; border: none; border-radius: 8px; padding: 6px 14px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.labor-hint .lh-apply:hover { filter: brightness(1.05); }

/* Aviso de datos faltantes al cargar por IA/voz/foto (que no quede vacio/mal). */
.missing-note { margin: 6px 0 10px; padding: 9px 13px; border-radius: 10px; font-size: 13px; background: rgba(192,122,0,0.10); border: 1px solid rgba(192,122,0,0.35); color: #8a5a00; }
input.field-missing, select.field-missing, textarea.field-missing { border-color: #c07a00 !important; background: rgba(192,122,0,0.07) !important; }

/* "Revisá esto": lo que no cierra, bien visible en Inicio. */
.review-nudge { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; background: rgba(192,122,0,0.07); border: 1px solid rgba(192,122,0,0.28); }
.rn-title { font-size: 13px; font-weight: 800; color: #a8690a; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 9px; }
.rn-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.rn-item { display: flex; align-items: center; gap: 11px; text-align: left; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: transform .12s ease; }
.rn-item:hover { transform: translateY(-1px); }
.rn-n { flex: 0 0 auto; min-width: 26px; height: 26px; padding: 0 6px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; background: #c07a00; color: #fff; font-weight: 800; font-size: 13px; }
.rn-tx { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.rn-tx b { font-size: 13px; font-weight: 700; }
.rn-tx small { font-size: 11.5px; color: var(--muted, #777); }
.rn-go { flex: 0 0 auto; color: #c07a00; font-weight: 800; }

/* Buscador global (Ctrl+K) */
/* Buscador AL LADO del ⊕ (abajo a la izquierda), para que NO se encime con el
   botón de IA que vive en la esquina derecha. */
.gs-btn { position: fixed; bottom: 20px; left: 80px; right: auto; z-index: 60; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text, #333); font-size: 19px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,0.18); }
.gs-btn:hover { background: var(--surface-strong, #eee); }
.gs-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(20,25,20,0.45); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; backdrop-filter: blur(2px); }
.gs-overlay[hidden] { display: none !important; }
.gs-modal { width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); overflow: hidden; display: flex; flex-direction: column; max-height: 78vh; }
#gsInput { border: none; border-bottom: 1px solid var(--line); padding: 16px 18px; font-size: 16px; background: transparent; color: var(--text, #333); outline: none; }
.gs-results { overflow-y: auto; padding: 6px; }
.gs-empty { padding: 24px 18px; color: var(--muted, #777); font-size: 13.5px; text-align: center; }
.gs-hit { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border: none; background: transparent; border-radius: 10px; cursor: pointer; }
.gs-hit:hover { background: var(--surface-strong, rgba(127,127,127,0.08)); }
.gs-tipo { flex: 0 0 auto; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; color: var(--green, #2e7d4f); background: var(--green-tint, rgba(46,125,79,0.12)); padding: 3px 8px; border-radius: 999px; min-width: 74px; text-align: center; }
.gs-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.gs-main b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-main small { font-size: 11.5px; color: var(--muted, #777); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-go { flex: 0 0 auto; color: var(--muted, #999); font-weight: 700; }

/* Tarjeta de tendencia (mini-gráficos de "cómo venís"). */
.trend-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 8px; box-shadow: var(--shadow); margin: 0 0 14px; }
.trend-title { font-size: 13px; font-weight: 700; margin: 0 0 6px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.trend-title span { font-size: 11.5px; font-weight: 500; color: var(--muted, #777); }

/* Recorrida (scouting) */
.recorrida-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 8px; }
.recorrida-thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: 0 0 auto; background: var(--surface-strong, rgba(127,127,127,0.1)); }
.recorrida-noimg { display: flex; align-items: center; justify-content: center; font-size: 26px; }
.recorrida-body { flex: 1; min-width: 0; }
.recorrida-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.recorrida-head b { font-size: 14px; }
.rec-sev { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em; }
.rec-sev-baja { background: rgba(46,125,79,.14); color: #2e7d4f; }
.rec-sev-media { background: rgba(192,122,0,.15); color: #a8690a; }
.rec-sev-alta { background: rgba(192,57,43,.14); color: #c0392b; }
.recorrida-meta { font-size: 12px; color: var(--muted, #777); margin-top: 2px; }
.recorrida-accion { font-size: 12.5px; margin-top: 5px; color: var(--green, #2e7d4f); font-weight: 600; }
.recorrida-notas { font-size: 12px; color: var(--muted, #777); margin-top: 3px; }
.recorrida-actions { display: flex; flex-direction: column; gap: 4px; flex: 0 0 auto; }

/* Emparejar socios (transferencias netas) */
.settle-card { margin: 12px 0 4px; padding: 13px 15px; border-radius: 12px; background: var(--green-tint, rgba(46,125,79,0.08)); border: 1px solid rgba(46,125,79,0.22); }
.settle-title { font-size: 13px; font-weight: 800; margin: 0 0 9px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.settle-title span { font-size: 11.5px; font-weight: 500; color: var(--muted, #777); }
.settle-list { display: flex; flex-direction: column; gap: 6px; }
.settle-row { display: flex; align-items: center; gap: 10px; padding: 8px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.settle-name { font-weight: 600; font-size: 13px; }
.settle-to { color: var(--green, #2e7d4f); }
.settle-arrow { color: var(--muted, #999); font-weight: 700; }
.settle-amt { margin-left: auto; font-variant-numeric: tabular-nums; }
.settle-note { font-size: 11.5px; color: var(--muted, #777); margin: 8px 0 0; }
.gs-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted, #888); }
@media (max-width: 760px) { .gs-btn { bottom: 14px; right: 14px; width: 46px; height: 46px; } }

/* ============================================================
   REFINAMIENTO ESTÉTICO v2 — "cuaderno de campo de lujo".
   Recomendaciones del director de diseño. Solo tipografía, color y
   profundidad; NO cambia la estructura (shell/hero/sidebar intactos).
   Norte: papel cálido + tinta verde-negra + PLATA como heroína +
   acento trigo (--wheat) con cuentagotas. Verde = identidad; wheat =
   detalle premium; money-pos/neg = plata; amber/red = alerta.
   ============================================================ */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Títulos con serif editorial (Fraunces) SOLO en H1/H2 grande y marca.
   Encabezados chicos, números y labels: Inter (nunca serif). */
h1 { font-family: var(--display); font-weight: 600; font-size: clamp(1.55rem, 2.6vw, 2rem); letter-spacing: -0.021em; }
h2, .section-head h2 { font-family: var(--display); font-weight: 600; letter-spacing: -0.014em; }
.brand strong { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; }

/* Foco visible con anillo trigo (accesibilidad + toque premium). */
:focus-visible { outline: 2px solid var(--wheat); outline-offset: 1px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; box-shadow: var(--focus); border-color: var(--wheat); }

/* Superficies: papel que "levanta" (highlight interior superior). */
.panel, .kpi, .lot-card, .order-card { border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 20px 22px; }

/* KPIs: el número (plata) manda; etiqueta discreta pero LEGIBLE (--text-2, no faint);
   hairline trigo arriba para leerlos como familia "producto caro". */
.kpi { padding: 18px 20px; border-top: 2px solid var(--wheat); }
.kpi small { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.055em; text-transform: uppercase; color: var(--text-2); margin-bottom: 7px; }
.kpi strong { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.02; }
.kpi-grid { gap: 16px; }

/* Botones: definidos, con profundidad sutil y estado :active. */
.primary { border-radius: var(--radius-sm); font-weight: 600; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 2px 9px rgba(33, 80, 58, 0.16); }
.secondary { border-radius: var(--radius-sm); border-color: var(--line-strong); font-weight: 600; }
.secondary:hover { border-color: var(--green-2); color: var(--green); }
.primary:active, .secondary:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(33, 80, 58, 0.14); }

/* Sidebar: item activo como pastilla con acento TRIGO a la izquierda. */
.nav-item { border-radius: var(--radius-sm); transition: background 0.12s ease; }
.nav-item:hover { background: rgba(255, 255, 255, 0.06); }
.nav-item.active { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.14); font-weight: 600; box-shadow: inset 3px 0 0 var(--wheat); }

/* Hero y quick-cards: cuerpo + micro-interacción al pasar. */
.inicio-hero { border-radius: 18px; box-shadow: var(--shadow); }
.quick-card { border-radius: var(--radius); transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease; }
.quick-card:hover { transform: translateY(-2px); border-color: var(--green-2); box-shadow: var(--shadow-lg); }

/* Tablas densas (Despachos/Aportes/Presupuesto): cebra + números a la derecha +
   header con borde verde + hover. Cebra SOLO en filas sin clase, para no pisar
   totales/negativos/coloreadas. Números solo en celdas .num/.n (seguro). */
.table-wrap thead th { letter-spacing: 0.02em; background: var(--surface-strong); border-bottom: 2px solid var(--green); color: var(--text-2); position: sticky; top: 0; z-index: 2; }
.table-wrap tbody tr:nth-child(even):not([class]) { background: var(--surface-2); }
.table-wrap tbody tr:hover { background: rgba(33, 80, 58, 0.05); }
.table-wrap td.num, .table-wrap th.num, .table-wrap td.n, .table-wrap th.n { text-align: right; font-variant-numeric: tabular-nums; }

/* CONGELAR la 1ª columna (inmovilizar paneles, como Excel): al deslizar una tabla
   ancha de costado, la columna que identifica la fila queda fija a la izquierda.
   Solo en las tablas grandes (.table-wrap); el fondo se hace opaco por fila para que
   no se transparente el contenido que pasa por debajo (respeta cebra y filas de color). */
.table-wrap tbody td:first-child,
.table-wrap thead th:first-child { position: sticky; left: 0; }
.table-wrap tbody td:first-child { z-index: 1; background: var(--surface); border-right: 1px solid var(--hairline); }
.table-wrap tbody tr:nth-child(even):not([class]) td:first-child { background: var(--surface-2); }
.table-wrap tbody tr[class] td:first-child { background: inherit; } /* filas con color propio (negativos, totales) */
.table-wrap thead th:first-child { z-index: 4; border-right: 1px solid var(--hairline); }
/* Al deslizar de costado, la columna congelada proyecta una sombrita para que se
   note que "flota" sobre los datos que pasan por debajo (se activa con .scrolled-x). */
.table-wrap.scrolled-x tbody td:first-child,
.table-wrap.scrolled-x thead th:first-child { box-shadow: 6px 0 6px -4px rgba(20, 45, 30, 0.18); }

/* Toggle "Tablas compactas" en el pie del sidebar (preferencia de densidad). */
.nav-foot { margin-top: auto; padding: 12px 14px 14px; }
.dense-toggle { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: rgba(255,255,255,0.72); cursor: pointer; user-select: none; }
.dense-toggle input { width: 16px !important; height: 16px !important; min-height: 0 !important; accent-color: var(--wheat); }
/* Modo compacto: filas más bajas en las tablas grandes (más info de un vistazo). */
body.tables-compact .table-wrap td,
body.tables-compact .table-wrap th { padding: 5px 8px; }
body.tables-compact .table-wrap { font-size: 0.82rem; }
body.tables-compact .table-wrap .filter-row th { padding: 3px 5px; }
/* % de cada rubro sobre el costo total, al lado del valor de la barra. */
.bar-pct { color: var(--text-2); font-size: 0.82em; font-weight: 700; margin-left: 5px; }
/* Ventana de aplicación por día en las tarjetas del pronóstico. */
.wx-spray { font-size: 11.5px; margin-top: 3px; font-weight: 600; }
.wx-spray.ok { color: var(--money-pos); }
.wx-spray.no { color: var(--text-2); opacity: 0.8; }
.wx-frost { font-size: 11.5px; margin-top: 2px; font-weight: 600; color: var(--blue); }
.wx-frost.hd { color: var(--money-neg); }
/* Panel "cada máquina, una sub-empresa" (P&L por máquina). */
.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 6px; }
.mp-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.mp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.mp-name { font-weight: 700; }
.mp-tipo { font-size: 12px; color: var(--muted); }
.mp-badge { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.mp-badge.pos { background: rgba(21,128,61,.12); color: var(--money-pos); }
.mp-badge.neg { background: rgba(192,57,43,.12); color: var(--money-neg); }
.mp-badge.neutral { background: rgba(127,127,127,.12); color: var(--muted); }
.mp-pnl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mp-pnl td { padding: 5px 0; border-bottom: 1px solid var(--hairline, rgba(127,127,127,.14)); vertical-align: baseline; }
.mp-pnl td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.mp-pnl td small { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; }
.mp-pnl .in td:last-child { color: var(--money-pos); }
.mp-pnl .cost td:last-child { color: var(--money-neg); }
.mp-pnl .tot td { border-bottom: 0; padding-top: 8px; font-family: var(--display, inherit); font-size: 15px; }
.mp-pnl .tot.pos td:last-child { color: var(--money-pos); font-weight: 800; }
.mp-pnl .tot.neg td:last-child { color: var(--money-neg); font-weight: 800; }
.mp-kpis { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.mp-kpi { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; min-width: 62px; }
.mp-kpi small { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.mp-kpi b { font-variant-numeric: tabular-nums; font-size: 14px; }
.mp-verdict { font-size: 13px; padding: 9px 12px; border-radius: 8px; }
.mp-verdict.pos { background: rgba(21,128,61,.08); color: var(--money-pos); }
.mp-verdict.neg { background: rgba(176,114,31,.1); color: var(--amber); }
.mp-verdict.neutral { background: var(--surface-2); color: var(--muted); }
/* Mini-barra por socio en Distribución de aportes: real (relleno) vs objetivo (marca). */
.apo-minibar { position: relative; height: 5px; border-radius: 3px; background: var(--surface-2); margin: 4px 0 1px; min-width: 54px; }
.apo-minibar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--money-pos); }
.apo-minibar-fill.under { background: var(--amber); }
.apo-minibar-tick { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--text); opacity: 0.55; }

/* Login (primera impresión / marketing): card con hairline trigo y detalles finos. */
.auth-card { border-top: 3px solid var(--wheat); }
.auth-tagline { color: var(--wheat) !important; }
.auth-card .primary { box-shadow: 0 2px 12px rgba(33, 80, 58, 0.22); }

/* Segmented control unificado para tabs de vista (Cierre/Conciliaciones, etc.).
   Se aplica donde el HTML ya usa .subtabs/.seg (no fuerza cambios de estructura). */
.subtabs, .seg-tabs { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; display: inline-flex; gap: 2px; }
.subtabs > button, .seg-tabs > button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 0.85rem; color: var(--text-2); cursor: pointer; }
.subtabs > button.active, .seg-tabs > button.active { background: var(--surface); color: var(--green); box-shadow: var(--shadow-sm); }

/* Estados vacíos: un poco más presentes (no párrafos gris perdidos). */
.empty-state { text-align: center; color: var(--text-2); padding: 26px 16px; }
.empty-state .es-ic { font-size: 30px; opacity: 0.55; display: block; margin-bottom: 8px; }

/* Barra superior (utility bar): estado de guardado como pastilla, acciones alineadas. */
.cloud-status { color: var(--text-2); font-weight: 700; font-size: 0.8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; min-width: 0; white-space: nowrap; }
.top-save-btn { border-radius: var(--radius-sm) !important; }

/* Pills/chips: peso más contenido y consistente (antes 850, muy pesado). */
.pill, .tag, .badge { font-weight: 700; }

/* Estados vacíos existentes (párrafos .muted sueltos en tablas/paneles) legibles. */
td.muted, .list > .muted, .empty { color: var(--text-2); }

/* Pestañas UNIFICADAS — un solo sistema (segmented control) para Stock, Aportes y
   Presupuesto (antes 3 estilos distintos: dos con subrayado, uno con pills). */
.stock-tabs, .aportes-tabs, .presu-tabs {
  border-bottom: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  display: inline-flex;
  flex-wrap: wrap;
  max-width: 100%;
}
.stock-tab, .aportes-tab, .presu-tab {
  border: 0 !important;
  background: transparent !important;
  border-radius: 999px !important;
  margin: 0 !important;
  padding: 7px 15px !important;
  color: var(--text-2) !important;
  font-weight: 600 !important;
  min-height: 34px;
}
.stock-tab:hover, .aportes-tab:hover, .presu-tab:hover { color: var(--green) !important; }
#view-stock .stock-tab.active,
#view-aportes .aportes-tab.active,
.presu-tab.active {
  background: var(--surface) !important;
  border-color: transparent !important;
  color: var(--green) !important;
  box-shadow: var(--shadow-sm);
}

/* En móvil el header sticky de tabla puede chocar con el nav superior fijo; se
   desactiva (las tablas se ven en tramos cortos igual). */
@media (max-width: 760px) {
  .table-wrap thead th { position: static; }
}

/* Resumen de Aportes jerarquizado: 2 KPIs de plata grandes + sub-datos compactos. */
.apo-sum { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: stretch; margin-bottom: 16px; }
.apo-sum-main { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.apo-sum-side { display: flex; flex-direction: column; justify-content: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); min-width: 170px; }
.apo-mini { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; font-size: 0.86rem; }
.apo-mini span { color: var(--text-2); }
.apo-mini b { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.95rem; }
@media (max-width: 720px) {
  .apo-sum { grid-template-columns: 1fr; }
  .apo-sum-side { flex-direction: row; flex-wrap: wrap; justify-content: space-around; min-width: 0; }
}

/* ===== Configuración: perfil, módulos y plan de cuentas (árbol) ===== */
.perfil-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.perfil-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.perfil-card:hover { border-color: var(--line-strong); }
.perfil-card.active { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); background: var(--surface-strong); }
.perfil-card strong { font-size: 1rem; color: var(--text); }
.perfil-card small { color: var(--muted); }

.modulos-lista { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.modulo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.modulo-row span { font-weight: 600; color: var(--text); }
.modulo-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); cursor: pointer; }

/* --- IA "trae tu clave" (Config) --- */
.ia-key-status { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.9rem; margin: 4px 0 14px; }
.ia-key-status.on { border-color: var(--green); background: var(--surface-strong); color: var(--text); }
.ia-key-status.on .ic { color: var(--green); flex: 0 0 auto; }
.ia-key-status small { color: var(--muted); }
.ia-key-grid { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.ia-key-field { display: flex; flex-direction: column; gap: 5px; }
.ia-key-field > span { font-size: 0.82rem; font-weight: 600; color: var(--text-2); }
.ia-key-field select, .ia-key-field input { padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 0.92rem; }
.ia-key-grow { flex: 1 1 260px; }
.ia-key-grow input { width: 100%; }
.ia-key-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.ia-key-help { font-size: 0.82rem; }
.ia-key-note { margin-top: 10px; }

/* --- Resultados de "Ayuda" en el buscador universal --- */
.gs-tipo-help { background: var(--green) !important; color: #fff !important; }
.gs-hit-help .gs-go { color: var(--green); font-weight: 700; }
/* Comandos de navegación (paleta ⌘K): destacados con acento trigo */
.gs-tipo-nav { background: var(--wheat, #c39b45) !important; color: #fff !important; }
.gs-hit-nav .gs-go { color: var(--wheat, #c39b45); font-weight: 700; }
.gs-hit-nav b { color: var(--green-2, #2d6a49); }

/* ===== Sueldos: preview del cálculo + checkbox activo ===== */
.liq-preview { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin: 4px 0 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.9rem; color: var(--muted); }
.liq-preview b { color: var(--text); font-variant-numeric: tabular-nums; }
.liq-preview .liq-neto, .liq-preview .liq-neto b { color: var(--green-2, #2d6a49); font-weight: 600; }
.liq-preview .liq-costo, .liq-preview .liq-costo b { color: var(--money-neg, #c0392b); font-weight: 600; }
.emp-activo { flex-direction: row !important; align-items: center; gap: 8px; }
.emp-activo input { width: auto !important; }
.campaign-del { color: var(--money-neg, #c0392b) !important; }

/* ===== Cotizaciones del dólar (tira compacta en el Inicio) ===== */
#view-inicio #inicioCotiz { order: 0 !important; } /* siempre arriba de todo, sea cual sea la vista elegida */
.cotiz-strip { margin-bottom: 12px; }
.cotiz-bar { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--wheat, #c39b45); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 8px 12px; cursor: pointer; font-family: inherit; color: inherit; }
.cotiz-ico { font-size: 0.95rem; flex: none; }
.cotiz-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 10px; flex: 1; min-width: 0; }
.cotiz-name { font-weight: 700; font-size: 0.84rem; }
.cotiz-nums { font-variant-numeric: tabular-nums; font-size: 0.9rem; white-space: nowrap; }
.cotiz-nums b { font-weight: 800; }
.cotiz-nums small { color: var(--muted); font-size: 0.72rem; }
.cotiz-chev { flex: none; color: var(--faint); font-size: 0.72rem; }
.cotiz-more { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 2px 2px; }
.cotiz-more[hidden] { display: none; }
.cotiz-chip { font-size: 0.82rem; font-variant-numeric: tabular-nums; background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px 11px; white-space: nowrap; }
.cotiz-chip .cc-lbl { color: var(--faint); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-right: 3px; }
.cotiz-grano { border-color: var(--green-bright, #3d8a5f); }
.cotiz-grano .cc-lbl { color: var(--green-2); }
.cotiz-up { color: var(--money-pos, #15803d); font-weight: 700; font-size: 0.72rem; }
.cotiz-dn { color: var(--money-neg, #c0392b); font-weight: 700; font-size: 0.72rem; }
.cotiz-chip b { font-weight: 800; }
.cotiz-chip small { color: var(--muted); }
.cotiz-foot { margin-left: auto; font-size: 0.72rem; color: var(--faint); display: flex; align-items: center; gap: 4px; }
.cotiz-refresh { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.cotiz-refresh:hover { background: var(--surface-2); color: var(--green-2); }

/* --- Centro de ayuda / tutorial (view-ayuda) --- */
.ayuda-filter { width: 100%; padding: 11px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 0.95rem; margin-bottom: 18px; }
.ayuda-area { margin-bottom: 22px; }
.ayuda-area h3 { font-size: 0.98rem; color: var(--green); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.ayuda-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ayuda-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.ayuda-card:hover { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.ayuda-card b { font-size: 0.92rem; color: var(--text); }
.ayuda-card span { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }

/* --- Link contextual "¿No te responde la IA?" en avisos de fallo --- */
.ia-help-link { display: inline-block; margin-top: 6px; color: var(--green); font-weight: 600; text-decoration: underline; }

/* --- Tour guiado ("video tutorial" con flechitas) --- */
.ayuda-tour-cta { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 16px; border: 1px solid var(--green); border-radius: var(--radius-sm); background: var(--surface-strong); }
.ayuda-tour-cta strong { color: var(--green); }
.help-tour-row { margin-top: 14px; }
.help-tour-btn { font-size: 0.9rem; }
.tour-overlay { position: fixed; inset: 0; z-index: 4000; pointer-events: none; }
.tour-spot { position: fixed; display: none; border-radius: 10px; border: 2px solid var(--wheat); box-shadow: 0 0 0 9999px rgba(15, 25, 20, 0.62); transition: left .25s, top .25s, width .25s, height .25s; pointer-events: none; }
.tour-bubble { position: fixed; z-index: 4001; max-width: calc(100vw - 24px); background: var(--surface, #fff); color: var(--text); border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 40px rgba(15, 25, 20, 0.35); pointer-events: auto; }
.tour-bubble h4 { margin: 2px 0 6px; font-size: 1rem; color: var(--text); }
.tour-bubble p { margin: 0 0 12px; font-size: 0.9rem; color: var(--text-2); line-height: 1.4; }
.tour-stepnum { font-size: 0.74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--green); }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-nav { display: inline-flex; gap: 8px; }
.tour-nav button { padding: 7px 14px; font-size: 0.85rem; }

.pc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.pc-chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.pc-chip:hover { border-color: var(--green); }
.pc-chip.active { background: var(--green); border-color: var(--green); color: #fff; }

.pc-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.pc-tipo { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.pc-tipo-btn { padding: 6px 16px; background: var(--surface); border: 0; color: var(--text-2); font-weight: 600; cursor: pointer; }
.pc-tipo-btn.active { background: var(--wheat-tint); color: var(--amber); }
.pc-tool-actions { display: inline-flex; gap: 14px; }
.linklike { background: none; border: 0; color: var(--green-2); font-weight: 600; cursor: pointer; padding: 4px; }
.linklike:hover { text-decoration: underline; }

.pc-grupo { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 10px; overflow: hidden; }
.pc-grupo-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--hairline); }
.pc-grupo-name { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.02rem; color: var(--green); }
.pc-grupo-actions, .pc-cuenta-actions { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.pc-mini { padding: 3px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text-2); font-size: 0.82rem; cursor: pointer; white-space: nowrap; }
.pc-mini:hover { border-color: var(--green); color: var(--green); }
.pc-cuentas { list-style: none; margin: 0; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.pc-cuentas li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.pc-cuentas li:hover { background: var(--surface-2); }
.pc-cuentas li span:first-child { color: var(--text); }
.pc-archived span:first-child { color: var(--faint); }
.pc-tag { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-strong); padding: 1px 6px; border-radius: 6px; }
.pc-empty { padding: 10px 2px; }
.pc-add-grupo { margin-top: 4px; }
.pc-inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px 8px; }
.pc-inline-grupo { padding: 8px 0; }
.pc-inline-input { flex: 1 1 150px; min-width: 130px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; background: var(--surface); color: var(--text); }
.pc-inline-input:focus { outline: none; border-color: var(--green); box-shadow: var(--focus); }
.pc-inline-save { border-color: var(--green); color: var(--green); }

@media (max-width: 720px) {
  .perfil-opciones, .modulos-lista { grid-template-columns: 1fr; }
  .pc-grupo-head { flex-wrap: wrap; }
}

/* ===== Mantenimiento de máquinas ===== */
.mant-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.mant-card { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--surface); padding: 10px 12px; }
.mant-card.mant-vencido { border-left-color: var(--money-neg); }
.mant-card.mant-pronto { border-left-color: var(--amber); }
.mant-card.mant-ok { border-left-color: var(--money-pos); }
.mant-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.mant-badge { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.mant-badge.mant-vencido { background: rgba(192, 57, 43, 0.14); color: var(--money-neg); }
.mant-badge.mant-pronto { background: var(--wheat-tint); color: var(--amber); }
.mant-badge.mant-ok { background: rgba(21, 128, 61, 0.12); color: var(--money-pos); }
.mant-bar { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 6px 0; }
.mant-bar span { display: block; height: 100%; border-radius: 999px; }
.mant-bar span.mant-vencido { background: var(--money-neg); }
.mant-bar span.mant-pronto { background: var(--amber); }
.mant-bar span.mant-ok { background: var(--money-pos); }
.mant-card small { color: var(--muted); }

/* ===== Libro de movimientos ===== */
.libro-filtros { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.libro-filtros label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; color: var(--muted); }
.libro-filtros select { min-width: 180px; }
.libro-tag { font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.libro-tag.libro-ingreso { background: rgba(21, 128, 61, 0.12); color: var(--money-pos); }
.libro-tag.libro-egreso { background: rgba(192, 57, 43, 0.12); color: var(--money-neg); }
.libro-fuente { color: var(--faint); font-size: 0.85rem; }

/* ===== Libro IVA (fiscal) ===== */
.fiscal-sub { font-size: 0.95rem; font-weight: 700; color: var(--green); margin: 0 0 8px; }
.fiscal-tot td { border-top: 2px solid var(--line); background: var(--surface-strong); }
.fiscal-row-est td { color: var(--muted); }
.fiscal-est { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--wheat); background: rgba(195, 155, 69, 0.14); padding: 1px 6px; border-radius: 6px; cursor: help; }
.ret-tag { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--green); background: rgba(33, 80, 58, 0.1); padding: 1px 6px; border-radius: 6px; }
/* Botón "Leer con IA" (lee PDF/foto y prellena el formulario). */
.ia-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ia-btn, .libro-filtros label.ia-btn { display: inline-flex; align-items: center; gap: 8px; background: var(--green); color: #fff; border-radius: 999px; padding: 9px 16px; font-size: 0.86rem; font-weight: 600; cursor: pointer; border: 1px solid var(--green); transition: filter .12s; }
.ia-btn, .ia-btn * { color: #fff; }
.ia-btn:hover { filter: brightness(1.08); }
.ia-btn .ia-ic svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.ia-info { font-size: 0.84rem; color: var(--muted); }
/* Íconos SVG dentro de botones (reemplazan emojis sueltos 💾📸🎤). */
.btn-ic { display: inline-flex; align-items: center; vertical-align: -3px; margin-right: 4px; }
.btn-ic svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.top-save-btn .btn-ic { margin-right: 0; }
/* LPG: vista previa del neto a cobrar mientras se carga. */
.lpg-preview { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 12px 14px; background: var(--surface-strong); border: 1px solid var(--line); border-radius: 12px; font-size: 0.86rem; color: var(--muted); }
.lpg-preview .lpg-neto { margin-left: auto; color: var(--green); font-size: 0.95rem; }
.lpg-preview b { color: var(--text); }
.lpg-preview .lpg-neto b { color: var(--green); }
/* Cuenta corriente: filas de tercero clicables (abren el extracto). */
.cc-row { cursor: pointer; }
.cc-row:hover { background: var(--surface-strong); }
/* Ficha/historia de un animal (caravana). */
.ani-caravana { background: none; border: none; padding: 0; font: inherit; color: var(--green); cursor: pointer; }
.ani-caravana:hover { text-decoration: underline; }
.animal-detalle { margin-top: 14px; }
.ad-card { position: relative; background: var(--surface-strong); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.ad-close { position: absolute; top: 12px; right: 14px; font-size: 0.82rem; }
.ad-head { font-size: 0.98rem; margin-bottom: 12px; padding-right: 60px; }
.ad-sub { font-size: 0.85rem; font-weight: 700; color: var(--green); margin: 14px 0 6px; }
/* Feedlot: ración/dieta agrupada. */
.racion-dieta { margin-bottom: 16px; }
.racion-head { font-size: 0.95rem; margin-bottom: 6px; }
.dieta-warn { color: var(--money-neg); font-size: 0.82rem; font-weight: 600; }
/* Feedlot: MAPA de corrales (módulos con calles + corrales pintables). */
.mapa-grid { display: grid; gap: 20px; margin: 14px 0; justify-content: start; }
.mapa-modulo { background: var(--surface-strong); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 7px; }
.mapa-mod-grid { display: grid; gap: 6px; }
.mapa-corral { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 62px; min-height: 54px; border: none; border-radius: 8px; padding: 6px 8px; cursor: pointer; font: inherit; text-align: left; transition: transform .1s; }
.mapa-corral:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.mc-n { font-size: 0.74rem; font-weight: 700; line-height: 1; }
.mc-s { font-size: 0.72rem; opacity: .9; line-height: 1; }
.mapa-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 4px; font-size: 0.8rem; color: var(--muted); }
.mapa-leg { display: inline-flex; align-items: center; gap: 6px; }
.mapa-swatch { width: 13px; height: 13px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }
.mapa-config { margin-top: 12px; }
.mapa-config > summary { cursor: pointer; font-size: 0.85rem; font-weight: 600; color: var(--green-2); }
/* Vista "sobre el plano": imagen de fondo + corrales arrastrables. */
.mapa-plano { position: relative; width: 100%; min-height: 400px; background-size: contain; background-repeat: no-repeat; background-position: center; background-color: var(--surface-strong); border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; overflow: hidden; }
.mapa-free { position: absolute; min-width: 54px; min-height: 40px; touch-action: none; box-shadow: var(--shadow); cursor: grab; }
.mapa-free:active { cursor: grabbing; }
/* Mapa de potreros (ganadería): grilla auto-acomodada, sin módulos. */
.mapa-potreros-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin: 12px 0; }
.mapa-potrero { cursor: default; }
.mapa-potrero:hover { transform: none; box-shadow: none; }

/* ===== Mapa de calor de rinde por lote ===== */
.heat-crop { margin-bottom: 14px; }
.heat-crop-head { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1rem; color: var(--text); margin-bottom: 6px; }
.heat-crop-head small { font-family: var(--sans, inherit); color: var(--muted); font-weight: 500; font-size: 0.82rem; }
.heat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.heat-cell { border: 1px solid rgba(0,0,0,0.06); border-radius: 10px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; gap: 1px; color: #17301f; }
.heat-lote { font-size: 0.78rem; font-weight: 600; text-align: center; line-height: 1.1; }
.heat-rinde { font-size: 1.02rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.heat-dif { font-size: 0.75rem; font-weight: 600; opacity: 0.8; }

/* ===== Menú lateral en acordeón por áreas ===== */
.nav-area { display: grid; gap: 2px; }
.nav-area-head { display: flex; align-items: center; gap: 9px; width: 100%; background: transparent; border: 1px solid transparent; border-radius: 8px; color: rgba(247,243,235,0.92); padding: 9px 12px; cursor: pointer; font: inherit; font-weight: 700; font-size: 0.82rem; letter-spacing: 0.02em; text-align: left; }
.nav-area-head:hover { background: rgba(255,255,255,0.07); }
.nav-area-head .na-icon { font-size: 1rem; line-height: 1; }
/* Íconos SVG monolínea del menú (reemplazan los emojis: look consistente). */
.na-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; flex: 0 0 auto; }
.na-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.nav-home .na-icon, .nav-transversal .na-icon { margin-right: 8px; }
.nav-area-head .na-label { flex: 1; }
.nav-area-head .na-chev { color: rgba(247,243,235,0.5); font-size: 1.15rem; line-height: 1; transition: transform 0.18s ease; }
.nav-area.open > .nav-area-head .na-chev { transform: rotate(90deg); }
.nav-area-items { display: grid; gap: 2px; overflow: hidden; max-height: 0; opacity: 0; transition: max-height 0.22s ease, opacity 0.18s ease; }
.nav-area.open > .nav-area-items { max-height: 680px; opacity: 1; margin-top: 2px; }
.nav-area-items .nav-item { padding-left: 30px; font-size: 0.9rem; }
/* Sub-grupos dentro de un área (2º nivel, solo divisor visual — no colapsable) */
.nav-subgroup { padding: 8px 12px 3px 16px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: rgba(247,243,235,0.42); }
.nav-subgroup:first-child { padding-top: 4px; }
.nav-home { font-weight: 700; }
.nav-transversal { display: grid; gap: 2px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.12); }
@media (prefers-reduced-motion: reduce){ .nav-area-items, .nav-area-head .na-chev { transition: none; } }

/* ===== Tablero de control (Inicio) ===== */
/* ===== Tablero por ÁREA (boceto): tarjetas claras iguales, 2 columnas ===== */
.ini-areas { position: relative; }
.tab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.tab-slot { position: relative; display: flex; }
.tab-card { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius, 16px); padding: 16px 18px; box-shadow: var(--shadow-sm); position: relative; min-height: 118px; cursor: pointer; transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s; display: flex; flex-direction: column; font: inherit; }
.tab-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
/* Acento de estado (Fase 3): el color comunica alerta. Ámbar = atención, rojo = problema. */
.tab-card.tab-warn { border-left: 3px solid var(--amber); }
.tab-card.tab-bad { border-left: 3px solid var(--money-neg); }
.tab-card.tab-warn .tab-sub2 { color: var(--amber); font-weight: 600; }
.tab-card.tab-bad .tab-sub2 { color: var(--money-neg); font-weight: 600; }
.tab-edit-btn { font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--green-2); background: transparent; border: none; cursor: pointer; padding: 0; }
.tab-edit-btn:hover { color: var(--green); text-decoration: underline; }
.tab-grid.is-editing .tab-card { pointer-events: none; }
.tab-slot.is-off .tab-card { opacity: 0.42; }
.tab-ec-row { position: absolute; top: 6px; left: 6px; z-index: 2; display: flex; gap: 4px; }
.tab-ec { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 0.9rem; line-height: 1; cursor: pointer; box-shadow: var(--shadow-sm); display: inline-flex; align-items: center; justify-content: center; }
.tab-ec:hover { border-color: var(--green); color: var(--green); }
.tab-ec.off { color: var(--money-neg); }
.tab-ec.on { color: var(--money-pos); }
.tab-ec .ic { width: 15px; height: 15px; vertical-align: 0; }
/* Íconos SVG de línea (set único para acciones repetidas). Heredan color del texto. */
.ic { display: inline-block; vertical-align: -3px; }
.pc-mini { display: inline-flex; align-items: center; gap: 4px; }
.pc-mini .ic { vertical-align: 0; width: 15px; height: 15px; }
/* Área-tag (pill de rubro) arriba a la izquierda de la tarjeta. */
.area-tag { align-self: flex-start; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 8px; border-radius: 999px; margin-bottom: 8px; }
.area-tag.t-emp { background: rgba(47,93,124,.13); color: var(--blue); }
.area-tag.t-agr { background: rgba(21,128,61,.1); color: var(--money-pos); }
.area-tag.t-gan { background: rgba(176,114,31,.15); color: var(--amber); }
.area-tag.t-maq { background: rgba(47,93,124,.13); color: var(--blue); }
.tab-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); font-weight: 700; }
.tab-big { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: clamp(1.5rem, 3vw, 2rem); line-height: 1.05; margin-top: 6px; font-variant-numeric: tabular-nums; color: var(--green); }
.tab-big .tab-u { font-family: 'Inter', system-ui, sans-serif; font-weight: 500; font-size: 0.9rem; color: var(--muted); }
.tab-big.money-neg { color: var(--money-neg); }
.tab-big.money-pos { color: var(--money-pos); }
.tab-sub2 { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }
.ini-spark { width: 100%; height: 32px; margin-top: 10px; }
.ini-spark polyline { fill: none; stroke: var(--green-bright, var(--green)); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab-gauge { width: 118px; height: 72px; margin-top: 2px; }
.tab-gauge-val { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 20px; fill: var(--green); }
@media (max-width: 640px){ .tab-grid { grid-template-columns: 1fr; } }
/* De-duplicación de Inicio: el Tablero es ahora el único bloque de métricas;
   los KPIs viejos (#kpiGrid) repetían margen/ingreso/%cosechado. Las órdenes
   pendientes y las alertas viven en otros contenedores (siguen visibles). */
#view-inicio > #kpiGrid { display: none; }
/* El héroe del Inicio es ahora el BENTO (#tableroPanel). El hero viejo
   (#inicioHero: "Managro 25-26 · lotes · ha" + barras) competía como segundo
   bloque grande; lo retiramos para no tener dos héroes apilados. (El [hidden]
   no alcanzaba porque .inicio-hero pone display:flex.) */
#view-inicio > #inicioHero { display: none !important; }
/* Órdenes / Alertas como botones chicos con número (pantalla de teléfono): el
   panel se despliega al hacer clic, no ocupa lugar por defecto. */
.inicio-toggles { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.inicio-toggle { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 600; font-size: 0.9rem; color: var(--text-2); cursor: pointer; }
.inicio-toggle:hover { border-color: var(--green); color: var(--green); }
.inicio-toggle.open { background: var(--surface-strong); border-color: var(--green); color: var(--green); }
.inicio-toggle .it-ic { font-size: 1rem; line-height: 1; }
.it-count { font-size: 0.74rem; font-weight: 700; min-width: 20px; text-align: center; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.it-count.alert { background: rgba(192, 57, 43, 0.14); color: var(--money-neg); }
/* OJO: la regla base ".split { display:grid }" le ganaba al atributo hidden, así
   que la panel de Alertas/Órdenes (#iniDetail) quedaba SIEMPRE expandida en el
   Inicio. Esta regla fuerza que hidden gane (se abre con "+N más"). */
#view-inicio .split[hidden] { display: none !important; }
#view-inicio .split:not([hidden]) { display: block; }
#view-inicio .split > .panel { margin-bottom: 12px; }
#view-inicio #iniDetail { margin-top: 8px; }
/* Botón "Cargar por voz" (IA universal) con sub-línea explicativa. */
.cap-btn .cap-tx small { display: block; font-weight: 400; font-size: 0.74rem; color: var(--muted); margin-top: 2px; line-height: 1.25; }
.cap-ai { border-color: var(--green); box-shadow: inset 0 0 0 1px rgba(33, 80, 58, 0.12); }
.cap-ai .cap-ic { color: var(--green); }

/* ===== Inicio rediseñado (boceto aprobado: bento claro) ===== */
/* Topbar: saludo grande (Fraunces) + fecha; pills de campaña/sociedad a la derecha. */
.ini-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.ini-hi { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.28rem; color: var(--text); }
.ini-date { color: var(--muted); font-size: 0.86rem; margin-top: 1px; text-transform: capitalize; }
.ini-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.ini-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 13px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
/* Fila de HÉROE: 4 KPIs de empresa, tarjetas claras iguales. */
/* Héroe del Inicio: un PROTAGONISTA (margen, verde, grande) + 2 KPI secundarios.
   Jerarquía clara: la pregunta "¿cómo venís?" se responde de un vistazo. */
.ini-hero-row { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; margin-bottom: 16px; align-items: stretch; }
.ini-hero-main { text-align: left; cursor: pointer; font: inherit; border: 0; border-radius: var(--card-radius, 16px); padding: 16px 20px; position: relative; overflow: hidden; display: flex; flex-direction: column; min-height: 108px; color: #f3efe3; box-shadow: var(--shadow); background: radial-gradient(120% 120% at 85% -20%, rgba(195,155,69,.28), transparent 55%), linear-gradient(165deg, #1e4835, #173a2b 62%, #12321f); transition: transform 0.14s, box-shadow 0.14s; }
.ini-hero-main:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg, var(--shadow)); }
.ihm-k { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: #e4c574; font-weight: 700; }
.ihm-num { font-family: 'Fraunces', Georgia, serif; font-weight: 600; line-height: 0.98; margin-top: auto; padding-top: 8px; font-size: clamp(1.7rem, 2.8vw, 2.15rem); letter-spacing: -0.02em; color: #fbf7ec; }
.ini-hero-main.neg .ihm-num { color: #f4b8ac; }
.ihm-sub { font-size: 0.84rem; color: #cdd6c8; margin-top: 8px; }
.ini-hero-side { display: grid; grid-template-rows: 1fr 1fr; gap: 14px; min-width: 0; }
.ini-kpi { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius, 16px); padding: 14px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; font: inherit; transition: transform 0.14s, box-shadow 0.14s; }
.ini-kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.ini-kpi.accent::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--wheat); }
.ikp-lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; }
.ikp-num { font-family: 'Fraunces', Georgia, serif; font-weight: 700; line-height: 1; margin-top: auto; padding-top: 8px; font-size: clamp(1.3rem, 2.2vw, 1.7rem); color: var(--green); }
.ini-kpi.neg .ikp-num { color: var(--money-neg); }
.ikp-slash { color: var(--faint); font-weight: 400; font-size: 0.7em; }
.ikp-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.ikp-gauge { margin-top: auto; }
.ikp-gauge .tab-gauge { width: 110px; height: 66px; }
/* Franja "Avance de campaña": 4 barras finas bajo los KPIs (reincorpora el
   estado sembrado/cosechado/despachado/cierre sin volver al hero viejo). */
/* Relojes de campaña: forma + color se leen de un vistazo. */
.ini-avance { margin-bottom: 22px; padding: 14px 18px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--card-radius, 16px); box-shadow: var(--shadow-sm); }
.ini-avance:empty { display: none; }
.iav-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.iav-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; white-space: nowrap; }
.iav-ha { font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.iav-rings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.iring { background: none; border: none; padding: 6px 0 2px; cursor: pointer; font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.iring-svg { display: block; }
.irg-track { stroke: var(--surface-strong); }
.irg-fill { transition: stroke-dashoffset .5s ease; }
.irg-fill.g-siem { stroke: var(--green); }
.irg-fill.g-cos { stroke: #3d8a5f; }
.irg-fill.g-desp { stroke: var(--wheat); }
.irg-val { fill: var(--text); font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 17px; }
.iring figcaption { font-size: 0.78rem; color: var(--text-2, var(--muted)); font-weight: 600; }
.iring:hover .irg-fill { filter: brightness(1.08); }
/* Layout: áreas a lo ANCHO arriba; cargar/trabajar ABAJO, en dos columnas.
   (Antes iban apretados en una columna a la derecha y quedaba amontonado.) */
.ini-main { display: block; }
.ini-col-left { margin-bottom: 24px; }
/* "Ir a…" ocupa TODO el ancho (antes iba apretado a la derecha para dejar lugar a
   los botones de carga, que se fueron al "+"). Botones parejos que llenan la fila. */
.ini-col-right { display: block; }
/* Contadores vestigiales (eran badges de botones-toggle que ya no existen):
   setInicioToggleCount los des-ocultaba y dejaba un "74" suelto en el Inicio. */
#ordersCount, #alertsCount { display: none !important; }
.ini-cr-block { min-width: 0; }
.ini-sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 2px 2px 12px; }
.ini-sec-h h2 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.12rem; margin: 0; }
.ini-sub-gap { margin-top: 18px; }
/* "Mirá esto hoy": banner de foco, PRIMERO en el Inicio (lo accionable arriba). */
.ini-revisa { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin: 0 0 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--wheat); border-radius: var(--card-radius, 16px); box-shadow: var(--shadow-sm); }
.ini-revisa:empty { display: none; }
.ini-revisa-link { margin-left: auto; background: none; border: none; color: var(--green-2); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.ini-revisa-link:hover { text-decoration: underline; }
.revisa-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--green-2); font-weight: 700; margin-right: 2px; }
.ini-chip { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 0.84rem; font-weight: 600; border: 1px solid transparent; cursor: pointer; }
.ini-chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.ini-chip.warn { background: var(--wheat-tint); color: var(--amber); border-color: rgba(176,114,31,.2); } .ini-chip.warn .dot { background: var(--amber); }
.ini-chip.bad { background: rgba(192,57,43,.1); color: var(--money-neg); border-color: rgba(192,57,43,.2); } .ini-chip.bad .dot { background: var(--money-neg); }
.ini-chip.info { background: var(--surface); color: var(--muted); border-color: var(--line-strong); } .ini-chip.info .dot { background: var(--faint); }
.ini-chip:hover { filter: brightness(0.97); }
.ini-ok { color: var(--pos, var(--money-pos)); font-weight: 600; font-size: 0.86rem; }
/* Dos columnas: Cargar / Trabajar */
.ini-cols2 { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; margin-top: 4px; }
.ini-sub { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; margin: 2px 2px 9px; }
.ini-cargar { display: grid; gap: 10px; }
.ini-act { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; text-align: left; font: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
.ini-act:hover { border-color: var(--green); box-shadow: var(--shadow); transform: translateY(-1px); }
.ini-act.primary { border-color: var(--green); box-shadow: inset 0 0 0 1px rgba(33,80,58,.1); }
.ini-act-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-strong); display: grid; place-items: center; flex: 0 0 auto; color: var(--green); }
/* Set SVG monolínea único: mismo grosor, heredan el color del contenedor. */
.ini-act-ic svg { width: 21px; height: 21px; }
.ini-tb-ic svg { width: 24px; height: 24px; }
.ini-act-ic svg, .ini-tb-ic svg { stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ini-tb-ic { color: var(--green); }
.ini-act-tx b { display: block; font-size: 0.92rem; color: var(--text); }
.ini-act-tx small { color: var(--muted); font-size: 0.76rem; line-height: 1.25; display: block; margin-top: 1px; }
.ini-trab { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
.ini-tb { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 6px; cursor: pointer; font: inherit; transition: border-color .12s, transform .12s; }
.ini-tb:hover { border-color: var(--green); transform: translateY(-1px); }
.ini-tb-ic { font-size: 1.3rem; line-height: 1; }
.ini-tb span:last-child { font-size: 0.78rem; font-weight: 600; color: var(--text); }
/* ===== VISTA del Inicio: 4 modelos elegibles (A relojes / B billetera /
   C por actividad / D foco). Mismos datos; cambia orden y qué se muestra. ===== */
.ini-top-right { display: flex; align-items: center; gap: 10px; }
.ini-layout-wrap { position: relative; }
.ini-layout-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--text-2); cursor: pointer; }
.ini-layout-btn:hover { border-color: var(--green); color: var(--text); }
.ini-layout-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.ini-layout-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: min(290px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-lg, var(--shadow)); padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.ini-layout-menu[hidden] { display: none !important; }
.ilm-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 700; padding: 2px 8px 4px; }
.ilm-item { text-align: left; background: var(--surface); border: 1px solid transparent; border-radius: 10px; padding: 9px 11px; cursor: pointer; font: inherit; }
.ilm-item:hover { background: var(--surface-strong); }
.ilm-item[aria-checked="true"] { border-color: var(--green); background: var(--surface-strong); }
.ilm-item b { display: block; font-size: 0.9rem; color: var(--text); }
.ilm-item[aria-checked="true"] b::after { content: " ✓"; color: var(--green); }
.ilm-item small { display: block; font-size: 0.76rem; color: var(--muted); margin-top: 1px; }

/* Bloque PLATA (modelo Billetera): plata para mirar, en fila */
.ini-plata { margin-bottom: 16px; }
.ini-plata:empty { display: none; }
.ini-plata-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ini-plata-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; box-shadow: var(--shadow-sm); cursor: pointer; font: inherit; display: flex; flex-direction: column; gap: 4px; }
.ini-plata-card:hover { border-color: var(--green); transform: translateY(-1px); }
.ipc-k { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.ipc-v { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 1.15rem; color: var(--green); }
@media (max-width: 560px){ .ini-plata-row { grid-template-columns: 1fr; } }

/* Bloque ACTIVIDADES (modelos Billetera y Por actividad): resultado por actividad */
.ini-actividades { margin-bottom: 18px; }
.ini-actividades:empty { display: none; }
.ia-list { display: flex; flex-direction: column; gap: 8px; }
.ia-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 15px; box-shadow: var(--shadow-sm); cursor: pointer; font: inherit; text-align: left; }
.ia-row:hover { border-color: var(--green); }
.ia-flow { font-size: 0.8rem; color: var(--muted); flex: 1; }
.ia-net { font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 1.05rem; margin-left: auto; }

/* --- Disposición por modelo: orden + mostrar/ocultar (mismos datos) --- */
#view-inicio.active { display: flex; flex-direction: column; }
#view-inicio.active > * { order: 5; }
#view-inicio.active > .ini-topbar { order: 0; }
#view-inicio.active > #iniDetail { order: 90; }
#view-inicio.active > .ini-last { order: 100; }
#iniPlata, #iniActividades { display: none; }
/* A · Relojes: mirá-esto-hoy, héroe, relojes, tablero de tiles */
#view-inicio[data-layout="A"] > #iniRevisa { order: 1; }
#view-inicio[data-layout="A"] > #iniHeroRow { order: 2; }
#view-inicio[data-layout="A"] > #iniAvance { order: 3; }
#view-inicio[data-layout="A"] > .ini-main { order: 4; }
/* B · Billetera: héroe, plata, actividades (lista), mirá-esto-hoy, accesos */
#view-inicio[data-layout="B"] > #iniHeroRow { order: 1; }
#view-inicio[data-layout="B"] > #iniPlata { order: 2; display: block; }
#view-inicio[data-layout="B"] > #iniActividades { order: 3; display: block; }
#view-inicio[data-layout="B"] > #iniRevisa { order: 4; }
#view-inicio[data-layout="B"] > .ini-main { order: 5; }
#view-inicio[data-layout="B"] > #iniAvance { display: none; }
#view-inicio[data-layout="B"] .ini-col-left { display: none; }
/* C · Por actividad: héroe, actividades (tarjetas), mirá-esto-hoy, accesos */
#view-inicio[data-layout="C"] > #iniHeroRow { order: 1; }
#view-inicio[data-layout="C"] > #iniActividades { order: 2; display: block; }
#view-inicio[data-layout="C"] > #iniRevisa { order: 3; }
#view-inicio[data-layout="C"] > .ini-main { order: 4; }
#view-inicio[data-layout="C"] > #iniAvance { display: none; }
#view-inicio[data-layout="C"] .ini-col-left { display: none; }
#view-inicio[data-layout="C"] .ia-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#view-inicio[data-layout="C"] .ia-row { flex-direction: column; align-items: flex-start; gap: 6px; min-height: 92px; }
#view-inicio[data-layout="C"] .ia-flow { flex: none; font-size: 0.72rem; }
#view-inicio[data-layout="C"] .ia-net { margin-left: 0; font-size: 1.25rem; }
@media (max-width: 480px){ #view-inicio[data-layout="C"] .ia-list { grid-template-columns: 1fr 1fr; } }
/* D · Foco del día: mirá-esto-hoy (arriba), héroe, relojes, accesos */
#view-inicio[data-layout="D"] > #iniRevisa { order: 1; }
#view-inicio[data-layout="D"] > #iniHeroRow { order: 2; }
#view-inicio[data-layout="D"] > #iniAvance { order: 3; }
#view-inicio[data-layout="D"] > .ini-main { order: 4; }
#view-inicio[data-layout="D"] .ini-col-left { display: none; }

/* Últimas cargas: fuera de la vista, a un clic */
.ini-last { margin-top: 20px; }
.ini-last .recent-list { margin-top: 10px; }
@media (max-width: 900px){
  .ini-hero-row { grid-template-columns: 1fr; }
  .ini-hero-side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .ini-col-right { grid-template-columns: 1fr; }
}
@media (max-width: 480px){
  .ini-hero-main { min-height: 128px; padding: 18px 18px; }
  .ini-hero-side { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ini-trab { grid-template-columns: repeat(3, 1fr); }
  .ini-topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ===== Secciones plegables (decisión 2: resumen primero, detalle a un toque) ===== */
.collapsible-panel .sec-toggle { cursor: pointer; position: relative; padding-right: 30px; user-select: none; }
.collapsible-panel .sec-toggle:hover { color: var(--green-2); }
.collapsible-panel .sec-toggle::after { content: "▾"; position: absolute; right: 2px; top: 0.12em; font-size: 0.82em; font-weight: 400; color: var(--muted); transition: transform 0.18s ease; }
.collapsible-panel.is-collapsed .sec-toggle::after { transform: rotate(-90deg); }
.collapsible-panel.is-collapsed > .panel-head { margin-bottom: 0; }
.collapsible-panel.is-collapsed > .panel-head .subcopy,
.collapsible-panel.is-collapsed > .panel-head .section-actions { display: none; }
.collapsible-panel.is-collapsed > :not(.panel-head) { display: none !important; }
.collapsible-panel .sec-toggle:focus-visible { outline: 2px solid var(--wheat, #c39b45); outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { .collapsible-panel .sec-toggle::after { transition: none; } }

/* ===== Barra de pestañas MÓVIL (decisión 4: nav al alcance del pulgar) ===== */
.tabbar { display: none; }
.tab-sheet[hidden] { display: none; }
.tab-sheet { position: fixed; inset: 0; z-index: 70; }
.tab-sheet-backdrop { position: absolute; inset: 0; background: rgba(20,23,20,0.42); opacity: 0; transition: opacity 0.2s ease; }
.tab-sheet.open .tab-sheet-backdrop { opacity: 1; }
.tab-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 34px rgba(0,0,0,0.25); padding: 4px 14px calc(16px + env(safe-area-inset-bottom, 0px)); max-height: 76vh; overflow-y: auto; transform: translateY(101%); transition: transform 0.22s cubic-bezier(.32,.72,0,1); }
.tab-sheet.open .tab-sheet-panel { transform: translateY(0); }
.tsh-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 2px 8px; position: sticky; top: 0; background: var(--surface); }
.tsh-head b { font-family: var(--display); font-size: 1.2rem; letter-spacing: -0.01em; }
.tsh-x { background: none; border: 0; font-size: 1.05rem; color: var(--muted); cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.tsh-grp { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); padding: 13px 4px 3px; }
.tsh-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 10px; padding: 13px 12px; font-size: 1.02rem; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; }
.tsh-item:active { background: var(--surface-2); }
.tsh-item.active { background: var(--surface-strong); color: var(--green-2); }
@media (prefers-reduced-motion: reduce) { .tab-sheet-backdrop, .tab-sheet-panel { transition: none; } }

@media (max-width: 760px) {
  .mobile-nav { display: none !important; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--green); box-shadow: 0 -2px 14px rgba(0,0,0,0.2);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: 0; color: rgba(255,255,255,0.72); padding: 9px 2px 8px;
    font-family: inherit; cursor: pointer; min-height: 54px; position: relative;
  }
  .tabbar-btn .tb-ic svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
  .tabbar-btn .tb-lb { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.01em; }
  .tabbar-btn.active { color: #fff; }
  .tabbar-btn.active::before { content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--wheat); }
  .main { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)) !important; }
  .ai-float { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .gs-btn { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
