/* ============================================================
   BARRA · components — piezas reutilizables de la app
   ============================================================ */

/* ---------------- Tarjeta ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
}
.card > header {
  display: flex; align-items: baseline; gap: var(--sp-3);
  margin: calc(-1 * var(--sp-1)) 0 var(--sp-3);
  flex-wrap: wrap;
}
.card > header h3, .card > header h4 { flex: 1; min-width: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card.acc { border-color: var(--acc); }
.card.flush > header { padding: var(--sp-4) var(--sp-4) 0; margin: 0 0 var(--sp-3); }

.grid { display: grid; gap: var(--sp-3); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spread { margin-left: auto; }

/* ---------------- Cifra destacada ---------------- */
.stat {
  display: grid; gap: 2px;
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.stat .k { font-size: var(--t-2xs); letter-spacing: 0.13em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.stat .v {
  font-family: var(--mono); font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 700; letter-spacing: -0.04em; line-height: 1.1;
}
.stat .s { font-size: var(--t-xs); color: var(--ink-2); }
.stat.acc { background: var(--acc-soft); border-color: transparent; }
.stat.acc .v { color: var(--acc); }
.stat.dat { background: var(--data-soft); border-color: transparent; }
.stat.dat .v { color: var(--data); }
.stat.ok { background: var(--ok-soft); border-color: transparent; } .stat.ok .v { color: var(--ok); }
.stat.aviso { background: var(--aviso-soft); border-color: transparent; } .stat.aviso .v { color: var(--aviso); }
.stat.grave { background: var(--grave-soft); border-color: transparent; } .stat.grave .v { color: var(--grave); }

/* ---------------- Lista de filas ---------------- */
.list { display: grid; }
.list__row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 11px var(--sp-4);
  border-top: 1px solid var(--line);
  min-width: 0;
}
.list__row:first-child { border-top: 0; }
.list__row .main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.list__row .main b { font-size: var(--t-sm); font-weight: 600; letter-spacing: -0.008em; }
.list__row .main span { font-size: var(--t-xs); color: var(--ink-3); }
.list__row .val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: var(--t-sm); flex: none; }
.list__row.on { background: var(--acc-soft); }
.list__row.hoverable { cursor: pointer; transition: background-color var(--d-xs) var(--ease-out); }
.list__row.hoverable:hover { background: var(--surface-2); }

.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center; color: var(--ink-3); font-size: var(--t-sm);
  border: 1px dashed var(--line-2); border-radius: var(--r-md);
  display: grid; gap: 6px; justify-items: center;
}
.empty .big { font-size: 1.6rem; opacity: 0.5; }

/* ---------------- Tabla ---------------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: var(--t-sm); min-width: 440px; }
th, td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th {
  background: var(--surface-2); position: sticky; top: 0;
  font-size: var(--t-2xs); letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------- Teclado numérico ---------------- */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.keypad button {
  padding: 15px 0; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--r-sm); font-family: var(--mono); font-size: 1.2rem; font-weight: 650;
  cursor: pointer; transition: background-color var(--d-xs) var(--ease-out), transform var(--d-xs) var(--ease-out);
}
.keypad button:hover { background: var(--surface-3); }
.keypad button:active { transform: scale(0.94); background: var(--acc-soft); }
.keypad button.wide { grid-column: span 2; }
.keypad button.act { background: var(--acc); color: var(--acc-ink); border-color: transparent; }

/* ---------------- Chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: var(--r-full); padding: 5px 12px; font-size: var(--t-xs); font-weight: 600;
  cursor: pointer; transition: all var(--d-xs) var(--ease-out); white-space: nowrap;
}
.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--acc); border-color: transparent; color: var(--acc-ink); }
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--line); color: var(--ink-2); }

/* ---------------- Aviso ---------------- */
.note {
  border-left: 3px solid var(--acc);
  background: var(--acc-soft);
  padding: 11px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: var(--t-sm); line-height: 1.5;
}
.note.aviso { border-left-color: var(--aviso); background: var(--aviso-soft); }
.note.grave { border-left-color: var(--grave); background: var(--grave-soft); }
.note.ok { border-left-color: var(--ok); background: var(--ok-soft); }
.note.dat { border-left-color: var(--data); background: var(--data-soft); }
.note b { font-weight: 650; }

