:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --entrada: #16a34a;
  --entrada-dark: #15803d;
  --entrada-light: #f0fdf4;
  --salida: #dc2626;
  --salida-dark: #b91c1c;
  --salida-light: #fef2f2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

.hidden { display: none !important; }

/* ── Login ── */
#login-screen {
  min-height: 100vh;
}
.login-bg {
  min-height: 100vh;
  background: linear-gradient(160deg, #1a3a2a 0%, #2d5a3d 45%, #4a7c59 80%, #6b9e78 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem 1rem; position: relative; overflow: hidden;
}
.login-mountains {
  position: absolute; bottom: 0; left: 0; right: 0; width: 100%; height: 220px;
  pointer-events: none;
}
.login-box {
  background: rgba(255,255,255,0.97);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  padding: 2rem 2rem 1.75rem;
  width: 100%; max-width: 400px;
  position: relative; z-index: 2;
}
.login-logos {
  display: flex; align-items: center; justify-content: center;
  gap: 1.5rem; margin-bottom: 1.25rem; padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.login-logo-item { display: flex; align-items: center; justify-content: center; }
.login-logo-img { height: 70px; width: auto; object-fit: contain; }
.login-logo-sep { width: 1px; height: 60px; background: var(--border); }
.login-subtitle {
  text-align: center; font-size: .95rem; color: var(--text-muted);
  margin-bottom: 1.25rem; font-weight: 500;
}
.btn-login {
  background: #2d5a3d; color: #fff; border: none;
  width: 100%; padding: .7rem; border-radius: 10px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-login:hover { background: #1a3a2a; }
.logo { display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem; color: var(--primary); }
.logo h1 { font-size: 1.4rem; font-weight: 700; }

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.25rem; gap: 1rem;
}
.header-left { display: flex; align-items: center; gap: .6rem; color: var(--primary); font-weight: 700; }
.app-title { font-size: 1.1rem; }
.header-right { display: flex; align-items: center; gap: .75rem; font-size: .85rem; color: var(--text-muted); }
nav { display: flex; gap: 0; padding: 0 1rem; overflow-x: auto; }
.nav-btn {
  background: none; border: none; cursor: pointer;
  padding: .6rem 1rem; font-size: .875rem; font-weight: 500;
  color: var(--text-muted); border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color .15s, border-color .15s;
}
.nav-btn:hover { color: var(--primary); }
.nav-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Main ── */
main { padding: 1.5rem 1rem; max-width: 900px; margin: 0 auto; }

/* ── Cards ── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.center-card { text-align: center; max-width: 480px; margin: 0 auto 1.5rem; }

/* ── Fichar ── */
.status-badge {
  display: inline-block; padding: .35rem 1rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; margin-bottom: 1rem;
}
.status-badge.in { background: var(--entrada-light); color: var(--entrada); }
.status-badge.out { background: #f1f5f9; color: var(--text-muted); }

.fichar-buttons { display: flex; gap: 1rem; justify-content: center; margin: 1.5rem 0 .75rem; flex-wrap: wrap; }

.btn-entrada {
  background: var(--entrada); color: #fff; border: none;
  display: flex; align-items: center; gap: .5rem;
}
.btn-entrada:hover:not(:disabled) { background: var(--entrada-dark); }
.btn-salida {
  background: var(--salida); color: #fff; border: none;
  display: flex; align-items: center; gap: .5rem;
}
.btn-salida:hover:not(:disabled) { background: var(--salida-dark); }

.geo-note { font-size: .78rem; color: var(--text-muted); }
.location-info {
  background: var(--entrada-light); border-radius: 8px;
  padding: .6rem 1rem; font-size: .85rem; color: var(--entrada);
  margin-bottom: .75rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .55rem 1.1rem; border-radius: 8px;
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-ghost { background: none; color: var(--text-muted); border: none; }
.btn-ghost:hover { color: var(--text); background: var(--bg); }
.btn-danger { background: var(--salida); color: #fff; border-color: var(--salida); }
.btn-danger:hover:not(:disabled) { background: var(--salida-dark); }
.btn-full { width: 100%; }
.btn-lg { padding: .8rem 1.5rem; font-size: 1rem; border-radius: 10px; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ── Form fields ── */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--text-muted); }
input, select, textarea {
  width: 100%; padding: .6rem .85rem; border: 1px solid var(--border);
  border-radius: 8px; font-size: .9rem; color: var(--text);
  background: var(--surface); transition: border-color .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── Filters / toolbar ── */
.filter-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.filter-row h2 { font-size: 1.1rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: .6rem .75rem; font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 2px solid var(--border); }
td { padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-in { background: var(--entrada-light); color: var(--entrada); }
.badge-out { background: var(--salida-light); color: var(--salida); }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-active { background: var(--entrada-light); color: var(--entrada); }
.badge-inactive { background: #f1f5f9; color: var(--text-muted); }

/* ── Summary box ── */
.summary-box {
  background: var(--primary-light); border-radius: 10px;
  padding: 1rem 1.25rem; margin-bottom: 1.25rem;
  display: flex; gap: 2rem; flex-wrap: wrap;
}
.summary-stat { }
.summary-stat .value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.summary-stat .label { font-size: .78rem; color: var(--text-muted); margin-top: .1rem; }

/* Resumen mensual todos los empleados */
.resumen-mensual {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: .75rem; margin-bottom: 1.25rem;
}
.resumen-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: .9rem 1rem;
}
.resumen-card .name { font-weight: 600; font-size: .9rem; }
.resumen-card .hours { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin: .25rem 0; }
.resumen-card .days { font-size: .78rem; color: var(--text-muted); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; padding: 1rem;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  background: none; border: none; font-size: 1.4rem; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: .1rem .3rem;
}
.modal-close:hover { color: var(--text); }
#modal-body { padding: 1.5rem; }

/* ── Error / alerts ── */
.error {
  background: var(--salida-light); color: var(--salida);
  border-radius: 8px; padding: .6rem .9rem; font-size: .875rem;
  margin-bottom: .75rem;
}
.success {
  background: var(--entrada-light); color: var(--entrada);
  border-radius: 8px; padding: .6rem .9rem; font-size: .875rem;
  margin-bottom: .75rem;
}
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); font-size: .9rem; }

/* ── Location checkboxes ── */
.loc-checks { display: flex; flex-direction: column; gap: .5rem; max-height: 180px; overflow-y: auto; }
.loc-check { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.loc-check input[type=checkbox] { width: auto; cursor: pointer; }

/* ── Responsive ── */
@media (max-width: 600px) {
  main { padding: 1rem .75rem; }
  .card { padding: 1.1rem; }
  .field-row, .field-3 { grid-template-columns: 1fr; }
  .fichar-buttons { flex-direction: column; align-items: center; }
  .btn-lg { width: 100%; max-width: 280px; }
}
