/* Marcación DBS · sistema de diseño
   Marca DBS: granate + oro de acento. Estados: verde/ámbar/rojo. */
:root {
  --brand: oklch(0.40 0.13 22);
  --brand-strong: oklch(0.33 0.11 22);
  --brand-soft: oklch(0.95 0.02 22);
  --brand-ink: oklch(0.99 0 0);
  --gold: oklch(0.80 0.13 85);

  --bg: oklch(0.975 0.003 22);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.962 0.004 22);
  --line: oklch(0.90 0.006 22);
  --ink: oklch(0.22 0.012 22);
  --ink-2: oklch(0.40 0.012 22);
  --ink-3: oklch(0.52 0.010 22);

  --ok: oklch(0.55 0.14 150);
  --ok-soft: oklch(0.95 0.04 150);
  --warn: oklch(0.58 0.13 70);
  --warn-soft: oklch(0.96 0.05 90);
  --err: oklch(0.53 0.19 27);
  --err-soft: oklch(0.95 0.03 27);
  --info: oklch(0.52 0.12 250);
  --info-soft: oklch(0.95 0.025 250);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-1: 0 1px 2px oklch(0.2 0.02 22 / 0.06), 0 1px 1px oklch(0.2 0.02 22 / 0.04);
  --shadow-2: 0 14px 36px oklch(0.2 0.02 22 / 0.16), 0 2px 6px oklch(0.2 0.02 22 / 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: oklch(0.62 0.15 22); --brand-strong: oklch(0.70 0.14 22); --brand-soft: oklch(0.30 0.05 22);
    --bg: oklch(0.17 0.008 22); --surface: oklch(0.21 0.009 22); --surface-2: oklch(0.25 0.010 22);
    --line: oklch(0.31 0.010 22); --ink: oklch(0.95 0.004 22); --ink-2: oklch(0.80 0.008 22); --ink-3: oklch(0.66 0.010 22);
    --ok: oklch(0.72 0.15 150); --ok-soft: oklch(0.30 0.06 150); --warn: oklch(0.80 0.13 80); --warn-soft: oklch(0.32 0.06 80);
    --err: oklch(0.70 0.17 27); --err-soft: oklch(0.32 0.07 27); --info: oklch(0.72 0.12 250); --info-soft: oklch(0.30 0.05 250);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: oklch(0.62 0.15 22); --brand-strong: oklch(0.70 0.14 22); --brand-soft: oklch(0.30 0.05 22);
  --bg: oklch(0.17 0.008 22); --surface: oklch(0.21 0.009 22); --surface-2: oklch(0.25 0.010 22);
  --line: oklch(0.31 0.010 22); --ink: oklch(0.95 0.004 22); --ink-2: oklch(0.80 0.008 22); --ink-3: oklch(0.66 0.010 22);
  --ok: oklch(0.72 0.15 150); --ok-soft: oklch(0.30 0.06 150); --warn: oklch(0.80 0.13 80); --warn-soft: oklch(0.32 0.06 80);
  --err: oklch(0.70 0.17 27); --err-soft: oklch(0.32 0.07 27); --info: oklch(0.72 0.12 250); --info-soft: oklch(0.30 0.05 250);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }

/* ---------- botones / campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  font-weight: 600; transition: background .15s var(--ease), transform .1s var(--ease); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-danger { color: var(--err); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.campo { display: grid; gap: 6px; margin-bottom: 14px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.codigo { font: 600 26px/1 var(--mono); letter-spacing: .35em; text-align: center; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 60; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--surface); padding: 12px 14px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2); font-size: 14px; animation: sube .25s var(--ease); }
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes sube { from { transform: translateY(8px); opacity: 0; } }

.cargando { min-height: 70vh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--ink-3); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand);
  animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ================= app del trabajador ================= */
