/* =====================================================
   PANEL DE REPORTERÍA — GOBIERNO DE PANAMÁ
   Main Stylesheet — Responsive v2
   ===================================================== */

:root {
  --primary:       #1a3a5c;
  --primary-hover: #14304f;
  --primary-light: #e8f0f8;
  --accent-green:  #2e9e6b;
  --accent-orange: #e87d2e;
  --accent-purple: #7c5cbf;
  --accent-blue:   #2d7dd2;
  --accent-red:    #d63b3b;
  --bg:            #f0f3f7;
  --surface:       #ffffff;
  --surface-2:     #f7f9fc;
  --border:        #dde2ea;
  --text-1:        #1a2535;
  --text-2:        #4a5568;
  --text-3:        #8a95a3;
  --sidebar-w:     220px;
  --topbar-h:      60px;
  --radius:        10px;
  --shadow:        0 2px 12px rgba(0,0,0,0.07);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.10);
  --font:          'DM Sans', sans-serif;
  --mono:          'DM Mono', monospace;
  --transition:    0.2s ease;
  --content-pad:   24px;
}

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

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.brand-logo {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.brand-logo img { width: 100%; object-fit: contain; }
.brand-fallback { font-size: 22px; }
.brand-text {
  display: flex; flex-direction: column;
  line-height: 1.2; min-width: 0;
}
.brand-top  { font-size: 9px; color: rgba(255,255,255,0.55); letter-spacing: 0.08em; text-transform: uppercase; }
.brand-main { font-size: 11px; color: white; font-weight: 600; letter-spacing: 0.02em; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
.nav-item i { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
  font-weight: 500;
  border-left: 3px solid #4db8ff;
}
.badge-count {
  margin-left: auto;
  background: var(--accent-red);
  color: white;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px;
  min-width: 20px; text-align: center;
}
.sidebar-footer { padding: 12px 0; border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; }
.logout { color: rgba(255,255,255,0.5) !important; }
.logout:hover { color: #ff8080 !important; background: rgba(214,59,59,0.1) !important; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* =====================================================
   MAIN WRAPPER
   ===================================================== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* =====================================================
   TOPBAR
   ===================================================== */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--content-pad);
  position: sticky; top: 0;
  z-index: 50;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: var(--text-2); padding: 4px; flex-shrink: 0;
}
.page-title { min-width: 0; }
.page-title h1 { font-size: 18px; font-weight: 600; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title span { font-size: 12px; color: var(--text-3); display: block; margin-top: -2px; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px;
  background: none; border: none; cursor: pointer;
  border-radius: 50%; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn i { width: 18px; height: 18px; }
.notif-dot {
  position: absolute; top: 4px; right: 4px;
  background: var(--accent-red); color: white;
  font-size: 9px; font-weight: 700;
  padding: 1px 4px; border-radius: 10px;
  min-width: 16px; text-align: center; line-height: 1.4;
}

.user-menu {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius);
  cursor: pointer; position: relative;
  transition: background var(--transition);
}
.user-menu:hover { background: var(--bg); }
.avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--primary); color: white;
  border-radius: 50%; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name   { font-size: 13px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.user-entity { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.chevron { width: 14px; height: 14px; color: var(--text-3); flex-shrink: 0; }
.user-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 180px; overflow: hidden;
  display: none; z-index: 200;
}
.user-dropdown.open { display: block; }
.user-dropdown a {
  display: block; padding: 10px 16px;
  font-size: 13px; color: var(--text-2); text-decoration: none;
  transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--bg); color: var(--text-1); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* =====================================================
   CONTENT
   ===================================================== */
.content {
  flex: 1;
  padding: var(--content-pad);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* =====================================================
   CARD BASE
   ===================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-header h3 {
  font-size: 14.5px; font-weight: 600; color: var(--text-1);
  display: flex; align-items: center; gap: 7px;
}
.card-header h3 i { width: 16px; height: 16px; color: var(--text-3); }

/* =====================================================
   ENTITY HEADER
   ===================================================== */
.entity-header {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; flex-wrap: wrap;
}
.entity-logo {
  width: 54px; height: 54px; flex-shrink: 0;
  background: var(--primary-light);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.entity-info { min-width: 0; }
.entity-info h2 { font-size: 17px; font-weight: 600; color: var(--primary); }
.entity-info p  { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.entity-meta { margin-left: auto; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.meta-block { display: flex; flex-direction: column; }
.meta-label { font-size: 11px; color: var(--text-3); }
.meta-value { font-size: 13px; font-weight: 500; color: var(--text-1); }
.meta-block.realtime {
  flex-direction: row; align-items: center; gap: 7px;
  background: #e8f8f1; padding: 6px 12px; border-radius: 20px;
  font-size: 12.5px; font-weight: 500; color: var(--accent-green);
}
.live-dot {
  width: 8px; height: 8px; flex-shrink: 0;
  background: var(--accent-green); border-radius: 50%;
  animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }

/* =====================================================
   KPI GRID
   ===================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow); min-width: 0;
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon i { width: 20px; height: 20px; }
.kpi-card.primary .kpi-icon { background: #ddeaf7; color: var(--primary); }
.kpi-card.green   .kpi-icon { background: #d5f0e5; color: var(--accent-green); }
.kpi-card.orange  .kpi-icon { background: #fde8d5; color: var(--accent-orange); }
.kpi-card.purple  .kpi-icon { background: #e9e0f7; color: var(--accent-purple); }
.kpi-card.blue    .kpi-icon { background: #d5e8f8; color: var(--accent-blue); }
.kpi-card.primary { border-top: 3px solid var(--primary); }
.kpi-card.green   { border-top: 3px solid var(--accent-green); }
.kpi-card.orange  { border-top: 3px solid var(--accent-orange); }
.kpi-card.purple  { border-top: 3px solid var(--accent-purple); }
.kpi-card.blue    { border-top: 3px solid var(--accent-blue); }
.kpi-body { display: flex; flex-direction: column; min-width: 0; }
.kpi-label { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text-1); line-height: 1.1; }
.kpi-sub   { font-size: 11px; color: var(--text-3); }

/* =====================================================
   LAYOUT GRIDS
   ===================================================== */
.row-2col {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
}
.row-4col {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* =====================================================
   DONUT CHART
   ===================================================== */
.chart-card { display: flex; flex-direction: column; }
.donut-wrapper {
  position: relative; width: 180px; height: 180px;
  margin: 0 auto 12px;
}
.donut-wrapper canvas { width: 100% !important; height: 100% !important; }
.donut-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.donut-total { display: block; font-size: 28px; font-weight: 700; color: var(--text-1); line-height: 1; }
.donut-label { font-size: 11px; color: var(--text-3); }
.chart-legend { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-val { margin-left: auto; font-weight: 600; font-size: 12.5px; color: var(--text-1); }
.legend-pct { color: var(--text-3); font-size: 11px; }

/* =====================================================
   BRANCH INFO BOX
   ===================================================== */
.branch-info-box {
  background: #f0f5fb; border: 1px solid #c8d8ed;
  border-radius: 8px; padding: 12px 14px; margin-top: auto;
}
.branch-info-title {
  font-size: 12.5px; font-weight: 600; color: var(--primary);
  display: flex; align-items: center; gap: 6px; margin-bottom: 10px;
}
.branch-info-title i { width: 14px; height: 14px; }
.info-table { width: 100%; border-collapse: collapse; }
.info-table td { padding: 5px 4px; font-size: 12px; vertical-align: top; }
.info-table td:first-child { color: var(--text-3); width: 110px; }
.info-table td:last-child { color: var(--text-1); font-weight: 500; }
.edit-obs-btn { background: none; border: none; cursor: pointer; color: var(--accent-blue); padding: 0 0 0 6px; }
.edit-obs-btn i { width: 12px; height: 12px; }

/* =====================================================
   MAP
   ===================================================== */
.map-card { display: flex; flex-direction: column; }
.map-container {
  position: relative; flex: 1; min-height: 320px;
  background: #eef2f6; border-radius: 8px;
  overflow: hidden; border: 1px solid var(--border);
}
.map-container svg { width: 100%; height: 100%; display: block; }
.pins-layer { position: absolute; inset: 0; pointer-events: none; }
.map-pin {
  position: absolute; transform: translate(-50%, -100%);
  cursor: pointer; pointer-events: all;
  transition: transform var(--transition);
}
.map-pin:hover { transform: translate(-50%, -100%) scale(1.2); z-index: 10; }
.pin-circle {
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3); border: 2px solid white;
}
.pin-circle span { transform: rotate(45deg); font-size: 9px; font-weight: 700; color: white; font-family: var(--mono); }
.pin-normal .pin-circle { background: #1a3a5c; }
.pin-warn   .pin-circle { background: var(--accent-orange); }
.pin-error  .pin-circle { background: var(--accent-red); }
.pin-label {
  position: absolute; top: 32px; left: 50%; transform: translateX(-50%);
  background: rgba(26,58,92,0.85); color: white;
  font-size: 9px; padding: 2px 5px; border-radius: 3px; white-space: nowrap;
  opacity: 0; transition: opacity 0.2s;
}
.map-pin:hover .pin-label { opacity: 1; }
.map-popup {
  position: absolute; background: white; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2); width: 220px; z-index: 20; overflow: hidden;
}
.popup-header {
  background: var(--primary); color: white; padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12.5px; font-weight: 600;
}
.popup-header button { background: none; border: none; cursor: pointer; color: white; opacity: 0.7; }
.popup-header button i { width: 14px; height: 14px; }
.popup-body { padding: 10px 12px; }
.popup-body p { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.popup-body strong { color: var(--text-3); font-weight: 500; }
.popup-link {
  display: block; padding: 8px 12px;
  background: var(--primary-light); color: var(--primary);
  font-size: 12px; font-weight: 500; text-decoration: none;
  border-top: 1px solid var(--border);
}
.popup-link:hover { background: #d5e5f5; }
.map-zoom-controls {
  position: absolute; top: 50px; right: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.map-zoom-controls button {
  width: 28px; height: 28px; background: white; border: 1px solid var(--border);
  border-radius: 4px; font-size: 16px; font-weight: 600; cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.map-zoom-controls button:hover { background: var(--bg); }

/* =====================================================
   ALERTS
   ===================================================== */
.alerts-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 7px; }
.alert-item.warn  { background: #fff7ed; }
.alert-item.info  { background: #eff6ff; }
.alert-item.error { background: #fef2f2; }
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-item.warn  .alert-icon i { color: var(--accent-orange); width: 15px; height: 15px; }
.alert-item.info  .alert-icon i { color: var(--accent-blue);   width: 15px; height: 15px; }
.alert-item.error .alert-icon i { color: var(--accent-red);    width: 15px; height: 15px; }
.alert-time { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }
.alert-msg  { font-size: 12.5px; color: var(--text-1); }

/* =====================================================
   BUTTONS
   ===================================================== */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--primary); color: white;
  border: none; border-radius: 7px; font-family: var(--font);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary i { width: 14px; height: 14px; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  border-radius: 7px; font-size: 13px; cursor: pointer;
  font-family: var(--font); transition: background var(--transition);
}
.btn-outline i { width: 13px; height: 13px; }
.btn-outline:hover { background: var(--bg); }

.export-desc { font-size: 12.5px; color: var(--text-3); margin-bottom: 14px; line-height: 1.5; }
.export-buttons { display: flex; flex-direction: column; gap: 8px; }
.btn-export {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 8px;
  border: none; cursor: pointer; font-family: var(--font);
  font-size: 13.5px; font-weight: 500;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-export:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-export i { width: 16px; height: 16px; }
.btn-export.green { background: var(--accent-green); color: white; }
.btn-export.gray  { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

.select-sm {
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 12px;
  background: var(--surface); color: var(--text-2);
  font-family: var(--font); cursor: pointer;
}
.icon-btn-sm {
  width: 28px; height: 28px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 5px;
  cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.icon-btn-sm i { width: 13px; height: 13px; }
.link-sm { font-size: 12px; color: var(--accent-blue); text-decoration: none; font-weight: 500; }
.link-sm:hover { text-decoration: underline; }

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 12px;
  width: 100%; max-width: 420px; box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 600; color: var(--text-1); }
.modal-header button { background: none; border: none; cursor: pointer; color: var(--text-3); padding: 4px; }
.modal-header button i { width: 16px; height: 16px; }
.modal-body { padding: 20px; }
.modal-body label { font-size: 13px; color: var(--text-2); display: block; margin-bottom: 10px; }
.modal-body textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  font-family: var(--font); font-size: 13.5px; color: var(--text-1);
  resize: vertical; background: var(--surface-2);
}
.modal-body textarea:focus { outline: none; border-color: var(--accent-blue); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--border);
}
.btn-cancel {
  padding: 8px 18px; border: 1px solid var(--border);
  background: var(--surface); border-radius: 7px;
  font-size: 13.5px; cursor: pointer; font-family: var(--font); color: var(--text-2);
}
.btn-save {
  padding: 8px 18px; background: var(--primary);
  color: white; border: none; border-radius: 7px;
  font-size: 13.5px; cursor: pointer; font-family: var(--font); font-weight: 500;
}
.btn-save:hover { background: var(--primary-hover); }

/* =====================================================
   PAGE HEADER
   ===================================================== */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 4px;
}
.page-header h2 { font-size: 20px; font-weight: 700; color: var(--text-1); }
.page-header p   { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* =====================================================
   TABLE
   ===================================================== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 500px; }
.data-table thead th {
  padding: 10px 14px; text-align: left;
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 14px; border-bottom: 1px solid #f0f2f5; color: var(--text-1);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }

/* =====================================================
   STATUS BADGES
   ===================================================== */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.status-badge.active { background: #d5f0e5; color: #1a7a4a; }
.status-badge.warn   { background: #fde8d5; color: #c45a10; }
.status-badge.error  { background: #fee2e2; color: #c53030; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* =====================================================
   SKELETON
   ===================================================== */
.skeleton {
  background: linear-gradient(90deg, #f0f2f5 25%, #e4e8ef 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite; border-radius: 6px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* =====================================================
   RESPONSIVE — LARGE DESKTOP (1400px+)
   ===================================================== */
@media (min-width: 1400px) {
  :root { --content-pad: 32px; }
  .kpi-value { font-size: 28px; }
}

/* =====================================================
   RESPONSIVE — LAPTOP (1024px–1280px)
   ===================================================== */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .row-4col { grid-template-columns: repeat(2, 1fr); }
  .kpi-value { font-size: 24px; }
}

/* =====================================================
   RESPONSIVE — TABLET LANDSCAPE (768px–1024px)
   ===================================================== */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; --content-pad: 20px; }
  .row-2col { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .entity-meta { gap: 10px; }
  .user-name { max-width: 120px; }
  .user-entity { display: none; }
  .chevron { width: 12px; height: 12px; }
}

/* =====================================================
   RESPONSIVE — TABLET PORTRAIT (600px–768px)
   ===================================================== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; --content-pad: 16px; --topbar-h: 56px; }

  .sidebar { transform: translateX(-220px); width: 220px; box-shadow: 4px 0 20px rgba(0,0,0,0.2); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: flex; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 12px; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; }
  .kpi-icon i { width: 17px; height: 17px; }
  .kpi-value { font-size: 22px; }

  .row-2col { grid-template-columns: 1fr; }
  .row-4col { grid-template-columns: repeat(2, 1fr); }

  .entity-header { padding: 14px 16px; gap: 12px; }
  .entity-meta { margin-left: 0; width: 100%; justify-content: space-between; }

  .card { padding: 16px; }
  .content { gap: 14px; }

  .page-title h1 { font-size: 16px; }
  .topbar { padding: 0 16px; }

  .user-info { display: none; }
  .user-menu { padding: 4px 6px; gap: 6px; }
  .chevron { display: none; }

  .map-container { min-height: 260px; }
}

/* =====================================================
   RESPONSIVE — MOBILE (max 600px)
   ===================================================== */
@media (max-width: 600px) {
  :root { --content-pad: 12px; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 10px 12px; gap: 8px; flex-direction: column; align-items: flex-start; }
  .kpi-icon { width: 32px; height: 32px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11px; }

  .row-4col { grid-template-columns: 1fr; }
  .row-2col { grid-template-columns: 1fr; }

  .card { padding: 14px 12px; }
  .content { gap: 12px; padding: 12px; }

  .page-header { flex-direction: column; }
  .page-header h2 { font-size: 18px; }

  .card-header { flex-direction: column; align-items: flex-start; }

  .entity-header { flex-wrap: wrap; }
  .entity-logo { width: 44px; height: 44px; }
  .entity-info h2 { font-size: 15px; }
  .entity-meta { margin-left: 0; width: 100%; flex-direction: column; gap: 8px; }

  .modal { max-width: 100%; border-radius: 12px 12px 0 0; margin-top: auto; }
  .modal-overlay { align-items: flex-end; padding: 0; }

  .data-table thead th,
  .data-table tbody td { padding: 8px 10px; font-size: 12px; }

  .topbar { padding: 0 12px; }
  .page-title h1 { font-size: 15px; }
  .page-title span { display: none; }

  .map-container { min-height: 220px; }
  .donut-wrapper { width: 150px; height: 150px; }
  .donut-total { font-size: 24px; }
}

/* =====================================================
   RESPONSIVE — SMALL MOBILE (max 400px)
   ===================================================== */
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .kpi-card { padding: 8px 10px; }
  .kpi-value { font-size: 18px; }
  .content { padding: 10px; gap: 10px; }
}

