:root {
  --bg: #F2F2F2; --card: #fff; --line: #dde3dc; --text: #01261F; --muted: #5d6e66;
  --g900: #038C33; --g700: #025928; --g100: #e8f4cc; --g50: #f3f9e4; --brown: #025928; --orange: #f27100; --yellow: #f9ae00;
  --red: #d53a21; --red-bg: #fbe3de; --amber: #8a5d00; --amber-bg: #fef0c4; --blue: #b85200; --blue-bg: #fde6cc;
  --radius: 14px; --side: 256px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--g700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 30px; margin: 4px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 4px; }
.eyebrow { color: var(--brown); font-weight: 600; font-size: 14px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side { width: var(--side); background: #fafbf8; border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: #A5D936; color: #01261F; display: grid; place-items: center; font-size: 20px; }
.ico { display: block; flex-shrink: 0; }
.ni { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #01261F; flex-shrink: 0; transition: background .15s; }
.ni .ico { width: 25px; height: 25px; }
.nav a:hover .ni { background: #eef7d6; }
.nav a.active .ni { background: #A5D936; color: #01261F; }
.campico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: #A5D936; color: #01261F; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--muted); }
.navgroup { font-size: 12px; color: var(--muted); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--g50); text-decoration: none; }
.nav a.active { background: var(--g100); color: var(--g900); font-weight: 600; }
.main { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; z-index: 5; }
.top .sp { flex: 1; }
.burger { display: none; background: none; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 20px; cursor: pointer; }
.campsel { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; background: var(--card); }
.campsel small { color: var(--muted); display: block; font-size: 11px; line-height: 1.1; }
.campsel select { border: 0; background: none; font-weight: 600; font-size: 15px; padding: 0; outline: none; }
.userbox { text-align: right; line-height: 1.2; font-size: 13px; }
.userbox small { color: var(--muted); }
.content { max-width: 1240px; margin: 0 auto; padding: 24px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }

/* componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.stat .ic { width: 38px; height: 38px; background: #A5D936; color: #01261F; border-radius: 10px; display: grid; place-items: center; margin-bottom: 18px; }
.stat .lbl { color: var(--muted); }
.stat .val { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat .val small { font-size: 13px; font-weight: 400; color: var(--muted); }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar-row { margin: 14px 0; }
.bar-row .t { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar-row .t span:last-child { color: var(--muted); font-size: 13px; text-align: right; }
.bar { height: 8px; background: #e9ede7; border-radius: 6px; margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--g700); border-radius: 6px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--g50); text-decoration: none; }
.btn.primary { background: var(--g900); border-color: var(--g900); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--g700); }
.btn.danger { background: var(--red-bg); border-color: #f3c0b6; color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.tag { display: inline-block; background: var(--g100); color: var(--g900); font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.tag.finalizada { background: var(--g100); color: var(--g900); }
.tag.en_curso { background: var(--amber-bg); color: var(--amber); }
/* Estados con semáforo: verde = completo, amarillo = parcial / en curso, rojo = falta / problema.
   Uso: <span class="tag ok|warn|bad">. Llevan un símbolo para no depender solo del color. */
.tag.ok   { background: var(--g100); color: var(--g700); }
.tag.warn { background: var(--amber-bg); color: var(--amber); }
.tag.bad  { background: var(--red-bg); color: var(--red); }
.tag.ok::before   { content: "✓ "; }
.tag.warn::before { content: "◐ "; }
.tag.bad::before  { content: "✕ "; }
.tag.pendiente { background: var(--amber-bg); color: var(--amber); }
.tag.cancelada { background: var(--red-bg); color: var(--red); }
.flash { background: var(--g100); border: 1px solid #d3e8a6; color: var(--g900); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.pos { color: var(--g700); } .neg { color: var(--red); }

/* tablas */
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fafbf8; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; background: #fafbf8; }
td.wrap { white-space: normal; }

/* formularios */
label { display: block; font-weight: 600; font-size: 13px; margin: 0 0 5px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 12px; border: 1px solid #cdd5cc; border-radius: 10px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #f9ae00; border-color: #f9ae00; }
input[type=checkbox] { width: auto; }
input:disabled, select:disabled { background: #eceeea; color: var(--muted); }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.inline { display: inline; }
.unit { color: var(--muted); font-size: 12px; }
details.card summary { cursor: pointer; font-weight: 600; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

/* lotes / campos */
.lote { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.lote .nm { font-weight: 600; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
a.pill { background: var(--g50); border: 1px solid #d3e8a6; color: var(--g900); padding: 4px 10px; border-radius: 99px; font-size: 13px; }
.ot { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.ot .hd { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.ot ul { margin: 8px 0 0; padding-left: 18px; color: var(--text); }
.ot li { margin: 2px 0; }
.login { max-width: 400px; margin: 10vh auto; padding: 0 16px; }

/* resultado */
.res td:first-child { color: var(--muted); }
.res tr.t td { font-weight: 700; background: #eef3e0; }
.res tr.m td { font-weight: 700; font-size: 17px; }

/* tarjetas tipo "Campos / Lotes" */
.searchbox { display: flex; align-items: center; gap: 8px; max-width: 450px; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 0 12px; margin-bottom: 22px; color: var(--muted); }
.searchbox input { border: 0; outline: none !important; padding: 10px 0; background: none; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.tile { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 20px; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.03); transition: box-shadow .15s, border-color .15s, transform .15s; }
.tile:hover { text-decoration: none; border-color: #d3e8a6; box-shadow: 0 6px 20px rgba(6,138,74,.12); transform: translateY(-1px); }
.tile-top { display: flex; justify-content: space-between; align-items: flex-start; }
.tile-ic { width: 44px; height: 44px; border-radius: 12px; background: #fdefc9; display: grid; place-items: center; }
.tile-id, .tile-arrow { color: var(--muted); font-size: 13px; }
.tile-name { font-weight: 600; margin-top: 34px; font-size: 15px; }
.tile-name.big { font-size: 19px; margin-top: 22px; }
.tile-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); margin-top: 6px; }
.tile-foot { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.tile-foot small { display: block; color: var(--muted); font-size: 12px; }
.pill-s { background: var(--g50); border: 1px solid #d3e8a6; color: var(--g900); padding: 2px 9px; border-radius: 99px; font-size: 12px; }
.tabs { display: inline-flex; gap: 4px; background: var(--g100); border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.tabs a { padding: 6px 14px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.tabs a:hover { text-decoration: none; }
.tabs a.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
/* tabla de reportes agrupada */
#rep tbody.grp tr.lr { display: none; }
#rep tbody.grp.open tr.lr { display: table-row; }
#rep tr.lr.nomatch { display: none !important; }
#rep tr.gh { background: #f4f7f2; cursor: pointer; }
#rep tr.gh:hover { background: var(--g100); }
#rep .chev { display: inline-block; width: 14px; color: var(--muted); }
#rep tbody.grp td { border-bottom: 1px solid var(--line); }
#rep tfoot td { border-top: 2px solid var(--line); border-bottom: 0; }
.dlg { border: 0; border-radius: 16px; padding: 24px; width: min(440px, calc(100vw - 28px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(43,29,18,.45); }

@media (max-width: 980px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .burger { display: block; }
  .side { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .top { padding: 8px 12px; }
  .content { padding: 16px 14px 40px; }
  h1 { font-size: 25px; }
  .userbox { display: none; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .campsel small { display: none; }
  th, td { padding: 9px 10px; }
}

.brand .wm { font-size: 18px; letter-spacing: -.01em; line-height: 1.15; }
.wm .fe { font-weight: 700; }
.wm .ag { font-weight: 300; }
