:root {
  --blue: #1B2EE8;
  --blue-dark: #010088;
  --blue-soft: #E9ECFF;
  --ink: #08083A;
  --muted: #565B7C;
  --line: #DEE1F2;
  --bg: #F4F5FD;
  --card: #ffffff;
  --green: #12805c;
  --green-soft: #e3f4ec;
  --amber: #a85d00;
  --amber-soft: #fdf1df;
  --red: #b42318;
  --red-soft: #fdeceb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 16px rgba(15, 27, 45, .06);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.topbar {
  background: var(--blue-dark); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; }
.brand .logo { display: block; color: #fff; text-decoration: none; }
.brand .logo svg { height: 22px; width: auto; display: block; }
.brand .sep { width: 1px; height: 26px; background: rgba(174,185,255,.35); }
.brand small { display: block; font-weight: 600; opacity: .85; font-size: 13px; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.btn-ghost {
  background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 8px;
  padding: 7px 11px; font-size: 13px; font-weight: 600;
}
.btn-ghost:hover { background: rgba(255,255,255,.24); }

/* ---------- Genéricos ---------- */
.wrap { max-width: 520px; margin: 0 auto; padding: 18px 16px 40px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 5px; }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=search], input[type=date], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.btn {
  border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700;
  background: var(--blue); color: #fff;
}
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.secondary { background: var(--blue-soft); color: var(--blue); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.ok { background: var(--green-soft); color: var(--green); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.err { color: var(--red); font-size: 14px; min-height: 18px; margin-top: 10px; }

/* ---------- Empleado ---------- */
.clock { text-align: center; }
.clock .time { font-size: 44px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.clock .date { color: var(--muted); }
.who { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.status::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status.off { background: #eef1f5; color: var(--muted); }
.status.working { background: var(--green-soft); color: var(--green); }
.status.lunch { background: var(--amber-soft); color: var(--amber); }
.punch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.punch-btn {
  border: 2px solid var(--line); background: #fff; border-radius: 16px; padding: 20px 10px;
  font-weight: 800; font-size: 16px; color: var(--ink); display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .08s ease, border-color .15s;
}
.punch-btn svg { width: 28px; height: 28px; }
.punch-btn.main { border-color: var(--blue); color: var(--blue); }
.punch-btn:not(:disabled):active { transform: scale(.97); }
.punch-btn:disabled { opacity: .35; cursor: not-allowed; }
.punch-btn.primary-in:not(:disabled) { background: var(--blue); border-color: var(--blue); color: #fff; }
.punch-btn.primary-out:not(:disabled) { background: var(--ink); border-color: var(--ink); color: #fff; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.list li:last-child { border-bottom: 0; }
.kind-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.k-clock_in { background: var(--green); } .k-clock_out { background: var(--ink); }
.k-lunch_start { background: #e08a00; } .k-lunch_end { background: var(--blue); }

.overlay {
  position: fixed; inset: 0; background: rgba(8, 20, 40, .55); display: grid; place-items: center; z-index: 100; padding: 16px;
}
.overlay .card { width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; margin: 8px auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { text-align: center; }
.big-check { width: 60px; height: 60px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 4px auto 12px; }

#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; transition: opacity .4s; }
.toast.error { background: var(--red); } .toast.success { background: var(--green); }
.toast.out { opacity: 0; }

/* ---------- Admin ---------- */
.admin-shell { max-width: 1280px; margin: 0 auto; padding: 16px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tab {
  border: 0; background: transparent; padding: 9px 14px; border-radius: 999px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.tab.active { background: var(--blue); color: #fff; }
.tab .badge { background: var(--red); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .n { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi.green .n { color: var(--green); } .kpi.amber .n { color: var(--amber); } .kpi.red .n { color: var(--red); }
.two-col > .card { margin-top: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 14px; }
#map { height: 460px; border-radius: 10px; z-index: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.toolbar > div { min-width: 150px; }
.toolbar label { margin-top: 0; }
.toolbar .grow { flex: 1; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.voided td { opacity: .5; text-decoration: line-through; }
tr.voided td.keep { text-decoration: none; opacity: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; margin: 1px 2px 1px 0; white-space: nowrap; }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.bad { background: var(--red-soft); color: var(--red); }
.chip.info { background: var(--blue-soft); color: var(--blue); }
.chip.okc { background: var(--green-soft); color: var(--green); }
.chip.grey { background: #eef1f5; color: var(--muted); }
.emp-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.emp-row:last-child { border-bottom: 0; }
.emp-row .name { font-weight: 700; }
a { color: var(--blue); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

@media (max-width: 600px) { #adminName { display: none; } }
@media (max-width: 440px) { .brand .sep, .brand small { display: none; } .topbar { gap: 8px; } .btn-ghost { padding: 6px 9px; } }
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  #map { height: 320px; }
}

/* ---------- Trabajo: pestañas, agenda, fotos, materiales ---------- */
.linkbtn { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 600; text-decoration: underline; cursor: pointer; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(8, 8, 58, .06);
}
.bottom-nav button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; color: var(--muted); font-weight: 700; font-size: 12px; border-radius: 10px; }
.bottom-nav button svg { width: 22px; height: 22px; }
.bottom-nav button.active { color: var(--blue); background: var(--blue-soft); }
#vMain { padding-bottom: 84px; }
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpis.two { grid-template-columns: 1fr 1fr; }
.kpis.two .n { font-size: 24px; }
.day { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-top: 10px; }
.day.today { outline: 2px solid var(--blue); }
.day-h { font-weight: 800; margin-bottom: 8px; }
.shift-row { padding: 4px 0; }
.task-row { width: 100%; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 10px; color: inherit; }
.task-row:hover { border-color: var(--blue); }
.thumbs, .picker-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs:empty, .picker-grid:empty { display: none; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; background: #e7eaf5 center/cover no-repeat; border: 1px solid var(--line); padding: 0; display: inline-grid; place-items: center; color: var(--muted); }
button.thumb { cursor: zoom-in; }
.thumb.loading { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.thumb button { position: absolute; top: -7px; right: -7px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 14px; line-height: 1; padding: 0; }
.picker-add { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 10px 14px; border: 2px dashed var(--line); border-radius: 12px; color: var(--blue); font-weight: 700; font-size: 14px; cursor: pointer; }
.picker-add:hover { border-color: var(--blue); }
.update { border-left: 3px solid var(--line); padding: 6px 0 6px 12px; margin: 8px 0; }
.update.mine { border-left-color: var(--blue); }
.req { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; }
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(4, 4, 30, .92); display: grid; place-items: center; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 8px; }
.lightbox button { position: absolute; background: rgba(255,255,255,.14); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 26px; line-height: 1; }
.lb-close { top: 14px; right: 14px; } .lb-prev { left: 14px; top: 50%; } .lb-next { right: 14px; top: 50%; }
.lb-count { position: absolute; bottom: 16px; color: #fff; font-size: 13px; }
/* Panel: agenda semanal */
.wk-grid { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 900px; font-size: 13px; }
.wk-grid th { text-transform: none; letter-spacing: 0; font-size: 12px; }
.wk-grid td { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 6px; vertical-align: top; min-width: 110px; }
.wk-grid td:first-child { border-left: 0; min-width: 150px; }
.wk-grid td.today, .wk-grid th.today { background: var(--blue-soft); }
.wk-item { display: block; width: 100%; text-align: left; border: 0; border-radius: 8px; padding: 5px 7px; margin-bottom: 4px; font-size: 12px; line-height: 1.3; }
.wk-item.shift { background: #e9ecff; color: var(--blue-dark); }
.wk-item.task { background: #fff4e5; color: #7a4400; }
.wk-item.task.done { background: var(--green-soft); color: var(--green); }
.wk-add { border: 1px dashed var(--line); background: none; color: var(--muted); border-radius: 8px; width: 100%; padding: 3px; font-size: 12px; }
.wk-add:hover { border-color: var(--blue); color: var(--blue); }
.mat-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.small-thumbs .thumb { width: 44px; height: 44px; border-radius: 8px; }
td .thumbs .thumb { width: 44px; height: 44px; border-radius: 8px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 130px; gap: 10px; align-items: center; padding: 5px 0; font-size: 14px; }
.bar-track { background: var(--bg); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .bar-row { grid-template-columns: 110px 1fr 100px; font-size: 13px; } }
.seg { display: inline-flex; background: var(--bg); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--blue); box-shadow: var(--shadow); }
#fiPeriods th, #fiPeriods td { white-space: nowrap; }
/* Lugares */
.site-row { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; color: inherit; }
.site-row:hover { border-color: var(--blue); }
.site-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; flex: none; }
.big-thumbs .thumb { width: 120px; height: 120px; }
.job h2 { font-size: 20px; }
.print-only { display: none; }
@media print {
  .topbar, .tabs, .no-print, #toasts, .bottom-nav { display: none !important; }
  .print-only { display: block; }
  body, .admin-shell { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .thumb { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .big-thumbs .thumb { width: 160px; height: 160px; }
  a { color: inherit; text-decoration: none; }
}
.pick { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 8px 0 0; cursor: pointer; color: var(--ink); font-weight: 400; font-size: 15px; }
.pick input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--blue); }
.pick:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.cur-task { border-left: 4px solid var(--green); }
.hours-box { background: var(--green-soft); color: var(--ink); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
/* Dictado por voz */
.voice-box { display: flex; gap: 14px; align-items: flex-start; }
.mic { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 6px 18px rgba(27,46,232,.35); }
.mic.on { background: var(--red); animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(180,35,24,.45); } 50% { box-shadow: 0 0 0 14px rgba(180,35,24,0); } }
.draft { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: #fff; }
.grid4 { display: grid; grid-template-columns: 1.3fr 1fr 1fr .8fr; gap: 0 10px; }
@media (max-width: 560px) { .grid4 { grid-template-columns: 1fr 1fr; } .voice-box { flex-direction: column; align-items: center; } }
/* Grupo de trabajo */
.chips-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-weight: 600; font-size: 14px; color: var(--ink); }
.pick-chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.pick-chip.on::before { content: '✓ '; }
.calc { padding: 11px 12px; border: 1px dashed var(--line); border-radius: 10px; background: var(--bg); min-height: 44px; }
.team-line { font-size: 13px; color: var(--muted); margin-top: 4px; }
