:root {
  --bg: #f4f5f7; --card: #fff; --ink: #111827; --ink2: #4b5563; --muted: #6b7280; --line: #e5e7eb;
  --side: #17181c; --side2: #23252b; --acc: #b91c1c; --acc2: #991b1b; --acc-soft: #fef2f2;
  --ok: #047857; --ok-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb; --info: #1d4ed8; --info-soft: #eff6ff;
  --r: 10px; --sh: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }

/* -------- layout */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: #d1d5db; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: #fff; font-weight: 700; letter-spacing: .02em; }
.brand .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--acc); display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; color: #9ca3af; font-size: 11px; letter-spacing: 0; }
.nav a { display: flex; align-items: center; gap: 10px; color: #d1d5db; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; font-weight: 500; }
.nav a:hover { background: var(--side2); text-decoration: none; color: #fff; }
.nav a.on { background: var(--acc); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .sep { font-size: 11px; text-transform: uppercase; color: #6b7280; padding: 14px 10px 6px; letter-spacing: .06em; }
.side .who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #2d3036; font-size: 12px; color: #9ca3af; }
.side .who b { color: #fff; display: block; font-size: 13px; }
.side .who button { margin-top: 8px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top .sub { color: var(--muted); margin-top: 2px; }
.btn.menu-btn { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .main { padding: 14px 14px 60px; }
  .btn.menu-btn { display: inline-flex; }
}

/* -------- cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 16px 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2, .card.flush > .card-head { padding: 14px 18px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid > .card, .grid > div > .card:last-child { margin-bottom: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh); }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--muted); font-size: 12px; }
.kpi.acc { border-left: 4px solid var(--acc); }
.kpi.warn { border-left: 4px solid var(--warn); }
.kpi.ok { border-left: 4px solid var(--ok); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } }

/* -------- tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafafa; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fafafa; }
tfoot td { font-weight: 700; background: #fafafa; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* -------- badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: #f3f4f6; color: var(--ink2); }
.b-Abierta { background: var(--info-soft); color: var(--info); }
.b-Cerrada { background: var(--ok-soft); color: var(--ok); }
.b-Anulada { background: #f3f4f6; color: #6b7280; text-decoration: line-through; }
.b-Pagada { background: var(--ok-soft); color: var(--ok); }
.b-Pendiente { background: var(--acc-soft); color: var(--acc); }
.b-Abonada { background: var(--warn-soft); color: var(--warn); }
.b-Externo { background: #f5f3ff; color: #6d28d9; }
.b-Interno { background: #f0fdfa; color: #0f766e; }
.b-vencida { background: var(--acc); color: #fff; }
.placa { display: inline-block; font-weight: 800; letter-spacing: .06em; background: #fde047; color: #111; border: 1.5px solid #111; border-radius: 5px; padding: 0 7px; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* -------- forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: inherit; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #fecaca; border-color: var(--acc); }
input[type=checkbox] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.f { margin-bottom: 12px; }
.fr { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.search { position: relative; max-width: 360px; flex: 1; }
.search input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters > div { min-width: 140px; }
.placa-input { text-transform: uppercase; font-weight: 700; letter-spacing: .08em; font-size: 20px; max-width: 220px; }

/* -------- buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: var(--acc); color: #fff; font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--acc2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sec { background: #fff; color: var(--ink); border-color: #d1d5db; }
.btn.sec:hover { background: #f9fafb; }
.btn.ghost { background: transparent; color: var(--ink2); border-color: transparent; padding: 5px 8px; }
.btn.ghost:hover { background: #f3f4f6; }
.btn.okb { background: var(--ok); }
.btn.okb:hover { background: #065f46; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.side .btn.sec { background: transparent; color: #d1d5db; border-color: #3a3d44; }

/* -------- detalle orden */
.head-orden { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 4px 10px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12.5px; }
.dl dd { margin: 0; }
.totales { min-width: 280px; }
.totales .row { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totales .tot { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 8px; font-size: 18px; font-weight: 800; }
.totales .saldo { color: var(--acc); font-weight: 700; }
.notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-weight: 500; }
.notice.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #fde68a; }
.notice.info { background: var(--info-soft); color: var(--info); border: 1px solid #bfdbfe; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.week { display: flex; align-items: center; gap: 8px; }
.week b { min-width: 230px; text-align: center; }

/* -------- bars */
.bars .bar { display: grid; grid-template-columns: 140px 1fr 110px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.bars .track { background: #f3f4f6; border-radius: 4px; height: 10px; overflow: hidden; }
.bars .fill { background: var(--acc); height: 100%; border-radius: 4px; }

/* -------- login */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #17181c 0%, #2a1416 100%); padding: 20px; }
.login .box { background: #fff; border-radius: 14px; padding: 30px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login .brand { color: var(--ink); padding: 0 0 18px; }
.login .brand small { color: var(--muted); }
.err { color: var(--acc); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }

/* -------- modal & toasts */
dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 24px)); box-shadow: 0 25px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(17,24,39,.5); }
.m-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.m-head h2 { margin: 0; }
.m-body { padding: 18px 20px; max-height: calc(100vh - 200px); overflow-y: auto; }
.m-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: #fafafa; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--sh); max-width: 360px; animation: up .2s; }
.toast.error { background: var(--acc); }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* -------- fotos y videos */
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.thumb { position: relative; display: block; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #111; padding: 0; cursor: pointer; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb:hover { outline: 2px solid var(--acc); outline-offset: 1px; }
.thumb .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; pointer-events: none; }
.thumb .play svg { width: 34px; height: 34px; filter: drop-shadow(0 1px 3px rgba(0,0,0,.6)); }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 11px; color: #fff; text-align: left; background: linear-gradient(transparent, rgba(0,0,0,.75)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .nofmt { display: grid; place-items: center; height: 100%; color: #d1d5db; gap: 2px; }
.thumb .nofmt svg { width: 28px; height: 28px; }
.thumb .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 12px; }
.dropzone { border: 2px dashed #d1d5db; border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.gal-wrap.drag { outline: 2px dashed var(--acc); outline-offset: 6px; border-radius: 10px; }
.gal-wrap.drag .dropzone { border-color: var(--acc); background: var(--acc-soft); }
.lb-wrap { position: relative; background: #111; border-radius: 10px; display: grid; place-items: center; min-height: 240px; }
.lb { max-width: 100%; max-height: calc(100vh - 330px); display: block; border-radius: 10px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); left: 8px; z-index: 2; opacity: .9; }
.lb-nav.r { left: auto; right: 8px; }
#uploader { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 200; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; width: min(420px, calc(100vw - 24px)); box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: 13px; }
#uploader .prog { height: 6px; background: #374151; border-radius: 3px; margin-top: 8px; overflow: hidden; }
#uploader .prog div { height: 100%; background: #f87171; transition: width .15s; }
label.btn { margin: 0; }

/* lista de trabajos a realizar en la recepción */
.trab { display: grid; grid-template-columns: minmax(180px, 1.2fr) 2fr minmax(120px, .7fr) auto; gap: 8px; margin-bottom: 8px; align-items: center; }
@media (max-width: 700px) { .trab { grid-template-columns: 1fr auto; padding-bottom: 8px; border-bottom: 1px dashed var(--line); } .trab select, .trab [data-k=descripcion] { grid-column: 1 / -1; } }
.ev-col .dropzone { min-height: 90px; }
tr.muted td { color: var(--muted); }