.app-marca main { max-width: 480px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px
  calc(28px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 12px; padding: 6px 0 14px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; flex: none; }
.logo svg { width: 22px; height: 22px; }
.top h1 { font-size: 16px; margin: 0; line-height: 1.2; }
.top small { color: var(--ink-3); font-size: 12.5px; }
.top .estado-red { margin-left: auto; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px;
  background: var(--ok-soft); color: var(--ok); }
.top .estado-red.off { background: var(--warn-soft); color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow-1); margin-bottom: 12px; }
.persona { display: flex; gap: 12px; align-items: center; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; flex: none; }
.persona b { display: block; font-size: 15.5px; line-height: 1.25; }
.persona span { font-size: 13px; color: var(--ink-3); }

.reloj { text-align: center; padding: 18px 0 8px; }
.reloj .hora { font: 700 54px/1 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.reloj .hora small { font-size: 22px; color: var(--ink-3); font-weight: 600; margin-left: 2px; }
.reloj .fecha { color: var(--ink-2); margin-top: 6px; font-size: 14px; }
.reloj .fuente { color: var(--ink-3); font-size: 12px; margin-top: 2px; }

.gps { display: flex; gap: 12px; align-items: center; }
.gps .punto { width: 12px; height: 12px; border-radius: 50%; background: var(--ink-3); flex: none; box-shadow: 0 0 0 4px var(--surface-2); }
.gps.ok .punto { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.gps.warn .punto { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.gps.err .punto { background: var(--err); box-shadow: 0 0 0 4px var(--err-soft); }
.gps b { display: block; font-size: 14.5px; }
.gps span { font-size: 13px; color: var(--ink-3); }
.medidor { height: 6px; border-radius: 99px; background: var(--surface-2); margin-top: 12px; overflow: hidden; }
.medidor i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width .4s var(--ease); }
.gps.warn + .medidor i { background: var(--warn); }
.gps.err + .medidor i { background: var(--err); }

.marcar { width: 100%; min-height: 76px; border: 0; border-radius: var(--radius); font-size: 20px; font-weight: 700;
  color: #fff; background: var(--brand); cursor: pointer; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; box-shadow: var(--shadow-2); transition: transform .1s var(--ease), opacity .2s; }
.marcar small { font-size: 12.5px; font-weight: 500; opacity: .85; }
.marcar.salida { background: oklch(0.36 0.06 250); }
.marcar:active { transform: scale(.985); }
.marcar:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }

.lista-marcas { list-style: none; margin: 0; padding: 0; }
.lista-marcas li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.lista-marcas li:first-child { border-top: 0; }
.lista-marcas .t { font-weight: 600; }
.lista-marcas .h { font: 600 15px var(--mono); }
.chip { white-space: nowrap; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.err { background: var(--err-soft); color: var(--err); }
.chip.info { background: var(--info-soft); color: var(--info); }
.sec-t { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.aviso { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--ink); font-size: 13.5px; margin-bottom: 12px; }
.aviso.err { background: var(--err-soft); }
.aviso.info { background: var(--info-soft); }

/* cámara */
.camara { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.camara video { flex: 1; width: 100%; object-fit: cover; transform: scaleX(-1); }
.camara .marco { position: absolute; left: 50%; top: 42%; width: 62vw; max-width: 300px; aspect-ratio: 3/4;
  transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.85); border-radius: 48% 48% 44% 44%; pointer-events: none; }
.camara .barra { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center;
  justify-content: space-between; background: rgba(0,0,0,.6); color: #fff; }
.camara .disparo { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.camara .txt { position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; color: #fff;
  font-weight: 600; text-shadow: 0 1px 3px #000; }

/* recibo */
.recibo { text-align: center; padding: 22px 8px 6px; }
.recibo .check { width: 78px; height: 78px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok); animation: pop .35s var(--ease); }
.recibo .check.warn { background: var(--warn-soft); color: var(--warn); }
.recibo .check svg { width: 42px; height: 42px; }
.recibo h2 { margin: 0 0 4px; font-size: 22px; }
.recibo .hora { font: 700 44px/1.1 var(--font); font-variant-numeric: tabular-nums; margin: 6px 0; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.pasos { display: flex; gap: 6px; margin: 0 0 16px; }
.pasos i { flex: 1; height: 4px; border-radius: 99px; background: var(--line); }
.pasos i.on { background: var(--brand); }
.pie { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 18px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
