/* ==========================================================================
   KEYLOOP — sistema de diseño
   Dirección: claridad de tablero de instrumentos. Herramienta de campo:
   alto contraste, tipografía grande, ámbar de pintura de lot como acento.
   CLARO POR DEFAULT. Oscuro opcional.
   ========================================================================== */

:root {
  /* --- superficie --- */
  --ground:      #F1F4F6;
  --surface:     #FFFFFF;
  --surface-2:   #F7F9FA;
  --surface-in:  #E9EDF0;   /* hundido: campos, pistas */
  --line:        #D6DDE3;
  --line-soft:   #E6EBEF;

  /* --- tinta --- */
  --ink:         #11171C;
  --ink-2:       #56616B;
  --ink-3:       #8C97A1;
  --on-accent:   #11171C;
  --on-solid:    #FFFFFF;

  /* --- acento: pintura de lot / aguja de instrumento --- */
  --accent:      #ED9F00;
  --accent-deep: #A56E00;
  --accent-soft: #FDF1D8;
  --accent-line: #F3C978;

  /* --- semánticos de estado (independientes del acento) --- */
  --go:          #0B7D42;   --go-soft:   #E1F1E7;   --go-line:   #9BD0B2;
  --hold:        #B8430B;   --hold-soft: #FBE9DF;   --hold-line: #EFB894;
  --test:        #14539F;   --test-soft: #E3ECF8;   --test-line: #A3C0E4;
  --flag:        #B32114;   --flag-soft: #FBE4E1;   --flag-line: #EFAFA8;
  --idle:        #6B7681;   --idle-soft: #ECEFF2;   --idle-line: #CBD3DA;
  /* "atención": misma familia que hold, con nombre propio porque significa
     otra cosa (algo que revisar), no un estado del vehículo. */
  --warn:        #B8430B;   --warn-soft: #FBE9DF;   --warn-line: #EFB894;

  /* --- elevación --- */
  --sh-1: 0 1px 2px rgba(17,23,28,.07), 0 1px 1px rgba(17,23,28,.04);
  --sh-2: 0 4px 12px rgba(17,23,28,.09), 0 1px 3px rgba(17,23,28,.05);
  --sh-3: 0 12px 32px rgba(17,23,28,.16), 0 2px 8px rgba(17,23,28,.08);
  --sh-bar: 0 -1px 0 var(--line), 0 -8px 24px rgba(17,23,28,.06);

  /* --- tipografía --- */
  --sans: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
          "SF Pro Text", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, "Roboto Mono", Consolas, monospace;

  --t-xs:   11px;
  --t-sm:   13px;
  --t-base: 15px;
  --t-md:   17px;
  --t-lg:   21px;
  --t-xl:   27px;
  --t-2xl:  34px;
  --t-3xl:  44px;

  /* --- geometría --- */
  --r-sm: 5px;
  --r:    9px;
  --r-lg: 14px;
  --r-pill: 999px;
  --col: 480px;          /* la app es un teléfono */
  --bar-h: 84px;         /* barra de acción inferior */
  --pad: 18px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:     #0E1215;
    --surface:    #181E23;
    --surface-2:  #1F262C;
    --surface-in: #131A1F;
    --line:       #2B333B;
    --line-soft:  #222A31;

    --ink:        #E7ECEF;
    --ink-2:      #97A3AD;
    --ink-3:      #6D7A85;
    --on-accent:  #11171C;
    --on-solid:   #11171C;

    --accent:      #FFBB1C;
    --accent-deep: #FFCE55;
    --accent-soft: #2E2308;
    --accent-line: #6B5312;

    --go:   #4FBE84;  --go-soft:   #10251A;  --go-line:   #24503A;
    --hold: #F0894B;  --hold-soft: #2C1809;  --hold-line: #603418;
    --test: #6BA6ED;  --test-soft: #101F33;  --test-line: #274468;
    --flag: #EE8074;  --flag-soft: #2E1512;  --flag-line: #642B24;
    --idle: #8B959E;  --idle-soft: #1D242A;  --idle-line: #333C44;
    --warn: #F0894B;  --warn-soft: #2C1809;  --warn-line: #603418;

    --sh-1: 0 1px 2px rgba(0,0,0,.4);
    --sh-2: 0 4px 12px rgba(0,0,0,.45);
    --sh-3: 0 12px 32px rgba(0,0,0,.6);
    --sh-bar: 0 -1px 0 var(--line), 0 -8px 24px rgba(0,0,0,.35);
  }
}

