:root {
  --bg: #eef4f0;
  --bg-gradient-top: #e3f1e8;
  --bg-gradient-bottom: #ffffff;
  --panel: #ffffff;
  --accent: #ffcc33;
  --accent-strong: #f5a623;
  --accent-green: #008a3a;
  --text-main: #12232f;
  --text-muted: #6b7785;
  --border-soft: rgba(0, 0, 0, 0.06);
  --radius-lg: 16px;
  --radius-md: 12px;
  --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(
    180deg,
    var(--bg-gradient-top) 0,
    var(--bg-gradient-bottom) 55%
  );
  color: var(--text-main);
}

/* HEADER */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.logo-img {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(0, 138, 58, 0.2),
    0 0 16px rgba(0, 138, 58, 0.28);
}

.title-block h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.title-block p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-row label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.role-select {
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  padding: 4px 10px;
  font-size: 0.78rem;
  background: #f5f7f9;
  color: var(--text-main);
}

.badge-path {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 138, 58, 0.08);
  color: var(--accent-green);
  font-size: 0.72rem;
  font-weight: 600;
}

.last-update {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* NAV */

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 0;
}

.nav-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 6px 14px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-btn.active {
  background: linear-gradient(90deg, var(--accent-green), var(--accent));
  color: #1b1b1b;
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* MAIN */

.app-main {
  padding: 14px 16px 30px;
  max-width: 1200px;
  margin: 0 auto;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

/* KPI CARDS */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-soft);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: -40%;
  background: radial-gradient(
    circle at top left,
    rgba(255, 204, 51, 0.25),
    transparent 55%
  );
  opacity: 0.6;
  pointer-events: none;
}

.kpi-card h2 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.kpi-number {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-green);
}

.kpi-small {
  font-size: 1rem;
}

.kpi-caption {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* PANELS */

.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.panel-header h3 {
  margin: 0;
  font-size: 0.98rem;
}

.panel-body {
  margin-bottom: 10px;
}

.texto-ayuda {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* GRID 2 */

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

/* SEARCH INPUT */

.search-input {
  background: #f5f7f9;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  padding: 6px 12px;
  color: var(--text-main);
  font-size: 0.82rem;
  min-width: 220px;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: 1px solid var(--accent-green);
  border-color: var(--accent-green);
}

/* TABLE */

.table-wrapper {
  max-height: 360px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead {
  position: sticky;
  top: 0;
  background: #edf1f5;
  z-index: 1;
}

th,
td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
}

tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

tbody tr:hover {
  background: rgba(255, 204, 51, 0.08);
}

/* DOWNLOADS */

.download-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.btn-primary,
.btn-secondary {
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(90deg, var(--accent-green), var(--accent-strong));
  color: #1b1b1b;
  font-weight: 600;
}

.btn-secondary {
  background: #f5f7f9;
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

/* FORM ASISTENCIA */

.form-asistencia {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
}

.field-label input,
.field-label select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  font-size: 0.82rem;
  background: #f7f9fb;
}

.field-label span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.field-label span input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.form-asistencia-row {
  display: flex;
  gap: 8px;
}

.field-label.small {
  flex: 1;
}

.form-asistencia-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* MAPA */

.map-container {
  width: 100%;
  height: 280px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

/* LOGIN OVERLAY */

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 17, 12, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 20px 18px 16px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-logo {
  width: 60px;
  height: 60px;
  border-radius: 999px;
  object-fit: contain;
  margin-bottom: 6px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 1.02rem;
}

.login-card p {
  margin: 0 0 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.login-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 0.86rem;
  background: #f7f9fb;
}

.login-input:focus {
  outline: 1px solid var(--accent-green);
  border-color: var(--accent-green);
}

.login-error {
  min-height: 16px;
  font-size: 0.78rem;
  color: #c0392b;
}

.login-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* RESPONSIVE */

@media (max-width: 800px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .header-right {
    align-items: flex-start;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-input {
    width: 100%;
  }

  .main-nav {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .form-asistencia-row {
    flex-direction: column;
  }

  .form-asistencia-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}
