:root {
  --bg: #060910;
  --card: rgba(19, 25, 35, 0.62);
  --card-solid: #131926;
  --ink: #e9eef6;
  --muted: #93a2b6;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --primary: #46c7ff;
  --secondary: #3fdd97;
  --danger: #ff6b74;
  --warn-bg: rgba(122, 92, 8, 0.28);
  --warn-ink: #f4dc92;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 18px 48px rgba(0, 0, 0, 0.4);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* fondo de rayos */
.bg-rays {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 700px at 50% -15%, rgba(70, 199, 255, 0.10), transparent 60%),
    var(--bg);
}

.wrap { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 28px 16px 72px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -0.02em; font-weight: 700; }
.fecha {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 600; color: var(--ink);
  text-transform: capitalize;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 12px;
}
.fecha svg { width: 20px; height: 20px; color: var(--primary); flex: none; }

.card {
  background: var(--card);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 15px; margin: 0; letter-spacing: -0.01em; }
.card-actions { display: flex; gap: 8px; }

.grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 16px; }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; } }

/* ---------- hero ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; flex-wrap: wrap;
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(70, 199, 255, 0.08), transparent 70%),
    var(--card);
}
.hero-next { display: flex; align-items: center; gap: 16px; min-width: 0; }
.avatar {
  width: 62px; height: 62px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #fff; letter-spacing: -0.02em;
  background: var(--muted);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22), 0 6px 20px rgba(0, 0, 0, 0.4);
}
.hero-text { display: flex; flex-direction: column; min-width: 0; }
.hero-text .label { color: var(--muted); font-size: 13px; }
.next-nombre { font-size: 31px; line-height: 1.1; letter-spacing: -0.02em; }
.hero-last {
  --hl: var(--secondary); /* siempre verde */
  display: inline-flex; align-items: center; gap: 9px; align-self: flex-start;
  margin-top: 12px; padding: 8px 15px; border-radius: 999px;
  font-size: 15px; color: var(--ink);
  background: color-mix(in srgb, var(--hl) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--hl) 40%, transparent);
}
.hero-last .hl-txt { white-space: nowrap; }
.hero-last b { font-weight: 700; }
.hero-last .hl-dot {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: var(--hl, #7a8aa0); box-shadow: 0 0 10px var(--hl, #7a8aa0);
}
.hero-last.pulse { animation: hlpop .55s ease; }
@keyframes hlpop {
  0%   { transform: scale(0.9); box-shadow: 0 0 0 0 color-mix(in srgb, var(--hl) 55%, transparent); }
  45%  { transform: scale(1.06); }
  100% { transform: scale(1); box-shadow: 0 0 0 12px color-mix(in srgb, var(--hl) 0%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-last.pulse { animation: none; }
}
.acciones { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- botones normales ---------- */
.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); color: var(--ink);
  padding: 10px 15px; border-radius: 11px; font-weight: 500;
  transition: transform .05s ease, background .15s, opacity .15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-xs { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn-sm { padding: 7px 11px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
#btn-undo:hover:not(:disabled) {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 13%, transparent);
}

/* ---------- botones specular ---------- */
.specular-button {
  --sb-radius: 12px;
  --sb-text-color: #f5f5f5;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; margin: 0; font-family: inherit; font-weight: 600;
  letter-spacing: 0.01em; line-height: 1; color: var(--sb-text-color);
  background: rgba(255, 255, 255, 0.045);
  border-radius: var(--sb-radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer; outline: none;
  transition: transform .15s ease, background .2s;
}
.specular-button:hover { background: rgba(255, 255, 255, 0.08); }
.specular-button:active { transform: scale(0.97); }
.specular-button:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 3px; }
.specular-button:disabled { opacity: 0.4; cursor: default; }
.specular-button:disabled:active { transform: none; }
.specular-button--lg { font-size: 1.02rem; padding: 15px 26px; }
.specular-button__fx { position: absolute; inset: -20px; pointer-events: none; z-index: 1; }
.specular-button__fx canvas { display: block; width: 100%; height: 100%; }
.specular-button__label { position: relative; z-index: 2; }
.sb-primary { --sb-text-color: #ecfaff; background: rgba(70, 199, 255, 0.10); }
.sb-secondary { --sb-text-color: #ecfff5; background: rgba(63, 221, 151, 0.09); }

/* ---------- orden ---------- */
.orden { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.orden li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.orden li .pos {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: rgba(255, 255, 255, 0.07); color: var(--muted);
}
.orden li .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.orden li .nombre { font-weight: 600; flex: 1; }
.orden li.is-next {
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent), 0 0 24px color-mix(in srgb, var(--primary) 18%, transparent);
}
.orden li.is-next .pos { background: var(--primary); color: #04121c; }
.tag { font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.tag[data-tip] { cursor: help; position: relative; outline: none; }
.tag[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); right: 0;
  width: max-content; max-width: 230px;
  background: var(--card-solid); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 11px; font-size: 12px; font-weight: 500; line-height: 1.4;
  text-transform: none; letter-spacing: normal; white-space: normal;
  box-shadow: var(--shadow); z-index: 30;
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.tag[data-tip]:hover::after, .tag[data-tip]:focus-visible::after { opacity: 1; transform: translateY(0); }
.tag[data-tip]:focus-visible { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 60%, transparent); }
.tag-first { background: color-mix(in srgb, var(--secondary) 22%, transparent); color: var(--secondary); }
.tag-last { background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger); }
.tag-next { background: var(--primary); color: #04121c; }

.orden li .mover { display: flex; gap: 4px; }
.orden li .mover button {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05); cursor: pointer; color: var(--ink); font-size: 14px;
}
.orden li .mover button:disabled { opacity: .35; cursor: not-allowed; }

/* ---------- técnicos ---------- */
.tecnicos { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tecnicos li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 6px; border-bottom: 1px solid var(--line);
}
.tecnicos li:last-child { border-bottom: 0; }
.tecnicos .who { display: flex; align-items: center; gap: 10px; }
.tecnicos .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.tecnicos .estado { color: var(--muted); font-size: 12.5px; margin-left: 2px; }
.tecnicos .who { flex: 1; min-width: 0; }
.tec-actions { display: flex; align-items: center; gap: 7px; flex: none; }
.icon-btn {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04);
  border-radius: 8px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.danger:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.tec-input {
  flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.06);
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--line));
  color: var(--ink); border-radius: 9px; padding: 6px 10px; font: inherit; outline: none;
}
.tec-add { display: flex; gap: 8px; margin-top: 12px; }
.tec-add input {
  flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  color: var(--ink); border-radius: 9px; padding: 8px 12px; font: inherit; outline: none;
}
.tec-add input:focus { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); }
.tec-add input::placeholder { color: var(--muted); }

.switch { position: relative; display: inline-block; width: 46px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; cursor: pointer; background: rgba(255, 255, 255, 0.16); border-radius: 999px; transition: .2s; }
.slider::before {
  content: ""; position: absolute; height: 21px; width: 21px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
.switch input:checked + .slider { background: var(--secondary); }
.switch input:checked + .slider::before { transform: translateX(19px); }

/* ---------- incidencias ---------- */
.incidencias { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 6px; }
.incidencias:empty::after { content: "Aún no hay incidencias en esta jornada."; color: var(--muted); font-size: 14px; }
.incidencias li {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.03);
}
.incidencias .seq { color: var(--muted); font-variant-numeric: tabular-nums; width: 26px; font-size: 13px; }
.incidencias .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
.incidencias .quien { font-weight: 600; flex: 1; }
.incidencias .hora { color: var(--muted); font-size: 13px; }

.badge {
  min-width: 26px; text-align: center; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary);
  font-weight: 700; font-size: 13px;
}

.nota { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.aviso {
  background: var(--warn-bg); color: var(--warn-ink);
  border: 1px solid color-mix(in srgb, var(--warn-ink) 25%, transparent);
  border-radius: 12px; padding: 11px 14px; margin-bottom: 16px; font-size: 14px;
}

details summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.historial { margin-top: 14px; overflow-x: auto; }
.historial table { width: 100%; border-collapse: collapse; font-size: 13px; }
.historial th, .historial td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.historial th { color: var(--muted); font-weight: 600; }

/* ---------- título animado ---------- */
.split-char { will-change: transform, opacity; }

/* ---------- modal propio ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(4, 7, 12, 0.6); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .15s ease;
}
/* el atributo hidden debe ganar al display:grid de arriba */
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--card-solid); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; max-width: 400px; width: 100%;
  animation: pop .16s ease;
}
.modal-title { margin: 0 0 8px; font-size: 17px; letter-spacing: -0.01em; }
.modal-msg { margin: 0 0 20px; color: var(--muted); font-size: 14.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-actions .btn-primary {
  background: var(--primary); color: #04121c; border-color: transparent; font-weight: 600;
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #eef3fa; color: #0b111b; padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow); font-size: 14px; font-weight: 600; z-index: 60;
  animation: pop .16s ease;
}

@media (prefers-reduced-motion: reduce) {
  .split-char { transition: none !important; }
}
