/* Bagger Mars Live Monitor — Mars-rust / IBM Plex, Spanish plant UI */
:root {
  --bg: #1c0d10;
  --bg-2: #14080a;
  --surface: #2a1518;
  --surface-2: #351c20;
  --line: #4a272c;
  --fg: #f3e6e4;
  --muted: #a8908c;
  --dim: #7a6360;
  --red: #E52120;
  --red-dim: #8c1818;
  --ok: #3dba7a;
  --warn: #e8a838;
  --bad: #E52120;
  --esab: #d8dee8;
  --ebx: #f0c9a0;
  --radius: 14px;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(229,33,32,.16), transparent 55%),
    radial-gradient(800px 500px at 100% 100%, rgba(80,20,24,.35), transparent 50%),
    var(--bg-2);
  min-height: 100dvh;
  letter-spacing: 0.01em;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.55'/></svg>");
}
a { color: inherit; text-decoration: none; }
button, input { font-family: inherit; }

.app { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 22px 20px 48px; }

/* Gate */
.gate {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background:
    radial-gradient(700px 420px at 50% 30%, rgba(229,33,32,.2), transparent 60%),
    #100608;
  padding: 24px;
}
.gate[hidden] { display: none !important; }
.gate-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 26px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.gate-kicker { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.gate h1 { font-size: 22px; margin: 8px 0 6px; font-weight: 600; }
.gate p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.gate label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.gate input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  outline: none;
}
.gate input:focus { border-color: var(--red); }
.gate .err { color: var(--red); font-size: 13px; min-height: 1.2em; margin: 8px 0 12px; }
.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--red); color: #fff;
  font-weight: 600; font-size: 14px;
  padding: 12px 16px; border-radius: 10px;
  letter-spacing: .04em;
}
.btn:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost.on { color: var(--warn); border-color: var(--warn); }

