/* ===================================================
   DASHBOARD – GESTÃO DE MANUTENÇÃO ASFÁLTICA
   Clean & Modern Design
   =================================================== */

:root {
  --sw: 280px;
  --th: 64px;

  --pg: #f0f2f6;
  --sb: #0f1628;
  --card: #fff;
  --top: #fff;

  --blue: #2563eb;
  --blue-l: #dbeafe;
  --green: #16a34a;
  --green-l: #dcfce7;
  --orange: #ea580c;
  --orange-l: #ffedd5;
  --purple: #7c3aed;
  --purple-l: #ede9fe;
  --teal: #0891b2;
  --teal-l: #cffafe;

  --txt: #111827;
  --txt2: #6b7280;
  --sbt: #cbd5e1;
  --sbm: #64748b;
  --bdr: #e5e7eb;
  --r: 14px;
  --rs: 8px;
  --sh: 0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.04);
  --shh: 0 4px 14px rgba(0,0,0,.11);
  --tr: .2s ease;
}

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

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--pg);
  color: var(--txt);
  font-size: 14px;
}

/* ══ SIDEBAR ══════════════════════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sw);
  height: 100vh;
  background: var(--sb);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--tr), transform var(--tr);
  overflow: hidden;
}

#sidebar.collapsed {
  width: 68px;
}

.sb-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.sb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sb-logo-icon {
  min-width: 38px;
  height: 38px;
  background: var(--blue);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  flex-shrink: 0;
}

.sb-logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sb-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  line-height: 1.2;
}

.sb-subtitle {
  font-size: 11px;
  color: var(--sbt);
  white-space: nowrap;
  line-height: 1.4;
}

#sidebar.collapsed .sb-logo-text,
#sidebar.collapsed .sb-label,
#sidebar.collapsed .sb-select,
#sidebar.collapsed .sb-btn-clear,
#sidebar.collapsed .sb-section-label,
#sidebar.collapsed .sb-menu-item span,
#sidebar.collapsed .sb-footer-info span {
  display: none;
}

/* NAV */
.sb-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sb-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--sbm);
  padding: 0 4px;
  margin-bottom: 10px;
}

.sb-filter-group {
  margin-bottom: 14px;
}

.sb-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--sbt);
  margin-bottom: 6px;
  padding: 0 4px;
}

.sb-label i {
  font-size: 12px;
  color: var(--sbm);
}

.sb-select {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--rs);
  color: #e2e8f0;
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  padding: 8px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--tr), background var(--tr);
}

.sb-select:focus {
  border-color: var(--blue);
  background: rgba(37,99,235,.15);
}

.sb-select option {
  background: #1e293b;
  color: #e2e8f0;
}

.sb-btn-clear {
  width: 100%;
  margin-top: 4px;
  padding: 9px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--rs);
  background: transparent;
  color: var(--sbt);
  font-size: 12px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background var(--tr), color var(--tr);
}

.sb-btn-clear:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

/* MENU */
.sb-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rs);
  color: var(--sbt);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--tr), color var(--tr);
  white-space: nowrap;
}

.sb-menu-item i {
  min-width: 18px;
  text-align: center;
  font-size: 14px;
}

.sb-menu-item:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.sb-menu-item.active {
  background: rgba(37,99,235,.25);
  color: #93c5fd;
}

/* FOOTER */
.sb-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}

.sb-footer-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sbm);
  font-size: 11px;
}

/* ══ MAIN CONTENT ═════════════════════════════════════════════ */
#main-content {
  margin-left: var(--sw);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--tr);
}

#main-content.sidebar-collapsed {
  margin-left: 68px;
}

/* ══ TOPBAR ═══════════════════════════════════════════════════ */
#topbar {
  position: sticky;
  top: 0;
  height: var(--th);
  background: var(--top);
  border-bottom: 1px solid var(--bdr);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  box-shadow: var(--sh);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--txt);
  line-height: 1;
}

.empresa-badge {
  display: inline-block;
  background: var(--blue-l);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: 10px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--rs);
  background: var(--pg);
  color: var(--txt2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background var(--tr), color var(--tr);
}

.icon-btn:hover {
  background: var(--bdr);
  color: var(--txt);
}

.btn-overview {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--rs);
  border: none;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: opacity var(--tr);
}

.btn-overview:hover { opacity: .88; }

.topbar-date {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--txt2);
  font-size: 13px;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--blue-l);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* ══ LOADER ═══════════════════════════════════════════════════ */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 14px;
  color: var(--txt2);
}

.loader-spinner { font-size: 32px; color: var(--blue); }

/* ══ CONTENT ══════════════════════════════════════════════════ */
#content-area {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ══ KPI GRID ═════════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.kpi-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--sh);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow var(--tr), transform var(--tr);
}

.kpi-card:hover {
  box-shadow: var(--shh);
  transform: translateY(-2px);
}

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

.kpi-card.blue .kpi-icon  { background: var(--blue-l);   color: var(--blue);   }
.kpi-card.green .kpi-icon { background: var(--green-l);  color: var(--green);  }
.kpi-card.orange .kpi-icon{ background: var(--orange-l); color: var(--orange); }
.kpi-card.purple .kpi-icon{ background: var(--purple-l); color: var(--purple); }

.kpi-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--txt2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.1;
}

