/* Fichaje — hoja de estilos.
   Idea: el color de la pantalla de fichar indica el estado (fuera / trabajando / en pausa).
   Tipografía: Barlow Condensed para la hora y los títulos, Barlow para el texto. */

:root {
  --ink: #17202a;
  --ink-2: #46515c;
  --ink-3: #6f7a84;
  --paper: #eef1ef;
  --sheet: #ffffff;
  --line: #d8dedb;
  --accent: #2457d6;
  --danger: #b3261e;

  --fuera: #2b3440;
  --trabajando: #0e6b4d;
  --pausa: #9a5500;
  --estado: var(--fuera);

  --warn-bg: #fbebcb;
  --warn: #6e3d00;

  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-disp: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
}

body[data-estado="trabajando"] { --estado: var(--trabajando); }
body[data-estado="pausa"] { --estado: var(--pausa); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.45 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
body[data-vista="login"] { background: var(--ink); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.wrap { width: 100%; max-width: 760px; margin: 0 auto; }
.pad { padding: 24px 16px 120px; }
.pad > :first-child { margin-top: 0; }

h1, h2, h3 { font-family: var(--f-disp); font-weight: 700; line-height: 1.1; margin: 0; }
h2 { font-size: 1.6rem; margin: 32px 0 12px; }
h3 { font-size: 1.35rem; }
.nota { color: var(--ink-3); font-size: .875rem; margin: 6px 0 12px; }
.error { color: var(--danger); min-height: 1.3em; margin: 10px 0; font-weight: 500; }

/* ---------- Cabecera y pestañas ---------- */
.top { background: var(--ink); color: #fff; transition: background .4s ease; }
body[data-vista="login"] .top { display: none; }
body[data-tab="fichar"] .top { background: var(--estado); }
.top-in { max-width: 1040px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.marca-mini { font: 700 1.5rem/1 var(--f-disp); letter-spacing: .01em; }
#usuario-box { display: flex; align-items: center; gap: 10px; font-size: .9rem; white-space: nowrap; }
.top .link { color: #fff; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; gap: 2px;
  background: var(--sheet);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  flex: 1; min-height: 56px;
  display: grid; justify-items: center; align-content: center; gap: 2px;
  border: 0; border-radius: 12px; background: none; cursor: pointer;
  font: 600 .75rem/1.1 var(--f-body); color: var(--ink-3);
}
.tabs button.on { background: var(--paper); color: var(--ink); }
.tabs svg { width: 24px; height: 24px; }

@media (min-width: 760px) {
  .tabs {
    position: static; background: none; border: 0; padding: 0; gap: 4px; flex: 1; justify-content: center;
  }
  .tabs button {
    flex: 0 0 auto; min-height: 40px; padding: 0 14px;
    grid-auto-flow: column; gap: 8px;
    font-size: .9rem; color: rgba(255, 255, 255, .8);
  }
  .tabs button.on { background: rgba(255, 255, 255, .18); color: #fff; }
  .tabs svg { width: 20px; height: 20px; }
  .pad { padding-bottom: 48px; }
}

/* ---------- Acceso ---------- */
.login { min-height: 100dvh; display: grid; align-content: center; padding: 24px 20px; color: #fff; }
.login-in { width: 100%; max-width: 380px; margin: 0 auto; }
.marca { font-size: clamp(4.5rem, 22vw, 6.5rem); line-height: .85; letter-spacing: -.005em; }
.login-sub { margin: 10px 0 32px; color: rgba(255, 255, 255, .7); font-size: 1.05rem; }
.login label { color: rgba(255, 255, 255, .85); }
.login .btn-ok { width: 100%; background: #fff; color: var(--ink); border-color: #fff; }
.login .error { color: #ffb4ab; }
.login .link { color: rgba(255, 255, 255, .85); }

/* ---------- Formularios y botones ---------- */
label { display: block; font-size: .875rem; font-weight: 500; color: var(--ink-2); margin-bottom: 14px; }
input, select {
  display: block; width: 100%; min-height: 48px; margin-top: 6px; padding: 0 14px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  font: inherit; font-size: 1rem; color: var(--ink);
}
.fila-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; align-items: end; }
.fila-form .ancho { grid-column: 1 / -1; }
.fila-btns { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.fila-btns .btn { flex: 1 1 200px; }

.btn {
  min-height: 48px; padding: 0 20px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
  font: 600 1rem/1 var(--f-body); cursor: pointer;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ok { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-azul { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-stop { background: var(--danger); border-color: var(--danger); color: #fff; }
.fila-form .btn { margin-bottom: 14px; }

.link { background: none; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: 500 .9rem var(--f-body); padding: 6px 2px; }

.panel { background: var(--sheet); border-radius: 18px; padding: 20px 18px 8px; margin-bottom: 8px; }
.panel h2 { margin-top: 0; }

/* ---------- Fichar ---------- */
.hero {
  background: var(--estado); color: #fff;
  padding: 4px 0 32px;
  border-radius: 0 0 32px 32px;
  transition: background .4s ease;
}
.hero-in { padding: 0 16px; }
.estado { font: 600 1.7rem/1 var(--f-disp); letter-spacing: .01em; margin: 12px 0 0; }
.reloj {
  font: 600 clamp(5.2rem, 27vw, 9.5rem)/.95 var(--f-disp);
  font-variant-numeric: tabular-nums; margin: 6px 0 4px; letter-spacing: -.01em;
}
.reloj small { font-size: .36em; font-weight: 500; opacity: .7; margin-left: .06em; }
.hero-sub { margin: 0; min-height: 1.5em; font-size: 1.05rem; opacity: .92; }
.hero-nota { margin: 18px 0 0; font-size: .8rem; opacity: .7; max-width: 34ch; }

.acciones { display: grid; gap: 12px; margin-top: 22px; }
.acciones .btn { min-height: 68px; font-size: 1.25rem; border-width: 2px; }
.hero .btn-ok, .hero .btn-stop { background: #fff; border-color: #fff; color: var(--estado); }
.hero .btn-azul { background: transparent; border-color: rgba(255, 255, 255, .6); color: #fff; }
@media (min-width: 560px) { .acciones { grid-auto-flow: column; grid-auto-columns: 1fr; } }

.linea { list-style: none; margin: 0; padding: 0; }
.linea li {
  position: relative; display: grid; grid-template-columns: 4.2rem 1fr; gap: 10px; align-items: baseline;
  padding: 10px 0 10px 28px;
}
.linea li::before { content: ""; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.linea li:first-child::before { top: 22px; }
.linea li:last-child::before { bottom: calc(100% - 22px); }
.linea li::after {
  content: ""; position: absolute; left: 0; top: 17px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--paper); border: 3px solid var(--fuera);
}
.linea li.entrada::after { border-color: var(--trabajando); }
.linea li.pausa_inicio::after, .linea li.pausa_fin::after { border-color: var(--pausa); }
.linea time { font: 600 1.4rem/1 var(--f-disp); font-variant-numeric: tabular-nums; }
.linea .vacio { display: block; padding-left: 0; color: var(--ink-3); }
.linea .vacio::before, .linea .vacio::after { display: none; }

/* ---------- Tablas ---------- */
.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th {
  text-align: left; font-weight: 600; font-size: .8rem; color: var(--ink-3);
  padding: 8px 8px; border-bottom: 2px solid var(--ink); white-space: nowrap;
}
td { padding: 12px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.anulado td { text-decoration: line-through; color: var(--ink-3); }
.tag {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600; background: #e3e8e5; color: var(--ink-2);
}
.tag.corr { background: var(--warn-bg); color: var(--warn); }
.tag.off { background: #f8dad6; color: #8c1d18; }

/* ---------- Informe ---------- */
.hoja { background: var(--sheet); border-radius: 6px; padding: 20px 18px; margin-bottom: 14px; }
.hoja-cab { border-top: 6px solid var(--ink); }
.hoja-cab h2 { margin: 0 0 8px; font-size: 1.9rem; }
.hoja-cab p { margin: 2px 0; color: var(--ink-2); font-size: .95rem; }
.hoja h3 { margin-bottom: 2px; }
.resumen { margin: 0 0 10px; color: var(--ink-3); font-size: .9rem; }
.hoja table { min-width: 560px; }
.hoja td.dia { font-weight: 600; white-space: nowrap; }
.total { display: flex; justify-content: flex-end; align-items: baseline; gap: 12px; margin: 14px 0 0; color: var(--ink-2); }
.total b { font: 700 2.2rem/1 var(--f-disp); color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Aviso ---------- */
#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(8px);
  max-width: min(92%, 420px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 20;
}
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--danger); }
@media (min-width: 760px) { #toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Impresión ---------- */
@media print {
  body, body[data-vista] { background: #fff; }
  .top, .tabs, .no-print, #toast { display: none !important; }
  .pad { padding: 0; }
  .wrap { max-width: none; }
  .hoja { padding: 0 0 8px; margin-bottom: 18px; break-inside: avoid; }
  .hoja table { min-width: 0; font-size: 11px; }
  .tag.corr { background: none; padding: 0; border: 0; color: #000; }
}