:root[data-theme="dark"] {
  --ground:     #0E1215;
  --surface:    #181E23;
  --surface-2:  #1F262C;
  --surface-in: #131A1F;
  --line:       #2B333B;
  --line-soft:  #222A31;

  --ink:        #E7ECEF;
  --ink-2:      #97A3AD;
  --ink-3:      #6D7A85;
  --on-accent:  #11171C;
  --on-solid:   #11171C;

  --accent:      #FFBB1C;
  --accent-deep: #FFCE55;
  --accent-soft: #2E2308;
  --accent-line: #6B5312;

  --go:   #4FBE84;  --go-soft:   #10251A;  --go-line:   #24503A;
  --hold: #F0894B;  --hold-soft: #2C1809;  --hold-line: #603418;
  --test: #6BA6ED;  --test-soft: #101F33;  --test-line: #274468;
  --flag: #EE8074;  --flag-soft: #2E1512;  --flag-line: #642B24;
  --idle: #8B959E;  --idle-soft: #1D242A;  --idle-line: #333C44;
  --warn: #F0894B;  --warn-soft: #2C1809;  --warn-line: #603418;

  --sh-1: 0 1px 2px rgba(0,0,0,.4);
  --sh-2: 0 4px 12px rgba(0,0,0,.45);
  --sh-3: 0 12px 32px rgba(0,0,0,.6);
  --sh-bar: 0 -1px 0 var(--line), 0 -8px 24px rgba(0,0,0,.35);
}

/* ========================= base ========================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

:where(a) { color: var(--accent-deep); }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* etiqueta de instrumento */
.label {
  font-family: var(--mono);
  font-size: var(--t-xs);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ========================= armazón ========================= */

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: 100%;
  max-width: var(--col);
  margin: 0 auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--ground);
  position: relative;
}

@media (min-width: 560px) {
  body { background: var(--surface-in); }
  .shell {
    box-shadow: var(--sh-2);
    min-height: 100dvh;
  }
}

/* La consola de dirección se usa en laptop, no de pie en el lot: ahí la
   columna de teléfono estorba y el ancho es la decisión correcta. */
.shell.wide { max-width: 1120px; }
.shell.wide .body { padding: 24px; }

/* barra superior */
.top {
  position: sticky; top: 0; z-index: 40;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 58px;
}
.top-title { font-size: var(--t-md); font-weight: 700; letter-spacing: -.01em; }
.top-sub { font-size: var(--t-xs); color: var(--ink-2); font-family: var(--mono); }
.top-actions { display: flex; gap: 6px; align-items: center; }

.iconbtn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r);
  color: var(--ink-2);
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.iconbtn svg { width: 21px; height: 21px; }

/* cuerpo desplazable */
.body {
  flex: 1;
  padding: var(--pad);
  padding-bottom: calc(var(--bar-h) + 24px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.body.flush { padding-left: 0; padding-right: 0; }
.body.tight { gap: 10px; }

/* barra de acción inferior — el pulgar vive aquí */
.actionbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--surface);
  box-shadow: var(--sh-bar);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}
.actionbar-inner {
  max-width: var(--col);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* En pantalla ancha la barra no debe pintar una banda de borde a borde debajo
   de una columna angosta: el fondo se queda con la columna. */
@media (min-width: 560px) {
  .actionbar {
    background: transparent;
    box-shadow: none;
    pointer-events: none;
    padding-left: 0; padding-right: 0;
  }
  .actionbar-inner {
    pointer-events: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: none;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--sh-3);
    padding: 12px 14px 14px;
  }
}
.actionbar .hint {
  font-size: var(--t-xs);
  color: var(--ink-2);
  text-align: center;
  font-family: var(--mono);
}
.actionbar .hint.block { color: var(--flag); }

