:root {
  --primary:   #1a5276;
  --primary-d: #154360;
  --green:     #1e8449;
  --red:       #922b21;
  --orange:    #d35400;
  --gray:      #5d6d7e;
  --bg:        #f4f6f8;
  --card:      #ffffff;
  --text:      #1c2833;
  --muted:     #717d87;
  --border:    #d5d8dc;
  --radius:    10px;
  --shadow:    0 2px 12px rgba(0,0,0,.09);
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── TOPBAR ── */
.topbar {
  background: var(--primary);
  color: #fff;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; flex: 1; }
.topbar a { color: #fff; opacity: .85; font-size: .875rem; }
.topbar a:hover { opacity: 1; text-decoration: none; }
.topbar .sep { opacity: .3; }

/* ── LAYOUT ── */
.wrap { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem; }
.wrap-sm { max-width: 520px; margin: 0 auto; padding: 2rem 1rem; }
.wrap-lg { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── CARD ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}

/* ── STATS GRID ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-num { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.stat-lbl { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.stat.green .stat-num { color: var(--green); }
.stat.red   .stat-num { color: var(--red); }
.stat.blue  .stat-num { color: var(--primary); }
.stat.orange .stat-num { color: var(--orange); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .65rem 1.3rem;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: .9rem; font-weight: 600;
  transition: .15s ease;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-green   { background: var(--green);   color: #fff; }
.btn-red     { background: var(--red);     color: #fff; }
.btn-gray    { background: var(--border);  color: var(--text); }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* BIG ACTION BUTTONS */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin: 1.5rem 0; }
.action-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .75rem; padding: 2rem 1rem;
  border-radius: 14px; border: none; cursor: pointer;
  font-size: 1.1rem; font-weight: 700; color: #fff;
  transition: .2s ease; box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.action-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.action-btn .icon { font-size: 2.5rem; line-height: 1; }
.action-btn.entrada { background: linear-gradient(135deg, #1e8449, #27ae60); }
.action-btn.salida  { background: linear-gradient(135deg, #922b21, #c0392b); }
.action-btn:disabled { opacity: .45; transform: none; cursor: not-allowed; }

/* ── FORM ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .4rem; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: .65rem .85rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .95rem; color: var(--text);
  background: #fff; transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group .hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }

/* ── TABLE ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .85rem; text-align: left; font-size: .875rem; }
th { background: #eaf0f6; color: var(--primary); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--border); }
tr:hover td { background: #f8fafc; }
td { border-bottom: 1px solid var(--border); vertical-align: middle; }

/* ── BADGE ── */
.badge { display: inline-block; padding: .25rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-ok   { background: #d4efdf; color: #1a6035; }
.badge-late { background: #fde8e8; color: #7b241c; }
.badge-warn { background: #fef3cd; color: #784212; }
.badge-gray { background: #eaecee; color: #5d6d7e; }
.badge-blue { background: #d6eaf8; color: #1a5276; }

/* ── ALERT ── */
.alert { padding: .85rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-ok  { background: #d4efdf; color: #1a6035; border-left: 4px solid var(--green); }
.alert-err { background: #fde8e8; color: #7b241c; border-left: 4px solid var(--red); }
.alert-info { background: #d6eaf8; color: #154360; border-left: 4px solid var(--primary); }
.alert-warn { background: #fef3cd; color: #784212; border-left: 4px solid var(--orange); }

/* ── LOGIN ── */
.login-box {
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  padding: 2.5rem;
  margin-top: 3rem;
}
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo .icon { font-size: 3rem; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: var(--primary); margin-top: .5rem; }
.login-logo p { color: var(--muted); font-size: .875rem; }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 2.5px dashed var(--border);
  border-radius: 12px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: .2s;
  position: relative;
}
.upload-zone:hover,
.upload-zone.drag { border-color: var(--primary); background: #eaf0f6; }
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-zone .uz-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.upload-zone .uz-txt  { font-weight: 600; color: var(--primary); }
.upload-zone .uz-hint { font-size: .8rem; color: var(--muted); margin-top: .3rem; }

/* ── PREVIEW ── */
#preview-section { display: none; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media(max-width:600px){ .preview-grid { grid-template-columns: 1fr; } .action-grid { grid-template-columns: 1fr; } }
.foto-preview { width: 100%; max-height: 300px; object-fit: cover; border-radius: 10px; }
#map { height: 260px; border-radius: 10px; }

/* ── EXIF DATA ── */
.exif-row { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .6rem; }
.exif-icon { font-size: 1.1rem; flex-shrink: 0; }
.exif-val  { font-size: .875rem; }
.exif-label { font-size: .75rem; color: var(--muted); display: block; }

/* ── SIDEBAR ADMIN ── */
.admin-layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--primary-d);
  padding: 1.25rem 0;
}
.sidebar a {
  display: flex; align-items: center; gap: .65rem;
  padding: .7rem 1.25rem;
  color: rgba(255,255,255,.75);
  font-size: .875rem;
  transition: .15s;
}
.sidebar a:hover,
.sidebar a.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.sidebar .sep-lbl {
  font-size: .7rem; color: rgba(255,255,255,.35);
  text-transform: uppercase; letter-spacing: .8px;
  padding: 1rem 1.25rem .4rem;
}
.admin-content { flex: 1; padding: 1.5rem; overflow-x: auto; }

/* ── MISC ── */
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* Horario config grid */
.horario-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.horario-card { border: 1.5px solid var(--border); border-radius: 10px; padding: 1rem; }
.horario-card h4 { font-size: .9rem; font-weight: 600; margin-bottom: .75rem; }
.horario-card.inactive { opacity: .55; }

/* Foto thumb en tabla */
.foto-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 999; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 14px; max-width: 480px; width: 90%; padding: 1.5rem; position: relative; }
.modal-close { position: absolute; top: 1rem; right: 1rem; font-size: 1.5rem; cursor: pointer; line-height: 1; }
.modal-img { width: 100%; border-radius: 10px; margin-bottom: 1rem; }

/* Pagination */
.pager { display: flex; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; }
.pager a, .pager span { padding: .35rem .75rem; border: 1px solid var(--border); border-radius: 6px; font-size: .875rem; }
.pager a:hover { background: #eaf0f6; text-decoration: none; }
.pager .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Spinner */
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── RESPONSIVE ────────────────────────────────────────────── */

/* Clase helper: grilla 2 columnas que colapsa en móvil */
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

@media (max-width: 768px) {

  /* Admin: sidebar pasa a barra horizontal con scroll */
  .admin-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar a {
    white-space: nowrap;
    flex-shrink: 0;
    padding: .75rem 1rem;
    border-bottom: 3px solid transparent;
    font-size: .82rem;
  }
  .sidebar a.active {
    background: rgba(255,255,255,.12);
    border-bottom-color: #D0B610;
  }
  .sidebar .sep-lbl { display: none; }
  .admin-content { padding: 1rem .75rem; }

  /* Card */
  .card { padding: 1.1rem .9rem; }
  .card-title { font-size: .95rem; }

  /* Grid de formularios → 1 columna */
  .form-2col { grid-template-columns: 1fr; }

  /* Stats: 2x2 en lugar de fila */
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-num { font-size: 1.8rem; }

  /* Tablas: fuente más pequeña */
  th, td { padding: .5rem .55rem; font-size: .8rem; }

  /* Topbar: menos padding */
  .topbar { padding: 0 .85rem; gap: .6rem; }

  /* Login */
  .login-box { padding: 0 0 1.5rem; margin-top: 1.5rem; }
  .login-box form { padding: 0 1.25rem; }
  .wrap-sm { padding: 1rem .75rem; }

  /* Modal más ancho en tablet */
  .modal-box { width: 92%; }

  /* Horario: 1 col */
  .horario-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {

  /* Topbar: separadores ocultos, links más pequeños */
  .topbar .sep { display: none; }
  .topbar a { font-size: .78rem; }
  .topbar { gap: .5rem; }

  /* Botones de acción: touch-friendly */
  .action-grid { gap: .75rem; margin: 1rem 0; }
  .action-btn {
    padding: 1.4rem .6rem;
    border-radius: 12px;
    font-size: .95rem;
    gap: .5rem;
  }
  .action-btn .icon { font-size: 2rem; }

  /* Stats 2x2 compacto */
  .stat { padding: 1rem .6rem; }
  .stat-num { font-size: 1.6rem; }
  .stat-lbl { font-size: .72rem; }

  /* Alertas */
  .alert { font-size: .85rem; padding: .75rem .85rem; }

  /* Botones normales: más grandes para touch */
  .btn { padding: .7rem 1.1rem; }
  .btn-sm { padding: .5rem .75rem; font-size: .8rem; }

  /* Tabla: ocultar columnas menos importantes */
  .td-hide-xs { display: none; }
  .th-hide-xs { display: none; }

  /* Modal full-width */
  .modal-box { width: 97%; padding: 1rem; border-radius: 10px; }
  .modal-close { top: .75rem; right: .75rem; }

  /* Card más compacto */
  .card { padding: 1rem .75rem; }

  /* Paginación */
  .pager a, .pager span { padding: .4rem .6rem; font-size: .8rem; }

  /* Foto thumb más pequeña */
  .foto-thumb { width: 36px; height: 36px; }
}
