:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --line: #dce4ee;
  --text: #24324a;
  --muted: #6f7d92;
  --navy: #0d1a36;
  --blue: #3867f0;
  --blue-soft: #edf3ff;
  --purple: #8d43ef;
  --purple-soft: #f3eaff;
  --red: #ef4444;
  --red-soft: #fff2f2;
  --green: #16a34a;
  --green-soft: #effcf3;
  --orange: #f97316;
  --orange-soft: #fff3e8;
  --shadow: 0 8px 22px rgba(15, 30, 60, 0.06);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Open Sans', Arial, sans-serif;
}
button, input, select { font: inherit; }
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 0;
}
.brand {
  background: var(--navy);
  color: #fff;
  padding: 24px 24px 22px;
}
.brand-title {
  font-family: 'Work Sans', sans-serif;
  font-size: 28px;
  line-height: 1.05;
  font-weight: 800;
}
.brand-subtitle {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255,255,255,.72);
}
.filters-card {
  margin: 18px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.filters-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 800;
  color: #4f5f76;
  text-transform: uppercase;
}
.clear-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.filters-grid { display: grid; gap: 16px; }
.filters-grid-dates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #68788f;
}
.field input,
.field select {
  width: 100%;
  height: 50px;
  border: 1px solid #cfd9e6;
  border-radius: 12px;
  padding: 0 14px;
  background: #f8fafc;
  color: var(--text);
}
.field input::placeholder { color: #98a6b9; }
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 103, 240, 0.12);
}
.primary-btn {
  margin-top: 8px;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}
.api-status {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f9fbff;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.main-content { min-width: 0; }
.topbar {
  min-height: 82px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  gap: 20px;
}
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0 18px;
  font-weight: 700;
  color: #5b6777;
  cursor: pointer;
}
.tab.active {
  background: #eef4ff;
  color: var(--blue);
  border-color: #bfd0fb;
}
.topbar-logo {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 300px;
}
.topbar-logo img {
  max-width: 240px;
  width: 100%;
  height: auto;
  object-fit: contain;
}
.tab-panel { display: none; padding: 20px; }
.tab-panel.active { display: block; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.no-padding { padding: 0; position: relative; overflow: hidden; }
.map-panel { height: calc(100vh - 122px); min-height: 620px; }
#map { width: 100%; height: 100%; }
.legend-box {
  position: absolute;
  right: 18px;
  bottom: 18px;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  min-width: 200px;
  font-size: 12px;
}
.legend-box h4 { margin: 0 0 10px; font-size: 12px; color: #445065; }
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
}
.dot-red { background: #d62828; }
.dot-orange { background: #ff8c42; }
.dot-yellow { background: #f4d35e; }
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.kpi-card {
  border-radius: 14px;
  background: #fff;
  padding: 18px 20px;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
}
.kpi-card .kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 800;
  color: #6e7c91;
}
.kpi-card .kpi-icon {
  float: right;
  font-size: 22px;
  line-height: 1;
  opacity: .9;
}
.kpi-card .kpi-value {
  display: block;
  margin-top: 10px;
  font-family: 'Work Sans', sans-serif;
  font-size: 28px;
  font-weight: 800;
}
.kpi-card .kpi-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.kpi-card.blue { border-color: #5a8afe; }
.kpi-card.purple { border-color: #b26af4; }
.kpi-card.indigo { border-color: #7788ff; }
.kpi-card.orange { border-color: #ff9642; }
.kpi-card.blue .kpi-value, .kpi-card.blue .kpi-icon { color: #2554d7; }
.kpi-card.purple .kpi-value, .kpi-card.purple .kpi-icon { color: #8a37eb; }
.kpi-card.indigo .kpi-value, .kpi-card.indigo .kpi-icon { color: #4b54e1; }
.kpi-card.orange .kpi-value, .kpi-card.orange .kpi-icon { color: #ea6b09; }
.deadline-section { margin-bottom: 16px; }
.section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  color: #3e4a5c;
}
.deadline-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.deadline-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 18px;
  text-align: left;
  cursor: pointer;
  background: #fff;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.deadline-card:hover,
.deadline-card.active { transform: translateY(-1px); box-shadow: var(--shadow); }
.deadline-card.antecipado { background: #eef4ff; border-color: #b8cdfd; }
.deadline-card.no-prazo { background: var(--green-soft); border-color: #b9efcc; }
.deadline-card.atrasado { background: #fff0f0; border-color: #ffc5c5; }
.deadline-card.devolvido { background: #fff6ee; border-color: #ffd1aa; }
.deadline-label { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.deadline-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  font-family: 'Work Sans', sans-serif;
}
.deadline-card small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}
.detail-panel { margin-bottom: 16px; }
.hidden { display: none; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.panel-header h3 { margin: 0; font-size: 15px; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.ghost-inline {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.chart-panel { margin-bottom: 16px; }
.chart-area { height: 300px; position: relative; }
.chart-area-large { height: 320px; }
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.table-scroller {
  overflow: auto;
  max-height: 380px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.detail-table-wrap { max-height: 320px; }
.all-table-wrap { max-height: 440px; }
.ranking-wrap { max-height: 320px; }
.table-scroller table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.table-scroller th,
.table-scroller td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table-scroller th {
  position: sticky;
  top: 0;
  background: #eef2f7;
  color: #607086;
  font-weight: 800;
}
.table-scroller tbody tr:hover { background: #fafcff; }
.status-chip {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.status-chip.antecipado { background: #dce9ff; color: #2f66de; }
.status-chip.no_prazo { background: #dcfce7; color: #14803b; }
.status-chip.atrasado { background: #fee2e2; color: #b91c1c; }
.status-chip.devolvido { background: #ffedd5; color: #c2410c; }
.otif-good { color: #16a34a; font-weight: 800; }
.otif-mid { color: #ca8a04; font-weight: 800; }
.otif-bad { color: #ef4444; font-weight: 800; }
.muted-text { color: var(--muted); font-size: 12px; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); }
@media (max-width: 1500px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .deadline-grid, .bottom-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-logo { min-width: 0; width: 100%; justify-content: flex-start; }
}
@media (max-width: 900px) {
  .kpi-strip, .filters-grid-dates { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpi-strip, .deadline-grid { grid-template-columns: 1fr; }
  .filters-card { margin: 12px; padding: 14px; }
  .tab-panel { padding: 12px; }
}
