/* PuntoCheck · identidad MARKAS (rojo, negro, blanco) */
:root {
  --red: #c8202a;
  --red-dark: #a3171f;
  --red-soft: #fbeced;
  --ink: #1f2a44;
  --ink-2: #2d3a56;
  --text: #25314a;
  --muted: #667086;
  --line: #e1e5ee;
  --bg: #f3f5f9;
  --white: #fff;
  --slate: #5f6b85;
  --slate-dark: #4a566f;
  --ok: #17803d;
  --ok-soft: #e7f5ec;
  --radius: 14px;
  --display: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Impact, sans-serif;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); line-height: 1.5; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.15; }
p { margin: 0; color: var(--muted); }
a { color: var(--red); }
svg { display: block; }

/* ---------- Marca ---------- */
.logo { display: inline-flex; flex-direction: column; align-items: center; gap: 10px; color: var(--red); }
.logo svg { width: 64px; height: auto; }
.logo b { font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: 3px; color: var(--ink); text-transform: uppercase; }
.logo.inline { flex-direction: row; gap: 12px; }
.logo.inline svg { width: 34px; }
.logo.inline img { height: 15px; width: auto; }

/* ---------- Formularios ---------- */
form { display: grid; gap: 16px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; color: var(--ink-2); }
input, select, button { font: inherit; border-radius: 10px; }
input, select {
  width: 100%; min-width: 0; padding: 12px 14px; color: var(--ink);
  background: var(--white); border: 1px solid #cfd1d4; font-weight: 400; font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px #c8202a22; }
button, .button-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 20px; border: 1px solid var(--red);
  background: var(--red); color: var(--white); font-weight: 700; font-size: 15px;
  text-decoration: none; cursor: pointer; transition: background .15s, transform .05s;
}
button:hover, .button-link:hover { background: var(--red-dark); border-color: var(--red-dark); }
button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline: 3px solid #c8202a44; outline-offset: 2px; }
button:disabled { color: #8a8d92; background: #ececed; border-color: #dcdcde; cursor: default; transform: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: #cfd1d4; }
.btn-ghost:hover { background: var(--bg); border-color: var(--ink); }
.btn-dark { background: var(--slate); border-color: var(--slate); }
.btn-dark:hover { background: var(--slate-dark); border-color: var(--slate-dark); }
.checkbox { display: flex; align-items: center; gap: 10px; align-self: end; min-height: 46px; font-weight: 600; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--red); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; min-width: 0; }
.fields > label { min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }

/* ---------- Avisos ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; font-weight: 550; }
.alert.error { background: var(--red-soft); color: var(--red-dark); border: 1px solid #f6c4c5; }
.alert.notice { background: var(--ok-soft); color: var(--ok); border: 1px solid #bfe3cb; }
.error { color: var(--red-dark); }

/* ---------- Login ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(32px, 5vw, 64px); color: var(--white);
  background: linear-gradient(150deg, #cf2a33 0%, var(--red) 50%, #8f141b 100%);
}
.auth-brand::after {
  content: ""; position: absolute; right: -18%; bottom: -22%; width: 70%; aspect-ratio: 1;
  background: #00000026; clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.auth-brand .mark { width: clamp(90px, 14vw, 150px); color: var(--white); position: relative; z-index: 1; }
.auth-brand .mark svg { width: 100%; height: auto; }
.auth-brand h2 { position: relative; z-index: 1; color: var(--white); font-family: var(--display); font-size: clamp(34px, 4.4vw, 58px); letter-spacing: 1px; text-transform: uppercase; line-height: 1.02; max-width: 12ch; }
.auth-brand p { position: relative; z-index: 1; color: #ffffffcc; margin-top: 14px; max-width: 34ch; font-size: 16px; }
.auth-brand small { position: relative; z-index: 1; color: #ffffffa6; letter-spacing: 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.auth-form-wrap { display: grid; place-items: center; padding: clamp(24px, 5vw, 64px); background: var(--white); }
.auth-form { width: min(100%, 400px); display: grid; gap: 22px; }
.auth-form .eyebrow { font-size: 11px; font-weight: 800; letter-spacing: 2.5px; color: var(--red); text-transform: uppercase; }
.auth-form h1 { font-size: clamp(30px, 4vw, 40px); letter-spacing: -1px; margin-top: 8px; }
.auth-form .lead { margin-top: 8px; }
.auth-form button[type="submit"] { width: 100%; min-height: 50px; font-size: 16px; margin-top: 4px; }
.auth-foot { font-size: 13px; text-align: center; }
.pw { position: relative; }
.pw input { padding-right: 76px; }
.pw button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-height: 34px; padding: 4px 12px; font-size: 12px; background: transparent; color: var(--muted); border-color: transparent; }
.pw button:hover { background: var(--bg); color: var(--ink); border-color: transparent; }

/* ---------- Layout administrador ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 24px 16px; background: var(--white); border-right: 1px solid var(--line); color: var(--ink); }
.sidebar .logo { align-self: flex-start; padding: 0 8px; }
.side-nav { display: grid; gap: 4px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px;
  color: var(--slate); font-weight: 600; font-size: 15px; text-decoration: none; border-left: 3px solid transparent;
}
.side-nav a svg { width: 20px; height: 20px; flex: none; }
.side-nav a:hover { background: var(--bg); color: var(--ink); }
.side-nav a[aria-current="page"] { background: var(--red-soft); color: var(--red-dark); border-left-color: var(--red); }
.side-nav a[aria-current="page"] svg { color: var(--red); }
.side-user { margin-top: auto; display: grid; gap: 12px; padding: 14px; border-radius: 12px; background: var(--bg); }
.side-user .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: var(--white); font-weight: 800; font-size: 14px; }
.avatar svg { width: 22px; height: 22px; }
.side-user strong { display: block; color: var(--ink); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user .who div span { color: var(--muted); font-size: 12px; }
.side-user button { width: 100%; min-height: 38px; font-size: 13px; background: var(--white); border-color: #cfd5e1; color: var(--ink); }
.side-user button:hover { background: var(--red-soft); border-color: var(--red); color: var(--red-dark); }
.content { min-width: 0; padding: clamp(20px, 3.5vw, 44px); display: grid; gap: 24px; align-content: start; }
.page-head h1 { font-size: clamp(26px, 3.4vw, 34px); letter-spacing: -.8px; }
.page-head p { margin-top: 6px; max-width: 70ch; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px, 2.6vw, 28px); display: grid; gap: 20px; box-shadow: 0 1px 2px #0000000a; }
.panel > h2 { font-size: 18px; letter-spacing: -.3px; }
.panel > h3 { font-size: 16px; }
.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title::before { content: ""; width: 4px; height: 20px; border-radius: 2px; background: var(--red); }

.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
th { background: #fafafa; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; white-space: nowrap; }
th, td { padding: 13px 16px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfcfc; }
td a { font-weight: 650; text-decoration: none; }
td a:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #ececed; color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.red { background: var(--red-soft); color: var(--red-dark); }
.badge.dark { background: #e7eaf1; color: var(--slate-dark); }
.badge.missing { background: #fff4e0; color: #8a5200; border: 1px dashed #e0a84a; }
.record-missing td { background: #fffaf2; color: var(--muted); }
.muted { color: var(--muted); }

.record-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.record-filters form { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fafafa; }
.record-photo-cell { min-width: 110px; }
.record-photo-link { display: inline-grid; justify-items: center; gap: 4px; color: var(--red); font-size: 12px; text-decoration: none; }
.record-photo-link img { display: block; width: 72px; height: 72px; max-width: none; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #111; }
.record-photo-link:hover img, .record-photo-link:focus-visible img { border-color: var(--red); box-shadow: 0 0 0 3px #c8202a22; }
.record-photo-dialog { width: min(94vw, 760px); max-height: 94vh; padding: 18px; border: 0; border-radius: 18px; box-shadow: 0 24px 60px #1f2a4455; }
.record-photo-dialog::backdrop { background: #1f2a44b8; }
.record-photo-dialog[open] { display: grid; gap: 14px; }
.record-photo-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.record-photo-head h2 { font-size: 20px; }
.record-photo-head p { margin-top: 4px; font-size: 13px; }
.record-photo-head button { flex: none; min-height: 38px; padding: 6px 12px; }
.record-photo-dialog > img { display: block; width: 100%; height: auto; max-height: calc(94vh - 110px); object-fit: contain; border-radius: 12px; background: #111; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; }
.pager a { padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; font-weight: 650; color: var(--ink); }
.pager a:hover { border-color: var(--red); color: var(--red); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.empty { padding: 28px; text-align: center; border: 1px dashed #cfd1d4; border-radius: 12px; }

/* ---------- Vista del trabajador ---------- */
.worker-shell { min-height: 100vh; display: flex; flex-direction: column; }
.worker-top { display: flex; align-items: center; gap: 16px; padding: 12px clamp(16px, 4vw, 32px); background: var(--white); border-bottom: 3px solid var(--red); }
.worker-top form { display: block; }
.worker-top button { min-height: 38px; padding: 6px 14px; font-size: 13px; background: var(--white); border-color: #cfd5e1; color: var(--ink); }
.worker-top button:hover { background: var(--red-soft); border-color: var(--red); color: var(--red-dark); }
.worker-main { flex: 1; width: 100%; padding: clamp(18px, 3vw, 32px) clamp(16px, 3vw, 32px) 40px; }
.worker-panel {
  display: grid; gap: 20px; align-items: stretch;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  grid-template-areas: "hello hello" "history action";
}
.action-clock { display: grid; justify-items: center; gap: 2px; padding-bottom: 18px; border-bottom: 1px solid var(--line); text-align: center; }
.action-time { font-size: clamp(40px, 11vw, 58px); font-weight: 800; letter-spacing: -1px; line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--ink); }
.action-time::after { content: ""; display: block; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--red); }
.action-date { font-size: 13px; color: var(--muted); text-transform: capitalize; }.worker-hello { grid-area: hello; }
.worker-action-card { grid-area: action; justify-self: end; width: 100%; align-content: start; }
.worker-history { grid-area: history; }
.worker-hello p { font-size: 14px; }
.worker-hello h1 { text-transform: uppercase; font-size: clamp(30px, 5vw, 44px); letter-spacing: -1px; margin-top: 4px; }
.worker-hello h1::after { content: ""; display: block; width: 48px; height: 4px; margin-top: 12px; border-radius: 2px; background: var(--red); }
.worker-card { background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: clamp(16px, 2.4vw, 24px); display: grid; gap: 18px; box-shadow: 0 4px 14px #1f2a4410; min-width: 0; }
.worker-card .table-scroll { max-height: 440px; }
.worker-location { min-width: 0; display: grid; gap: 10px; overflow-wrap: anywhere; }
.worker-location h2 { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.worker-location .place { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 17px; }
.worker-location .place svg { width: 22px; height: 22px; color: var(--red); flex: none; }
.worker-location [data-location-status] { font-size: 14px; padding: 10px 12px; border-radius: 10px; background: var(--bg); color: var(--text); }
.worker-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.worker-actions button { min-height: 76px; border-radius: 16px; font-size: 18px; font-weight: 800; letter-spacing: 1px; box-shadow: 0 6px 16px #1f2a4426; }
.worker-actions button[data-mark="SALIDA"] { background: var(--slate); border-color: var(--slate); }
.worker-actions button[data-mark="SALIDA"]:hover { background: var(--slate-dark); }
.worker-actions button:disabled { box-shadow: none; }
.camera-note { font-size: 13px; line-height: 1.4; }
.camera-dialog { width: min(94vw, 480px); padding: 22px; border: 0; border-radius: 18px; box-shadow: 0 24px 60px #1f2a4455; }
.camera-dialog::backdrop { background: #1f2a44aa; }
.camera-dialog[open] { display: grid; gap: 14px; }
.camera-dialog h2 { font-size: 22px; }
.camera-dialog p { font-size: 14px; }
.camera-frame { position: relative; height: min(55vh, 520px); display: grid; place-items: center; overflow: hidden; border-radius: 12px; background: #111; }
.camera-frame video, .camera-frame img { width: 100%; height: 100%; object-fit: contain; }
/* Vista en espejo, como la cámara frontal del celular. La foto enviada conserva la orientación real. */
.camera-frame video, .camera-frame img[data-camera-preview] { transform: scaleX(-1); }
.camera-face-guide { position: absolute; top: 16%; left: 25%; width: 50%; height: 56%; border: 3px dashed #ffffffcc; border-radius: 50%; pointer-events: none; }
.camera-actions { display: flex; gap: 10px; }
.camera-actions button { padding: 10px; }
.camera-actions button[data-camera-capture] { flex: 1; }

/* Aviso modal */
.alert-dialog { width: min(92vw, 400px); padding: 28px 24px 24px; border: 0; border-radius: 20px; text-align: center; box-shadow: 0 24px 60px #1f2a4455; color: var(--text); }
.alert-dialog::backdrop { background: #1f2a4488; }
.alert-dialog[open] { display: grid; gap: 12px; justify-items: center; }
.alert-dialog h2 { font-size: 22px; }
.alert-dialog p { color: var(--text); }
.alert-dialog button { width: 100%; margin-top: 8px; }
.dialog-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 30px; font-weight: 800; }
.alert-dialog[data-kind="ok"] .dialog-icon { background: var(--ok-soft); color: var(--ok); }
/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .worker-panel { grid-template-columns: 1fr; grid-template-areas: "hello" "action" "history"; }
    .auth { grid-template-columns: 1fr; min-height: 0; }
  .auth-brand { flex-direction: row; align-items: center; gap: 16px; padding: 22px 24px; }
  .auth-brand h2, .auth-brand p, .auth-brand small { display: none; }
  .auth-brand .mark { width: 54px; }
  .auth-brand::after { display: none; }
  .auth-form-wrap { align-items: start; min-height: calc(100vh - 98px); padding-top: 36px; }

  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell > * { min-width: 0; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; }
  .side-nav { order: 3; width: 100%; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .side-nav a { flex: none; padding: 10px 14px; border-left: 0; border-bottom: 3px solid transparent; border-radius: 8px; }
  .side-nav a[aria-current="page"] { border-bottom-color: var(--red); }
  .side-user { margin: 0 0 0 auto; padding: 0; background: none; display: flex; align-items: center; }
  .side-user .who div { display: none; }
  .side-user button { width: auto; padding: 6px 12px; }
}

@media (max-width: 860px) {
  .worker-action-card { position: static; justify-self: stretch; }
  .content { padding: 18px 14px 32px; }
}
@media (max-width: 560px) {
  input, select { font-size: 16px; } /* evita el zoom automático en iOS */
  .worker-top { padding: 10px 14px; }
  .logo.inline svg { width: 28px; }
  .logo.inline img { height: 12px; }
  .worker-main { padding: 16px 12px 32px; }
  .worker-panel { gap: 14px; }
  .worker-card { padding: 16px; border-radius: 16px; }
  .worker-hello h1 { font-size: 30px; }
  .worker-actions button { min-height: 68px; font-size: 16px; }
  th, td { padding: 10px 12px; }
  table { font-size: 13px; }
  .panel { padding: 16px; border-radius: 12px; }
  .record-filters form { padding: 14px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .button-link { width: 100%; }
  .form-actions button { flex: 1 1 100%; }
  .auth-form-wrap { padding: 28px 20px; }
  .sidebar { padding: 10px 12px; }
  .side-user button { min-height: 38px; }
  .alert-dialog { padding: 24px 18px 18px; }
}

/* ---------- App móvil / instalación ---------- */
[hidden] { display: none !important; }
.install-btn { display: none; }
.worker-top .logo { margin-right: auto; }
.worker-top .install-btn { min-height: 38px; padding: 6px 12px; font-size: 13px; }

@media (max-width: 860px) {
  .install-btn { display: inline-flex; }
  .auth-form .install-btn { width: 100%; }
}
.worker-shell { padding-bottom: env(safe-area-inset-bottom); }
.worker-top { padding-top: max(12px, env(safe-area-inset-top)); }
button, a, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* Evita que cualquier contenido ensanche la página en móvil */
html { overflow-x: hidden; }
img, svg, table { max-width: 100%; }
@media (max-width: 860px) {
  .sidebar { max-width: 100vw; }
  .side-nav { min-width: 0; max-width: 100%; }
  .side-user { min-width: 0; }
  input[type="month"], input[type="date"], input[type="search"] { min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; min-height: 46px; }
}

/* ---------- Admin móvil: menú de íconos sobre el título ---------- */
.tab-nav { display: none; }
@media (max-width: 860px) {
  .side-nav { display: none; }
  .sidebar { padding: 12px 16px; flex-wrap: nowrap; justify-content: space-between; }
  .sidebar .logo.inline svg { width: 46px; }
  .sidebar .logo.inline img { height: 20px; }
  .worker-top .logo.inline svg { width: 38px; }
  .worker-top .logo.inline img { height: 16px; }
  .tab-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .tab-nav a {
    display: grid; place-items: center; min-height: 54px; border-radius: 14px; color: var(--slate);
    background: var(--white); border: 1px solid var(--line); box-shadow: 0 1px 2px #1f2a440d; text-decoration: none;
  }
  .tab-nav a svg { width: 26px; height: 26px; }
  .tab-nav a[aria-current="page"] { background: var(--red-soft); border-color: var(--red); color: var(--red); box-shadow: inset 0 -3px 0 var(--red); }
}