/* Header / logos */
.logos {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 6px 0 16px;
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 600; letter-spacing: .14em; font-size: 13px; }
.logo.esab { justify-self: start; color: var(--esab); font-stretch: condensed; }
.logo.ebx { justify-self: center; color: var(--ebx); letter-spacing: .18em; }
.logo.ebx span { color: var(--red); }
.logo.mars { justify-self: end; color: var(--red); letter-spacing: .16em; font-size: 12px; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  align-items: flex-end; justify-content: space-between;
  margin: 18px 0 22px;
}
.brand-kicker { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.brand h1 { margin: 4px 0 0; font-size: 28px; font-weight: 600; }
.clock-wrap { text-align: right; }
.clock { font-family: var(--mono); font-size: 28px; font-weight: 500; font-variant-numeric: tabular-nums; }
.clock-sub { color: var(--muted); font-size: 12px; letter-spacing: .08em; }

.status-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.pill.live .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.live { color: var(--ok); border-color: rgba(61,186,122,.35); }
.pill.down .dot { background: var(--red); }
.pill.down { color: #ff8a80; border-color: rgba(229,33,32,.4); }
.pill.sim .dot { background: var(--warn); }
.pill.sim { color: var(--warn); border-color: rgba(232,168,56,.4); }

.banner {
  display: none;
  margin: 0 0 18px;
  background: rgba(232,168,56,.12);
  border: 1px solid rgba(232,168,56,.4);
  color: var(--warn);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 600;
}
.banner.show { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.banner-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .02em;
  text-transform: none;
  color: var(--muted);
}
.banner-hint[hidden] { display: none !important; }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .logos { font-size: 11px; }
  .brand h1 { font-size: 22px; }
  .clock { font-size: 22px; }
  .clock-wrap { text-align: left; }
}

.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: rgba(229,33,32,.55); transform: translateY(-1px); }
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--red);
}
.card-line { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.card h2 { margin: 4px 0 2px; font-size: 22px; font-weight: 600; }
.card .topic { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.pzas {
  font-family: var(--mono);
  font-size: 42px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin: 14px 0 2px;
  line-height: 1;
}
.pzas small { font-size: 14px; color: var(--muted); margin-left: 6px; letter-spacing: .08em; }
.meta-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.track { height: 8px; background: #1a0c0e; border-radius: 99px; overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--red); border-radius: 99px; width: 0%; transition: width .4s ease; }
.track.ok > span { background: var(--ok); }
.track.warn > span { background: var(--warn); }
.pct { font-family: var(--mono); font-size: 18px; margin-top: 10px; }

.card.pending {
  opacity: .78;
  cursor: default;
}
.card.pending:hover { border-color: var(--line); transform: none; }
.card.pending::before { background: var(--dim); }
.card.pending .pzas { color: var(--dim); font-size: 32px; }
.pending-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--warn);
  border: 1px solid rgba(232,168,56,.35);
  border-radius: 999px;
  padding: 4px 10px;
}
.card-go { margin-top: 12px; font-size: 13px; color: var(--red); font-weight: 600; letter-spacing: .06em; }

/* Detail */
.back { display: inline-flex; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.back:hover { color: var(--fg); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin: 16px 0 22px; }
@media (max-width: 800px) { .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.kpi .lbl { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kpi .val { font-family: var(--mono); font-size: 28px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11px; color: var(--dim); margin-top: 4px; }

.shift-bar { display: flex; gap: 8px; margin: 8px 0 16px; flex-wrap: wrap; }
button.shift-chip {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  font: inherit;
}
.shift-chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; color: var(--muted);
}
.shift-chip.active { border-color: var(--red); color: var(--fg); background: rgba(229,33,32,.12); }

.chart {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 10px;
}
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.chart-head span { font-size: 12px; color: var(--muted); }
.bars {
  position: relative;
  height: 240px;
  display: flex; align-items: stretch; gap: 6px;
  padding: 8px 0 28px;
  overflow: visible;
}
@media (max-width: 700px) {
  .bars {
    height: 260px;
    gap: 4px;
    padding-bottom: 36px;
  }
}
.meta-line {
  position: absolute; left: 0; right: 0;
  border-top: 1px dashed rgba(229,33,32,.55);
  pointer-events: none;
}
.meta-line label {
  position: absolute; right: 0; top: -16px;
  font-size: 10px; color: var(--red); letter-spacing: .08em;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar-col .shaft {
  flex: 1; width: 100%; max-width: 36px;
  background: #1a0c0e;
  border-radius: 6px 6px 2px 2px;
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.bar-col .fill {
  width: 100%; background: var(--red);
  height: 0%; transition: height .35s ease, background .35s ease;
}
.bar-col.now .fill { background: #ff4a45; box-shadow: 0 0 12px rgba(229,33,32,.45); }
.bar-col.met .fill {
  background: var(--ok);
  box-shadow: 0 0 10px rgba(61,186,122,.35);
}
.bar-col.met.now .fill {
  background: #4fd68f;
  box-shadow: 0 0 12px rgba(61,186,122,.5);
}
.bar-col .n { font-family: var(--mono); font-size: 10px; color: var(--muted); margin: 6px 0 2px; }
.bar-col .h { font-size: 10px; color: var(--dim); letter-spacing: .04em; }

details.map {
  margin-top: 22px; color: var(--muted); font-size: 13px;
}
details.map summary { cursor: pointer; color: var(--dim); }
details.map table { width: 100%; border-collapse: collapse; margin-top: 10px; }
details.map th, details.map td {
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 12px;
}

footer.site {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  letter-spacing: .06em;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.offshift { color: var(--warn); font-size: 13px; margin: 8px 0 0; }

/* Top nav + reports */
.top-nav {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 600;
}
.top-nav a { color: var(--muted); }
.top-nav a:hover { color: var(--fg); }

.landing-actions { margin: 0 0 16px; }
.landing-actions .btn { display: inline-block; }

.report-head { margin-bottom: 8px; }
.report-head h2 { margin: 4px 0 0; font-size: 28px; font-weight: 600; }
.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 18px;
}
.report-toolbar label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 8px;
}
.report-toolbar input[type="date"] {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--mono);
  color-scheme: dark;
  outline: none;
}
.report-toolbar input[type="date"]:focus { border-color: var(--red); }
.days-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
}
.days-list .lbl {
  width: 100%;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.day-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  background: transparent;
  cursor: pointer;
}
.day-chip:hover { color: var(--fg); border-color: rgba(229,33,32,.45); }
.day-chip.active {
  border-color: var(--red);
  color: var(--fg);
  background: rgba(229,33,32,.12);
}
.report-empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 15px;
}
.report-machine {
  margin: 0 0 28px;
}
.report-machine h2 {
  margin: 4px 0 10px;
  font-size: 22px;
}
.report-shift { margin: 0 0 18px; }
.report-shift .chart { margin-top: 12px; }
.report-note { color: var(--dim); font-size: 12px; margin: 8px 0 0; }

/* Auth / admin */
.gate label + label { margin-top: 12px; }
.gate-check {
  display: flex !important;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 4px;
  font-size: 13px !important;
  color: var(--muted);
  line-height: 1.35;
  cursor: pointer;
}
.gate-check input {
  width: auto !important;
  margin-top: 2px;
  accent-color: var(--red);
}
.top-nav {
  display: flex; flex-wrap: wrap; gap: 10px 14px;
  align-items: center; justify-content: flex-end;
  margin-top: 8px;
}
.top-nav a {
  color: var(--muted); text-decoration: none; font-size: 13px;
  letter-spacing: .06em; text-transform: uppercase;
}
.top-nav a:hover { color: var(--fg); }
.user-chip {
  font-size: 12px; color: var(--muted);
  letter-spacing: .04em;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.btn-logout {
  appearance: none; border: 1px solid var(--line);
  background: transparent; color: var(--muted);
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
}
.btn-logout:hover { color: var(--fg); border-color: var(--fg); }
.admin h1 { font-size: 22px; margin: 8px 0 14px; }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.admin-panel h2 { font-size: 18px; margin: 0 0 8px; }
.admin-panel h3 { font-size: 15px; margin: 22px 0 10px; }
.admin-panel .muted { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.ok-msg { color: var(--ok); font-size: 13px; margin: 0 0 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.admin-table th, .admin-table td {
  text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.admin-table th {
  color: var(--muted); font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; font-size: 11px;
}
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .dim { color: var(--dim); font-size: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-form {
  margin-top: 8px; display: grid; gap: 10px;
  max-width: 420px;
  padding: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
}
.admin-form label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
.admin-form input, .admin-form select {
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--fg); border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.admin-form .err { color: var(--red); min-height: 1.2em; font-size: 13px; }

/* Activity / sessions admin */
.admin-table tr.row-kiosco td {
  background: rgba(232, 168, 56, 0.12);
}
.admin-table tr.row-kiosco td:first-child {
  font-weight: 600;
}

.muted-help { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.4; }
.muted-help code { font-family: var(--mono); font-size: 11px; }
.admin-form .err { margin-top: 10px; min-height: 1.2em; }


/* Hour-cause logging */
.bar-col.clickable { cursor: pointer; }
.bar-col.cause-future { cursor: default; }
.bar-col.cause-future .cause-tag.empty { opacity: .35; }
.bar-col.clickable:hover .shaft {
  outline: 1px solid rgba(229,33,32,.55);
  outline-offset: 2px;
}
.bar-col.has-cause .cause-tag {
  color: #ffb4b0;
  border-color: rgba(229,33,32,.45);
}
.cause-tag {
  font-size: 11px;
  line-height: 1.15;
  margin-top: 4px;
  padding: 4px 2px;
  border-radius: 5px;
  border: 1px solid transparent;
  color: var(--dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
  text-align: center;
  min-height: 2.2em;
  font-weight: 600;
  letter-spacing: .02em;
  pointer-events: none; /* tap goes to bar-col */
}
.cause-tag.empty {
  border: 1px dashed rgba(229,33,32,.35);
  color: var(--red);
  opacity: .85;
  font-size: 14px;
  line-height: 1.6;
}
@media (max-width: 700px) {
  .cause-tag { font-size: 12px; min-height: 2.4em; padding: 5px 1px; }
  .bar-col .h { font-size: 10px; }
  .bar-col .n { font-size: 11px; }
}
.bar-col.clickable {
  -webkit-tap-highlight-color: rgba(229,33,32,.25);
  touch-action: manipulation;
  min-width: 28px;
}
.bar-col.clickable .shaft,
.bar-col.clickable .n,
.bar-col.clickable .h {
  pointer-events: none;
}
.cause-hint {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 8px;
}
.cause-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 6, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.cause-modal {
  background: var(--bg);
  border: 1px solid rgba(229,33,32,.35);
  border-radius: 12px;
  padding: 18px 18px 14px;
  width: min(380px, 100%);
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.cause-modal h3 { margin: 0 0 4px; font-size: 18px; }
.cause-modal .muted { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.cause-modal label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.cause-modal-backdrop { z-index: 200; align-items: flex-end; }
@media (min-width: 701px) {
  .cause-modal-backdrop { align-items: center; }
}
.cause-modal {
  max-height: 90vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.cause-modal select,
.cause-modal input[type="text"] {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: #f2e8e8;
  border-radius: 8px;
  padding: 12px 12px;
  font: inherit;
  font-size: 16px; /* evita zoom iOS */
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
}
.cause-modal-actions .btn,
.cause-modal-actions .btn-ghost {
  min-height: 44px;
  padding: 10px 14px;
}
.cause-modal select:focus,
.cause-modal input[type="text"]:focus {
  outline: none;
  border-color: var(--red);
}
.cause-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.cause-modal .err { color: var(--red); font-size: 13px; min-height: 1.2em; margin-top: 10px; }


.cause-picks {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
}
.cause-pick {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(229,33,32,.2);
  touch-action: manipulation;
}
.cause-pick.on {
  border-color: var(--red);
  background: rgba(229,33,32,.16);
  color: #fff;
}


.cause-hour-list { margin-top: 14px; }
.cause-hour-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (min-width: 701px) {
  .cause-hour-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.cause-hour-btn {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-height: 52px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: rgba(229,33,32,.25);
  touch-action: manipulation;
}
.cause-hour-btn.has {
  border-color: rgba(229,33,32,.55);
  background: rgba(229,33,32,.12);
}
.cause-hour-btn .ch-hour {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .06em;
}
.cause-hour-btn .ch-cause {
  font-size: 15px;
  font-weight: 700;
}
#cause-overlay { position: relative; z-index: 300; }


/* —— Detalle de hora (admin · pulsos MQTT) —— */
#hour-detail-overlay { position: relative; z-index: 320; }
.hour-detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 6, .78);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 320;
  padding: 12px;
}
@media (min-width: 701px) {
  .hour-detail-backdrop { align-items: center; }
}
.hour-detail-modal {
  background: var(--bg);
  border: 1px solid rgba(229,33,32,.4);
  border-radius: 14px;
  padding: 18px 18px 14px;
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.hour-detail-modal h3 {
  margin: 0 0 2px;
  font-size: 20px;
}
.hour-detail-modal .muted {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 12px;
}
.hour-detail-modal .err {
  color: var(--red);
  font-size: 14px;
}
.hd-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.hd-kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 10px 8px;
}
.hd-kpi .lbl {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.hd-kpi .val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 600;
  margin-top: 2px;
}
.hd-kpi .sub {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}
.hd-chart-wrap {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 4px 4px;
  margin-bottom: 10px;
}
.hd-chart { width: 100%; height: auto; display: block; }
.hd-meta-line { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 3; }
.hd-meta-lbl { fill: var(--warn); font-size: 11px; font-family: var(--mono); }
.hd-gap { fill: rgba(229, 33, 32, .18); }
.hd-step {
  fill: none;
  stroke: #ff6b66;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.hd-tick { stroke: var(--dim); stroke-width: 1; }
.hd-tick-lbl { fill: var(--dim); font-size: 10px; font-family: var(--mono); }
.hd-empty { fill: var(--muted); font-size: 13px; }
.hd-cause {
  font-size: 13px;
  margin: 0 0 6px;
}
.hd-cause .lbl { color: var(--muted); margin-right: 6px; }
.hd-note { font-size: 11px; margin: 0 0 12px; }
.hd-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(61,186,122,.35);
  color: var(--ok);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}
.hd-live .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
  animation: hd-live-blink 1.6s ease-in-out infinite;
}
.hd-live.stale { color: var(--warn); border-color: rgba(232,168,56,.35); }
.hd-live.stale .dot { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.hd-live.closed { color: var(--muted); border-color: rgba(255,255,255,.15); }
@keyframes hd-live-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.hour-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.hour-detail-actions .btn,
.hour-detail-actions .btn-ghost {
  min-height: 44px;
  padding: 10px 14px;
}
@media (max-width: 700px) {
  .hd-kpis { grid-template-columns: 1fr; }
  .hd-kpi .val { font-size: 20px; }
}


/* —— Indicador de datos en vivo (barra superior) —— */
.live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.live-status:empty { display: none; }
.live-status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.live-status.ok { color: var(--ok); }
.live-status.ok .dot { background: var(--ok); box-shadow: 0 0 6px var(--ok); animation: hd-live-blink 1.6s ease-in-out infinite; }
.live-status.warn { color: var(--warn); }
.live-status.warn .dot { background: var(--warn); }
.live-status.bad { color: var(--red); }
.live-status.bad .dot { background: var(--red); }


/* Must-change-password flow */
.pw-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.pw-actions #pw-logout { margin-left: auto; }
.temp-pw-box {
  border: 1px solid var(--warn); border-radius: 12px;
  background: rgba(232, 168, 56, 0.10);
  padding: 14px 16px; margin: 0 0 16px;
}
.temp-pw-box h3 { margin: 0 0 6px !important; font-size: 15px; color: var(--warn); }
.temp-pw-box p { margin: 6px 0; font-size: 13px; color: var(--muted); line-height: 1.4; }
.temp-pw-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.temp-pw-row input {
  font-family: var(--mono); font-size: 18px; letter-spacing: .06em;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; padding: 8px 12px; min-width: 220px;
}
.pill.pending { color: var(--warn); border-color: var(--warn); }
#pw-form input + label { margin-top: 12px; }

/* Histórico: causas por hora */
.hist-causes { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; }
.hist-causes li { padding: 3px 0; border-top: 1px solid rgba(127,127,127,.15); }
.hist-causes .hc-h { font-family: var(--mono); font-weight: 700; margin-right: 6px; }
.hist-causes .hc-note { opacity: .75; }
.hist-causes li.hc-none { opacity: .65; font-style: italic; }

.hist-locked { margin: 6px 0 0; font-size: 11px; opacity: .6; letter-spacing: .03em; }

/* Reportes avanzados (admin) */
.rr-tabs { display: flex; gap: 6px; align-items: center; margin: 4px 0 16px; flex-wrap: wrap; }
.rr-tab { padding: 6px 14px; border: 1px solid rgba(127,127,127,.3); border-radius: 999px; font-size: 13px; text-decoration: none; color: inherit; }
.rr-tab.on { background: #ffe600; border-color: #ffe600; color: #111; font-weight: 700; }
.rr-admin-tag { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; opacity: .55; margin-left: 6px; }
.rr-toolbar { flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.rr-toolbar select, .rr-toolbar input[type=date] { padding: 6px 8px; border: 1px solid rgba(127,127,127,.35); border-radius: 8px; font: inherit; background: #fff; color: #111; }
.rr-check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.rr-h3 { font-size: 15px; font-weight: 700; margin: 22px 0 8px; }
.rr-scroll { overflow-x: auto; }
.rr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rr-table th, .rr-table td { padding: 6px 8px; border-bottom: 1px solid rgba(127,127,127,.18); text-align: left; white-space: nowrap; }
.rr-table th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.rr-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.rr-table tr.flag-row td { background: rgba(255,230,0,.12); }
.rr-table tr.muted-row td { opacity: .7; font-style: italic; }
.rr-compare td:first-child { font-weight: 600; }
.rr-diff { font-weight: 700; }
.rr-diff.up { color: #1a8a3a; }
.rr-diff.down { color: #d22; }
.rr-periods { display: flex; gap: 24px; flex-wrap: wrap; margin: 8px 0; font-size: 14px; }
.rr-pill { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; font-weight: 800; font-size: 12px; }
.rr-pill.a { background: #ffe600; color: #111; }
.rr-pill.b { background: #111; color: #fff; }
.rr-flags { font-size: 13px; padding-left: 18px; }
.rr-bars .bar-col .h { font-size: 9px; }
.rr-bars .bar-col .n { font-size: 9px; }
.rr-exports { margin: 26px 0 8px; padding-top: 14px; border-top: 1px solid rgba(127,127,127,.2); }
.rr-exports .lbl { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .7; margin-bottom: 8px; }
.rr-exp-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; font-size: 13px; }
.rr-exp-row span { min-width: 150px; }
.rr-exp-row a { text-decoration: none; }

.btn[disabled]{opacity:.6;cursor:wait}

#rr-from,#rr-to,#rc-af,#rc-at,#rc-bf,#rc-bt{cursor:pointer}