/* ---------------- Toast ---------------- */
.toaster {
  position: fixed; left: 50%; bottom: calc(var(--sp-5) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: grid; gap: 8px; justify-items: center;
  width: max-content; max-width: calc(100vw - 2 * var(--sp-4));
  pointer-events: none;
}
.toast {
  background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: 600;
  box-shadow: var(--shadow-3);
  display: flex; align-items: center; gap: 9px;
  animation: toastIn 320ms var(--ease-spring) both;
}
.toast.out { animation: toastOut 220ms var(--ease-in-out) both; }
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--acc); flex: none; }
.toast.ok .dot { background: var(--ok); }
.toast.grave .dot { background: var(--grave); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.97); } }

/* ---------------- Diálogo ---------------- */
dialog {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--r-lg); padding: 0; max-width: min(520px, calc(100vw - 2 * var(--sp-4)));
  width: 100%; box-shadow: var(--shadow-3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(3px); }
dialog[open] { animation: viewIn var(--d-sm) var(--ease-out) both; }
dialog > form, dialog > .dlg { display: grid; gap: var(--sp-4); padding: var(--sp-5); }
dialog h3 { font-size: var(--t-lg); }

/* ---------------- Barra de acciones fija (móvil) ---------------- */
.dock {
  position: sticky; bottom: 0;
  background: var(--glass);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--glass-line);
  padding: var(--sp-3) 0 calc(var(--sp-3) + env(safe-area-inset-bottom));
  margin-top: var(--sp-3);
  display: flex; gap: var(--sp-2); align-items: center;
  z-index: var(--z-sticky);
}
.dock .total { flex: 1; display: grid; }
.dock .total .k { font-size: var(--t-2xs); text-transform: uppercase; letter-spacing: 0.11em; color: var(--ink-3); }
.dock .total .v { font-family: var(--mono); font-size: 1.35rem; font-weight: 700; letter-spacing: -0.04em; }

/* ---------------- Gráfico de barras simple ---------------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 92px; }
.bars > div {
  flex: 1; min-width: 4px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--acc), var(--acc-lo));
  position: relative;
  transform-origin: bottom;
  animation: pourFill 620ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 26ms);
}
.bars > div[data-zero="1"] { background: var(--surface-3); }
.barsx { display: flex; gap: 3px; margin-top: 5px; }
.barsx > span { flex: 1; min-width: 4px; text-align: center; font-size: 9px; color: var(--ink-3); font-family: var(--mono); }

/* ---------------- Anillo de temporizador ---------------- */
.timer {
  display: grid; gap: var(--sp-3); justify-items: center;
  padding: var(--sp-4); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  position: relative; overflow: hidden;
}
.timer.done { border-color: var(--grave); background: var(--grave-soft); }
.timer.run { border-color: var(--acc); }
.timer__ring { position: relative; width: 108px; height: 108px; }
.timer__ring svg { width: 100%; height: 100%; }
.timer__val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--mono); font-size: 1.4rem; font-weight: 700; letter-spacing: -0.04em;
}
.timer__name { font-size: var(--t-sm); font-weight: 650; text-align: center; }
.timer__row { display: flex; gap: 6px; }

/* ---------------- Divisor de sección dentro de una vista ---------------- */
.subhead {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--t-2xs); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
  margin-top: var(--sp-2);
}
.subhead::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------------- Etiqueta arrastrable / borrar ---------------- */
.del {
  border: 0; background: transparent; color: var(--ink-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; font-size: 1rem; line-height: 1;
  transition: color var(--d-xs) var(--ease-out), background-color var(--d-xs) var(--ease-out);
}
.del:hover { color: var(--grave); background: var(--grave-soft); }

/* ---------------- Stepper ---------------- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-full); overflow: hidden; flex: none; }
.stepper button {
  width: 30px; height: 30px; border: 0; background: var(--surface-2); color: var(--ink);
  cursor: pointer; font-size: 1rem; line-height: 1;
  transition: background-color var(--d-xs) var(--ease-out);
}
.stepper button:hover { background: var(--surface-3); }
.stepper .q { min-width: 30px; text-align: center; font-family: var(--mono); font-size: var(--t-sm); font-weight: 650; }