/* ========================= botones ========================= */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 56px;
  padding: 0 20px;
  border-radius: var(--r);
  border: 1.5px solid transparent;
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--t-md);
  font-weight: 650;
  letter-spacing: -.005em;
  width: 100%;
  transition: transform .06s ease, background .14s ease, border-color .14s ease;
}
.btn:active { transform: scale(.985); }
.btn svg { width: 20px; height: 20px; flex: none; }

.btn-primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn-primary:hover { background: #000; }
:root[data-theme="dark"] .btn-primary:hover,
:root:not([data-theme="light"]) .btn-primary:hover { background: #fff; }

.btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn-accent:hover { filter: brightness(1.06); }

.btn-go   { background: var(--go);   color: #fff; border-color: var(--go); }
.btn-flag { background: var(--flag); color: #fff; border-color: var(--flag); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); min-height: 46px; font-weight: 550; }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }

.btn:disabled {
  opacity: .42;
  cursor: not-allowed;
  transform: none;
}

.btn-sm { min-height: 42px; font-size: var(--t-sm); padding: 0 14px; border-radius: var(--r-sm); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { width: auto; flex: 1; }

/* ========================= tarjetas ========================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--sh-1);
}
.card-flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-h h2 { font-size: var(--t-md); font-weight: 700; margin: 0; letter-spacing: -.01em; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }

h1 { font-size: var(--t-xl); font-weight: 800; letter-spacing: -.02em; margin: 0; line-height: 1.15; text-wrap: balance; }
h2 { font-size: var(--t-lg); font-weight: 750; letter-spacing: -.015em; margin: 0; }
h3 { font-size: var(--t-base); font-weight: 700; margin: 0; }
p { margin: 0; }
.muted { color: var(--ink-2); }
.muted-2 { color: var(--ink-3); }
.small { font-size: var(--t-sm); }
.xs { font-size: var(--t-xs); }

/* ========================= chips de estado ========================= */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: var(--r-pill);
  font-size: var(--t-xs);
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  border: 1px solid;
  white-space: nowrap;
}
.chip::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; flex: none;
}
.chip.sq::before { border-radius: 2px; }
.chip.tri::before { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }

.s-AVAILABLE  { color: var(--go);   background: var(--go-soft);   border-color: var(--go-line); }
.s-HOLD       { color: var(--hold); background: var(--hold-soft); border-color: var(--hold-line); }
.s-KEY_OUT    { color: var(--hold); background: var(--hold-soft); border-color: var(--hold-line); }
.s-ON_TEST    { color: var(--test); background: var(--test-soft); border-color: var(--test-line); }
.s-RETURN     { color: var(--test); background: var(--test-soft); border-color: var(--test-line); }
.s-FLAGGED    { color: var(--flag); background: var(--flag-soft); border-color: var(--flag-line); }
.s-SERVICE    { color: var(--idle); background: var(--idle-soft); border-color: var(--idle-line); }

/* ========================= unidad del lot ========================= */

.unit {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--idle-line);
  border-radius: var(--r);
  padding: 13px 14px;
  box-shadow: var(--sh-1);
  transition: border-color .14s ease, transform .06s ease;
}
.unit:active { transform: scale(.99); }
.unit:hover { border-color: var(--ink-3); }
.unit.u-AVAILABLE { border-left-color: var(--go); }
.unit.u-HOLD, .unit.u-KEY_OUT { border-left-color: var(--hold); }
.unit.u-ON_TEST, .unit.u-RETURN { border-left-color: var(--test); }
.unit.u-FLAGGED { border-left-color: var(--flag); }
.unit.u-SERVICE { border-left-color: var(--idle); opacity: .72; }

.unit-name { font-size: var(--t-md); font-weight: 700; letter-spacing: -.01em; }
.unit-meta { font-size: var(--t-xs); color: var(--ink-2); font-family: var(--mono); }
.unit-right { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }

/* tier de rastreo */
.tier {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: var(--t-xs); font-weight: 700;
  padding: 2px 7px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.tier svg { width: 12px; height: 12px; }
.tier.t2 { color: var(--accent-deep); border-color: var(--accent-line); background: var(--accent-soft); }

/* ========================= campos ========================= */

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-family: var(--mono); font-size: var(--t-xs); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }

.input, .select, .textarea {
  width: 100%;
  min-height: 54px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  font-size: var(--t-md);
  color: var(--ink);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* código de 6 dígitos */
.code-in {
  font-family: var(--mono);
  font-size: var(--t-2xl);
  font-weight: 700;
  letter-spacing: .34em;
  text-align: center;
  padding: 16px 8px 16px 20px;
  min-height: 76px;
  background: var(--surface-in);
  border: 2px solid var(--line);
}
.code-in:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* filtros por toque — cero tecleo */
.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pill {
  padding: 8px 13px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
  font-weight: 600;
  white-space: nowrap;
}
.pill:hover { border-color: var(--ink-3); color: var(--ink); }
.pill[aria-pressed="true"] {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}

/* ========================= pasos del wizard ========================= */

.steps { display: flex; gap: 5px; padding: 0 var(--pad) 2px; }
.step {
  flex: 1; height: 5px; border-radius: var(--r-pill);
  background: var(--surface-in);
  overflow: hidden;
}
.step.done { background: var(--go); }
.step.now { background: var(--accent); }

.stepnum {
  font-family: var(--mono); font-size: var(--t-xs); letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent-deep); font-weight: 700;
}

/* ========================= cámara ========================= */

.cam {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0B0F12;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
}
.cam video, .cam canvas, .cam img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.cam-ghost {
  position: absolute; inset: 0;
  pointer-events: none;
  display: grid; place-items: center;
  padding: 9%;
}
.cam-ghost svg { width: 100%; height: 100%; }
.ghost-stroke {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: .92;
  filter: drop-shadow(0 0 5px rgba(0,0,0,.65));
}
.ghost-dash { stroke-dasharray: 7 6; opacity: .7; stroke-width: 2; }

.cam-tag {
  position: absolute; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px;
  background: rgba(11,15,18,.82);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: var(--r-pill);
  font-family: var(--mono); font-size: var(--t-xs); font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.cam-tag .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.cam-note {
  position: absolute; bottom: 10px; left: 10px; right: 10px;
  padding: 9px 12px;
  background: rgba(11,15,18,.82);
  backdrop-filter: blur(6px);
  color: #fff;
  border-radius: var(--r);
  font-size: var(--t-sm);
  line-height: 1.35;
}
.cam-off {
  position: absolute; inset: 0;
  display: grid; place-items: center; gap: 10px;
  align-content: center;
  color: #93A0AA;
  text-align: center;
  padding: 20px;
  font-size: var(--t-sm);
}

/* miniaturas de las 5 tomas */
.shots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.shot {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  background: var(--surface-in);
  border: 1.5px solid var(--line);
  overflow: hidden;
  display: grid; place-items: center;
}
.shot img { width: 100%; height: 100%; object-fit: cover; }
.shot.ok { border-color: var(--go); }
.shot.now { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.shot-k {
  font-family: var(--mono); font-size: 9px; font-weight: 700;
  letter-spacing: .06em; color: var(--ink-3);
}
.shot .tick {
  position: absolute; right: 2px; bottom: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--go); color: #fff;
  display: grid; place-items: center; font-size: 10px; font-weight: 800;
}

/* ========================= comparador pre/post ========================= */

.compare {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface-in);
  border: 1px solid var(--line);
  touch-action: none;
  user-select: none;
  cursor: ew-resize;
}
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.compare .post { clip-path: inset(0 0 0 var(--wipe, 50%)); }
.compare .divider {
  position: absolute; top: 0; bottom: 0;
  left: var(--wipe, 50%);
  width: 3px; margin-left: -1.5px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
.compare .knob {
  position: absolute; top: 50%; left: var(--wipe, 50%);
  transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: var(--sh-2);
  font-size: 13px; font-weight: 800;
}
.compare .tagL, .compare .tagR {
  position: absolute; top: 10px;
  padding: 4px 9px; border-radius: var(--r-pill);
  background: rgba(11,15,18,.8); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
}
.compare .tagL { left: 10px; }
.compare .tagR { right: 10px; }

/* ========================= mapa del lot ========================= */

.lotmap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.05;
  background: var(--surface-in);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.lotmap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.slot-fill { fill: var(--surface); stroke: var(--line); stroke-width: .8; }
.slot-line { stroke: var(--accent-line); stroke-width: 1; opacity: .55; }
.slot-txt { fill: var(--ink-3); font-family: var(--mono); font-size: 3.6px; letter-spacing: .04em; }
.lot-edge { fill: none; stroke: var(--ink-3); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .5; }
.lot-label { fill: var(--ink-3); font-family: var(--mono); font-size: 4px; letter-spacing: .18em; text-transform: uppercase; }
.slot-occ { fill: var(--idle-soft); stroke: var(--idle-line); }
.slot-target { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.6; }

.pin-ring { fill: none; stroke: var(--accent); stroke-width: 1.4; opacity: .9; }
.pin-core { fill: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .pin-pulse { animation: pulse 2.1s ease-out infinite; transform-origin: center; }
  @keyframes pulse {
    0%   { r: 3;  opacity: .85; stroke-width: 1.6; }
    70%  { r: 13; opacity: 0;   stroke-width: .5; }
    100% { r: 13; opacity: 0;   stroke-width: .5; }
  }
}

/* ========================= telemetría / guardian ========================= */

.telem { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.gauge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.gauge .k { font-family: var(--mono); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-3); }
.gauge .v { font-size: var(--t-lg); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.gauge .v small { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.gauge.hot { border-color: var(--flag-line); background: var(--flag-soft); }
.gauge.hot .v { color: var(--flag); }

.guardline {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 14px;
  border-radius: var(--r);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
}
.guardline svg { width: 22px; height: 22px; color: var(--accent-deep); flex: none; }

/* barra de nivel (gasolina) */
.bar { height: 9px; border-radius: var(--r-pill); background: var(--surface-in); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.bar.go > i { background: var(--go); }
.bar.flag > i { background: var(--flag); }

/* ========================= hallazgos ========================= */

.finding {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 11px;
  padding: 12px 13px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  border-left: 4px solid var(--ink-3);
}
.finding.new { border-left-color: var(--flag); background: var(--flag-soft); border-color: var(--flag-line); }
.finding.declared { border-left-color: var(--idle); }
.finding-badge {
  grid-row: span 2;
  width: 34px; height: 34px; border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-in); color: var(--ink-2);
  font-family: var(--mono); font-size: 10px; font-weight: 800;
}
.finding.new .finding-badge { background: var(--flag); color: #fff; }
.finding-t { font-weight: 650; font-size: var(--t-sm); }
.finding-m { font-size: var(--t-xs); color: var(--ink-2); font-family: var(--mono); }

/* ========================= avisos ========================= */

.note {
  display: flex; gap: 11px;
  padding: 13px 14px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: var(--t-sm);
  line-height: 1.45;
}
.note svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.note-gate { border-color: var(--flag-line); background: var(--flag-soft); color: var(--flag); }
.note-gate strong { color: var(--flag); }
.note-go { border-color: var(--go-line); background: var(--go-soft); color: var(--go); }
.note-accent { border-color: var(--accent-line); background: var(--accent-soft); }
.note-accent svg { color: var(--accent-deep); }

/* datos en renglón */
.kv { display: flex; flex-direction: column; gap: 0; }
.kv-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.kv-row:last-child { border-bottom: none; }
.kv-k { font-family: var(--mono); font-size: var(--t-xs); letter-spacing: .09em; text-transform: uppercase; color: var(--ink-2); }
.kv-v { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.kv-v.big { font-size: var(--t-md); }
.kv-v.delta { color: var(--accent-deep); }

/* cronómetro */
.timer {
  font-family: var(--mono);
  font-size: var(--t-3xl);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  text-align: center;
  line-height: 1;
}
.timer-wrap { padding: 8px 0 4px; }

/* vacío */
.empty {
  display: grid; place-items: center; gap: 10px;
  padding: 46px 20px; text-align: center;
  color: var(--ink-2);
}
.empty svg { width: 34px; height: 34px; color: var(--ink-3); }

/* separador con texto */
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.or span { font-family: var(--mono); font-size: var(--t-xs); letter-spacing: .12em; text-transform: uppercase; }

/* marca */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--ink); color: var(--accent);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name { font-size: var(--t-lg); font-weight: 800; letter-spacing: -.03em; }
.brand-name em { font-style: normal; color: var(--accent-deep); }

/* aviso emergente */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h) + 20px);
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(var(--col) - 36px);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  background: var(--ink); color: var(--surface);
  box-shadow: var(--sh-3);
  font-size: var(--t-sm); font-weight: 600;
}
.toast svg { width: 17px; height: 17px; flex: none; }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .22s cubic-bezier(.2,.9,.3,1); }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 12px); } }
}

