/* GCB Fichaje — estilos comunes (sin dependencias externas) */
:root {
  --musgo: #24502f;      /* marca, cabeceras */
  --hoja: #3f8f4e;       /* entrada / ok */
  --hoja-claro: #e4f1e2;
  --sol: #c98a0b;        /* pausa */
  --sol-claro: #fbf0d6;
  --pizarra: #33536f;    /* salida */
  --pizarra-claro: #e2ebf3;
  --alerta: #b3261e;
  --alerta-claro: #fbe4e1;
  --tinta: #17201b;
  --gris: #5d6862;
  --linea: #d9dfd9;
  --fondo: #f6f8f5;
  --papel: #ffffff;
  --radio-s: 8px;
  --radio-m: 14px;
  --sombra: 0 1px 2px rgba(23, 32, 27, .08), 0 2px 8px rgba(23, 32, 27, .05);
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --tinta: #e8eee9; --gris: #a5b0a9; --linea: #34403a; --fondo: #121815; --papel: #1b2420;
    --hoja-claro: #1f3a25; --sol-claro: #3a2f12; --pizarra-claro: #1d2c39; --alerta-claro: #3d1b18;
    --sombra: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--fuente); font-size: 16px; line-height: 1.45; color: var(--tinta); background: var(--fondo); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--hoja); }
