/* ===== Tueste en vivo: varias tostadoras, desviación, alarmas, fotos ===== */

/* Tabs, one per machine */
.machine-tabs { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.machine-tabs[hidden] { display: none; }
.mt-list { display: flex; gap: 8px; overflow-x: auto; flex: 1; min-width: 0; padding: 2px; scrollbar-width: thin; }
.mt-tab {
  height: auto; min-height: 44px; padding: 7px 14px 7px 12px; border-radius: 11px;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 8px; row-gap: 2px;
  text-align: left; align-items: center; flex-shrink: 0;
}
.mt-tab .mt-dot { grid-row: span 2; }
.mt-name { font-weight: 600; font-size: 13.5px; }
.mt-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--text3); font-variant-numeric: tabular-nums; }
.mt-tab[aria-selected="true"] { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.mt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); display: inline-block; flex-shrink: 0; }
.running > .mt-dot, .mt-tab.running .mt-dot, .mm-card.running .mt-dot { background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.mt-tab.nosignal .mt-dot { background: var(--amber); }
.mt-tab.running .mt-meta { color: var(--text); }
.mt-all[aria-pressed="true"] { background: var(--hover-strong); color: var(--text); }

/* All machines at once */
.live-multi { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.live-multi[hidden] { display: none; }
#view-live.multi-view .live-setup, #view-live.multi-view .instrument, #view-live.multi-view .prod-queue { display: none; }
.mm-card {
  background: var(--ink); color: var(--ink-text); border-radius: var(--r-lg); padding: 14px 16px;
  box-shadow: inset 0 0 0 1px var(--ink-line), var(--shadow-sm); display: flex; flex-direction: column; gap: 10px;
}
.mm-card header { display: flex; align-items: center; gap: 8px; }
.mm-card h3 { margin: 0; font-size: 14px; font-weight: 600; }
.mm-state { margin-left: auto; font-size: 12px; color: var(--ink-text3); }
.mm-card.running .mm-state { color: var(--ink-text); }
.mm-name { font-size: 12.5px; color: var(--ink-text2); margin-top: -4px; }
.mm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mm-stats span { display: block; font-size: 11px; color: var(--ink-text3); }
.mm-stats b { font-family: var(--font-mono); font-weight: 400; font-size: 20px; font-variant-numeric: tabular-nums; }
.mm-stats .bt b { color: var(--bt); } .mm-stats .et b { color: var(--et); } .mm-stats .ror b { color: var(--ror); }
.mm-curve { width: 100%; height: 80px; display: block; }
.mm-curve path { fill: none; stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.mm-empty { height: 80px; display: grid; place-items: center; font-size: 12.5px; color: var(--ink-text3); border: 1px dashed var(--ink-line); border-radius: 10px; }
.mm-card footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-text2); }
.mm-card footer button { background: transparent; color: var(--ink-text); border-color: var(--ink-line-2); box-shadow: none; }
.mm-card footer button:hover { background: rgba(255,255,255,0.06); }

/* Sidebar with several machines */
.side-live-list { display: none; margin-top: 6px; }
.side-live.multi .side-live-list { display: flex; flex-direction: column; gap: 4px; }
.side-live.multi .side-live-run, .side-live.multi svg.spark { display: none !important; }
.slm-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 7px; font-size: 12px; padding: 3px 4px; border-radius: 6px; }
.slm-row:hover { background: rgba(255,255,255,0.06); }
.slm-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-text3); }
.slm-row.running .slm-dot { background: var(--signal); }
.slm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-text2); }
.slm-row.running .slm-name { color: var(--ink-text); }
.slm-meta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-text3); font-variant-numeric: tabular-nums; }
.slm-row.running .slm-meta { color: var(--bt); }

/* Deviation from the reference */
.live-stats:has(#devStat:not([hidden])) { grid-template-columns: 1.15fr 1fr 1fr 1fr 1fr; }
.live-stat.dev[hidden] { display: none; }
.live-stat.dev .v { font-size: 36px; color: var(--ink-text); }
.live-stat.dev .dev-ror { font-family: var(--font-mono); font-size: 12px; color: var(--ink-text3); margin-top: 6px; }
.live-stat.dev.out .v, .live-stat.dev.out .dev-ror { color: var(--signal); }

/* Alarm banner */
.live-alarm {
  display: flex; align-items: center; gap: 12px; margin: 4px 16px 6px; padding: 10px 12px 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--signal) 18%, var(--ink)); color: #fff; box-shadow: inset 0 0 0 1px var(--signal);
  animation: alarm-in .2s var(--ease);
}
.live-alarm[hidden] { display: none; }
.live-alarm > svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--signal); }
.la-list { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; font-weight: 500; }
.live-alarm .la-mute { background: transparent; color: #fff; border-color: rgba(255,255,255,0.35); box-shadow: none; }
.live-alarm .la-mute[hidden] { display: none; }
@keyframes alarm-in { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .live-alarm { animation: none; } }
.alarm-cfg-btn { color: var(--ink-text2) !important; height: 26px !important; }
.alarm-cfg-btn:hover { background: rgba(255,255,255,0.06) !important; color: var(--ink-text) !important; }
.alarm-cfg-btn[hidden] { display: none; }
.alarm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.alarm-events { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.alarm-events legend { font-size: 12.5px; color: var(--text2); padding: 0 4px; }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 6px 0; }
.check-line small { color: var(--text3); margin-left: 2px; }
.alarm-events .check-line { align-items: flex-start; margin: 4px 0; }
.alarm-events .check-line input { margin-top: 2px; }
.alarm-events .check-line small { display: block; margin: 1px 0 0; font-size: 11.5px; }
.check-line input { width: 16px; height: 16px; accent-color: var(--text); }

/* Photos */
.btn-like {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.btn-like svg { width: 15px; height: 15px; }
.btn-like.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-like.sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-like.ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn-like:focus-within { box-shadow: 0 0 0 3px var(--ring); }
.live-photo { margin-left: auto; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 52vh; overflow: auto; }
.photo-item { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-item figcaption { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 10px; }
.photo-item .check-line { margin: 0; font-size: 12.5px; }
.photo-empty { grid-column: 1 / -1; padding: 28px; text-align: center; color: var(--text3); font-size: 13.5px; border: 1px dashed var(--border-strong); border-radius: 10px; }

@media (max-width: 760px) {
  .machine-tabs { flex-direction: column; align-items: stretch; }
  .live-stats:has(#devStat:not([hidden])) { grid-template-columns: 1fr 1fr; }
  .live-stat.dev .v { font-size: 28px; }
  .alarm-grid { grid-template-columns: 1fr; }
  .alarm-events { grid-template-columns: 1fr; }
  .mm-stats b { font-size: 17px; }
}