/* transición de vista */
@media (prefers-reduced-motion: no-preference) {
  .view-in { animation: slidein .2s cubic-bezier(.2,.9,.3,1); }
  @keyframes slidein { from { opacity: 0; transform: translateY(7px); } }
}

/* hoja modal */
.sheet-bg {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11,15,18,.5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.sheet {
  width: 100%; max-width: var(--col);
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--sh-3);
  max-height: 88dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .24s cubic-bezier(.2,.9,.3,1); }
  @keyframes up { from { transform: translateY(100%); } }
}
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 2px; }

/* resumen del dueño */
.digest-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px;
  display: flex; flex-direction: column; gap: 3px;
}
.stat .n { font-size: var(--t-2xl); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; }
.stat .l { font-family: var(--mono); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; color: var(--ink-2); }
.stat.alert { border-color: var(--flag-line); background: var(--flag-soft); }
.stat.alert .n { color: var(--flag); }
.stat.good .n { color: var(--go); }

/* ========================= tablero del yard ========================= */

.yardboard {
  position: relative;
  width: 100%;
  aspect-ratio: 100 / 104;
  background: var(--surface-in);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.yardboard svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.yard-slot { stroke-width: .7; }
/* cajón libre: nunca tuvo unidad asignada */
.yard-slot.y-free { fill: var(--surface); stroke: var(--line); }
/* cajón vacío porque la unidad salió: hueco y punteado, se lee de lejos */
.yard-slot.y-vacated {
  fill: none;
  stroke: var(--warn);
  stroke-width: 1.1;
  stroke-dasharray: 2 1.4;
}
/* cajón ocupado, por estado de la unidad */
.yard-slot.y-AVAILABLE { fill: var(--go-soft);   stroke: var(--go);   stroke-width: 1; }
.yard-slot.y-FLAGGED   { fill: var(--flag-soft); stroke: var(--flag); stroke-width: 1; }
.yard-slot.y-SERVICE   { fill: var(--idle-soft); stroke: var(--idle-line); }
.yard-slot.y-pick      { stroke: var(--accent); stroke-width: 1.8; }

.yard-txt {
  fill: var(--ink);
  font-family: var(--mono);
  font-size: 3.4px;
  font-weight: 700;
  letter-spacing: .04em;
}
.yard-txt-out { fill: var(--warn); }
.yard-sub {
  fill: var(--warn);
  font-family: var(--mono);
  font-size: 2.3px;
  font-weight: 700;
  letter-spacing: .12em;
}
.yard-mis { fill: var(--accent); }

/* leyenda del tablero */
.yard-legend { display: flex; flex-wrap: wrap; gap: 12px; }
.yl { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-xs); color: var(--ink-2); }
.yl i {
  width: 15px; height: 11px; border-radius: 2px; display: block; flex: none;
  border: 1px solid var(--line); background: var(--surface);
}
.yl.free i    { background: var(--surface);   border-color: var(--line); }
.yl.occ i     { background: var(--go-soft);   border-color: var(--go); }
.yl.vacated i { background: transparent;      border: 1.5px dashed var(--warn); }
.yl.flag i    { background: var(--flag-soft); border-color: var(--flag); }
.yl.svc i     { background: var(--idle-soft); border-color: var(--idle-line); }
.yl.mis i     { background: var(--surface); border-color: var(--line); position: relative; }

