/* Panel de Operación. Todo el diseño ancho vive dentro de @media (min-width:1024px); en teléfono no cambia nada. */
.bottom .ops-only { display: none; }
.ops-scrim, .ops-side { display: none; }

@media (min-width: 1024px) {
  #app.ops-wide { max-width: none; margin: 0; box-shadow: none; background: var(--cream); }
  body:has(#app.ops-wide) { background: var(--cream); }
  .ops-wide .topbar { padding: 14px clamp(24px, 3vw, 56px); }
  .ops-wide .topbar .who b { font-size: 1.05rem; }
  .ops-wide main.pad { padding: 8px clamp(24px, 3vw, 56px) 48px; max-width: 1760px; width: 100%; margin: 0 auto; }
  /* La barra inferior pasa a ser una barra de pestañas arriba */
  .ops-wide .bottom { position: static; order: 1; display: flex; gap: 6px; background: transparent; border: 0; padding: 12px clamp(24px, 3vw, 56px) 0; max-width: 1760px; width: 100%; margin: 0 auto; }
  .ops-wide .bottom button { flex: 0 0 auto; padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: .95rem; color: var(--purple) !important; text-decoration: none; }
  .ops-wide .bottom button.on { background: var(--purple); color: #fff !important; border-color: var(--purple); text-decoration: none; }
  .ops-wide .bottom .ops-only { display: flex; order: -1; }
  .ops-wide main.pad { order: 2; }
  /* Las demás pestañas aprovechan el ancho en dos columnas */
  .ops-wide main.pad:not(:has(.ops)) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
  .ops-wide main.pad:not(:has(.ops)) > * { min-width: 0; }
  .ops-wide main.pad:not(:has(.ops)) > :first-child:not(.card) { grid-column: 1 / -1; }

  .ops { padding-top: 12px; }
  .ops-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
  .ops-head h1 { font-family: var(--display); font-size: clamp(2rem, 2.6vw, 2.8rem); color: var(--ink); line-height: 1.05; }
  .ops-head p { color: var(--muted); font-weight: 500; margin-top: 4px; }
  .ops-tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
  .ops-tabs button { padding: 9px 20px; border-radius: 10px; font-weight: 700; color: var(--purple); }
  .ops-tabs button.on { background: var(--magenta); color: #fff; }
  .ops-tabs button:not(.on):hover { background: var(--cream-2); }

  .ops-nav { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
  .ops-nav button { padding: 7px 14px; border-radius: 10px; background: #fff; border: 1px solid var(--line); font-weight: 600; font-size: .9rem; color: var(--purple); }
  .ops-nav button:disabled { opacity: .4; cursor: default; }
  .ops-nav button:not(:disabled):hover { border-color: var(--magenta); }
  .ops-nav .ops-clear { background: var(--magenta); color: #fff; border-color: var(--magenta); margin-left: auto; }

  .ops-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
  .ops-kpi { background: var(--purple); color: #fff; border-radius: 20px; padding: 20px 24px; position: relative; overflow: hidden; }
  .ops-kpi:nth-child(1) { background: linear-gradient(135deg, var(--ink), var(--purple)); }
  .ops-kpi:nth-child(1)::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: var(--magenta); opacity: .35; }
  .ops-kpi .k { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
  .ops-kpi .v { font-family: var(--display); font-size: clamp(2.2rem, 3vw, 3.2rem); line-height: 1.1; margin: 6px 0 2px; }
  .ops-kpi .v small { font-family: var(--font); font-size: 1rem; opacity: .7; }
  .ops-kpi .s { font-size: .85rem; min-height: 1.2em; }
  .ops-d { opacity: .85; }
  .ops-d.up { color: #9cf08f; opacity: 1; }
  .ops-d.down { color: #ffb3d4; opacity: 1; }

  .ops-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .ops-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px 24px; min-width: 0; }
  .ops-card.span2 { grid-column: span 2; }
  .ops-card.span3 { grid-column: span 3; }
  .ops-card h2 { font-family: var(--display); font-size: 1.3rem; color: var(--ink); margin-bottom: 2px; }
  .ops-sub { color: var(--muted); font-size: .86rem; margin-bottom: 12px; }
  .ops-note { color: var(--muted); font-size: .84rem; margin-top: 12px; }
  .ops-empty { color: var(--muted); padding: 24px 0; }
  .ops-svg { width: 100%; height: auto; display: block; }
  .ops-ax { font: 500 11px var(--font); fill: var(--muted); }
  .ops-ax.today { fill: var(--magenta); font-weight: 700; }
  .ops-ax2 { font: 400 10px var(--font); fill: var(--muted); }
  .ops-val { font: 500 11px "IBM Plex Mono", ui-monospace, monospace; fill: var(--ink); }
  .ops-dn { font: 600 24px var(--display); fill: var(--ink); }
  .ops-bar.click { cursor: pointer; }
  .ops-bar.click:hover rect:not(:first-child), .ops-bar.sel rect:not(:first-child) { filter: brightness(1.12) saturate(1.2); }
  .ops-bar.sel rect:first-child { fill: rgba(226,24,124,.08); }

  .ops-donutwrap { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; align-items: center; margin-top: 8px; }
  .ops-donut { width: 100%; height: auto; }
  .ops-legend { list-style: none; display: grid; gap: 8px; }
  .ops-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 40px; gap: 8px; align-items: center; font-size: .9rem; }
  .ops-legend i { width: 12px; height: 12px; border-radius: 4px; }
  .ops-legend b { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; font-size: .84rem; }
  .ops-legend em { font-style: normal; color: var(--muted); text-align: right; font-size: .82rem; }

  .ops-tablewrap { max-height: 460px; overflow: auto; border-radius: 12px; border: 1px solid var(--line); }
  .ops-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
  .ops-table th { position: sticky; top: 0; background: var(--cream-2); text-align: left; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; }
  .ops-table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
  .ops-table tr:hover td { background: #fdf9f2; }
  .ops-table tr.click { cursor: pointer; }
  .ops-table .num { text-align: right; font-family: "IBM Plex Mono", ui-monospace, monospace; white-space: nowrap; }
  .ops-table td.mono { white-space: nowrap; }
  .ops-table .mono span { display: block; color: var(--muted); font-size: .78rem; font-family: var(--font); }
  .ops-table .note { color: var(--muted); max-width: 320px; }
  .ops-link { font-weight: 700; color: var(--purple); text-align: left; border-bottom: 1px dashed var(--magenta); }
  .ops-link:hover { color: var(--magenta); }
  .ops-chip { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
  .ops-chip i { width: 10px; height: 10px; border-radius: 50%; }

  .ops-rank { list-style: none; display: grid; gap: 4px; margin-top: 10px; }
  .ops-rank button { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; text-align: left; padding: 8px 10px; border-radius: 12px; }
  .ops-rank button:hover { background: var(--cream-2); }
  .ops-rank .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ops-rank b { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; font-size: .86rem; text-align: right; }
  .ops-rank .bar { grid-column: 1 / -1; grid-row: 2; height: 8px; background: var(--cream-2); border-radius: 6px; overflow: hidden; }
  .ops-rank .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--magenta), var(--purple)); border-radius: 6px; }
  .ops-rank em { grid-column: 1 / -1; grid-row: 3; font-style: normal; color: var(--muted); font-size: .78rem; }

  /* Panel lateral del cliente */
  .ops-scrim.open { display: block; position: fixed; inset: 0; background: rgba(26,13,61,.35); z-index: 60; }
  .ops-side.open { display: flex; flex-direction: column; gap: 6px; position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 92vw); background: var(--cream); z-index: 61; padding: 24px; overflow-y: auto; box-shadow: -20px 0 50px rgba(26,13,61,.25); animation: opsIn .22s ease-out; }
  @keyframes opsIn { from { transform: translateX(40px); opacity: 0; } }
  .ops-side header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
  .ops-side header small { color: var(--magenta); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: .72rem; }
  .ops-side h2 { font-family: var(--display); font-size: 1.7rem; line-height: 1.1; }
  .ops-side h3 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
  .ops-x { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
  .ops-sidekpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 6px; }
  .ops-sidekpis div { background: var(--purple); color: #fff; border-radius: 14px; padding: 12px 14px; }
  .ops-sidekpis b { display: block; font-family: var(--display); font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
  .ops-sidekpis span { font-size: .78rem; opacity: .8; }
  .ops-hist { list-style: none; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
  .ops-hist li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); font-size: .9rem; }
  .ops-hist li:first-child { border-top: 0; }
  .ops-hist span { display: block; color: var(--muted); font-size: .8rem; }
  .ops-hist strong { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; white-space: nowrap; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .ops-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ops-grid { grid-template-columns: 1fr; }
  .ops-card.span2, .ops-card.span3 { grid-column: auto; }
}
@media (min-width:1024px){ .ops-val.sm { font-size: 9px; } }

/* Leyenda «Tipo de material»: etiqueta en su columna, kg y % alineados a la derecha, sin solaparse (escritorio y teléfono). */
.ops-donutwrap { display: grid; grid-template-columns: 1fr; gap: 14px; justify-items: center; }
.ops-donutwrap .ops-donut { width: 100%; max-width: 170px; height: auto; }
.ops-legend { list-style: none; display: grid; gap: 8px; width: 100%; margin: 0; padding: 0; }
.ops-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 3.2em; column-gap: 12px; align-items: center; font-size: .9rem; line-height: 1.25; }
.ops-legend li.muted { display: block; }
.ops-legend i { width: 12px; height: 12px; border-radius: 4px; }
.ops-legend span { min-width: 0; overflow-wrap: anywhere; position: static; }
.ops-legend b { white-space: nowrap; text-align: right; font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 500; font-size: .84rem; position: static; }
.ops-legend em { white-space: nowrap; text-align: right; font-style: normal; color: var(--muted, #6b6480); font-size: .82rem; position: static; }

/* Vista «Materiales»: kilos por tipo de material por semana, por mes y totales */
.ops-mg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.ops-mg button { padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line, #e6dfd3); font-weight: 700; font-size: .9rem; color: var(--purple, #2c1a6b); }
.ops-mg button.on { background: var(--purple, #2c1a6b); color: #fff; border-color: var(--purple, #2c1a6b); }
.ops-legend.ops-legend-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; }
.ops-legend.ops-legend-row li { display: flex; align-items: center; gap: 8px; }
.ops-mattable td, .ops-mattable th { white-space: nowrap; }
.ops-mattable td:first-child, .ops-mattable th:first-child { position: sticky; left: 0; background: #fff; z-index: 1; }
.ops-matname { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.ops-matname i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.ops-mattable .ops-tot td { font-weight: 700; border-top: 2px solid var(--line, #e6dfd3); }
.ops-mattable td.num, .ops-mattable th.num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1023px) {
  .ops { padding-top: 8px; }
  .ops-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
  .ops-head h1 { font-family: var(--display); font-size: 1.8rem; color: var(--ink); }
  .ops-head p { color: var(--muted); }
  .ops-tabs { display: flex; flex-wrap: wrap; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 4px; }
  .ops-tabs button { padding: 8px 12px; border-radius: 10px; font-weight: 700; color: var(--purple); }
  .ops-tabs button.on { background: var(--magenta); color: #fff; }
  .ops-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .ops-kpi { background: var(--purple); color: #fff; border-radius: 16px; padding: 14px; }
  .ops-kpi:nth-child(1) { background: linear-gradient(135deg, var(--ink), var(--purple)); }
  .ops-kpi .k { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
  .ops-kpi .v { font-family: var(--display); font-size: 1.6rem; line-height: 1.15; margin: 4px 0 2px; overflow-wrap: anywhere; }
  .ops-kpi .v small { font-size: .85rem; opacity: .7; }
  .ops-kpi .s { font-size: .75rem; }
  .ops-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .ops-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; min-width: 0; }
  .ops-card h2 { font-family: var(--display); font-size: 1.15rem; color: var(--ink); }
  .ops-sub, .ops-note { color: var(--muted); font-size: .82rem; margin-bottom: 10px; }
  .ops-svg { width: 100%; height: auto; display: block; }
  .ops-ax { font: 500 11px var(--font); fill: var(--muted); }
  .ops-ax2 { font: 400 10px var(--font); fill: var(--muted); }
  .ops-ax.today { fill: var(--magenta); font-weight: 700; }
  .ops-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .ops-table { border-collapse: collapse; font-size: .85rem; width: 100%; }
  .ops-table th, .ops-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
  .ops-mg button { flex: 1 1 0; }
  .ops-scrim:not(.open), .ops-side:not(.open) { display: none; }
}
.ops-kpi .v .ops-kpitxt { display: block; font-size: clamp(1.3rem, 1.8vw, 1.9rem); line-height: 1.15; }
@media (max-width: 1023px) {
  .ops-val { font: 600 9px "IBM Plex Mono", ui-monospace, monospace; fill: var(--ink); }
  .ops-ax { font-size: 9px; }
  .ops-ax2 { display: none; }
}
/* Referencia de nutrientes por material */
.ops-nutgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.ops-nut { border: 1px solid var(--line, #e6dfd3); border-radius: 14px; background: var(--cream, #faf6ef); padding: 0; }
.ops-nut summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 12px 1fr; gap: 2px 10px; align-items: center; padding: 12px 14px; }
.ops-nut summary::-webkit-details-marker { display: none; }
.ops-nut summary i { width: 12px; height: 12px; border-radius: 4px; }
.ops-nut summary b { color: var(--ink, #1a0d3d); }
.ops-nut summary b::after { content: " ▾"; color: var(--muted, #6b6480); font-weight: 400; }
.ops-nut[open] summary b::after { content: " ▴"; }
.ops-nut summary span { grid-column: 2; color: var(--muted, #6b6480); font-size: .8rem; }
.ops-nut h4 { margin: 4px 14px 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--magenta, #e2187c); }
.ops-nut dl { margin: 0 14px 8px; display: grid; gap: 2px; }
.ops-nut dl div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line, #e6dfd3); font-size: .85rem; }
.ops-nut dt { font-weight: 700; color: var(--purple, #2c1a6b); }
.ops-nut dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ops-nut-hum, .ops-nut-src { margin: 6px 14px; font-size: .78rem; color: var(--muted, #6b6480); }
.ops-nut-src { margin-bottom: 12px; font-style: italic; }
@media (max-width: 1023px) { .ops-nutgrid { grid-template-columns: 1fr; } }
.ops-nut .ops-note { margin: 2px 14px 8px; }
.ops-nut-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ops-nut-chips em { font-style: normal; font-size: .74rem; font-weight: 600; color: var(--purple, #2c1a6b); background: #fff; border: 1px solid var(--line, #e6dfd3); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
/* Nutrientes estimados en lo recolectado */
.ops-npick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 8px; }
.ops-npick label { font-weight: 700; color: var(--purple, #2c1a6b); font-size: .9rem; }
.ops-npick select { font: inherit; padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line, #e6dfd3); background: #fff; color: var(--ink, #1a0d3d); max-width: 100%; }
.ops-h3 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--magenta, #e2187c); margin: 14px 0 6px; }
.ops-nmtable td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ops-nm dd b { display: block; font-weight: 600; }
.ops-nm dd small { color: var(--muted, #6b6480); font-size: .76rem; }
.ops-nm summary b::after { content: none; }
.ops-formula { background: var(--cream, #faf6ef); border-radius: 10px; padding: 8px 12px; }
#ops-nutmass .ops-tablewrap { max-height: none; }
#ops-nutmass .ops-nm dt, #ops-nutmass dl dt { min-width: 7.5em; white-space: nowrap; }
.ops-nrow { cursor: pointer; }
.ops-nrow:hover td, .ops-nrow.on td { background: rgba(232,30,120,.06); }
.ops-caret { display: inline-block; width: 1em; color: #e81e78; }
.ops-nprov td { background: #fbf7f0; padding: 10px 14px 14px; }
.ops-nprov-h { margin: 0 0 6px; font-weight: 600; font-size: .9em; }
.ops-nprov ol { list-style: none; margin: 0; padding: 0; }
.ops-nprov li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid rgba(0,0,0,.06); font-family: inherit; }
.ops-nprov li span { display: flex; flex-direction: column; min-width: 0; }
.ops-nprov li .num { text-align: right; white-space: nowrap; }
.ops-nprov small { opacity: .7; font-size: .82em; white-space: normal; }
.ops-nut summary b { white-space: normal; overflow-wrap: anywhere; }
.ops-nut-chips em { white-space: normal; }
