/* Montserrat (SIL Open Font License) incluida en la app: funciona sin internet */
@font-face {
  font-family: "Montserrat";
  src: url("fonts/montserrat-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Eye control — paleta: 60% fondo, 30% tinta (cabecera, textos), 10% acento */
:root {
  --bg: #EEE4D6;
  --ink: #3A2A21;
  --accent: #E3173E;
  --line: rgba(58, 42, 33, 0.14);
  --muted: rgba(58, 42, 33, 0.68);
  --glass: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.55));
  --float: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 2px 6px rgba(58, 42, 33, 0.07), 0 22px 44px -18px rgba(58, 42, 33, 0.35);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

h2 { margin: 0 0 6px; font-family: "Montserrat", system-ui, sans-serif; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.015em; }
h3 { margin: 0; font-family: "Montserrat", system-ui, sans-serif; font-size: 1rem; font-weight: 700; }
h4 { margin: 28px 0 10px; font-size: 0.95rem; font-weight: 650; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Cabecera (30%) */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: var(--ink);
  color: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 56px; height: auto; flex: none; }
/* Nombre de marca: "Eye" en negrita y "control" en regular */
.name {
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 1.75rem;
  letter-spacing: 0.005em;
  white-space: nowrap;
  line-height: 1;
}
.brand-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
/* Marca de agua del desarrollador: siempre visible, con degradado de la paleta */
.watermark {
  font-family: "Montserrat", system-ui, sans-serif;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  background: linear-gradient(90deg, #EEE4D6 0%, #E3173E 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0.9;
  user-select: none;
}
.name b { font-weight: 800; }
.name span { font-weight: 400; }

/* Parpadeo sutil del logo: el ojo se cierra y se abre cada pocos segundos */
.logo .eye {
  transform-box: view-box;
  transform-origin: 32px 20px;
  animation: blink 5s ease-in-out infinite;
}
@keyframes blink {
  0%, 88%, 100% { transform: scaleY(1); }
  92% { transform: scaleY(0.08); }
  96% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
  .logo .eye { animation: none; }
}
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px 56px;
}

/* Tarjetas */
.card {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--float);
  padding: 22px;
}
.card.narrow { max-width: 460px; margin: 40px auto; }
.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-bottom: 16px;
}

/* Formularios */
label { display: block; margin-bottom: 14px; }
label > span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(238, 228, 214, 0.7);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(58, 42, 33, 0.12);
}
button:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Botones */
button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
  transition: transform 0.15s, filter 0.2s, background 0.2s;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(227, 23, 62, 0.7);
}
button.primary:hover:not(:disabled) { filter: brightness(1.05); }
button.big { width: 100%; min-height: 60px; font-size: 1.1rem; }
button.block { width: 100%; margin-top: 4px; }
/* Sobre la cabecera oscura */
.top button.ghost, .hero button.ghost { color: var(--bg); border-color: rgba(238, 228, 214, 0.5); background: transparent; }
.top button.ghost:hover, .hero button.ghost:hover { border-color: var(--bg); }
/* Sobre fondo claro */
button.ghost-dark { background: transparent; border-color: var(--line); color: var(--ink); }
button.ghost-dark:hover:not(:disabled) { border-color: var(--ink); }

.msg { min-height: 1.4em; font-size: 0.9rem; font-weight: 600; margin: 10px 0 0; }
.msg.ok { color: var(--ink); }
.msg.error { color: var(--accent); }
.big-msg {
  font-size: 1.05rem;
  text-align: center;
  margin-top: 18px;
  padding: 0;
  min-height: 0;
}
.big-msg:not(:empty) {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(58, 42, 33, 0.06);
}
.big-msg.error:not(:empty) {
  background: rgba(227, 23, 62, 0.08);
  box-shadow: inset 3px 0 0 var(--accent);
}
.big-msg.ok:not(:empty) {
  box-shadow: inset 3px 0 0 var(--ink);
}

/* Marcación: entrada y salida */
.punch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

/* Caja de vidrio de la marcación: el fondo de color se ve a través del cristal */
#employee.glass {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.34));
  border: 1px solid rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 30px 60px -24px rgba(58, 42, 33, 0.45);
  padding: 26px;
}
#employee.glass::before,
#employee.glass::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
}
#employee.glass::before {
  width: 280px;
  height: 280px;
  top: -110px;
  right: -90px;
  background: radial-gradient(circle, rgba(227, 23, 62, 0.42), transparent 70%);
}
#employee.glass::after {
  width: 240px;
  height: 240px;
  bottom: -100px;
  left: -80px;
  background: radial-gradient(circle, rgba(58, 42, 33, 0.28), transparent 70%);
}

