/* Monkey Fix · estilos base mobile-first */
:root {
  --verde: #1f4e3d; --verde-osc: #163a2d; --verde-claro: #e6f0ec; --ambar: #f5a623; --ambar-osc: #d98c0a;
  --fondo: #f4f6f5; --tarjeta: #fff; --texto: #1c2320; --muted: #6b7570; --borde: #dfe5e2; --rojo: #c62828; --rojo-claro: #fdecea;
  --verde-ok: #2e7d32; --azul: #1565c0; --morado: #6a1b9a; --naranja: #ef6c00; --cian: #00838f;
  --radio: 14px; --sombra: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.04);
  --tab-h: 64px; --top-h: 56px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.4; color: var(--texto); background: var(--fondo); padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
body.sin-nav { padding-bottom: 0; }
a { color: var(--verde); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; vertical-align: middle; }
.oculto { display: none !important; }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem; height: var(--top-h); padding: 0 .75rem; background: var(--verde); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.topbar-titulo { flex: 1; font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-acciones { display: flex; gap: .25rem; align-items: center; }
.btn-icono { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 1.1rem; }
.btn-icono:hover { background: rgba(255,255,255,.12); }
.brand { display: flex; align-items: center; gap: .5rem; color: inherit; font-weight: 700; }
.brand-mini span { display: none; }
.logo-img { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #fff; }
.logo-txt { font-size: 1.5rem; }

/* Tab bar móvil */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: #fff; border-top: 1px solid var(--borde); }
.tabbar a, .tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .68rem; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.tabbar a span, .tabbar button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabbar .activo { color: var(--verde); font-weight: 600; }
.tabbar .ico svg { width: 24px; height: 24px; }

/* Sidebar escritorio */
.sidebar { display: none; }
@media (min-width: 1024px) {
  body { padding-bottom: 0; padding-left: 240px; }
  .sidebar { display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; width: 240px; background: var(--verde-osc); color: #fff; padding: 1rem .75rem; overflow-y: auto; }
  .sidebar .brand { font-size: 1.1rem; padding: .25rem .5rem .9rem; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar nav a { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: 10px; color: rgba(255,255,255,.85); font-size: .95rem; }
  .sidebar nav a:hover { background: rgba(255,255,255,.08); }
  .sidebar nav a.activo { background: var(--ambar); color: #1c1c1c; font-weight: 600; }
  .sidebar-pie { border-top: 1px solid rgba(255,255,255,.12); padding-top: .75rem; display: flex; flex-direction: column; gap: .5rem; }
  .usuario-mini { display: flex; flex-direction: column; font-size: .9rem; } .usuario-mini small { color: rgba(255,255,255,.6); }
  .sidebar .btn-ghost { color: #fff; }
  .tabbar { display: none; }
  .topbar { background: #fff; color: var(--texto); box-shadow: none; border-bottom: 1px solid var(--borde); }
  .topbar .brand-mini { display: none; }
  .topbar-titulo { font-size: 1.35rem; }
}
.sel-sucursal select { width: 100%; padding: .5rem; border-radius: 8px; border: 1px solid var(--borde); font-size: .9rem; background: #fff; color: var(--texto); }
.sucursal-nombre { font-size: .85rem; color: rgba(255,255,255,.7); }

/* Contenido */
.contenido { padding: .9rem .9rem 1.5rem; max-width: 1100px; margin: 0 auto; }
.contenido.ancho-angosto { max-width: 560px; }
.contenido.ancho-amplio { max-width: 1400px; }
.flash { padding: .75rem 1rem; border-radius: 10px; margin-bottom: .9rem; font-weight: 500; }
.flash-ok { background: #e3f4e5; color: #1b5e20; } .flash-error { background: var(--rojo-claro); color: var(--rojo); } .flash-info { background: #e3f0fb; color: #0d47a1; }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 1rem); transform: translateX(-50%); background: #222; color: #fff; padding: .7rem 1.1rem; border-radius: 12px; z-index: 100; max-width: 90vw; }

/* Tarjetas y listas */
.tarjeta { display: block; background: var(--tarjeta); border-radius: var(--radio); padding: .9rem 1rem; box-shadow: var(--sombra); color: inherit; margin-bottom: .7rem; }
.tarjeta.rep { border-left: 5px solid transparent; }
.tarjeta.alerta-atencion { border-left-color: var(--ambar); } .tarjeta.alerta-atrasado { border-left-color: var(--rojo); }
.rep-cab { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .25rem; }
.folio { font-weight: 700; color: var(--verde); letter-spacing: .3px; }
.rep-equipo { font-size: 1.05rem; font-weight: 600; } .rep-falla { color: var(--muted); font-size: .92rem; margin-bottom: .35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .85rem; }
.rep-pie { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; font-size: .85rem; }
.saldo { font-weight: 700; color: var(--rojo); }
.lista-tarjetas { display: grid; gap: .7rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .lista-tarjetas { grid-template-columns: repeat(2, 1fr); } .lista-tarjetas .tarjeta { margin: 0; } }
@media (min-width: 1300px) { .lista-tarjetas { grid-template-columns: repeat(3, 1fr); } }
.panel { background: var(--tarjeta); border-radius: var(--radio); padding: 1rem; box-shadow: var(--sombra); margin-bottom: .9rem; }
.panel h2, .panel h3 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.grid-2 { display: grid; gap: .9rem; grid-template-columns: 1fr; } @media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-3 { display: grid; gap: .9rem; grid-template-columns: 1fr; } @media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .18rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; background: #eceff1; color: #37474f; }
.badge .ico svg { width: 14px; height: 14px; }
.badge-azul { background: #e3f0fb; color: var(--azul); } .badge-morado { background: #f1e6f7; color: var(--morado); } .badge-ambar { background: #fff3dc; color: #a35d00; }
.badge-naranja { background: #ffe9d6; color: var(--naranja); } .badge-cian { background: #dff4f6; color: var(--cian); } .badge-verde { background: #e3f4e5; color: var(--verde-ok); }
.badge-gris { background: #eceff1; color: #546e7a; } .badge-rojo { background: var(--rojo-claro); color: var(--rojo); } .badge-suave { background: #f1f3f2; color: var(--muted); text-transform: none; font-weight: 500; }
.badge-grande { font-size: .95rem; padding: .35rem .9rem; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px; padding: .6rem 1.1rem; border-radius: 12px; border: 1px solid var(--borde); background: #fff; color: var(--texto); font-size: 1rem; font-weight: 600; cursor: pointer; font-family: inherit; text-align: center; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: #f5f7f6; } .btn:active { transform: translateY(1px); }
.btn-primario { background: var(--verde); border-color: var(--verde); color: #fff; } .btn-primario:hover { background: var(--verde-osc); }
.btn-acento { background: var(--ambar); border-color: var(--ambar); color: #1c1c1c; } .btn-acento:hover { background: var(--ambar-osc); }
.btn-peligro { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; } .btn-ghost:hover { background: rgba(0,0,0,.05); }
.btn-sm { min-height: 36px; padding: .35rem .8rem; font-size: .88rem; border-radius: 9px; }
.btn-lg { min-height: 56px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.acciones-rapidas { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .75rem 0; }
.acciones-rapidas .btn { flex-direction: column; gap: .2rem; min-height: 64px; font-size: .8rem; padding: .5rem .3rem; }
.acciones-rapidas .btn .ico svg { width: 24px; height: 24px; }
@media (min-width: 700px) { .acciones-rapidas { grid-template-columns: repeat(6, 1fr); } }
.acciones-grandes { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.acciones-grandes .btn { min-height: 90px; flex-direction: column; font-size: 1rem; border-radius: 16px; }
.acciones-grandes .btn .ico svg { width: 30px; height: 30px; }
.fila-botones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.fila-botones.derecha { justify-content: flex-end; }

/* Formularios */
.campo { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.campo-etq { font-size: .85rem; font-weight: 600; color: #37473f; } .campo-etq em { color: var(--rojo); font-style: normal; }
input, select, textarea { font: inherit; font-size: 1.05rem; padding: .7rem .8rem; border: 1.5px solid var(--borde); border-radius: 11px; background: #fff; color: var(--texto); width: 100%; min-height: 48px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--verde); box-shadow: 0 0 0 3px rgba(31,78,61,.15); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--verde); }
.check { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; font-size: 1rem; cursor: pointer; }
.ayuda { color: var(--muted); font-size: .8rem; }
.form-grid { display: grid; gap: 0 .9rem; grid-template-columns: 1fr; } @media (min-width: 600px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .col-2 { grid-column: span 2; } }
.form-seccion { margin: .5rem 0 .75rem; padding-top: .75rem; border-top: 1px dashed var(--borde); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
details.plegable summary { cursor: pointer; font-weight: 600; padding: .6rem 0; color: var(--verde); list-style: none; }
details.plegable summary::before { content: "▸ "; } details.plegable[open] summary::before { content: "▾ "; }
.segmento { display: flex; gap: .4rem; flex-wrap: wrap; }
.segmento label { flex: 1; min-width: 90px; }
.segmento input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmento span { display: flex; align-items: center; justify-content: center; min-height: 48px; padding: .5rem .6rem; border: 1.5px solid var(--borde); border-radius: 11px; background: #fff; text-align: center; font-weight: 600; cursor: pointer; font-size: .92rem; }
.segmento input:checked + span { background: var(--verde); border-color: var(--verde); color: #fff; }
.segmento.si-no span { min-height: 56px; font-size: 1.05rem; }
.buscador { position: relative; margin-bottom: .75rem; }
.buscador input { padding-left: 2.6rem; border-radius: 999px; font-size: 1.05rem; }
.buscador .ico { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.filtros select, .filtros input { width: auto; min-height: 40px; padding: .4rem .6rem; font-size: .9rem; flex: 1 1 140px; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; overflow-x: auto; }
.chip { border: 1.5px solid var(--borde); background: #fff; border-radius: 999px; padding: .4rem .9rem; font: inherit; font-size: .88rem; font-weight: 600; color: var(--texto); cursor: pointer; white-space: nowrap; min-height: 38px; }
.chip.activo { background: var(--verde); border-color: var(--verde); color: #fff; }
.chip .num { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .45rem; margin-left: .3rem; font-size: .8rem; } .chip.activo .num { background: rgba(255,255,255,.25); }
.rango { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; } .rango input { width: auto; flex: 1; min-height: 40px; }
.autocompletar { position: relative; }
.sugerencias { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--borde); border-radius: 10px; box-shadow: var(--sombra); z-index: 30; max-height: 240px; overflow-y: auto; }
.sugerencias button { display: block; width: 100%; text-align: left; padding: .7rem .9rem; border: 0; background: none; font: inherit; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.sugerencias button:hover { background: var(--verde-claro); }
.sugerencias small { display: block; color: var(--muted); }
.aviso-cliente { padding: .6rem .8rem; background: var(--verde-claro); border-radius: 10px; margin-bottom: .75rem; display: flex; justify-content: space-between; align-items: center; }

/* Modales y hojas */
dialog { border: 0; padding: 0; border-radius: 18px; max-width: min(96vw, 560px); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--texto); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.modal-form { display: flex; flex-direction: column; max-height: 92vh; }
.modal-cab { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem .5rem; } .modal-cab h2 { margin: 0; font-size: 1.15rem; }
.modal-cuerpo { padding: .5rem 1.1rem; overflow-y: auto; }
.modal-pie { display: flex; gap: .5rem; justify-content: flex-end; padding: .75rem 1.1rem 1rem; border-top: 1px solid var(--borde); }
.modal-pie .btn { flex: 1; }
@media (max-width: 600px) { dialog.modal { margin: auto 0 0; max-width: 100vw; border-radius: 18px 18px 0 0; } }
dialog.hoja { margin: auto 0 0; max-width: 100vw; border-radius: 18px 18px 0 0; padding: 1rem; }
.hoja-cab { display: flex; flex-direction: column; margin-bottom: .75rem; }
.menu-lista { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: .5rem 0 1rem; }
.menu-lista a { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .8rem .3rem; border-radius: 12px; background: var(--fondo); color: var(--texto); font-size: .8rem; text-align: center; }
.menu-lista .ico svg { width: 26px; height: 26px; color: var(--verde); }

/* Detalle de reparación */
.detalle-cab { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.detalle-cab .folio { font-size: 1.3rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .9rem; margin: 0; font-size: .95rem; }
.dl dt { color: var(--muted); font-weight: 500; } .dl dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--borde); }
.timeline li { position: relative; padding: 0 0 .9rem .9rem; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -1.45rem; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--verde); border: 2px solid #fff; }
.timeline small { display: block; color: var(--muted); }
.dinero-grid { display: grid; grid-template-columns: 1fr auto; gap: .4rem .8rem; font-size: 1rem; }
.dinero-grid .total { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--borde); padding-top: .4rem; }
.dinero-grid .neg { color: var(--rojo); } .dinero-grid .pos { color: var(--verde-ok); }
.interno { border: 2px dashed #ffcc80; background: #fff8ec; }
.interno h3::after { content: "INTERNO"; font-size: .65rem; background: var(--ambar); color: #1c1c1c; padding: .1rem .5rem; border-radius: 999px; }
.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid #f0f2f1; font-size: .93rem; }
.lista-simple li:last-child { border-bottom: 0; }
.lista-simple .cancelado { text-decoration: line-through; opacity: .6; }
.fotos { display: flex; gap: .5rem; flex-wrap: wrap; } .fotos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; }
.qr-mini { width: 90px; height: 90px; }

/* Stats y reportes */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: .9rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { display: flex; flex-direction: column; background: #fff; border-radius: var(--radio); padding: .8rem .9rem; box-shadow: var(--sombra); color: inherit; }
.stat-val { font-size: 1.5rem; font-weight: 700; line-height: 1.1; } .stat-etq { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-top: .2rem; }
.stat.rojo .stat-val { color: var(--rojo); } .stat.verde .stat-val { color: var(--verde-ok); } .stat.ambar .stat-val { color: #a35d00; } .stat.azul .stat-val { color: var(--azul); }

/* Tablas (escritorio) */
.tabla-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; background: #fff; border-radius: var(--radio); overflow: hidden; }
.tabla th, .tabla td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid #eef1f0; vertical-align: top; }
.tabla th { background: #f4f6f5; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.tabla td.num, .tabla th.num { text-align: right; white-space: nowrap; }
.tabla tr.cancelado td { opacity: .55; text-decoration: line-through; }
.tabla tfoot td { font-weight: 700; background: #f9faf9; }
.vacio { text-align: center; padding: 2.5rem 1rem; color: var(--muted); background: #fff; border-radius: var(--radio); }
.vacio p { font-size: 1.05rem; margin-bottom: .25rem; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, var(--verde-osc), var(--verde) 60%, #2d6a4f); }
.login-caja { background: #fff; padding: 2rem 1.5rem; border-radius: 22px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-caja .brand { justify-content: center; color: var(--verde); font-size: 1.4rem; margin-bottom: 1.25rem; flex-direction: column; }
.login-caja .logo-img { width: 72px; height: 72px; } .login-caja .logo-txt { font-size: 3rem; }

.aviso { padding: .8rem 1rem; border-radius: 12px; margin-bottom: .9rem; display: flex; gap: .6rem; align-items: flex-start; }
.aviso-error { background: var(--rojo-claro); color: var(--rojo); } .aviso-ambar { background: #fff3dc; color: #7a4600; } .aviso-info { background: #e3f0fb; color: #0d47a1; } .aviso-ok { background: #e3f4e5; color: #1b5e20; }
.sep { height: .75rem; }
.texto-derecha { text-align: right; } .texto-centro { text-align: center; }
.solo-escritorio { display: none; } @media (min-width: 900px) { .solo-escritorio { display: block; } .solo-movil { display: none !important; } }
.resumen-entrega { font-size: 1.05rem; } .resumen-entrega .dinero-grid { font-size: 1.1rem; }
.pill-garantia { font-weight: 700; }
.print-only { display: none; }
.segmento span small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
.segmento input:checked + span small { color: inherit; opacity: .85; }
