/* Página del ábaco: usa los colores, tarjetas y botones de la página de mediciones (app.css) */

.mode-banner { display: flex; gap: 12px; align-items: center; border-radius: var(--radius-sm); padding: 11px 16px; margin-bottom: var(--gap); font-weight: 600; font-size: 14.5px; position: sticky; top: 12px; z-index: 10; max-width: 1500px; border: 2px solid transparent; }
.mode-banner strong { font-weight: 700; }
.mode-banner svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mode-banner.sim { background: var(--lavender); color: var(--accent-deep); border-color: var(--accent); }
.mode-banner.real { background: var(--mint); color: var(--good); border-color: var(--good); }
.mode-banner.offline { background: var(--rose); color: var(--bad); border-color: var(--bad); }

.mode-switch { display: flex; flex-direction: column; gap: 8px; }
.mode-switch .segmented { width: 100%; }
.mode-switch .segmented button { flex: 1; padding: 9px 6px; font-size: 13.5px; }
.mode-switch .note { font-size: 12px; }

.abaco { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(360px, 1fr); gap: var(--gap); align-items: start; }
.abaco > .col:first-child { position: sticky; top: 76px; }

/* ---------- Visualizador ---------- */
.mat-card { padding: 16px; }
.mat-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; background: #E9ECF3; touch-action: none; }
.mat-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.mat-wrap canvas.grab { cursor: grab; }
.mat-wrap canvas.grabbing { cursor: grabbing; }
.map-controls { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.map-btn { width: 38px; height: 38px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, 0.95); color: var(--ink); font-size: 21px; font-weight: 700; line-height: 1; cursor: pointer; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(27, 33, 64, 0.2); }
.map-btn:hover { background: #fff; color: var(--accent-deep); }
.map-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.map-zoom { min-width: 38px; padding: 3px 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.95); font-size: 12px; font-weight: 700; color: var(--ink-2); text-align: center; box-shadow: 0 2px 8px rgba(27, 33, 64, 0.2); }
.follow-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-top: 14px; }
.follow-row .segmented { flex-wrap: wrap; }
.follow-row .segmented button { display: inline-flex; align-items: center; gap: 6px; }
.mat-tools { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-top: 14px; }
.mat-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-top: 10px; }
.mat-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ring-key { width: 14px; height: 14px; border-radius: 50%; border: 2px dashed var(--ink-2); flex: none; }
.dot-key { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--ink-2); flex: none; }
.small-input { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.small-input input { width: 78px; font-size: 16px; font-weight: 700; padding: 6px 10px; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--surface); }
.small-input input:focus { border-color: var(--accent); outline: none; }
.small-input input[aria-invalid="true"] { border-color: var(--bad); }
.sim-errors { display: flex; flex-wrap: wrap; gap: 10px 18px; }

