:root {
  --azul: #007aff;
  --azul-suave: #e8f1ff;
  --verde: #34c759;
  --naranja: #ff9500;
  --rojo: #ff3b30;
  --morado: #af52de;
  --texto: #1c1c1e;
  --gris: #8e8e93;
  --gris2: #c7c7cc;
  --linea: #e5e5ea;
  --fondo: #ffffff;
  --fondo2: #f5f5f7;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fondo); color: var(--texto);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* barra superior */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 18px 10px; background: rgba(255,255,255,.9);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--linea); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.topuser { font-size: 14px; color: var(--gris); }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(env(safe-area-inset-bottom) + 96px); }
.cargando { text-align: center; color: var(--gris); padding: 60px 0; }

h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; }
h2 { font-size: 20px; font-weight: 700; margin: 28px 0 10px; letter-spacing: -.01em; }
.sub { color: var(--gris); margin: 0 0 18px; }
.muted { color: var(--gris); }
.small { font-size: 13px; }

/* tarjetas */
.card { background: var(--fondo); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 16px; margin-bottom: 12px; }
.card.plana { box-shadow: none; }
.lista { border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; margin-bottom: 12px; background: #fff; }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--linea); }
.fila:last-child { border-bottom: 0; }
.fila .t { font-weight: 500; }
.fila .d { color: var(--gris); font-size: 14px; }
.fila.click { cursor: pointer; }
.fila.click:active { background: var(--fondo2); }

/* fichar */
.reloj { font-size: 54px; font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; text-align: center; margin: 6px 0 0; }
.estado { display: flex; justify-content: center; margin: 8px 0 22px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: var(--fondo2); color: var(--gris); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.trabajando { background: #e9f9ee; color: #1f9d45; }
.pill.pausa { background: #fff4e5; color: #c77700; }
.pill.fuera { background: var(--fondo2); color: var(--gris); }
.botonera { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; }
.fichar { width: 190px; height: 190px; border-radius: 50%; border: 0; color: #fff; font-size: 22px; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.15); transition: transform .12s ease; }
.fichar small { font-size: 14px; font-weight: 500; opacity: .9; }
.fichar:active { transform: scale(.96); }
.fichar.entrada, .fichar.vuelta { background: linear-gradient(160deg, #3ad16a, #22a94f); }
.fichar.pausa { background: linear-gradient(160deg, #ffad33, #ff8a00); }
.fichar.salida { background: linear-gradient(160deg, #ff5a50, #e5281e); }
.fichar.fin { background: var(--fondo2); color: var(--gris); box-shadow: none; cursor: default; }
.fichar[disabled] { opacity: .6; }
.btn-link { background: none; border: 0; color: var(--azul); font-weight: 500; cursor: pointer; padding: 8px; }
.btn-link.rojo { color: var(--rojo); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat { background: var(--fondo2); border-radius: var(--radio); padding: 14px 16px; }
.stat .k { font-size: 13px; color: var(--gris); font-weight: 500; }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .v small { font-size: 14px; color: var(--gris); font-weight: 500; }
.barra { height: 6px; background: var(--linea); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--azul); border-radius: 3px; transition: width .4s; }
.pos { color: #1f9d45; } .neg { color: var(--rojo); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--linea); }
.timeline li:last-child { border-bottom: 0; }
.timeline .h { font-variant-numeric: tabular-nums; font-weight: 600; width: 52px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.entrada, .dot.vuelta { background: var(--verde); } .dot.pausa { background: var(--naranja); } .dot.salida { background: var(--rojo); }

.aviso { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border-radius: var(--radio); margin-bottom: 12px;
  background: var(--azul-suave); color: #0a4fa6; font-size: 15px; }
.aviso.amarillo { background: #fff6e0; color: #8a5a00; }
.aviso.rojo { background: #ffecea; color: #b3261e; }
.aviso b { font-weight: 600; }
.aviso .btn-link { padding: 0; margin-left: auto; white-space: nowrap; }

/* botones y formularios */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 18px;
  font-weight: 600; cursor: pointer; background: var(--azul); color: #fff; text-decoration: none; font-size: 16px; }
.btn.sec { background: var(--azul-suave); color: var(--azul); }
.btn.gris { background: var(--fondo2); color: var(--texto); }
.btn.rojo { background: #ffecea; color: var(--rojo); }
.btn.verde { background: var(--verde); }
.btn.peq { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.full { width: 100%; }
.btn:active { opacity: .8; }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; }
label.campo { display: block; margin-bottom: 14px; }
label.campo > span { display: block; font-size: 13px; color: var(--gris); font-weight: 500; margin: 0 0 6px 2px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=month], select, textarea {
  width: 100%; border: 1px solid var(--linea); background: var(--fondo2); border-radius: 12px; padding: 12px 14px; outline: none;
  -webkit-appearance: none; appearance: none; min-height: 46px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
input:focus, select:focus, textarea:focus { border-color: var(--azul); background: #fff; box-shadow: 0 0 0 3px var(--azul-suave); }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cuatro { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.error { color: var(--rojo); font-size: 14px; margin: -4px 0 12px; min-height: 1em; }

/* login */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--sombra); }
.login form { text-align: left; margin-top: 24px; }

/* pestañas */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center;
  background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--linea); padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px); }
.tabs button { flex: 1; min-width: 0; max-width: 140px; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--gris); cursor: pointer; padding: 4px 0; position: relative; }
.tabs button svg { width: 26px; height: 26px; }
.tabs button.on { color: var(--azul); }
.badge { position: absolute; top: 0; left: calc(50% + 6px); background: var(--rojo); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; }

/* toast y modal */
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 30;
  background: rgba(28,28,30,.94); color: #fff; padding: 12px 16px; border-radius: 14px; display: flex; gap: 16px; align-items: center;
  font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.2); width: max-content; max-width: calc(100% - 32px); }
.toast span { flex: 1; }
.toast button { background: none; border: 0; color: #64a8ff; font-weight: 600; cursor: pointer; padding: 0; }
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px); animation: sube .22s ease; }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 20px; } }
@keyframes sube { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin: 0 0 16px; font-size: 20px; display: flex; justify-content: space-between; align-items: center; }
.cerrar { background: var(--fondo2); border: 0; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: var(--gris); font-size: 18px; line-height: 1; }

h3.anio { font-size: 17px; margin: 18px 0 8px; display: flex; align-items: baseline; gap: 10px; }
h3.anio span { font-weight: 500; }

/* saldos */
.saldo-cab { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.saldo-cab b { font-size: 17px; }
.card.saldo { padding: 6px 16px 12px; }
.card.saldo .saldo-cab { padding: 10px 0 4px; }
.saldo-fila { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--linea); }
.saldo-fila > div:first-child { flex: 1; }
.saldo-fila .t { font-weight: 500; }
.saldo-fila .d { color: var(--gris); font-size: 13px; }
.saldo-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
.saldo-fila.total { border-bottom: 0; }
.saldo-fila.total .t { font-weight: 700; }
.saldo-fila.total .saldo-v { color: var(--azul); font-size: 26px; }
.card.bolsa { padding-top: 14px; }
.card.click, .stat.click { cursor: pointer; }
.card.click:active, .stat.click:active { opacity: .7; }
.fila-bolsa { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.fila-bolsa .v { font-size: 20px; }
[data-mov] { width: 34px; padding: 6px 0; }

/* control segmentado */
.seg { display: flex; background: var(--fondo2); border-radius: 11px; padding: 3px; margin-bottom: 14px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 6px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--gris); cursor: pointer; }
.seg button.on { background: #fff; color: var(--texto); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.t-Día { background: #e6f7f7; color: #0f8a8a; }

/* revisar */
.rev .cab { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.rev .cab b { font-size: 17px; }
.slot { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; padding: 6px 0; }
.slot .tipo { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.slot .fijo { padding: 12px 14px; color: var(--gris); }
.slot input[type=time] { min-height: 42px; padding: 8px 12px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--fondo2); color: var(--gris); }
.chip.azul { background: var(--azul-suave); color: var(--azul); }
.chip.naranja { background: #fff4e5; color: #c77700; }
.chip.rojo { background: #ffecea; color: var(--rojo); }
.chip.verde { background: #e9f9ee; color: #1f9d45; }
.chip.morado { background: #f6ecfb; color: #8a35b5; }
.vacio { text-align: center; padding: 40px 16px; color: var(--gris); }
.vacio .ico { font-size: 44px; margin-bottom: 6px; }

/* calendario */
.cal-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-cab b { font-size: 17px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dn { text-align: center; font-size: 12px; color: var(--gris); font-weight: 600; padding-bottom: 4px; }
.cal .c { min-height: 64px; border-radius: 10px; background: var(--fondo2); padding: 5px; font-size: 13px; overflow: hidden; }
.cal .c.otro { background: transparent; }
.cal .c.finde { background: #fafafa; color: var(--gris2); }
.cal .c.hoy .n { background: var(--azul); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal .c.fest { background: #fff0ef; }
.cal .c.fest .n { color: var(--rojo); }
.cal .n { font-weight: 600; }
.cal .c.red { background: #fff6e0; }
.cal .c.red .n { color: #c77700; }
.t-Red { background: transparent; color: #c77700; padding-left: 0; }
.cal .ev { display: block; margin-top: 3px; font-size: 10.5px; font-weight: 600; padding: 2px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-Vacaciones { background: var(--azul-suave); color: var(--azul); }
.t-Baja { background: #ffecea; color: var(--rojo); }
.t-Asuntos { background: #f6ecfb; color: #8a35b5; }
.t-Permiso { background: #e9f9ee; color: #1f9d45; }
.t-Ausencia { background: #fff4e5; color: #c77700; }
.t-Fest { background: transparent; color: var(--rojo); padding-left: 0; }

/* informe */
.tabla-wrap { overflow-x: auto; border: 1px solid var(--linea); border-radius: var(--radio); }
table.inf { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.inf th { text-align: left; font-size: 12px; color: var(--gris); font-weight: 600; padding: 10px 10px; background: var(--fondo2); white-space: nowrap; }
table.inf td { padding: 10px; border-top: 1px solid var(--linea); white-space: nowrap; }
table.inf td.obs { white-space: normal; min-width: 140px; }
table.inf tr.nolab td { color: var(--gris2); }
table.inf tr.nolab td.obs { color: var(--gris); }
table.inf tr.inc td { background: #fffaf0; }
table.inf tr.click { cursor: pointer; }
table.inf tr.click:hover td { background: var(--fondo2); }
table.inf tfoot td { font-weight: 700; background: var(--fondo2); }
.marca { font-size: 10px; font-weight: 700; color: var(--naranja); vertical-align: super; margin-left: 1px; }
.print-only { display: none; }
.firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 40px; }
.firmas div { border-top: 1px solid #000; padding-top: 6px; font-size: 12px; }

@media (max-width: 520px) {
  h1 { font-size: 26px; }
  .cuatro { grid-template-columns: 1fr 1fr; }
  .reloj { font-size: 48px; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { font-size: 11px; }
  .no-print, .tabs, .topbar, .toast, .modal { display: none !important; }
  .print-only { display: block; }
  main { padding: 0; max-width: none; }
  .tabla-wrap { border: 0; overflow: visible; }
  table.inf { font-size: 10.5px; }
  table.inf th, table.inf td { padding: 4px 6px; border: 1px solid #bbb; }
  table.inf tr.inc td { background: none; }
  table.inf tr.nolab td { color: #666; }
  .stats { display: none; }
  .obs, .marca { display: none !important; }
  h1 { font-size: 18px; }
}