/* ========================= consola de dirección ========================= */

.dir-grid { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .dir-grid.two { grid-template-columns: 1fr 1fr; align-items: start; }
  .dir-grid.side { grid-template-columns: minmax(0,1.35fr) minmax(0,1fr); align-items: start; }
}
.dir-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }

/* renglón de alerta: severidad codificada en la barra y en la palabra */
.alert-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--idle);
  border-radius: var(--r);
  background: var(--surface);
  width: 100%; text-align: left;
}
.alert-row:hover { border-color: var(--ink-3); }
.alert-row.sev-alta  { border-left-color: var(--flag); background: var(--flag-soft); border-color: var(--flag-line); }
.alert-row.sev-media { border-left-color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.alert-row.sev-baja  { border-left-color: var(--idle); }
.alert-t { font-weight: 650; font-size: var(--t-sm); grid-column: 2; }
.alert-m { font-family: var(--mono); font-size: var(--t-xs); color: var(--ink-2); grid-column: 2; }
.alert-badge {
  grid-row: span 2; align-self: center;
  width: 40px; height: 40px; border-radius: var(--r-sm);
  display: grid; place-items: center; flex: none;
  background: var(--surface-in); color: var(--ink-2);
}
.sev-alta .alert-badge  { background: var(--flag); color: #fff; }
.sev-media .alert-badge { background: var(--warn); color: #fff; }
.alert-right {
  grid-row: span 2; align-self: center;
  font-family: var(--mono); font-size: var(--t-xs); font-weight: 700;
  text-align: right; white-space: nowrap; color: var(--ink-2);
}
.sev-alta .alert-right  { color: var(--flag); }
.sev-media .alert-right { color: var(--warn); }

/* tabla de dirección */
.dtable { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.dtable th {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-2); text-align: left; padding: 9px 10px;
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
.dtable td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.dtable tr:last-child td { border-bottom: none; }
.dtable td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.dtable .who { font-weight: 650; }
.dtable .unit-cell { font-weight: 650; }
.dtable .unit-cell small { display: block; font-weight: 400; color: var(--ink-2); font-family: var(--mono); font-size: 10.5px; }

/* panel de control remoto */
.cmdgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; }
.cmdbtn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 13px 14px; border-radius: var(--r);
  border: 1.5px solid var(--line); background: var(--surface);
  text-align: left; width: 100%;
}
.cmdbtn:hover { border-color: var(--ink-3); }
.cmdbtn .cn { font-weight: 700; font-size: var(--t-sm); display: flex; align-items: center; gap: 7px; }
.cmdbtn .cd { font-size: var(--t-xs); color: var(--ink-2); line-height: 1.35; }
.cmdbtn.on { border-color: var(--accent); background: var(--accent-soft); }
.cmdbtn.on .cn { color: var(--accent-deep); }
.cmdbtn.danger { border-color: var(--flag-line); }
.cmdbtn.danger .cn { color: var(--flag); }
.cmdbtn.danger.on { background: var(--flag-soft); border-color: var(--flag); }
.cmdbtn:disabled { opacity: .45; cursor: not-allowed; }

/* bitácora */
.logline {
  display: grid; grid-template-columns: 52px 1fr; gap: 11px;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft);
  font-size: var(--t-sm); align-items: baseline;
}
.logline:last-child { border-bottom: none; }
.logline .lt { font-family: var(--mono); font-size: var(--t-xs); color: var(--ink-3); }

/* selector de sección */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px; border-radius: var(--r-pill);
  border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: var(--t-sm); font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { border-color: var(--ink-3); color: var(--ink); }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tab .n {
  font-family: var(--mono); font-size: 10.5px; font-weight: 800;
  padding: 1px 6px; border-radius: var(--r-pill);
  background: var(--surface-in); color: var(--ink-2);
}
.tab[aria-pressed="true"] .n { background: rgba(255,255,255,.2); color: var(--surface); }
.tab .n.hot { background: var(--flag); color: #fff; }

/* línea de tiempo del viaje */
.tl { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; }
.tl-dot { display: flex; flex-direction: column; align-items: center; }
.tl-dot i {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: var(--surface); border: 2.5px solid var(--go); margin-top: 5px;
}
.tl-dot span { flex: 1; width: 2px; background: var(--line); margin: 3px 0; }
.tl-item:last-child .tl-dot span { display: none; }
.tl-item.pend .tl-dot i { border-color: var(--line); }
.tl-body { padding-bottom: 14px; }
.tl-t { font-weight: 650; font-size: var(--t-sm); }
.tl-m { font-family: var(--mono); font-size: var(--t-xs); color: var(--ink-2); }
.tl-item.pend .tl-t { color: var(--ink-3); }