/* ---------- Valor y operación ---------- */
.value-row { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; }
.digits { display: flex; gap: 10px; }
.digit { width: 64px; border-radius: var(--radius-sm); padding: 6px 0 8px; text-align: center; }
.digit-num { font-size: 40px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.digit-label { font-size: 11.5px; font-weight: 700; color: var(--ink-2); }
.digit.unknown .digit-num { color: var(--ink-3); }
.calc { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.calc .tape-field input { width: 132px; }
.calc .segmented button { font-size: 22px; padding: 8px 16px; font-weight: 700; }
.calc-eq { font-size: 28px; font-weight: 700; color: var(--ink-2); padding-bottom: 10px; }
.calc-result { font-size: 34px; font-weight: 700; padding-bottom: 6px; min-width: 70px; font-variant-numeric: tabular-nums; }
.calc-result.bad { color: var(--bad); font-size: 15px; padding-bottom: 14px; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { background: #8A2626; }

.steps { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; background: var(--bg); font-size: 14px; font-weight: 600; }
.steps li.moviendo { background: var(--accent-soft); }
.steps li.listo { background: var(--mint); }
.steps li.falla { background: var(--rose); color: var(--bad); }
.step-n { font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.step-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.step-note { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.step-state { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.tag { display: inline-flex; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag.acarreo { background: var(--peach); color: var(--warn); }
.tag.préstamo { background: var(--sky); color: #1F5BA8; }

.events { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.events div { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 8px; }
.events time { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Conexión y alineación ---------- */
.robots.compact .robot { cursor: default; padding: 12px 14px; }
.robots.compact .robot-name { font-size: 17px; }
.robot-col { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.05em; }
.pick-robot { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-robot .btn { padding: 9px 14px; }
.compass-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

/* ---------- Color de cada Sphero ---------- */
.robots.compact .robot { position: relative; }
.color-btn { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px rgba(27, 33, 64, 0.16), 0 2px 6px rgba(27, 33, 64, 0.14); cursor: pointer; padding: 0; transition: transform 0.12s ease; }
.color-btn:hover:not(:disabled) { transform: scale(1.1); }
.color-btn:disabled { cursor: not-allowed; opacity: 0.6; }

.picker { position: fixed; z-index: 30; width: min(352px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 18px 48px rgba(27, 33, 64, 0.18), 0 2px 6px rgba(27, 33, 64, 0.08); padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.picker-title { display: inline-flex; align-items: center; gap: 8px; font-size: 16.5px; font-weight: 700; }
.picker-close { width: 32px; height: 32px; border: 0; border-radius: 10px; background: var(--bg); color: var(--ink-2); font-size: 20px; line-height: 1; cursor: pointer; }
.picker-close:hover { background: var(--line); color: var(--ink); }
.picker-preview { display: grid; }
.picker-stage { background: #26272B; border-radius: var(--radius-sm); padding: 6px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.picker-stage canvas { width: 150px; height: 120px; display: block; }
.picker-stage span { font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, 0.78); }
.picker-label { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.picker-swatches { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.swatch-choice { aspect-ratio: 1 / 1; border-radius: 50%; border: 0; padding: 0; background: var(--c); cursor: pointer; display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(27, 33, 64, 0.12); transition: transform 0.12s ease, box-shadow 0.12s ease; }
.swatch-choice:hover { transform: scale(1.08); }
.swatch-choice[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.swatch-choice svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-on); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.swatch-choice[aria-pressed="true"] svg { opacity: 1; }
.hue { position: relative; height: 16px; margin: 6px 12px; border-radius: 999px; cursor: pointer; touch-action: none; background: linear-gradient(to right, hsl(0 60% 50%), hsl(45 60% 50%), hsl(90 60% 50%), hsl(150 60% 50%), hsl(200 60% 50%), hsl(250 60% 50%), hsl(300 60% 50%), hsl(359 60% 50%)); }
.hue:focus-visible { outline-offset: 6px; }
.hue-knob { position: absolute; top: 50%; width: 26px; height: 26px; border-radius: 50%; transform: translate(-50%, -50%); border: 4px solid #fff; box-shadow: 0 1px 5px rgba(27, 33, 64, 0.35); pointer-events: none; }
.picker-hex { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: center; }
.chip-color { width: 38px; height: 38px; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(27, 33, 64, 0.12); }
.picker-hex input { width: 112px; font-size: 16px; font-weight: 700; padding: 7px 10px; border: 2px solid var(--line-strong); border-radius: 10px; background: var(--surface); text-transform: uppercase; font-variant-numeric: tabular-nums; }
.picker-hex input:focus { border-color: var(--accent); outline: none; }
.picker-hex input[aria-invalid="true"] { border-color: var(--bad); }
.picker-hex .note { font-size: 12px; line-height: 1.35; }
.picker-warn { font-size: 13px; font-weight: 600; color: var(--warn); background: var(--peach); padding: 8px 12px; border-radius: 10px; }
.picker-actions { display: flex; align-items: center; gap: 10px; }
.picker-actions .spacer { flex: 1; }
.btn.small { padding: 8px 14px; font-size: 14px; }

/* ---------- Sensores ---------- */
.sensor-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.sensor-card .card-head { margin-bottom: 10px; }
.sensor-card .sensors { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sensor.off { opacity: 0.55; }
.spark-wrap { margin-top: 12px; }
.spark-canvas { width: 100%; height: 70px; display: block; }

@media (max-width: 1280px) {
  .abaco { grid-template-columns: minmax(0, 1fr); }
  .abaco > .col:first-child { position: static; }
  .sensor-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .calc .tape-field input { width: 100px; }
  .digit { width: 54px; }
}
