:root {
  --ink: #17241c;
  --muted: #5d6b63;
  --line: #e3e6e1;
  --paper: #f6f4ef;
  --card: #ffffff;
  --green: #146c43;
  --green-dark: #0e5233;
  --mint: #e7f5ee;
  --amber: #b86e00;
  --amber-bg: #fff4df;
  --danger: #a33b32;
  --danger-bg: #fdeceb;
  --shadow: 0 8px 24px rgba(23, 36, 28, .08);
  --safe-b: env(safe-area-inset-bottom);
  --safe-t: env(safe-area-inset-top);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 16.5px;
  line-height: 1.4;
}
a { color: var(--green-dark); }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.35rem; letter-spacing: -.02em; }
h2 { font-size: 1.12rem; }

.app { min-height: 100dvh; }
.main {
  padding: calc(12px + var(--safe-t)) 16px 108px;
  max-width: 860px;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}
.eyebrow { color: var(--muted); font-size: .85rem; margin-bottom: 2px; }
.top .salir { display: none; }

.side { display: none; }
.bottom {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + var(--safe-b));
  z-index: 20;
}
.bottom a, .bottom summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--muted);
  font-size: .72rem;
  min-height: 52px;
  justify-content: center;
  list-style: none;
}
.bottom a.on { color: var(--green); font-weight: 700; }
.bottom svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.mas { position: relative; flex: 1; }
.mas summary { cursor: pointer; }
.mas summary::-webkit-details-marker { display: none; }
.sheet {
  position: absolute;
  right: 0; bottom: 64px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 180px;
  padding: 6px;
}
.sheet a { display: block; padding: 12px 14px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.sheet a:active { background: var(--mint); }

.card, .panel {
  background: var(--card);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h2 { margin: 4px 0 6px; }
.code { color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.grid { display: grid; gap: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat {
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 1.6rem; letter-spacing: -.03em; }
.stat span { color: var(--muted); font-size: .85rem; }

.btn, button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 0;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}
.btn.ghost { background: var(--mint); color: var(--green-dark); }
.btn.warn { background: var(--amber-bg); color: #7a4a00; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: .75rem;
  background: var(--paper);
  color: var(--muted);
}
.pill.ok { background: var(--mint); color: var(--green-dark); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }

label { display: block; font-size: .86rem; color: var(--muted); margin: 10px 0 4px; }
input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.check input { width: auto; min-height: auto; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }

.flash { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.flash.ok { background: var(--mint); }
.flash.mal { background: var(--danger-bg); color: var(--danger); }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login .card { width: min(440px, 100%); }
.mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: inline-grid; place-items: center;
  background: var(--green); color: #fff; font-weight: 800;
}
.brand-lockup { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.help { margin-top: 16px; color: var(--muted); font-size: .9rem; }
.help summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.accounts { display: grid; gap: 6px; margin-top: 8px; }
.accounts code { background: var(--paper); padding: 2px 6px; border-radius: 6px; }

.daygrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.day {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--paper);
  border-radius: 14px;
  padding: 12px;
  min-height: 76px;
}
.day strong { display: block; }
.day.empty { opacity: .75; }
#mapa { height: 46dvh; min-height: 240px; border-radius: 18px; margin-bottom: 12px; background: #dce7e1; }
.leaflet-container { font: inherit; }
.pin-num {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}
.pin-num::before { display: none; }
.stop.done { opacity: .62; }
.num {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--green); color: #fff; font-size: .85rem; font-weight: 700;
}
.hero {
  background: linear-gradient(160deg, #146c43, #0e5233);
  color: #fff;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 12px;
}
.hero h2 { font-size: 1.7rem; }
.hero p { opacity: .9; margin-top: 4px; }
.hero .btn { background: #fff; color: var(--green-dark); margin-top: 14px; }

.list-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .8rem; font-weight: 600; }
.chips { display: flex; gap: 8px; overflow: auto; padding-bottom: 4px; }
.chips a {
  flex: 0 0 auto;
  text-decoration: none;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid var(--line);
}
.chips a.on { background: var(--green); color: #fff; border-color: var(--green); }

body.campo .main { padding: 0 0 calc(78px + var(--safe-b)); max-width: none; }
body.campo .top { display: none; }
body.campo .campo-stage { position: relative; }
body.campo #mapa {
  position: relative;
  z-index: 1;
  height: 42dvh;
  min-height: 220px;
  border-radius: 0;
  margin: 0;
}
body.campo .campo-chips { position: absolute; z-index: 8; top: 10px; left: 10px; }
.sheet-ruta {
  position: relative;
  z-index: 2;
  margin: 0;
  max-height: none;
  overflow: visible;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px 8px;
  box-shadow: 0 -8px 24px rgba(23, 36, 28, .12);
}
.progreso-bar { height: 8px; background: #e6ece8; border-radius: 99px; overflow: hidden; }
.progreso-bar span { display: block; height: 100%; background: var(--green); }
.progreso p { margin-top: 6px; font-size: .92rem; }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.lista-dia summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--green-dark); font-weight: 700; }
.mini { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.mini form, .mini a { grid-column: 1 / -1; }
.linea-prod { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: #fff; border-radius: 16px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.linea-prod input { width: 88px; text-align: center; font-size: 1.25rem; font-weight: 800; }
.pagos { display: grid; gap: 8px; margin: 8px 0 14px; }
.pagos label { margin: 0; color: var(--ink); background: #fff; border-radius: 14px; min-height: 52px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); }
.ticket { background: #fff; width: min(420px, 100%); margin: 0 auto 16px; padding: 18px; border-radius: 18px; box-shadow: var(--shadow); }
.ticket .total { font-size: 1.45rem; font-weight: 800; margin-top: 12px; }
.table-wrap { overflow: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
table.catalogo th, table.catalogo td { padding: 12px; }
details.card > summary { cursor: pointer; }
details.card > summary h2 { display: inline; }
.muestra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.muestra span { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px; background: var(--green); color: #fff; font-weight: 700; }
.muestra span.ghost { background: var(--danger-bg); color: var(--danger); }
.leyenda { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.propuesta #mapa { height: 520px; min-height: 420px; }
@media print {
  .side, .bottom, .top, .no-print { display: none !important; }
  body, .main, .app { background: #fff; }
  .propuesta #mapa { height: 420px !important; break-inside: avoid; }
  .propuesta .card, .propuesta .hero { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
  body, .main, .app { background: #fff; padding: 0; display: block; }
  .ticket { box-shadow: none; width: 58mm; }
}

@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 240px 1fr; }
  .side {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 16px;
    background: #10281c;
    color: #e7f5ee;
    min-height: 100dvh;
    position: sticky;
    top: 0;
  }
  .side .brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; display: flex; gap: 10px; align-items: center; }
  .side nav { display: grid; gap: 4px; }
  .side nav a { color: #d5e8de; text-decoration: none; padding: 10px 12px; border-radius: 12px; }
  .side nav a.on, .side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
  .who { margin-top: auto; display: grid; gap: 2px; }
  .who span, .who a { color: #b7d0c4; font-size: .9rem; }
  .bottom { display: none; }
  .main { padding: 28px 32px 40px; max-width: 1100px; }
  .top .salir { display: none; }
  .filters { grid-template-columns: 1.4fr .7fr .7fr .7fr auto; align-items: end; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .daygrid { grid-template-columns: repeat(3, 1fr); }
  body.campo .main { padding: 0 24px 24px; }
  body.campo .top { display: flex; }
  body.campo .campo-stage { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
  body.campo #mapa { height: calc(100dvh - 120px); border-radius: 18px; }
  body.campo .sheet-ruta { border-radius: 18px; max-height: calc(100dvh - 120px); overflow: auto; }
}
