/* SueloMec APM — estilos
   Autor: Álvaro Puentes Molina · SENA */
:root {
  --brand: #6b4423; --brand-2: #4e301a; --brand-ink: #ffffff; --band: #e9c46a;
  --sena: #39a900;
  --ink: #1b2430; --ink-2: #4b5563; --ink-3: #6b7280;
  --bg: #f3eee6; --paper: #fffdf9; --paper-2: #f7f1e8; --line: #e4d9c8; --side: #ebe2d4; --side-ink: #4a3626;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --pos: #1baf7a; --neg: #e34948;
  --div-neg: #d6453f; --div-mid: #e8e6e0; --div-pos: #2a78d6;
  --radius: 12px; --shadow: 0 1px 2px rgba(27, 36, 48, .05), 0 8px 24px rgba(27, 36, 48, .07);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink: #e8ecf2; --ink-2: #b8c1cd; --ink-3: #8e98a6; --bg: #12100d; --paper: #1b1813; --paper-2: #221e18; --line: #362f25; --side: #17140f; --side-ink: #d9c9b4; --band: #8a6d2b; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --pos: #199e70; --neg: #e66767; --div-mid: #2c3440; }
}
:root[data-theme="dark"] { --ink: #e8ecf2; --ink-2: #b8c1cd; --ink-3: #8e98a6; --bg: #12100d; --paper: #1b1813; --paper-2: #221e18; --line: #362f25; --side: #17140f; --side-ink: #d9c9b4; --band: #8a6d2b; --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --pos: #199e70; --neg: #e66767; --div-mid: #2c3440; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Encabezado ---------- */
.hdr { background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.hdr-top { display: flex; align-items: center; gap: 16px; padding: 10px 20px 6px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo b { font-size: 17px; letter-spacing: .2px; }
.logo small { display: block; font-size: 11.5px; opacity: .8; }
.sena-badge { font-size: 10.5px; font-weight: 700; background: var(--sena); color: #fff; padding: 2px 7px; border-radius: 5px; letter-spacing: .5px; }
.hdr .sp { flex: 1; }
.season { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .1); border-radius: 10px; padding: 4px 6px 4px 12px; }
.season label { font-size: 12px; opacity: .85; }
.season select { background: var(--brand-2); color: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: 8px; padding: 5px 8px; font-weight: 600; }
.hbtn { background: transparent; border: 1px solid rgba(255, 255, 255, .3); color: #fff; border-radius: 8px; padding: 5px 9px; cursor: pointer; }
.hbtn:hover { background: rgba(255, 255, 255, .12); }
.tabs { display: flex; gap: 2px; padding: 0 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a { color: rgba(255, 255, 255, .82); padding: 9px 13px 11px; cursor: pointer; white-space: nowrap; border-bottom: 3px solid transparent; font-size: 13.5px; display: flex; gap: 7px; align-items: center; }
.tabs a svg { width: 16px; height: 16px; opacity: .85; }
.tabs a:hover { color: #fff; }
.tabs a.on { color: #fff; border-bottom-color: var(--sena); font-weight: 600; }

/* ---------- Página ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 22px 20px 60px; }
.ptitle { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.ptitle h1 { font-size: 22px; margin: 0; }
.ptitle p { margin: 2px 0 0; color: var(--ink-2); }
.ptitle .acts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g21 { grid-template-columns: 2fr 1fr; } .g12 { grid-template-columns: 1fr 2fr; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 14px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.card h2 .r { margin-left: auto; display: flex; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat span { color: var(--ink-3); font-size: 12px; display: block; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; display: block; margin-top: 2px; }
.stat small { color: var(--ink-2); font-size: 12px; }
.stat.hero { background: var(--brand); color: #fff; border-color: var(--brand); }
.stat.hero span, .stat.hero small { color: rgba(255, 255, 255, .8); }
.muted { color: var(--ink-3); } .small { font-size: 12px; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 7px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn.pri { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.btn.pri:hover { background: var(--brand-2); }
.btn.ok { background: var(--sena); color: #fff; border-color: var(--sena); font-weight: 600; }
.btn.danger { color: var(--neg); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
select.ctl, input.ctl { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 6px 9px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--ink-2); font-weight: 600; font-size: 12px; padding: 7px 9px; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.t td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tbody tr:hover td { background: var(--paper-2); }
table.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.tw { overflow-x: auto; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chip.warn { border-color: var(--s4); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 15px; }

/* Gráficos */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .grid.zero { stroke: var(--ink-3); }
svg.chart .ax { fill: var(--ink-3); font-size: 11px; }
svg.chart .ref { stroke: var(--ink-2); stroke-dasharray: 4 4; }
svg.chart .mark { stroke: var(--paper); stroke-width: 0; }
.legend-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.legend-row i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 7px; }
.hb { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.hb .hl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .ht { background: var(--paper-2); border-radius: 4px; height: 12px; overflow: hidden; }
.hb .ht span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hb .hv { font-variant-numeric: tabular-nums; color: var(--ink); min-width: 70px; text-align: right; }
.tip { position: fixed; z-index: 5000; pointer-events: none; background: var(--ink); color: var(--paper); padding: 6px 10px; border-radius: 7px; font-size: 12px; opacity: 0; transition: opacity .1s; max-width: 280px; box-shadow: var(--shadow); }

/* Mapa */
.map { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: #dfe3e8; }
.map.sm { height: 380px; }
.ll-legend { background: rgba(255, 255, 255, .95); color: #1b2430; padding: 8px 10px; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow); }
.ll-legend b { display: block; margin-bottom: 4px; }
.ll-legend div { display: flex; align-items: center; gap: 6px; }
.ll-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.flabel { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 700; text-shadow: 0 0 3px #000, 0 0 6px #000; }
.flabel::before { display: none; }
.leaflet-container { font-family: var(--font); }

/* Árbol de lotes */
.tree .gr { margin-bottom: 14px; }
.tree .gh { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 0; }
.tree .fh { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); margin: 6px 0 4px 10px; }
.tree .acts { margin-left: auto; display: flex; gap: 4px; }
.lot { margin-left: 10px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-bottom: 5px; cursor: pointer; background: var(--paper); }
.lot:hover { border-color: var(--brand); }
.lot.on { border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }

/* Formularios y modal */
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f { display: flex; flex-direction: column; gap: 4px; }
.f label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.f input, .f select, .f textarea { border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; background: var(--paper); width: 100%; }
.f input:focus, .f select:focus, .f textarea:focus { outline: 2px solid rgba(107, 68, 35, .3); border-color: var(--brand); }
.f .hint { font-size: 11.5px; color: var(--ink-3); }
.mbg { position: fixed; inset: 0; background: rgba(16, 21, 28, .55); display: none; align-items: center; justify-content: center; z-index: 3000; padding: 16px; }
.mbg.on { display: flex; }
.modal { background: var(--paper); border-radius: 14px; width: min(620px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal .mh { padding: 15px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .mh h3 { margin: 0; font-size: 16px; flex: 1; }
.modal .mb { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.modal .mf { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 9px; z-index: 6000; opacity: 0; transition: opacity .2s; pointer-events: none; border-left: 4px solid var(--sena); }
.toast.on { opacity: 1; } .toast.err { border-left-color: var(--neg); }
.busy { position: fixed; inset: 0; z-index: 5500; background: rgba(16, 21, 28, .35); display: none; align-items: center; justify-content: center; }
.busy.on { display: flex; } .busy div { background: var(--paper); padding: 14px 22px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); }
.maphint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1200; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 9px; display: none; gap: 10px; align-items: center; font-size: 13px; }
.maphint.on { display: flex; }
.maphint button { background: var(--paper); color: var(--ink); border: 0; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.mapwrap { position: relative; }

/* Créditos y reporte */
.credit-foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 24px 0 8px; }
.credit-foot b { color: var(--ink-2); }
.hero-about { background: linear-gradient(120deg, #4e301a 0%, #6b4423 50%, #2c7a1b 100%); color: #fff; border-radius: 16px; padding: 26px; display: flex; gap: 18px; align-items: center; margin-bottom: 16px; }
.hero-about h1 { margin: 0; font-size: 26px; }
.hero-about p { margin: 4px 0 0; opacity: .88; }
.report { background: #fff; color: #1b2430; border: 1px solid var(--line); border-radius: 12px; padding: 30px 34px; max-width: 980px; margin: 0 auto; }
.report .rh { display: flex; align-items: center; gap: 14px; border-bottom: 3px solid var(--brand); padding-bottom: 12px; margin-bottom: 14px; }
.report .rh h1 { margin: 0; font-size: 20px; }
.report h3 { font-size: 14px; color: var(--brand); margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.report table.t td, .report table.t th { color: #1b2430; border-color: #e3ddd0; }
.report .rf { margin-top: 22px; border-top: 1px solid #e3ddd0; padding-top: 10px; font-size: 11px; color: #4b5563; display: flex; justify-content: space-between; gap: 12px; }
.report svg.chart .ax { fill: #6b7280; } .report svg.chart .grid { stroke: #e3ddd0; }

@media print {
  .hdr, .noprint, .credit-foot { display: none !important; }
  body { background: #fff; } .page { padding: 0; max-width: none; }
  .report { border: 0; padding: 0; }
  tr { break-inside: avoid; }
}
@media (max-width: 900px) {
  .g2, .g3, .g21, .g12 { grid-template-columns: 1fr; }
  .fgrid { grid-template-columns: 1fr; }
  .hdr-top { flex-wrap: wrap; padding: 8px 14px 4px; }
  .page { padding: 16px 14px 50px; }
  .map { height: 360px; }
  .logo small { display: none; }
}

/* ---------- Disposición con barra lateral ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 14px 10px; }
.side .brandbox { display: flex; gap: 10px; align-items: center; padding: 4px 8px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.side .brandbox b { font-size: 16px; color: var(--side-ink); display: block; }
.side .brandbox small { font-size: 11px; color: var(--ink-3); }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--side-ink); cursor: pointer; font-size: 13.5px; text-decoration: none; }
.side a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.side a:hover { background: rgba(107, 68, 35, .1); }
.side a.on { background: var(--brand); color: #fff; font-weight: 600; }
.side a.on svg { opacity: 1; }
.side .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink-3); padding: 12px 10px 4px; }
.side .who { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-3); }
.side .who b { color: var(--side-ink); display: block; font-size: 12.5px; }
.topline { display: flex; align-items: center; gap: 10px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 900; }
.topline label { font-size: 12px; color: var(--ink-3); }
.topline select { border: 1px solid var(--line); background: var(--paper); border-radius: 9px; padding: 6px 9px; font-weight: 600; min-width: 220px; }
.topline .sp { flex: 1; }
.risk { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; }
.risk i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.r0 { background: rgba(42, 157, 143, .14); color: #1f7a6f; } .r0 i { background: #2a9d8f; }
.r1 { background: rgba(233, 196, 106, .22); color: #8a6a12; } .r1 i { background: #e9c46a; }
.r2 { background: rgba(244, 162, 97, .2); color: #a2531b; } .r2 i { background: #f4a261; }
.r3 { background: rgba(209, 73, 91, .16); color: #b02a3e; } .r3 i { background: #d1495b; }
.note { background: var(--paper-2); border-left: 4px solid var(--brand); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.note.ok { border-left-color: var(--sena); } .note.warn { border-left-color: #f4a261; } .note.bad { border-left-color: #d1495b; }
.ctfstrip { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { border: 1px solid var(--line); border-radius: 9px; padding: 7px; font-size: 11.5px; text-align: center; background: var(--paper); }
.day b { display: block; font-size: 13px; }
.day.ok { border-color: #2a9d8f; box-shadow: inset 0 3px 0 #2a9d8f; }
.day.no { border-color: #d1495b; box-shadow: inset 0 3px 0 #d1495b; }
.day.warn { border-color: #e9c46a; box-shadow: inset 0 3px 0 #e9c46a; }
.day input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; font-size: 11.5px; background: var(--paper); text-align: center; margin-top: 3px; }
table.t input.cell { width: 70px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; background: var(--paper); text-align: right; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 6px; }
  .side .brandbox, .side .grp, .side .who { display: none; }
  .side a { flex: none; }
  .days { grid-template-columns: repeat(4, 1fr); }
}
@media print { .side, .topline { display: none !important; } .shell { display: block; } }

@media (max-width: 900px) { .row > span[style*="width:200px"] { width: 100% !important; font-weight: 600; } }

/* ---------- Penetrometría 3D ---------- */
.p3d-card { padding: 0; overflow: hidden; position: relative; }
.p3d { width: 100%; height: 620px; }
.p3d .empty { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.p3d-hint { position: absolute; left: 12px; bottom: 8px; pointer-events: none; }
.p3d-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.p3d-side .card { display: flex; flex-direction: column; gap: 10px; }
.p3d-side h2 { margin: 0; }
.p3d-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.p3d-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.p3d-chips .btn { justify-content: center; font-family: var(--mono); opacity: .55; }
.p3d-chips .btn.on { opacity: 1; border-color: var(--brand); }
.p3d-seg .btn { justify-content: center; }
.p3d-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.p3d-row output { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.p3d-side input[type=range] { width: 100%; accent-color: var(--brand); }
.p3d-chk { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.p3d-ramp { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #2a9d8f 0%, #e9c46a 42.9%, #f4a261 57.1%, #d1495b 85.7%, #8f1d2c 100%); }
.p3d-ramp-l { position: relative; height: 16px; }
.p3d-ramp-l span { position: absolute; transform: translateX(-50%); }
.p3d-ramp-l span:nth-child(1) { left: 0; transform: none; } .p3d-ramp-l span:nth-child(2) { left: 42.9%; } .p3d-ramp-l span:nth-child(3) { left: 57.1%; } .p3d-ramp-l span:nth-child(4) { right: 0; left: auto; transform: none; }
@media (max-width: 900px) { .p3d { height: 440px; } }