:focus-visible { outline: 3px solid var(--sol); outline-offset: 2px; }
.oculto { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* Cabecera */
.barra { background: var(--musgo); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.barra h1 { font-size: 17px; margin: 0; font-weight: 650; flex: 1; letter-spacing: .1px; }
.barra .quien { font-size: 14px; opacity: .85; }
.barra button { background: rgba(255,255,255,.14); border: 0; color: #fff; padding: 8px 12px; border-radius: var(--radio-s); cursor: pointer; }

.contenedor { max-width: 560px; margin: 0 auto; padding: 16px; }
.caja { background: var(--papel); border-radius: var(--radio-m); padding: 16px; box-shadow: var(--sombra); margin-bottom: 14px; }
.caja h2 { font-size: 17px; margin: 0 0 10px; }
.suave { color: var(--gris); font-size: 14px; }
.fila { display: flex; gap: 10px; align-items: center; }
.fila > * { flex: 1; }
.entre { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* Formularios */
label { display: block; font-size: 14px; color: var(--gris); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--linea); border-radius: var(--radio-s); background: var(--papel); min-height: 46px; }
textarea { min-height: 84px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; margin: 0 10px 0 0; flex: none; accent-color: var(--musgo); }
.check { display: flex; align-items: center; color: var(--tinta); font-size: 15px; }
.boton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--radio-s); padding: 12px 18px; min-height: 46px;
  background: var(--musgo); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.boton.secundario { background: transparent; color: var(--tinta); border: 1px solid var(--linea); }
.boton.peligro { background: var(--alerta); }
.boton.ancho { width: 100%; }
.boton:disabled { opacity: .5; cursor: not-allowed; }
.enlace { background: none; border: 0; padding: 6px 0; color: var(--hoja); text-decoration: underline; cursor: pointer; }

.aviso { border-radius: var(--radio-s); padding: 12px 14px; margin: 12px 0 0; font-size: 15px; }
.aviso.ok { background: var(--hoja-claro); color: var(--tinta); border-left: 4px solid var(--hoja); }
.aviso.error { background: var(--alerta-claro); color: var(--tinta); border-left: 4px solid var(--alerta); }
.aviso.info { background: var(--sol-claro); color: var(--tinta); border-left: 4px solid var(--sol); }

/* ---------- Pantalla de fichaje ---------- */
.reloj { text-align: center; padding: 8px 0 4px; }
.reloj .hora { font-size: 64px; font-weight: 700; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.reloj .dia { color: var(--gris); margin-top: 6px; }
.estado { display: flex; justify-content: center; gap: 8px; align-items: center; margin: 16px 0 4px; font-weight: 600; font-size: 17px; }
.punto { width: 12px; height: 12px; border-radius: 50%; background: var(--gris); }
.estado.trabajando .punto { background: var(--hoja); }
.estado.pausa .punto { background: var(--sol); }
.horas-hoy { text-align: center; color: var(--gris); }
.horas-hoy b { color: var(--tinta); font-size: 20px; }

.accion-principal { display: block; width: 100%; border: 0; border-radius: 22px; padding: 30px 16px; font-size: 26px; font-weight: 750; color: #fff;
  background: var(--hoja); cursor: pointer; margin: 18px 0 10px; box-shadow: 0 6px 18px rgba(23,32,27,.18); touch-action: manipulation; }
.accion-principal small { display: block; font-size: 15px; font-weight: 500; opacity: .9; margin-top: 4px; }
.accion-principal.salida { background: var(--pizarra); }
.accion-principal.fin-pausa { background: var(--sol); }
.accion-principal:active { transform: scale(.985); }
.accion-principal:disabled { background: var(--linea); color: var(--gris); box-shadow: none; cursor: not-allowed; }
.secundarias { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.secundarias button { border: 2px solid var(--linea); background: var(--papel); border-radius: var(--radio-m); padding: 16px 10px; font-weight: 650; font-size: 16px; cursor: pointer; min-height: 60px; }
.secundarias button.pausa { border-color: var(--sol); }
.secundarias button.salida { border-color: var(--pizarra); }
.secundarias button:disabled { opacity: .4; cursor: not-allowed; }

.linea-tiempo { list-style: none; padding: 0; margin: 0; }
.linea-tiempo li { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--linea); font-size: 15px; }
.linea-tiempo li:last-child { border-bottom: 0; }
.etiqueta { font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 20px; background: var(--linea); color: var(--tinta); white-space: nowrap; }
.etiqueta.sin-conexion { background: var(--sol-claro); }
.etiqueta.aprobada, .etiqueta.revisada, .etiqueta.trabajando, .etiqueta.finalizada { background: var(--hoja-claro); }
.etiqueta.pendiente, .etiqueta.pausa, .etiqueta.abierta { background: var(--sol-claro); }
.etiqueta.rechazada, .etiqueta.sin_fichar, .etiqueta.error { background: var(--alerta-claro); }

.pendientes { background: var(--sol-claro); border-radius: var(--radio-s); padding: 10px 12px; font-size: 14px; margin-top: 10px; }

/* Pestañas inferiores (móvil) */
.pestanas { position: fixed; bottom: 0; left: 0; right: 0; background: var(--papel); border-top: 1px solid var(--linea); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.pestanas button { flex: 1; background: none; border: 0; padding: 10px 4px 12px; font-size: 13px; color: var(--gris); cursor: pointer; }
.pestanas button span { display: block; font-size: 20px; line-height: 1.2; }
.pestanas button.activa { color: var(--musgo); font-weight: 700; }
.con-pestanas { padding-bottom: 88px; }

/* Calendario */
.seg { display: flex; background: var(--fondo); border-radius: var(--radio-s); padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 10px 4px; border-radius: 6px; font-weight: 600; color: var(--gris); cursor: pointer; }
.seg button.activa { background: var(--papel); color: var(--musgo); box-shadow: var(--sombra); }
.mes { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.mes b { text-transform: capitalize; }
.mes button { width: 44px; height: 44px; border-radius: var(--radio-s); border: 1px solid var(--linea); background: var(--papel); font-size: 20px; cursor: pointer; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: 12px; color: var(--gris); padding: 4px 0; }
.cal button { aspect-ratio: 1; border: 0; border-radius: var(--radio-s); background: var(--fondo); cursor: pointer; font-variant-numeric: tabular-nums; position: relative; padding: 0; }
.cal .vacio { background: none; }
.cal .finde { color: var(--gris); }
.cal .pasado { color: var(--linea); background: none; cursor: default; }
.cal .hoy { outline: 2px solid var(--musgo); outline-offset: -2px; }
.cal .festivo { color: var(--alerta); }
.cal .festivo::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--alerta); }
.cal .aprob { background: var(--hoja-claro); font-weight: 700; }
.cal .pend { background: var(--sol-claro); font-weight: 700; }
.cal .sel { background: var(--musgo); color: #fff; font-weight: 700; }
.cal .rango { background: var(--hoja-claro); outline: 1px dashed var(--musgo); outline-offset: -3px; }
.leyenda { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--gris); margin-top: 10px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.l-sel { background: var(--musgo); } .l-aprob { background: var(--hoja-claro); border: 1px solid var(--hoja); } .l-pend { background: var(--sol-claro); border: 1px solid var(--sol); } .l-fest { background: var(--alerta); }

/* Diálogo */
dialog { border: 0; border-radius: var(--radio-m); padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--papel); color: var(--tinta); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(23, 32, 27, .45); }
dialog .cuerpo { padding: 18px; max-height: 80vh; overflow: auto; }
dialog h3 { margin: 0 0 8px; }
dialog .pie { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 18px; flex-wrap: wrap; }

/* ---------- Panel de administración ---------- */
.admin { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.menu { background: var(--musgo); color: #fff; padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.menu .marca { font-weight: 700; padding: 6px 10px 16px; font-size: 16px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: #fff; opacity: .82; padding: 10px 12px; border-radius: var(--radio-s); cursor: pointer; font-size: 15px; }
.menu button.activa, .menu button:hover { background: rgba(255,255,255,.13); opacity: 1; }
.menu .grupo { font-size: 12px; opacity: .6; padding: 14px 12px 4px; }
.menu .cuenta { margin-top: 18px; border-top: 1px solid rgba(255,255,255,.2); padding-top: 12px; font-size: 13px; opacity: .85; padding-left: 12px; }
.principal { padding: 22px 26px; min-width: 0; }
.principal h2 { font-size: 22px; margin: 0 0 16px; }
.principal * + h2, .principal * + .entre { margin-top: 26px; }
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metricas div { background: var(--papel); border-radius: var(--radio-m); padding: 14px 16px; box-shadow: var(--sombra); }
.metricas b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.metricas span { color: var(--gris); font-size: 14px; }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; background: var(--papel); padding: 12px; border-radius: var(--radio-m); box-shadow: var(--sombra); }
.filtros > div { min-width: 150px; flex: 1; }
.filtros label { margin-top: 0; }
.tabla-env { overflow-x: auto; background: var(--papel); border-radius: var(--radio-m); box-shadow: var(--sombra); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--linea); vertical-align: top; }
th { font-weight: 650; color: var(--gris); background: var(--fondo); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: 0; }
td .boton { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.acciones { display: flex; gap: 6px; flex-wrap: wrap; }
.tachado { text-decoration: line-through; color: var(--gris); }
.rejilla-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.dias { display: flex; gap: 6px; flex-wrap: wrap; }
.dias label { display: flex; align-items: center; gap: 4px; margin: 0; padding: 8px 10px; border: 1px solid var(--linea); border-radius: var(--radio-s); color: var(--tinta); cursor: pointer; }
.secreto { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 20px; letter-spacing: 2px; background: var(--fondo); padding: 12px; border-radius: var(--radio-s); word-break: break-all; text-align: center; }
.mini { font-size: 12px; }

@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .menu { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .menu .marca { width: 100%; padding-bottom: 6px; }
  .menu button { width: auto; padding: 8px 10px; font-size: 14px; }
  .menu .grupo, .menu .cuenta { display: none; }
  .principal { padding: 16px; }
}
@media (max-width: 380px) {
  .reloj .hora { font-size: 52px; }
  .accion-principal { font-size: 22px; padding: 26px 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } .accion-principal:active { transform: none; } }

/* ---------- Kiosco ---------- */
.kiosco .contenedor { max-width: 640px; }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.teclado button { min-height: 68px; font-size: 26px; font-weight: 650; border: 1px solid var(--linea); background: var(--papel); border-radius: var(--radio-m); cursor: pointer; }
.pin-visor { font-size: 34px; letter-spacing: 10px; text-align: center; min-height: 50px; font-variant-numeric: tabular-nums; }
.fila-boton { width: 100%; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.fila-boton + div { margin-top: 10px; }

.opciones { display: grid; gap: 8px; margin: 10px 0; }
.opcion { border: 1px solid var(--linea); border-radius: var(--radio-s); padding: 12px; cursor: pointer; }
.opcion:has(input:checked) { border-color: var(--musgo); background: var(--hoja-claro); }
.condiciones h3 { font-size: 16px; margin: 18px 0 6px; }
.condiciones p { margin: 0 0 8px; font-size: 15px; }
.condiciones .texto { max-height: 55vh; overflow: auto; border: 1px solid var(--linea); border-radius: var(--radio-s); padding: 4px 14px 10px; background: var(--fondo); }
.aviso.fin { background: var(--pizarra-claro); border-left: 4px solid var(--pizarra); color: var(--tinta); font-weight: 600; }

/* Acceso de asesor: se ocultan las acciones que modifican datos (el servidor también las impide) */
body.solo-lectura .principal .boton:not(.lectura), body.solo-lectura .principal .enlace:not(.lectura),
body.solo-lectura .principal input[type=checkbox], body.solo-lectura .principal .acciones:empty,
body.solo-lectura dialog .enlace:not(.lectura), body.solo-lectura dialog .pie .boton.secundario { display: none; }
body.solo-lectura .principal .filtros .boton.lectura { display: inline-flex; }