.kpi-sub {
  font-size: 11px;
  color: var(--txt2);
}

/* ══ CHARTS ═══════════════════════════════════════════════════ */
.charts-row {
  display: flex;
  gap: 18px;
  align-items: stretch;
}

.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--sh);
  overflow: hidden;
  transition: box-shadow var(--tr);
}

.card:hover { box-shadow: var(--shh); }

.chart-card {
  display: flex;
  flex-direction: column;
}

.chart-lg  { flex: 2; }
.chart-sm  { flex: 1; }
.chart-md  { flex: 1.5; }
.chart-full{ flex: 1; width: 100%; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--bdr);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--txt);
}

.card-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--blue-l);
  color: var(--blue);
  padding: 3px 10px;
  border-radius: 20px;
}

.chart-wrap {
  padding: 16px;
  flex: 1;
  position: relative;
}

/* ══ TABLE ════════════════════════════════════════════════════ */
.table-card {
  width: 100%;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

#contratos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#contratos-table thead th {
  background: var(--pg);
  color: var(--txt2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--bdr);
}

#contratos-table tbody tr {
  border-bottom: 1px solid var(--bdr);
  transition: background var(--tr);
}

#contratos-table tbody tr:hover {
  background: #f8faff;
}

#contratos-table tbody td {
  padding: 11px 14px;
  color: var(--txt);
  white-space: nowrap;
}

.td-regiao {
  font-weight: 600;
  text-transform: capitalize;
}

.td-valor { font-weight: 600; color: var(--green); }
.td-saldo-neg { color: var(--red, #dc2626); font-weight: 600; }

.badge-tipo {
  background: var(--teal-l);
  color: var(--teal);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ══ GAUGE ════════════════════════════════════════════════════ */
.gauge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.gauge-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--txt2);
  text-align: center;
  max-width: 80px;
}

.gauge-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
}

/* ══ MONITORAMENTO DE PRAZO ═══════════════════════════════════ */
.monitor-card {
  padding: 0;
  overflow: hidden;
}

.monitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--bdr);
  flex-wrap: wrap;
  gap: 12px;
}

.monitor-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.monitor-icon {
  width: 44px;
  height: 44px;
  background: var(--orange);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

.monitor-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.2;
}

.monitor-subtitle {
  font-size: 12px;
  color: var(--txt2);
  margin-top: 3px;
}

.monitor-badges {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.monitor-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
}

.monitor-badge.alerta  { background: #fee2e2; color: #dc2626; }
.monitor-badge.atencao { background: #dbeafe; color: #2563eb; }
.monitor-badge.prazo   { background: #dcfce7; color: #16a34a; }

/* Lista de contratos */
.monitor-list {
  display: flex;
  flex-direction: column;
}

.monitor-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--bdr);
  transition: background var(--tr);
}

.monitor-item:last-child { border-bottom: none; }
.monitor-item:hover { background: #fafbff; }

/* Faixa lateral colorida */
.monitor-item-bar {
  width: 4px;
  height: 38px;
  border-radius: 4px;
  flex-shrink: 0;
}
.monitor-item-bar.alerta  { background: #dc2626; }
.monitor-item-bar.atencao { background: #2563eb; }
.monitor-item-bar.prazo   { background: #16a34a; }

/* Empresa + região */
.monitor-item-info {
  min-width: 160px;
  flex-shrink: 0;
}

.monitor-item-empresa {
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
  white-space: nowrap;
}

.monitor-item-regiao {
  font-size: 11px;
  color: var(--txt2);
  margin-top: 2px;
}

/* Barra de progresso */
.monitor-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.monitor-progress-label {
  font-size: 11px;
  color: var(--txt2);
}

.monitor-progress-track {
  height: 10px;
  background: #e5e7eb;
  border-radius: 99px;
  overflow: hidden;
}

.monitor-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .6s ease;
}

.monitor-progress-fill.alerta  { background: #dc2626; }
.monitor-progress-fill.atencao { background: #3b82f6; }
.monitor-progress-fill.prazo   { background: #22c55e; }

/* Restante */
.monitor-item-restante {
  min-width: 120px;
  font-size: 12px;
  color: var(--txt2);
  text-align: right;
  flex-shrink: 0;
}

.monitor-item-restante.alerta { color: #dc2626; font-weight: 600; }

/* Badge status */
.monitor-status-badge {
  min-width: 90px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.monitor-status-badge.alerta  { background: #fee2e2; color: #dc2626; }
.monitor-status-badge.atencao { background: #dbeafe; color: #2563eb; }
.monitor-status-badge.prazo   { background: #dcfce7; color: #16a34a; }

/* Percentual */
.monitor-item-pct {
  min-width: 44px;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
  color: var(--txt);
  flex-shrink: 0;
}

/* ══ RESPONSIVE ═══════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { flex-wrap: wrap; }
  .chart-lg, .chart-sm, .chart-md { flex: 1 1 calc(50% - 9px); min-width: 280px; }
  .chart-full { flex: 1 1 100%; }
}

@media (max-width: 768px) {
  :root { --sw: 100%; }
  #sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }
  #main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .charts-row { flex-direction: column; }
  .chart-lg, .chart-sm, .chart-md, .chart-full { flex: none; width: 100%; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  #content-area { padding: 14px; }
}
