:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #d7e2ef;
  --text: #0d1b2f;
  --muted: #62738a;
  --primary: #1668f2;
  --primary-dark: #0d4fb8;
  --danger: #d92d20;
  --shadow: 0 14px 34px rgba(13, 27, 47, 0.08);
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, #edf3fa 100%);
  color: var(--text);
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand.compact { margin-bottom: 10px; }
.login-logo { width: min(100%, 310px); height: 150px; object-fit: contain; }
.login-logo-small { width: min(100%, 240px); height: 64px; object-fit: contain; }
.login-brand p, .muted { color: var(--muted); margin: 0; }
.login-alert {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: var(--radius);
  font-size: .9rem;
  line-height: 1.35;
}
.login-alert-error {
  background: #fff4f2;
  border: 1px solid #f5b4ac;
  color: #8a1f13;
}
.login-alert span { color: inherit; }

.login-fields { display: grid; gap: 12px; }
.login-fields label { font-weight: 700; font-size: .86rem; color: var(--text); }
.login-fields input { margin-top: 6px; }
.login-submit { width: 100%; margin-top: 18px; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  padding: 12px 0 0;
  width: 100%;
  font-weight: 700;
}

.app-layout { min-height: 100vh; display: flex; }
.app-sidebar {
  position: sticky;
  top: 0;
  width: 235px;
  height: 100vh;
  padding: 18px 14px;
  background: #07152f;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-link { display: block; padding: 6px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-link img { width: 100%; height: 96px; object-fit: contain; object-position: left center; }
.side-nav { display: grid; gap: 6px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.86);
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  font-weight: 700;
}
.side-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.side-link-badged { position: relative; padding-right: 48px; }
.side-link-badged span { min-width: 0; }
.side-badge {
  position: absolute;
  top: 4px;
  right: 5px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ff3b30;
  color: #fff;
  border: 2px solid #07152f;
  font-size: .72rem;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .22);
}
.side-button { text-align: left; }
.logout-link { margin-top: auto; color: #ffb4ad; }

.app-main { flex: 1; padding: 28px; overflow-x: hidden; display: flex; flex-direction: column; }
.app-main-footer {
  margin-top: auto;
  padding: 28px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
  text-align: center;
}
.app-main-footer img {
  width: 150px;
  max-width: 45vw;
  height: auto;
  display: block;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 1.55rem; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters .form-control { width: 150px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi-card { padding: 15px; display: grid; gap: 6px; min-height: 96px; }
.kpi-card span { color: var(--muted); font-size: .75rem; text-transform: uppercase; font-weight: 800; }
.kpi-card strong { font-size: 1.35rem; }
.grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.panel { padding: 16px; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 1rem; }

.admins-search-wrapper { position: relative; width: min(100%, 360px); }
.admins-search-results {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.admin-search-option, .admins-search-empty {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
  text-align: left;
  padding: 10px 12px;
}
.admin-search-option:hover { background: #f2f6fb; }

.admins-table-wrapper {
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
  overflow: auto;
}
.admins-table {
  margin-bottom: 0;
  table-layout: fixed;
  min-width: 880px;
}
.admins-table thead { background: #f5f8ff; }
.admins-table thead th {
  background: transparent !important;
  vertical-align: bottom;
  overflow: visible;
  position: relative;
}
.admins-email-th {
  width: 310px;
  white-space: nowrap;
}
.admins-actions-th { width: 104px; }
.admins-permission-th {
  width: 58px;
  height: 132px;
  padding: 0 !important;
  position: relative;
  overflow: visible;
}
.admins-permission-th span {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: 10px;
  transform: rotate(-50deg);
  transform-origin: left bottom;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-align: left;
}
.admins-table td {
  vertical-align: middle;
  overflow: hidden;
}
.admins-user-cell {
  overflow-wrap: anywhere;
  display: grid;
  gap: 2px;
}
.admins-user-cell span {
  color: var(--muted);
  font-weight: 700;
  font-size: .88rem;
}
.admin-permission {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.admin-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.user-search { max-width: 360px; }
.user-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr) 180px auto;
  gap: 10px;
  align-items: center;
}

.param-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.param-actions .form-control { width: 300px; }
.param-check { margin: 0; color: var(--muted); font-weight: 700; }
.param-page {
  height: 100vh;
  overflow: hidden;
}
.param-page .page-head,
.param-page .app-main-footer {
  flex: 0 0 auto;
}
.param-page .app-main-footer {
  margin-top: 18px;
}
.param-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.param-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.param-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.param-count {
  margin-left: 6px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
  white-space: nowrap;
}
.param-tab {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
  font-weight: 800;
}
.param-tab.active {
  background: #eaf2ff;
  border-color: var(--primary);
  color: var(--primary-dark);
}
.param-table-wrap { flex: 1 1 auto; min-height: 0; }
.param-table th { white-space: nowrap; }
.param-sort {
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 900;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.param-sort i { color: var(--muted); font-size: .78rem; }
.param-related-cell {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.param-related-cell:hover {
  color: var(--primary-dark);
  background: #f0f6ff;
}
.param-products-link {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 900;
  padding: 0;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.param-products-link:hover {
  color: var(--primary-dark);
}
.param-products-link:disabled {
  color: var(--muted);
  cursor: default;
  text-decoration: none;
}
.param-row-off { color: #7f8da1; }
.param-row-off td:not(.param-action-cell) {
  background: #f8fafc;
  opacity: .44;
}
.param-row-off .param-action-cell {
  background: #fff;
  opacity: 1;
}
.param-processing {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  gap: 10px;
  font-weight: 700;
}
.param-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 800;
}
.param-status.is-on { background: #e2f8ec; color: #16743a; }
.param-status.is-off { background: #ffe8e6; color: var(--danger); }
.param-status.is-erp { background: #fff7d6; color: #8a5c00; }

.alertas-table th:nth-child(1) { min-width: 120px; }
.alertas-table th:nth-child(3) { min-width: 220px; }
.alertas-table th:nth-child(4) { min-width: 260px; }
.alertas-table th:nth-child(5) { min-width: 130px; }
.alertas-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .76rem;
}
.alertas-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.alerta-pill,
.alerta-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .74rem;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}
.alerta-critico { background: #ffe8e6; color: #b42318; }
.alerta-moderada { background: #fff3d7; color: #8a5c00; }
.alerta-dica { background: #e9f3ff; color: #0d4fb8; }
.alerta-status-novo { background: #e9f3ff; color: #0d4fb8; }
.alerta-status-lido { background: #eef2f6; color: #4e5f72; }
.alerta-status-tratado { background: #fff3d7; color: #8a5c00; }
.alerta-status-resolvido { background: #e2f8ec; color: #16743a; }
.alerta-status-oculto { background: #f1f1f1; color: #777; }
.alerta-form {
  display: grid;
  gap: 10px;
  text-align: left;
}
.alerta-form label {
  display: grid;
  gap: 4px;
  color: var(--text);
  font-size: .78rem;
  font-weight: 800;
}
.alerta-form .swal2-input,
.alerta-form .swal2-select,
.alerta-form .swal2-textarea {
  width: 100%;
  margin: 0;
}
.clusters-table th:nth-child(1) { min-width: 220px; }
.clusters-table th:nth-child(2) { min-width: 120px; }
.clusters-table th:nth-child(4) { min-width: 260px; }
.clusters-table th:nth-child(6) { min-width: 130px; }
.cluster-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  font-size: .74rem;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}
.cluster-form {
  display: grid;
  gap: 10px;
  text-align: left;
}
.cluster-form label {
  display: grid;
  gap: 4px;
  color: var(--text);
  font-size: .78rem;
  font-weight: 800;
}
.cluster-form .swal2-input,
.cluster-form .swal2-select,
.cluster-form .swal2-textarea {
  width: 100%;
  margin: 0;
}
.cluster-form .swal2-textarea {
  min-height: 70px;
}
.cluster-selected-count {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}
.cluster-options {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.cluster-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  background: #fff;
}
.cluster-option span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}
.cluster-options-empty {
  padding: 14px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}
.clientes-table th:nth-child(2) { min-width: 240px; }
.clientes-table th:nth-child(4) { min-width: 180px; }
.clientes-table th:nth-child(5) { min-width: 150px; }
.cliente-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .74rem;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}
.cliente-type.is-retail { background: #eef2f6; color: #344054; }
.cliente-type.is-franchise { background: #e2f8ec; color: #16743a; }
.cliente-type.is-network { background: #e9f3ff; color: #0d4fb8; }

.modal-content { border-radius: var(--radius); border: 1px solid var(--border); }
.modal-header { background: #07152f; color: #fff; }
.modal-header .btn-close { filter: invert(1); }

.import-help { margin-bottom: 16px; }
.mode-card label { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.mode-card p { color: var(--muted); margin: 8px 0 0; }
.endpoint-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.endpoint-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
}
.endpoint-card span { display: grid; gap: 4px; }
.endpoint-card small { color: var(--muted); }
.schedule-form { display: grid; grid-template-columns: 1fr 180px 130px; gap: 10px; margin-bottom: 14px; }
.schedule-list { display: grid; gap: 8px; }
.schedule-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.schedule-item div { display: grid; gap: 3px; }
.schedule-item span { color: var(--muted); font-size: .86rem; }

.polibras-import-modal {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  color: var(--text);
  box-shadow: 0 24px 70px rgba(7, 21, 47, 0.32);
}
.polibras-import-modal::backdrop { background: rgba(7, 21, 47, 0.66); }
.polibras-import-shell { display: flex; flex-direction: column; max-height: calc(100vh - 40px); background: #fff; }
.polibras-import-head {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.polibras-import-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #e8f1ff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  font-weight: 900;
}
.polibras-modal-kicker { color: var(--primary); font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.polibras-import-heading h2 { margin: 2px 0 0; font-size: 1.15rem; }
.polibras-import-elapsed { font-weight: 900; color: var(--muted); }
.polibras-import-current { padding: 16px 20px; display: grid; gap: 5px; }
.polibras-import-current span { color: var(--muted); font-size: .76rem; text-transform: uppercase; font-weight: 900; }
.polibras-import-current strong { font-size: 1.05rem; }
.polibras-import-progress { padding: 0 20px 14px; }
.polibras-import-progress-copy { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: .88rem; }
.polibras-import-progress-track { height: 12px; border-radius: 999px; background: #edf3fb; overflow: hidden; }
.polibras-import-progress-track span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #20a4f3); transition: width .2s ease; }
.polibras-import-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 20px 14px; }
.polibras-import-totals span { border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 10px; color: var(--muted); }
.polibras-import-totals strong { color: var(--text); }
.polibras-import-steps { margin: 0; padding: 0 20px 14px; overflow: auto; display: grid; gap: 8px; }
.polibras-import-step {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 10px;
}
.polibras-import-step-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #edf3fb; color: var(--muted); font-weight: 900; }
.polibras-import-step.is-running .polibras-import-step-icon {
  background: #e8f1ff;
  color: var(--primary);
  box-shadow: 0 0 0 0 rgba(22, 104, 242, .32);
  animation: importStepPulse 1.15s ease-out infinite;
}
.polibras-import-step.is-success .polibras-import-step-icon { background: #e2f8ec; color: #16743a; }
.polibras-import-step.is-error .polibras-import-step-icon { background: #ffe8e6; color: var(--danger); }
.polibras-import-step-copy { display: grid; gap: 2px; }
.polibras-import-step-copy span, .polibras-import-step-time { color: var(--muted); font-size: .82rem; }
.polibras-import-step-meter {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: #edf3fb;
  overflow: hidden;
}
.polibras-import-step-meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #20a4f3);
  transition: width .25s ease;
}

@keyframes importStepPulse {
  0% { transform: scale(.94); box-shadow: 0 0 0 0 rgba(22, 104, 242, .36); }
  70% { transform: scale(1); box-shadow: 0 0 0 9px rgba(22, 104, 242, 0); }
  100% { transform: scale(.94); box-shadow: 0 0 0 0 rgba(22, 104, 242, 0); }
}
.polibras-import-footer { border-top: 1px solid var(--border); padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.polibras-import-footer p { margin: 0; color: var(--muted); }
.polibras-import-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

@media (max-width: 980px) {
  .app-layout { display: block; }
  .app-sidebar { position: relative; width: 100%; height: auto; }
  .side-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logout-link { margin-top: 0; }
  .kpi-grid, .grid-two { grid-template-columns: 1fr; }
  .endpoint-grid, .schedule-form, .user-form { grid-template-columns: 1fr; }
  .user-search { max-width: 100%; }
  .app-main { padding: 18px; }
  .param-toolbar { align-items: flex-start; flex-direction: column; }
  .param-actions, .param-actions .form-control { width: 100%; }
}

/* Business Intelligence */
.bi-page { background: #f4f7fb; min-width: 0; }
.page-kicker, .panel-kicker {
  display: block;
  color: var(--primary);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}
.bi-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.channel-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.channel-card {
  min-width: 142px;
  height: 52px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: .48;
  filter: grayscale(.65);
  font-size: .82rem;
  font-weight: 800;
  transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease, filter .15s ease;
}
.channel-card img {
  max-width: 56px;
  max-height: 28px;
  object-fit: contain;
}
.channel-card i { color: var(--primary); font-size: 1.35rem; }
.channel-card.active {
  border-color: var(--primary);
  background: #eef5ff;
  box-shadow: 0 0 0 3px rgba(22, 104, 242, .12);
  opacity: 1;
  filter: none;
}
.channel-card:not(.active) span { color: var(--muted); }
.bi-channel-refresh { height: 52px; }
.bi-filterbar label { flex: 0 0 142px; min-width: 0; }
.bi-filterbar .form-select,
.bi-filterbar .form-control { width: 142px; }
.city-filter {
  position: relative;
  width: 142px;
}
.city-filter-button {
  width: 142px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  text-align: left;
}
.city-filter-button span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.city-filter-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  width: 310px;
  max-width: calc(100vw - 32px);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.multi-filter .city-filter-menu { width: 420px; }
.city-filter-menu .form-control { width: 100%; margin-bottom: 8px; }
.city-filter-options {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 3px;
}
.city-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.city-filter-option:hover { background: #f2f6fb; }
.city-filter-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.city-filter-option small { color: var(--muted); font-weight: 700; }
.city-filter-divider {
  height: 1px;
  margin: 5px 0;
  background: var(--border);
}
.cluster-filter-type {
  margin: 8px 6px 2px;
  color: var(--muted);
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.city-filter-empty { color: var(--muted); padding: 8px 4px; }
.bi-filterbar label > span {
  display: block;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  margin: 0 0 4px 2px;
  text-transform: uppercase;
}
.bi-filterbar .btn { height: 38px; white-space: nowrap; }
.bi-filterbar .btn span { margin-left: 6px; }
.bi-analysisbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.bi-analysisbar-title {
  flex: 0 0 auto;
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px 0 2px;
  color: var(--primary);
  font-size: .76rem;
  font-weight: 900;
  text-transform: uppercase;
}
.bi-analysisbar label { flex: 0 0 172px; min-width: 0; }
.bi-analysisbar label > span {
  display: block;
  margin: 0 0 4px 2px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
}
.bi-analysisbar .form-select { width: 100%; }
.bi-analysisbar .bi-analysis-compare { flex-basis: 250px; }
.bi-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #f2ca72;
  border-radius: var(--radius);
  background: #fff8e6;
  color: #6f4b00;
}
.bi-alert a { color: inherit; font-weight: 800; margin-left: auto; }
.bi-alert.is-error { border-color: #f3a59e; background: #fff0ee; color: #a3251b; }

.bi-loading-modal {
  width: min(92vw, 440px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
}
.bi-loading-modal::backdrop { background: rgba(7, 21, 47, 0.62); }
.bi-loading-shell {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(7, 21, 47, .24);
  padding: 34px 34px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}
.bi-loading-logo {
  width: min(100%, 465px);
  height: auto;
  object-fit: contain;
}
.bi-loading-text {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 900;
  min-height: 1.8rem;
  transition: opacity .26s ease, transform .26s ease;
}
.bi-loading-text.is-changing {
  opacity: 0;
  transform: translateY(6px);
}
#bi_loading_elapsed {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.bi-loading-motion {
  display: grid;
  grid-template-columns: repeat(4, 10px);
  gap: 8px;
  align-items: end;
  height: 34px;
}
.bi-loading-motion span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  animation: biLoadingPulse .9s ease-in-out infinite;
}
.bi-loading-motion span:nth-child(2) { animation-delay: .1s; }
.bi-loading-motion span:nth-child(3) { animation-delay: .2s; }
.bi-loading-motion span:nth-child(4) { animation-delay: .3s; }

@keyframes biLoadingPulse {
  0%, 100% { transform: translateY(0); opacity: .4; }
  50% { transform: translateY(-12px); opacity: 1; }
}
.kpi-grid-six { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.climate-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-card { box-shadow: 0 5px 16px rgba(13, 27, 47, .045); }
.bi-page .kpi-grid { gap: 10px; margin-bottom: 13px; }
.bi-page .kpi-card { min-height: 78px; padding: 12px; gap: 4px; }
.bi-page .kpi-card span { font-size: .64rem; line-height: 1.15; }
.kpi-card strong { font-size: clamp(.92rem, 1.08vw, 1.12rem); line-height: 1.15; overflow-wrap: anywhere; }
.kpi-card small { color: var(--muted); font-size: .64rem; line-height: 1.2; }
.delta-up { color: #087c5b !important; font-weight: 700; }
.delta-down { color: #c1364c !important; font-weight: 700; }
.bi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.bi-grid-wide { grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr); }
.bi-grid + .panel, .panel + .source-strip { margin-bottom: 12px; }
.bi-page .panel { padding: 13px; box-shadow: 0 5px 16px rgba(13, 27, 47, .045); }
.panel-head > div:first-child { min-width: 0; }
.bi-page .panel-head { margin-bottom: 10px; }
.panel-head h2 { margin-top: 2px; font-size: .86rem; }
.panel-kicker { font-size: .64rem; }
.panel-metric { color: var(--muted); font-size: .7rem; font-weight: 700; }
.panel-chart { min-width: 0; }
.chart-frame { position: relative; width: 100%; height: 215px; }
.chart-frame-lg { height: 255px; }
.chart-frame-sm { height: 132px; margin-top: 10px; }
.bi-chart-expand {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(22, 104, 242, .22);
  border-radius: 6px;
  background: rgba(255, 255, 255, .92);
  color: var(--primary);
  box-shadow: 0 4px 12px rgba(13, 27, 47, .08);
  opacity: 0;
  transition: opacity .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.chart-frame:hover .bi-chart-expand,
.bi-chart-expand:focus-visible {
  opacity: 1;
}
.bi-chart-expand:hover {
  border-color: rgba(22, 104, 242, .45);
  box-shadow: 0 6px 16px rgba(22, 104, 242, .16);
  transform: translateY(-1px);
}
@media (hover: none) {
  .bi-chart-expand { opacity: 1; }
}
.bi-chart-modal {
  width: auto;
  max-width: 80vw;
  max-height: 80vh;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  overflow: visible;
}
.bi-chart-modal::backdrop {
  background: rgba(13, 27, 47, .58);
}
.bi-chart-modal-box {
  position: relative;
  max-width: 80vw;
  max-height: 80vh;
  background: transparent;
}
.bi-chart-modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 6;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(22, 104, 242, .24);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  box-shadow: 0 8px 22px rgba(13, 27, 47, .2);
}
.bi-chart-modal-close:hover {
  border-color: rgba(22, 104, 242, .5);
  color: var(--text);
}
.bi-chart-modal-content {
  width: 100%;
  height: 100%;
  max-width: 80vw;
  max-height: 80vh;
  overflow: hidden;
}
.bi-panel-expanded {
  max-width: 80vw;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(13, 27, 47, .28);
}
.bi-panel-expanded .bi-chart-expand {
  display: none;
}
.bi-chart-context { display: block; min-height: 1.1em; margin-top: 3px; color: var(--muted); font-size: .72rem; }
.bi-comparison-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 2px 0 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.bi-comparison-strip > div { min-width: 0; padding: 0 12px; border-right: 1px solid var(--border); }
.bi-comparison-strip > div:first-child { padding-left: 0; }
.bi-comparison-strip > div:last-child { border-right: 0; }
.bi-comparison-strip span { display: block; color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.bi-comparison-strip strong { display: block; overflow: hidden; margin-top: 2px; color: var(--text); font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.segmented {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f4f7fb;
  padding: 2px;
}
.segmented button {
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}
.segmented button.active { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 4px rgba(13,27,47,.12); }
.view-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.view-toolbar > span { font-size: .8rem; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.legend-list { display: grid; gap: 6px; margin-top: 10px; }
.legend-list div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: .78rem; }
.legend-list i { width: 8px; height: 8px; border-radius: 50%; }
.legend-list strong { font-size: .76rem; }
.bi-rank-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.bi-rank-panel .panel-head {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.bi-rank-list {
  display: grid;
  gap: 6px;
}
.bi-rank-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  grid-template-areas:
    "pos nome valor"
    "pos meta meta";
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
  min-height: 38px;
  padding: 6px 0;
  border-bottom: 1px solid #edf2f8;
}
.bi-rank-row:last-child { border-bottom: 0; }
.bi-rank-pos {
  grid-area: pos;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #e8f0ff;
  color: var(--primary);
  font-size: .68rem;
  font-weight: 900;
}
.bi-rank-row strong {
  grid-area: nome;
  min-width: 0;
  color: var(--ink);
  font-size: .75rem;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bi-rank-row b {
  grid-area: valor;
  color: var(--ink);
  font-size: .76rem;
  line-height: 1.15;
  white-space: nowrap;
}
.bi-rank-row small {
  grid-area: meta;
  color: var(--muted);
  font-size: .64rem;
  line-height: 1.1;
}
.bi-rank-empty {
  display: grid;
  place-items: center;
  min-height: 112px;
  color: var(--muted);
  font-size: .74rem;
}
.bi-table-wrap { max-height: 420px; overflow: auto; }
.bi-table-wrap.param-table-wrap {
  height: auto;
  max-height: none;
  overflow-y: scroll;
  overflow-x: auto;
  scrollbar-gutter: stable;
}
.bi-table-wrap.param-table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
.bi-table-wrap.param-table-wrap::-webkit-scrollbar-track { background: #edf3fa; }
.bi-table-wrap.param-table-wrap::-webkit-scrollbar-thumb {
  background: #9fb0c6;
  border: 3px solid #edf3fa;
  border-radius: 999px;
}
.bi-table { margin: 0; font-size: .72rem; }
.bi-table thead { position: sticky; top: 0; z-index: 2; }
.bi-table th {
  border-bottom: 1px solid var(--border);
  background: #f5f8fc;
  color: var(--muted);
  font-size: .61rem;
  text-transform: uppercase;
  white-space: nowrap;
}
.bi-table td { vertical-align: middle; border-color: #e8eef5; padding: .38rem .5rem; }
.bi-table tbody tr:hover td { background: #f7faff; }
.empty-cell { color: var(--muted); text-align: center; padding: 28px !important; }
.abc { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: .7rem; font-weight: 900; }
.abc-a { background: #dff6ed; color: #087c5b; }
.abc-b { background: #fff0c9; color: #8c5b00; }
.abc-c { background: #ffe4e1; color: #b22a20; }
.heatmap-panel { align-self: start; }
.heatmap { display: grid; gap: 5px; overflow-x: auto; }
.heatmap-row { display: grid; grid-template-columns: 48px repeat(5, minmax(62px, 1fr)); gap: 5px; min-width: 410px; }
.heatmap-row > span { align-self: center; color: var(--muted); font-size: .72rem; font-weight: 800; }
.heatmap-row strong { color: var(--muted); font-size: .66rem; text-align: center; }
.heatmap-row i {
  display: grid;
  place-items: center;
  min-height: var(--heatmap-row-height, 29px);
  border-radius: 4px;
  background: rgba(22, 104, 242, var(--heat));
  color: #07152f;
  font-size: .68rem;
  font-style: normal;
  font-weight: 800;
}
.heatmap-row i b { font-size: .68rem; }
.heatmap-row i small { font-size: .58rem; opacity: .82; }
.heatmap-empty {
  display: grid;
  min-height: 92px;
  place-items: center;
  color: var(--muted);
  font-size: .78rem;
}
.source-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px 15px;
  border: 1px solid #e6b7d0;
  border-left: 4px solid #b83f7e;
  border-radius: var(--radius);
  background: #fff;
}
.source-strip > i { color: #b83f7e; font-size: 1.25rem; }
.source-strip > div { display: grid; gap: 2px; }
.source-strip span { color: var(--muted); font-size: .82rem; }
.source-strip-info { border-color: #a8d5df; border-left-color: #00889a; }
.source-strip-info > i { color: #00889a; }
.source-strip.is-ready { border-color: #8fd0bc; border-left-color: #087c5b; }
.source-strip.is-ready > i { color: #087c5b; }
.empty-analysis {
  min-height: 180px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}
.empty-analysis i { color: #e47720; font-size: 1.8rem; }
.empty-analysis strong { color: var(--text); }
.empty-analysis span { max-width: 620px; font-size: .84rem; }
.weather-alert-list { place-items: stretch; align-content: start; text-align: left; }
.weather-alert {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.weather-alert > i { color: #e47720; }
.weather-alert > div { display: grid; }
.weather-alert span { color: var(--muted); font-size: .78rem; }
.weather-alert > b { color: #087c5b; font-size: .76rem; }
.bi-page.is-loading .panel, .bi-page.is-loading .kpi-card { opacity: .72; }
.side-link.is-active { background: rgba(255,255,255,.13); color: #fff; }
.liter-page .source-strip {
  flex: 0 0 auto;
  margin-bottom: 14px;
}
.liter-filter .form-control { width: 300px; }
.liter-filter .form-check { margin: 0; }
.liter-panel { margin-top: 0; }
.liter-table-wrap { flex: 1 1 auto; min-height: 0; }
.liter-table th,
.liter-table td { vertical-align: middle; }
.factor-input { width: 130px; min-width: 110px; }

@media (max-width: 1280px) {
  .kpi-grid-six { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .climate-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bi-grid-wide { grid-template-columns: minmax(0, 1.35fr) minmax(300px, .8fr); }
  .bi-rank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .bi-filterbar { width: 100%; }
  .bi-filterbar label,
  .bi-analysisbar label,
  .bi-analysisbar .bi-analysis-compare { flex: 1 1 calc(50% - 4px); }
  .bi-filterbar .form-select,
  .bi-filterbar .form-control,
  .city-filter,
  .city-filter-button { width: 100%; }
  .bi-filterbar .btn { align-self: end; }
  .channel-card { min-width: calc(33.333% - 6px); }
  .bi-grid, .bi-grid-wide { grid-template-columns: 1fr; }
  .chart-frame, .chart-frame-lg { height: 250px; }
}

@media (max-width: 620px) {
  .kpi-grid-six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .climate-kpis { grid-template-columns: 1fr; }
  .bi-rank-grid { grid-template-columns: 1fr; }
  .bi-filterbar label,
  .bi-analysisbar label,
  .bi-analysisbar .bi-analysis-compare { flex-basis: 100%; }
  .channel-card { min-width: 100%; }
  .view-toolbar { align-items: flex-start; flex-direction: column; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .bi-comparison-strip { grid-template-columns: 1fr; }
  .bi-comparison-strip > div { padding: 7px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .bi-comparison-strip > div:last-child { border-bottom: 0; }
}
