/* ==========================================================================
   ESSBIO UI Kit — Visor de Registros D1
   ========================================================================== */

:root {
  --navy: #0E2E63;
  --blue: #1652A8;
  --sky: #00AEEF;
  --orange: #F26522;
  --bg-tint: #EAF3FB;
  --paper: #F5F9FD;
  --ink: #0E2E63;
  --slate: #3E5375;
  --slate-soft: #7C8CA6;
  --line: #DCE7F5;
  --amber: #F2A93B;
  --red: #E2453C;
  --green: #2FA36B;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--slate);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  color: var(--navy);
}

/* Layout Shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar (side) */
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--navy);
  color: #B9CCE8;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
}

.side .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 20px;
}

.side .brand-badge {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  color: #fff;
  font-size: 13px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  padding-left: 8px;
  line-height: 1;
  margin-left: 2px;
}

.side nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #B9CCE8;
  background: transparent;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all .15s;
}

.side nav .nav-link:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.side nav .nav-link.active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}

.side .grp {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #6E88B5;
  margin: 16px 10px 6px;
}

.side-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(47, 163, 107, 0.15);
  color: #55d094;
}

.status-indicator.online {
  background: rgba(47, 163, 107, 0.2);
  color: #38d689;
}

.status-indicator .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.apk-info {
  font-size: 11px;
  color: #6E88B5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 4px;
}

/* Main Content Area */
main {
  padding: 30px 40px 80px;
  max-width: 1350px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.header-title h1 {
  font-size: 22px;
  font-weight: 700;
}

.header-title p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--slate-soft);
}

.header-actions {
  display: flex;
  gap: 10px;
}

/* ===== BUTTONS (ESSBIO UI Kit) ===== */
.btn {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 12.5px;
  padding: 9px 20px;
  border-radius: 30px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  transition: filter .15s, transform .15s;
}

.btn:hover {
  filter: brightness(0.92);
}

.btn.sm {
  padding: 6px 14px;
  font-size: 11.5px;
}

.btn.lg {
  padding: 13px 26px;
  font-size: 14px;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-navy {
  background: var(--navy);
  color: #fff;
}

.btn-sky {
  background: var(--sky);
  color: #fff;
}

.btn-orange {
  background: var(--orange);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--blue);
  border: 1.5px solid var(--blue);
}

.btn-ghost {
  background: var(--bg-tint);
  color: var(--navy);
}

/* ===== CARDS (ESSBIO UI Kit) ===== */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.card-stat {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--bg-tint); color: var(--blue); }
.stat-icon.sky { background: #E6F7FF; color: var(--sky); }
.stat-icon.green { background: #E1F5EA; color: var(--green); }
.stat-icon.orange { background: #FDF0DC; color: var(--orange); }

.card-stat .k {
  font-family: 'Poppins', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}

.card-stat .l {
  font-size: 12px;
  color: var(--slate-soft);
  margin-bottom: 2px;
}

/* Filter Card */
.filter-card {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-group {
  flex: 1;
  min-width: 260px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--slate-soft);
}

.search-group input {
  width: 100%;
  padding-left: 36px !important;
}

.field-date {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-date label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}

input[type=text], input[type=date] {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--slate);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}

input:focus {
  border-color: var(--sky);
}

/* Sections & Headers */
.sec-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 8px;
}

.sec-head h2 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== BADGES / CHIPS ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge.ok { background: #E1F5EA; color: var(--green); }
.badge.warn { background: #FDF0DC; color: #AD7317; }
.badge.risk { background: #FBE3E1; color: var(--red); }
.badge.info { background: var(--bg-tint); color: var(--blue); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Map Container */
.map-container {
  height: 380px;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

#leafletMap {
  width: 100%;
  height: 100%;
}

/* ===== TABLE ===== */
.table-card {
  border-radius: var(--radius);
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--slate-soft);
  font-weight: 600;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: #F8FAFC;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid #EEF3FA;
  color: var(--slate);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg-tint);
}

.loading-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--slate-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--sky);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-view-detail {
  padding: 5px 12px;
  background: var(--bg-tint);
  color: var(--blue);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 11.5px;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}

.btn-view-detail:hover {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

/* ===== MODAL (ESSBIO UI Kit) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 46, 99, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: 540px;
  max-width: 90vw;
  box-shadow: 0 12px 35px rgba(14, 46, 99, 0.2);
  border: 1px solid var(--line);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.modal-header h3 {
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--slate-soft);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--navy);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.detail-label {
  font-size: 12.5px;
  color: var(--slate-soft);
}

.detail-value {
  font-weight: 600;
  color: var(--navy);
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.photo-item {
  height: 100px;
  background: var(--bg-tint);
  border-radius: 10px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--slate-soft);
  font-size: 11px;
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media(max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 20px 16px; }
}
