* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eef2f6;
  color: #1e293b;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: #263248;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 999;
}
.brand {
  padding: 16px 18px;
  background: #1f293d;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #334155;
}
.brand-title {
  font-weight: 800;
  font-size: 14px;
  color: #ffffff;
  letter-spacing: 0.5px;
}
.brand-badge {
  font-size: 9px;
  background: #0284c7;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}
.nav-section {
  padding: 12px 16px 4px 16px;
  font-size: 10px;
  font-weight: 700;
  color: #7f92b0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.nav-item {
  padding: 8px 16px;
  font-size: 12px;
  color: #94a3b8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: #2f3c56;
  color: #f8fafc;
}
.nav-item.active {
  background: #1d2638;
  color: #38bdf8;
  font-weight: 600;
  border-left-color: #38bdf8;
}
.badge-pill {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}
.terrain-eye-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  line-height: 1;
}
.terrain-eye-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.15);
}
.terrain-eye-btn.hidden {
  opacity: 0.35;
  filter: grayscale(1);
}

/* Topbar */
.topbar {
  background: #ffffff;
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
}
.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: #1e293b;
  cursor: pointer;
  padding: 4px 8px;
}

/* Main Content Wrapper */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* 2 COLUMNS SPLIT LAYOUT */
.split-dashboard {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 14px;
  padding: 14px 16px;
  overflow: hidden;
  height: calc(100vh - 52px);
  transition: grid-template-columns 0.25s ease;
}

/* QUANDO O MAPA ESTICA (Afasta as coisas do lado direito) */
.split-dashboard.map-expanded {
  grid-template-columns: 1fr 0px !important;
  gap: 0px !important;
}
.split-dashboard.map-expanded .work-column {
  display: none !important;
}

/* LEFT COLUMN: TALL PROMINENT MAP */
.map-column {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
#map {
  height: 100%;
  width: 100%;
}
.map-column.fullscreen-map {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: 100vh !important;
  width: 100vw !important;
  z-index: 3000;
  border-radius: 0;
}
.map-overlay-card {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 270px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  padding: 12px 14px;
  z-index: 999;
  border: 1px solid #ffffff;
}

/* RIGHT COLUMN: WORK PANE (SCROLLABLE) */
.work-column {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

/* KPIs (2x2 Grid) */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.kpi-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
}
.kpi-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.kpi-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}
.kpi-value {
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
  margin: 4px 0 2px 0;
}
.kpi-desc {
  font-size: 11px;
  color: #64748b;
}

/* Work Cards */
.work-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.card-header h3 {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

/* Expense Row (Clickable) */
.expense-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.expense-row:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}
.source-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.source-tag-contrato { background: #e0f2fe; color: #0369a1; }
.source-tag-art { background: #dcfce7; color: #15803d; }
.source-tag-whatsapp { background: #fef3c7; color: #b45309; }
.source-tag-associacao { background: #f3e8ff; color: #7e22ce; }
.source-tag-fatura { background: #fce7f3; color: #be185d; }

/* Document Row */
.doc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12px;
}
.doc-badge-ok {
  background: #dcfce7;
  color: #15803d;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}
.doc-badge-wait {
  background: #fef3c7;
  color: #b45309;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: #ffffff;
  border-radius: 10px;
  width: 600px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  padding: 20px;
}

/* Form Styles */
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.form-control {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
}
.form-control:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

/* Floating Chat Copilot */
.chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0284c7;
  color: #fff;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.4);
  cursor: pointer;
  z-index: 1050;
  transition: transform 0.2s;
}
.chat-fab:hover {
  transform: scale(1.05);
}
.chat-drawer {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

/* Quick prompt chips */
.prompt-chip {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 14px;
  cursor: pointer;
  display: inline-block;
  margin: 2px;
  transition: all 0.15s ease;
}
.prompt-chip:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* Custom Leaflet Marker */
.vertex-label {
  background: #0284c7;
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  font-weight: bold;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* RESPONSIVE FOR MOBILE (Stacked) */
@media (max-width: 900px) {
  body {
    overflow-y: auto;
  }
  .menu-toggle-btn {
    display: inline-block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.35);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-overlay.active {
    display: block;
  }

  .split-dashboard {
    grid-template-columns: 1fr;
    height: auto;
    overflow-y: visible;
    padding: 10px;
  }
  .map-column {
    height: 440px;
    min-height: 440px;
  }
  .work-column {
    height: auto;
    overflow-y: visible;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .map-column {
    height: 380px;
    min-height: 380px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* Dropzone & Spinner do Custódio */
.dropzone-area {
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  padding: 30px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
}
.dropzone-area:hover, .dropzone-area.drag-over {
  border-color: #4f46e5;
  background: #eef2ff;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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