:root {
  --bg: #f1f5f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --line2: #cbd5e1;
  --brand: #0f172a; --brand2: #1e293b; --accent: #f59e0b; --accent2: #d97706;
  --ok: #16a34a; --warn: #f59e0b; --late: #dc2626; --wa: #16a34a;
  --radius: 14px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 14px rgba(15,23,42,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h3 { font-size: 15px; margin: 18px 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.r { text-align: right; }
.sp { flex: 1; }
.center { justify-content: center; }
.warn-txt { color: #b45309; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; background: var(--brand); color: #fff; padding: 0 20px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--brand); display: grid; place-items: center; overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a, .nav-settings { color: #cbd5e1; padding: 9px 13px; border-radius: 10px; display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: 15px; }
.nav a:hover, .nav-settings:hover { background: var(--brand2); color: #fff; text-decoration: none; }
.nav a.active, .nav-settings.active { background: var(--brand2); color: #fff; box-shadow: inset 0 -3px 0 var(--accent); }
.nav a.nav-cta { color: var(--accent); }

main { padding: 22px; max-width: 1500px; margin: 0 auto; }

/* ---------- Encabezados de página ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { font-size: 14px; color: var(--muted); display: inline-block; margin-bottom: 4px; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar input[type=search] { min-width: 280px; flex: 0 1 360px; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line2); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1c1100; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { background: #15803d; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.lg { min-height: 52px; padding: 0 22px; font-size: 16px; }
.btn.block { display: flex; width: 100%; }
.btn.danger-ghost { color: var(--late); border-color: #fecaca; background: #fff; }
.btn.danger-ghost:hover { background: #fef2f2; }
.icon-btn { width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 22px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: #fee2e2; color: var(--late); }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row-end { display: flex; justify-content: flex-end; margin-top: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* ---------- Tarjetas y formularios ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); font-weight: 500; margin-bottom: 10px; }
.f.row { flex-direction: row; justify-content: space-between; align-items: center; }
.f.row input { width: 90px; text-align: right; }
input, select, textarea { font: inherit; font-size: 16px; padding: 10px 12px; border: 1px solid var(--line2); border-radius: 10px; background: #fff; color: var(--ink); min-height: 46px; width: 100%; }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(245,158,11,.35); border-color: var(--accent); }
.input-placa { text-transform: uppercase; font-weight: 700; letter-spacing: .05em; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.check input[type=checkbox] { width: 20px; height: 20px; min-height: 0; }
.step { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 14px; }
.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }
.info.ok { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.sticky-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 0; background: linear-gradient(transparent, var(--bg) 30%); }

/* Segmentos (botones juntos) */
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-right: 1px solid var(--line2); background: transparent; font: inherit; font-size: 14px; font-weight: 600; padding: 0 14px; min-height: 42px; cursor: pointer; color: var(--muted); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.seg button.v-b.on { background: var(--ok); }
.seg button.v-r.on { background: var(--warn); color: #1c1100; }
.seg button.v-m.on { background: var(--late); }
.fuel { margin-top: 4px; }
.fuel button { min-width: 72px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 6px 24px; }
.chk-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.chk-tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 13px; margin: 2px 2px 0 0; }
.chk-tag.v-r { background: #fef3c7; color: #92400e; }
.chk-tag.v-m { background: #fee2e2; color: #991b1b; }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.chip { border: 1px solid var(--line2); background: #fff; border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Fotos y firma */
.photo-btn { margin-bottom: 12px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.ph { position: relative; border-radius: 10px; overflow: hidden; background: #e2e8f0; aspect-ratio: 4/3; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph span { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,.7); color: #fff; font-size: 11px; padding: 3px 6px; }
.ph button { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(15,23,42,.75); color: #fff; font-size: 18px; cursor: pointer; }
.firma { width: 100%; height: 200px; border: 2px dashed var(--line2); border-radius: 12px; background: #fff; touch-action: none; display: block; }
.firma-view { margin-top: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.firma-view img { max-width: 280px; border-bottom: 1px solid var(--line2); }

/* Placa */
.placa { display: inline-block; background: #fff; border: 2px solid var(--ink); border-radius: 6px; padding: 1px 8px; font-weight: 800; letter-spacing: .06em; font-size: 15px; color: var(--ink); white-space: nowrap; }
.placa.sm { font-size: 12px; padding: 0 6px; border-width: 1.5px; }
h1 .placa { font-size: 20px; vertical-align: middle; margin-left: 6px; }

/* Insignias */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--c) 14%, #fff); color: color-mix(in srgb, var(--c) 80%, #000); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.badge.sm { font-size: 12px; padding: 2px 8px; }
.cot-borrador { --c: #64748b; } .cot-enviada { --c: #2563eb; } .cot-aprobada { --c: #16a34a; } .cot-rechazada { --c: #dc2626; }

/* Tablas */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 12px 14px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.table td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table.click tbody tr[data-id] { cursor: pointer; }
.table.click tbody tr[data-id]:hover { background: #fffbeb; }
.table .empty, .empty { text-align: center; color: var(--muted); padding: 30px; }
.lvl-txt-warn { color: #b45309; font-weight: 600; }
.lvl-txt-late { color: var(--late); font-weight: 700; }
.tabs { display: flex; gap: 4px; background: #e2e8f0; border-radius: 12px; padding: 4px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; }

/* Historial */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 8px; }
.timeline li::before { content: ""; position: absolute; left: -26px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c, #94a3b8); border: 2px solid #fff; }

/* Estado en la orden */
.estado-card { border-left: 8px solid var(--c); }
.estado-big { font-size: 26px; font-weight: 800; color: var(--c); }
.estado-card .nota { font-weight: 600; margin: 4px 0; }
.estado-card.lvl-late { background: #fef2f2; }
.estado-card.lvl-warn { background: #fffbeb; }
.estado-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 14px 0; }
.estado-btn { border: 2px solid color-mix(in srgb, var(--c) 35%, #fff); background: #fff; color: var(--c); border-radius: 12px; min-height: 54px; font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; padding: 6px 10px; }
.estado-btn.on { background: var(--c); border-color: var(--c); color: #fff; }

/* ---------- Tablero (pantalla de cocina) ---------- */
.clock { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 6px; }
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--c, var(--brand)); border-radius: 12px; padding: 10px 14px; display: flex; align-items: baseline; gap: 10px; }
.kpi b { font-size: 30px; line-height: 1; }
.kpi span { color: var(--muted); font-size: 14px; font-weight: 600; }
.kpi.late { --c: var(--late); }
.kpi.late b { color: var(--late); }
.kds { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.kds-col { background: #e2e8f0; border-radius: 14px; display: flex; flex-direction: column; min-height: 62vh; scroll-snap-align: start; }
.kds-col header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; font-weight: 800; font-size: 15px; color: #fff; background: var(--c); border-radius: 14px 14px 0 0; }
.kds-col header b { background: rgba(255,255,255,.25); border-radius: 999px; min-width: 30px; text-align: center; padding: 1px 8px; }
.kds-col.is-empty { opacity: .65; }
.kds-cards { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.kcard { position: relative; text-align: left; font: inherit; color: inherit; background: #fff; border: 0; border-left: 8px solid var(--ok); border-radius: 12px; padding: 12px 12px 10px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 3px; width: 100%; }
.kcard:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(15,23,42,.12); }
.kcard.lvl-warn { border-left-color: var(--warn); background: #fffbeb; }
.kcard.lvl-late { border-left-color: var(--late); background: #fef2f2; animation: pulso 2.4s ease-in-out infinite; }
@keyframes pulso { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.0); } 50% { box-shadow: 0 0 0 4px rgba(220,38,38,.35); } }
.kc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kc-timer { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.lvl-warn .kc-timer { color: #b45309; }
.lvl-late .kc-timer { color: var(--late); }
.kc-veh { font-weight: 700; font-size: 15px; margin-top: 4px; }
.kc-cli { color: var(--muted); font-size: 14px; }
.kc-nota { background: color-mix(in srgb, var(--c) 12%, #fff); color: color-mix(in srgb, var(--c) 75%, #000); border-radius: 8px; padding: 5px 8px; font-size: 13px; font-weight: 600; margin-top: 4px; }
.kc-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.kc-entregar { margin-top: 8px; width: 100%; background: var(--ok); border-color: var(--ok); color: #fff; min-height: 46px; font-size: 16px; }
.kc-entregar:hover { background: #15803d; }
.kc-alert { position: absolute; top: -8px; right: 10px; background: var(--late); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .08em; padding: 2px 8px; border-radius: 6px; }
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.late { background: var(--late); }
.empty-board { text-align: center; padding: 50px 20px; }
.empty-board h2 { justify-content: center; font-size: 22px; }

/* Modo pantalla (para TV o tablet fija en la pared) */
body.kds-mode { background: #0b1220; }
body.kds-mode .topbar, body.kds-mode .legend, body.kds-mode .page-head h1, body.kds-mode .page-head .btn.primary { display: none; }
body.kds-mode main { max-width: none; padding: 14px; }
body.kds-mode .page-head { margin-bottom: 10px; }
body.kds-mode .clock { color: #fff; font-size: 32px; }
body.kds-mode .kpi { background: #111827; border-color: #1f2937; }
body.kds-mode .kpi b { color: #fff; }
body.kds-mode .kpi.late b { color: #f87171; }
body.kds-mode .kpi span { color: #94a3b8; }
body.kds-mode .kds-col { background: #111827; min-height: calc(100vh - 170px); }
body.kds-mode .kcard { font-size: 17px; }
body.kds-mode .kc-veh { font-size: 17px; }
body.kds-mode .placa { font-size: 18px; }

/* ---------- Cotizador ---------- */
.cot-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.cot-layout aside { position: sticky; top: 80px; }
.search-wrap { position: relative; margin-bottom: 14px; }
.results { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 12px 30px rgba(15,23,42,.15); max-height: 320px; overflow: auto; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 12px 14px; font: inherit; cursor: pointer; }
.results button:hover { background: #fffbeb; }
.pad { padding: 12px 14px; }
.chips.quick { padding: 10px; background: #f8fafc; border-radius: 12px; }
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; padding: 6px 6px; }
.items th.r { text-align: right; }
.items td { padding: 4px 4px; vertical-align: middle; }
.items td:first-child { width: 46%; }
.items .it-tipo { min-width: 130px; }
.items .it-cant { width: 80px; }
.items .it-precio { width: 120px; }
.items .it-total { font-weight: 700; white-space: nowrap; padding: 0 8px; }
.totals .tot-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.totals .tot-row input[name=descuento] { width: 130px; text-align: right; }
.totals .pct { width: 70px; min-height: 36px; padding: 4px 8px; text-align: right; }
.totals .grand { font-size: 22px; border-bottom: 0; }
.totals .grand b { color: var(--ink); }
.serv-row { display: grid; grid-template-columns: 1fr 150px 120px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.umbrales .f.row { border-bottom: 1px dashed var(--line); padding-bottom: 8px; color: var(--ink); }
.logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.logo-prev { width: 84px; height: 84px; border: 1px dashed var(--line2); border-radius: 12px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.logo-prev img { max-width: 100%; max-height: 100%; }

/* ---------- Modal y aviso ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-box.wide { max-width: 900px; }
.modal-box h2 { font-size: 21px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; align-items: center; }
body.modal-open { overflow: hidden; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); background: var(--brand); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .cols, .cot-layout { grid-template-columns: 1fr; }
  .cot-layout aside { position: static; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .nav a span { display: none; }
  .nav a.active span { display: inline; }
}

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  main { padding: 14px 12px 96px; }
  h1 { font-size: 22px; }
  .topbar { height: 56px; padding: 0 14px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--brand); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; gap: 0; }
  .nav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; flex: 1; }
  .nav a span, .nav a.active span { display: block; }
  .nav a.active { box-shadow: none; }
  .nav-settings { margin-left: auto; }
  .page-head { align-items: flex-start; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .toolbar input[type=search] { min-width: 0; flex: 1 1 100%; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi b { font-size: 24px; }
  .kds { grid-auto-columns: 86%; }
  .checklist { grid-template-columns: 1fr; }
  .chk-row .seg button { padding: 0 10px; }
  .fuel { display: flex; } .fuel button { flex: 1; min-width: 0; padding: 0 4px; }
  .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; }
  .serv-row { grid-template-columns: 1fr 110px 36px; } .serv-row .s-tipo { display: none; }
  /* Tablas como tarjetas */
  .table thead, .items thead { display: none; }
  .table tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .table td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 3px 0; text-align: right; }
  .table td::before { content: attr(data-l); color: var(--muted); font-size: 13px; text-align: left; }
  .table td.empty { display: block; text-align: center; } .table td.empty::before { content: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .items td { padding: 0; }
  .items td:first-child { grid-column: 1 / -1; width: auto; }
  .items td[data-l="Tipo"] { grid-column: 1 / 3; }
  .items td[data-l="Tipo"] + td { grid-column: 1; }
  .items .it-cant, .items .it-precio { width: 100%; }
  .items .it-total { grid-column: 1 / 3; text-align: right; }
  .items td:last-child { grid-column: 3; grid-row: 2; }
  .estado-grid { grid-template-columns: 1fr 1fr; }
  .modal { align-items: flex-end; padding: 0; }
  .modal-box { border-radius: 18px 18px 0 0; max-height: 94vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .sticky-actions { bottom: 70px; }
  .sticky-actions .btn { flex: 1; }
}

/* ---------- Impresión ---------- */
#print { display: none; }
@media print {
  @page { size: letter; margin: 14mm; }
  body.printing { background: #fff; }
  body.printing > :not(#print) { display: none !important; }
  body.printing #print { display: block; }
}
.doc { font-size: 12.5px; color: #111; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #111; padding-bottom: 12px; margin-bottom: 14px; }
.doc-taller { display: flex; gap: 14px; align-items: center; }
.doc-logo { max-width: 90px; max-height: 80px; }
.doc-nombre { font-size: 20px; font-weight: 800; }
.doc-meta { text-align: right; }
.doc-titulo { font-size: 18px; font-weight: 800; letter-spacing: .08em; }
.doc-num { font-size: 16px; font-weight: 700; color: #b45309; }
.doc-box { border: 1px solid #ccc; border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; }
.doc-box p { margin: 4px 0 0; }
.doc-box .lbl, .doc-grid span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #666; }
.doc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 14px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.doc-table th { background: #111; color: #fff; text-align: left; padding: 6px 8px; font-size: 11px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc-table td { border-bottom: 1px solid #ddd; padding: 6px 8px; }
.doc-bottom { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.doc-notas { flex: 1; color: #333; }
.doc-tot { min-width: 260px; border-collapse: collapse; }
.doc-tot td { padding: 5px 8px; border-bottom: 1px solid #ddd; }
.doc-tot .grand td { font-size: 16px; font-weight: 800; border-top: 2px solid #111; border-bottom: 0; }
.doc-check { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px 16px; margin-top: 6px; }
.doc-check div { display: flex; justify-content: space-between; border-bottom: 1px dotted #ccc; }
.doc-check .v-r { color: #b45309; } .doc-check .v-m { color: #b91c1c; }
.doc-fotos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.doc-fotos img { width: 100%; height: 120px; object-fit: cover; border-radius: 4px; }
.doc-legal { font-size: 10.5px; color: #555; }
.doc-firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; margin-top: 40px; text-align: center; font-size: 11px; color: #444; }
.doc-firmas .line { border-top: 1px solid #111; margin-bottom: 4px; }
.doc-firma { max-height: 70px; display: block; margin: 0 auto; }

/* ---------- Empleados ---------- */
.chip.emp { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.2; border-radius: 12px; padding: 8px 14px; min-height: 44px; justify-content: center; }
.chip.emp small { font-size: 11px; opacity: .7; }
.chip.emp.on::before { content: "✓ "; }
.emp-filtro { margin-bottom: 12px; }
.emp-filtro .chip b { margin-left: 4px; opacity: .7; }
.kc-emp { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin-top: 4px; }
.kc-emp svg { width: 14px; height: 14px; }
.kc-emp.none { color: var(--muted); font-weight: 500; font-style: italic; }
.emp-row { display: grid; grid-template-columns: 1fr 150px auto auto 36px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.emp-row.inactivo .e-nombre { opacity: .5; text-decoration: line-through; }
.emp-stats { white-space: nowrap; }
.sel-emp { width: auto; min-width: 190px; }
@media (max-width: 760px) {
  .emp-row { grid-template-columns: 1fr 1fr 36px; }
  .emp-row .check { grid-column: 1; } .emp-row .emp-stats { grid-column: 2 / 4; white-space: normal; }
  .emp-row .icon-btn { grid-column: 3; grid-row: 1; }
}

/* ---------- Reportes ---------- */
.rep-filtros { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px; margin-bottom: 14px; }
.rep-periodo { flex-wrap: wrap; }
.rep-periodo button { min-height: 40px; }
.rep-fechas { display: flex; gap: 10px; flex-wrap: wrap; }
.rep-fechas label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.rep-fechas input { width: auto; min-height: 40px; padding: 6px 10px; }
.rep-filtros .sel-emp { min-height: 42px; margin-left: auto; }
.rep-kpis .kpi { flex-direction: column; align-items: flex-start; gap: 4px; }
.kpi .kpi-txt { font-size: 22px; }
.rep-cols { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); margin-bottom: 16px; }
.sm-seg button { min-height: 32px; font-size: 13px; padding: 0 10px; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-base { stroke: var(--line2); stroke-width: 1; }
.ch-ytick { fill: var(--muted); font-size: 11px; text-anchor: end; }
.ch-xtick { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.ch-xtick.hoy { fill: var(--ink); font-weight: 700; }
.ch-hit { fill: transparent; cursor: default; }
.ch-bar { fill: var(--accent); transition: filter .15s; }
.ch-bar.hoy { stroke: var(--ink); stroke-width: 1.5; }
.ch-bar-g { outline: none; }
.ch-bar-g.hover .ch-bar, .ch-bar-g:focus .ch-bar { filter: brightness(1.18); }
.ch-bar-g.hover .ch-hit { fill: rgba(127,127,127,.08); }
.ch-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--card); color: var(--ink); border: 1px solid var(--line2); border-radius: 10px; padding: 6px 10px; font-size: 13px; white-space: nowrap; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 5; }
.ch-tip b { font-size: 16px; }
.ch-tip span { color: var(--muted); }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; cursor: pointer; border-radius: 10px; padding: 4px 6px; }
.hbar:hover, .hbar:focus { background: rgba(127,127,127,.08); outline: none; }
.hbar.dim { opacity: .4; }
.hb-name { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; font-size: 14px; overflow: hidden; }
.hb-name small { color: var(--muted); font-weight: 500; font-size: 11px; }
.hb-track { height: 14px; background: rgba(127,127,127,.12); border-radius: 4px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.hb-val { text-align: right; font-variant-numeric: tabular-nums; }
.day-sum { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.day-sum div { background: rgba(127,127,127,.07); border-radius: 12px; padding: 14px; color: var(--muted); font-size: 14px; }
.day-sum b { display: block; font-size: 30px; color: var(--ink); line-height: 1.1; }
.now-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.now-emp { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.now-emp.sin { border-style: dashed; }
.now-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.now-car, html[data-theme] .now-car { color: var(--ink); }
.now-car { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 10px; color: var(--ink); background: rgba(127,127,127,.06); border-left: 4px solid var(--ok); font-size: 14px; }
.now-car:hover { text-decoration: none; background: rgba(127,127,127,.12); }
.now-car.lvl-warn { border-left-color: var(--warn); }
.now-car.lvl-late { border-left-color: var(--late); }
.pad-h { padding: 16px 18px 0; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 150px auto 1fr auto; gap: 12px; align-items: center; padding: 9px 4px 9px 12px; border-bottom: 1px solid var(--line); border-left: 3px solid var(--c); font-size: 14px; }
.feed-t { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.feed-who { font-weight: 600; font-size: 13px; text-align: right; }
@media (max-width: 1100px) { .rep-cols { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .rep-filtros .sel-emp { margin-left: 0; width: 100%; }
  .rep-periodo { display: flex; width: 100%; } .rep-periodo button { flex: 1 1 30%; border-bottom: 1px solid var(--line2); }
  .day-sum { grid-template-columns: 1fr 1fr; }
  .hbar { grid-template-columns: 100px 1fr 30px; }
  .feed li { grid-template-columns: auto 1fr; } .feed-t { grid-column: 1 / -1; } .feed-who { grid-column: 1 / -1; text-align: left; }
  .now-grid { grid-template-columns: 1fr; }
}

/* ---------- Plano del vehículo (golpes) ---------- */
.bp { background: #0a2540; border: 1px solid rgba(120,190,255,.25); border-radius: 14px; padding: 6px; overflow: hidden; }
.bp-svg { width: 100%; height: auto; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.bp-svg.editable { cursor: crosshair; }
.bp-grid { fill: none; stroke: rgba(140,200,255,.09); stroke-width: 1; }
.bp-body { fill: rgba(143,208,255,.06); stroke: #8fd0ff; stroke-width: 1.6; stroke-linejoin: round; }
.bp-glass { fill: rgba(143,208,255,.18); stroke: #8fd0ff; stroke-width: 1; stroke-linejoin: round; }
.bp-thin { fill: none; stroke: #8fd0ff; stroke-width: 1; opacity: .75; }
.bp-faint { fill: none; stroke: #8fd0ff; stroke-width: 1; opacity: .35; }
.bp-faint-r { fill: none; stroke: #8fd0ff; stroke-width: 1; opacity: .35; stroke-dasharray: 4 4; }
.bp-wheel { fill: #0a2540; stroke: #8fd0ff; stroke-width: 1.6; }
.bp-lbl { fill: #8fd0ff; font-size: 11px; letter-spacing: .12em; font-weight: 700; opacity: .8; font-family: system-ui, sans-serif; }
.bp-mark { cursor: pointer; outline: none; }
.bp-mark circle { fill: #f43f5e; stroke: #fff; stroke-width: 2.5; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.bp-mark text { fill: #fff; font-size: 13px; font-weight: 800; text-anchor: middle; font-family: system-ui, sans-serif; pointer-events: none; }
.bp-mark:hover circle, .bp-mark:focus circle { stroke-width: 4; }
.danos-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.danos-list li { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.dano-num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: #f43f5e; color: #fff; font-weight: 800; font-size: 12px; display: grid; place-items: center; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.dano-txt { flex: 1; }
.tipo-veh { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 4px 0 14px; }
.tv { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 8px; border: 1px solid var(--line2); background: var(--card); color: var(--muted); border-radius: 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.tv:hover { border-color: var(--accent); }
.tv.on { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 14%, var(--card)); box-shadow: inset 0 0 0 1px var(--accent); }
.veh-ico { width: 100%; max-width: 90px; height: 34px; }
.veh-ico * { vector-effect: non-scaling-stroke; }
.veh-ico .bp-body, .veh-ico .bp-wheel { fill: none; stroke: currentColor; stroke-width: 1.4px; }
.veh-ico .bp-glass { fill: currentColor; fill-opacity: .15; stroke: currentColor; stroke-width: 1px; }
.veh-ico .bp-thin, .veh-ico .bp-faint { stroke: currentColor; stroke-width: 1px; }
.tv.on .veh-ico { color: var(--accent); }
@media (max-width: 760px) { .tipo-veh { grid-template-columns: repeat(3, 1fr); } }
/* Impresión: plano en blanco y negro para ahorrar tinta */
.doc .bp { background: #fff; border-color: #ccc; }
.doc .bp-bgrect { fill: none; }
.doc .bp-body { fill: none; stroke: #222; }
.doc .bp-glass { fill: #eee; stroke: #444; }
.doc .bp-thin, .doc .bp-faint, .doc .bp-faint-r { stroke: #555; }
.doc .bp-wheel { fill: #fff; stroke: #222; }
.doc .bp-lbl { fill: #444; }
.doc .danos-list li { font-size: 11.5px; padding: 3px 0; border-color: #ddd; }
.doc-danos { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; align-items: start; }
.plano-h { margin-top: 22px; }
#diag { max-width: 760px; }
.bp-arch { fill: #0a2540; stroke: #8fd0ff; stroke-width: 1.2; }
.bp-ref { fill: #8fd0ff; font-size: 10px; letter-spacing: .1em; opacity: .55; font-family: system-ui, sans-serif; }
.tv small { font-size: 10.5px; font-weight: 500; opacity: .75; margin-top: -2px; }
.veh-ico .bp-arch { fill: none; stroke: none; }
.doc .bp-arch { fill: #fff; stroke: #222; }
.doc .bp-ref { fill: #666; }
.bp-m * { vector-effect: non-scaling-stroke; }
.bp-pillar { fill: #0a2540; stroke: #8fd0ff; stroke-width: 1; }
.veh-ico .bp-pillar { fill: currentColor; fill-opacity: .35; stroke: currentColor; }
.doc .bp-pillar { fill: #fff; stroke: #444; }

/* ---------- Inicio de sesión y estado de la nube ---------- */
body.login-mode .topbar { display: none; }
body.login-mode main { max-width: none; padding: 0; }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; padding: 32px 28px; text-align: center; }
.login-card h1 { font-size: 24px; margin-top: 14px; }
.login-card .muted { margin: 4px 0 22px; }
.login-card .f { text-align: left; }
.login-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 18px; background: var(--accent); color: #1a1000; display: grid; place-items: center; overflow: hidden; }
.login-logo svg { width: 36px; height: 36px; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.login-err { color: var(--late); min-height: 22px; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.nube-estado { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.nube-estado.subiendo { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: pulso-nube 1s ease-in-out infinite; }
.nube-estado.error { background: var(--late); box-shadow: 0 0 8px var(--late); }
@keyframes pulso-nube { 50% { opacity: .35; } }
@media (max-width: 760px) { .nube-estado { margin-left: auto; } .nube-estado + .nav-settings { margin-left: 0; } }
/* Logo del taller (cuadrado con fondo amarillo propio) */
.brand-logo img, .login-logo img { background: transparent; object-fit: cover; }
html[data-theme="oscuro"] .brand-logo:has(img) { box-shadow: 0 0 14px rgba(250,215,0,.35); }
.login-logo:has(img) { width: 120px; height: 120px; border-radius: 24px; }
.doc-logo { max-width: 110px; max-height: 110px; border-radius: 10px; }
.brand, html[data-theme] .brand, .brand:hover { color: #fff; text-decoration: none; }