/* Estado de resultado de la marcación (entrada, salida, error o cargando) */
.punch-stage {
  --stage: #3A2A21;
  min-height: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 12px 8px 4px;
}
.punch-stage.is-entry { --stage: #2E9E5B; }
.punch-stage.is-error { --stage: #E3173E; }
.stage-icon { width: 132px; height: 132px; margin-bottom: 8px; }
.stage-icon svg { width: 100%; height: 100%; overflow: visible; }
.stage-icon svg * {
  transform-box: view-box;
  transform-origin: 60px 60px;
}
.stage-ring {
  fill: rgba(255, 255, 255, 0.55);
  stroke: var(--stage);
  stroke-width: 5;
}
.stage-check,
.stage-cross,
.stage-spinner {
  fill: none;
  stroke: var(--stage);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.stage-check, .stage-cross { stroke-dasharray: 120; stroke-dashoffset: 120; }
.stage-spinner { stroke-width: 6; stroke-dasharray: 70 200; }
#stage-title { font-size: 1.3rem; margin-top: 4px; color: var(--stage); }
#stage-detail { margin: 0; font-weight: 600; }
.stage-bar {
  width: 70%;
  height: 6px;
  margin-top: 16px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.stage-bar span {
  display: block;
  height: 100%;
  background: var(--stage);
  transform: scaleX(0);
  transform-origin: left center;
}

/* Cargando: anillo que gira mientras el servidor responde */
.punch-stage.is-loading { --stage: #3A2A21; }
.is-loading .stage-spinner { opacity: 1; animation: stage-spin 0.9s linear infinite; }
.is-loading #stage-title { color: var(--ink); }

/* Entrada: check verde que se dibuja y anillo que pulsa */
.is-entry .stage-ring { animation: stage-pop 0.5s ease-out both, ring-pulse 1.6s ease-out 0.5s 1 both; }
.is-entry .stage-check { opacity: 1; animation: draw-check 0.6s ease-out 0.3s forwards; }

/* Salida: check que entra girando; barra de tiempo de color tinta */
.is-exit .stage-ring { animation: stage-pop 0.5s ease-out both; }
.is-exit .stage-check { opacity: 1; animation: spin-in 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.15) 0.2s forwards; }

/* Error: cruz que se dibuja y sacudida breve */
.is-error .stage-ring { animation: stage-pop 0.4s ease-out both; }
.is-error .stage-cross { opacity: 1; animation: draw-check 0.45s ease-out 0.15s forwards; }
.is-error .stage-icon { animation: shake 0.55s ease-in-out 0.15s; }

/* Barra que dura lo mismo que la animación (1,5 s) */
.is-entry .stage-bar span,
.is-exit .stage-bar span,
.is-error .stage-bar span { animation: fill-bar 1.5s linear forwards; }

@keyframes stage-pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes ring-pulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.22); opacity: 0; }
}
@keyframes draw-check {
  to { stroke-dashoffset: 0; }
}
@keyframes spin-in {
  from { transform: rotate(-220deg) scale(0.4); opacity: 0; stroke-dashoffset: 120; }
  to { transform: none; opacity: 1; stroke-dashoffset: 0; }
}
@keyframes stage-spin {
  to { transform: rotate(360deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(5px); }
}
@keyframes fill-bar {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .punch-stage * { animation: none !important; }
  .stage-check, .stage-cross { stroke-dashoffset: 0; }
  .is-entry .stage-check, .is-exit .stage-check, .is-error .stage-cross { opacity: 1; }
  .is-loading .stage-spinner { opacity: 0.6; }
  .is-entry .stage-bar span, .is-exit .stage-bar span, .is-error .stage-bar span { transform: scaleX(1); }
}
@media (max-width: 560px) {
  .punch-stage { min-height: 300px; }
  #employee.glass { padding: 20px; }
}

/* Cabecera del panel de administrador */
.hero {
  position: relative;
  background: var(--ink);
  color: var(--bg);
  border-radius: 0 0 28px 28px;
  padding: 36px 28px 96px;
  margin: 0 -20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.hero .eyebrow { color: rgba(238, 228, 214, 0.7); }
.hero h2 { font-size: 2rem; color: var(--bg); letter-spacing: -0.02em; }
.hero-sub { margin: 0; color: rgba(238, 228, 214, 0.8); font-size: 0.95rem; }
.hero .period { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.hero .period label { margin: 0; min-width: 150px; }
.hero .period label > span { font-size: 0.72rem; margin-bottom: 4px; color: rgba(238, 228, 214, 0.75); }
.hero input {
  background: rgba(238, 228, 214, 0.12);
  color: var(--bg);
  border-color: rgba(238, 228, 214, 0.25);
  color-scheme: dark;
}
.hero input:focus { border-color: var(--bg); box-shadow: 0 0 0 3px rgba(238, 228, 214, 0.18); }
.hero .primary { color: #fff; }

/* KPIs flotantes sobre la cabecera */
.kpis {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: -62px 0 24px;
}
@media (min-width: 900px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.kpi {
  position: relative;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  box-shadow: var(--float);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.kpi:hover {
  transform: translateY(-4px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset, 0 4px 10px rgba(58, 42, 33, 0.08), 0 30px 54px -20px rgba(58, 42, 33, 0.42);
}
/* Detalle de marca: un punto del acento por indicador */
.kpi::before {
  content: "";
  position: absolute;
  top: 22px;
  left: 20px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.kpi-label {
  padding-left: 18px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-sub { font-size: 0.8rem; color: var(--muted); }

/* Diseño de dos columnas */
.layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
}
.side { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.layout > *, .side > * { min-width: 0; }

/* Barra de progreso de colaboradores */
.bar {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 14px;
}
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.4s ease;
}

/* Pestañas */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: rgba(238, 228, 214, 0.8);
  border: 1px solid var(--line);
}
.tab {
  flex: 1;
  min-height: 36px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
}
.tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--bg);
}

/* Acciones dentro de filas */
.row-action {
  min-height: 30px;
  padding: 4px 12px;
  font-size: 0.8rem;
  border-radius: 999px;
  border-color: var(--line);
  color: var(--ink);
  background: transparent;
}
.row-action:hover:not(:disabled) { border-color: var(--ink); }
.row-action.danger {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.confirm-text {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 6px;
  white-space: normal;
  max-width: 220px;
  text-align: left;
}

/* Tablas */
.table-wrap { overflow-x: auto; }
.list { max-height: 320px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 0.9rem;
}
th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(58, 42, 33, 0.035); }
th.num, td.num { text-align: right; }

@media (max-width: 560px) {
  .hero { padding: 28px 20px 92px; margin: 0 -20px; border-radius: 0 0 24px 24px; }
  .hero h2 { font-size: 1.6rem; }
  .punch-actions { grid-template-columns: 1fr; }
}
