:root {
  color: #17202a;
  background: #f5f7fa;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f5f7fa;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.dashboard-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: min(1560px, calc(100% - 32px));
  margin: 16px auto 0;
}

.dashboard-tabs button {
  min-height: 40px;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  padding: 0 16px;
  background: #ffffff;
  color: #344054;
  font-weight: 800;
}

.dashboard-tabs .dashboard-home-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  padding: 0 16px;
  background: #ffffff;
  color: #344054;
  font-weight: 800;
  text-decoration: none;
}

.dashboard-tabs button.is-active {
  border-color: #0f9f8f;
  background: #0f9f8f;
  color: #ffffff;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.brand-kicker {
  margin: 0 0 3px;
  color: #0f9f8f;
  font-size: 0.88rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: #101828;
  font-size: clamp(1.7rem, 2.4vw, 2.35rem);
  line-height: 1;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 14px;
  color: #667085;
  font-size: 0.95rem;
}

.header-meta strong {
  max-width: min(520px, 100%);
  overflow: hidden;
  color: #344054;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls-panel {
  display: grid;
  grid-template-columns: minmax(250px, auto) minmax(280px, 1fr) minmax(210px, auto) auto;
  align-items: end;
  gap: 14px;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
}

.affiliate-controls {
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, auto)) minmax(150px, auto) minmax(145px, auto) minmax(145px, auto);
}

.control-block,
.field-control {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.control-block > span,
.field-control > span {
  color: #667085;
  font-size: 0.88rem;
  font-weight: 700;
}

.status-control {
  min-width: 250px;
}

.diagnosis-control {
  grid-column: 1 / -1;
  min-width: 0;
}

.search-control,
.sort-control {
  min-width: 0;
}

.segmented-control,
.chip-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.segmented-control button,
.chip-list button {
  min-height: 38px;
  border: 1px solid #d0d5dd;
  border-radius: 999px;
  padding: 0 14px;
  background: #ffffff;
  color: #344054;
  font-weight: 700;
  white-space: nowrap;
}

.segmented-control button.is-active,
.chip-list button.is-active {
  border-color: #0f9f8f;
  background: #e8faf7;
  color: #08796e;
}

.chip-list .filter-diagnosis-escalar.is-active {
  border-color: #76d99b;
  background: #dff8e9;
  color: #087443;
}

.chip-list .filter-diagnosis-manter.is-active {
  border-color: #9eb7ff;
  background: #e9f0ff;
  color: #2752b8;
}

.chip-list .filter-diagnosis-observar.is-active {
  border-color: #e7ca57;
  background: #fff5cf;
  color: #8a5a00;
}

.chip-list .filter-diagnosis-revisar.is-active {
  border-color: #eeaa59;
  background: #fff0dc;
  color: #a14b00;
}

.chip-list .filter-diagnosis-pausar.is-active {
  border-color: #ef9891;
  background: #ffe5e5;
  color: #b42318;
}

.chip-list .filter-diagnosis-poucos-dados.is-active {
  border-color: #cbd5e1;
  background: #eef1f5;
  color: #475467;
}

.field-control input,
.field-control select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: #101828;
  outline: none;
}

.field-control input:focus,
.field-control select:focus {
  border-color: #0f9f8f;
  box-shadow: 0 0 0 3px rgba(15, 159, 143, 0.14);
}

.file-picker {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid #0f9f8f;
  border-radius: 8px;
  padding: 0 16px;
  background: #0f9f8f;
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
  align-self: end;
}

.file-picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.affiliate-file-control {
  display: grid;
  min-width: 0;
  gap: 6px;
  align-self: end;
}

.affiliate-file-control > span {
  color: #667085;
  font-size: 0.88rem;
  font-weight: 700;
}

.affiliate-file-control .file-picker {
  width: 100%;
}

.affiliate-file-control small {
  overflow: hidden;
  color: #667085;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-message {
  margin-top: 12px;
  color: #b42318;
  font-weight: 700;
}

.data-warning {
  border: 1px solid #f5dc87;
  border-radius: 8px;
  margin: 14px 0;
  padding: 12px 14px;
  background: #fff8df;
  color: #8a5a00;
  font-weight: 700;
}

.imported-files {
  overflow: hidden;
  margin: 12px 0 0;
  color: #667085;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.metric-card {
  min-height: 86px;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.05);
}

.metric-card span {
  color: #667085;
  font-size: 0.9rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  color: #101828;
  font-size: clamp(1.35rem, 1.8vw, 1.85rem);
  line-height: 1.08;
}

.ads-section {
  margin-top: 14px;
}

.period-summary {
  overflow: hidden;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  margin: 14px 0;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
}

.summary-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 0;
  padding: 16px;
  background: #ffffff;
  color: #101828;
  text-align: left;
}

.summary-toggle h2 {
  font-size: 1.18rem;
}

.summary-toggle p {
  margin-top: 4px;
  color: #475467;
  font-size: 0.96rem;
}

.summary-toggle small {
  display: block;
  margin-top: 4px;
  color: #667085;
  font-size: 0.9rem;
}

.summary-toggle > span {
  border: 1px solid #99e1d8;
  border-radius: 999px;
  padding: 7px 12px;
  background: #e8faf7;
  color: #08796e;
  font-weight: 800;
  white-space: nowrap;
}

.summary-content {
  display: grid;
  gap: 14px;
  border-top: 1px solid #eaecf0;
  padding: 14px;
  background: #fbfcfe;
}

.diagnosis-counts {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.summary-count {
  display: grid;
  min-height: 72px;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  text-align: left;
}

.summary-count span {
  color: #475467;
  font-size: 0.92rem;
  font-weight: 800;
}

.summary-count strong {
  margin-top: 4px;
  color: #101828;
  font-size: 1.55rem;
  line-height: 1;
}

.summary-count small {
  display: block;
  margin-top: 6px;
  color: #667085;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
}

.summary-count.is-active {
  border-color: #0f9f8f;
  background: #0f9f8f;
  box-shadow: 0 8px 18px rgba(15, 159, 143, 0.22);
}

.summary-count.is-active span,
.summary-count.is-active strong,
.summary-count.is-active small {
  color: #ffffff;
}

.summary-block {
  display: grid;
  gap: 10px;
}

.summary-block-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.summary-block-title h3 {
  color: #101828;
  font-size: 1.05rem;
}

.summary-block-title span {
  color: #667085;
  font-size: 0.9rem;
}

.recommendation-list,
.attention-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.recommendation-card,
.attention-card,
.ranking-card {
  min-width: 0;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.recommendation-card {
  display: grid;
  gap: 9px;
}

.recommendation-card h4,
.attention-card h4,
.ranking-item h5 {
  display: -webkit-box;
  overflow: hidden;
  color: #101828;
  font-size: 0.95rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.recommendation-card > div:first-child {
  display: grid;
  gap: 7px;
}

.recommendation-card p,
.attention-card p,
.summary-empty {
  color: #475467;
  font-size: 0.92rem;
  line-height: 1.35;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.mini-metrics span {
  border-radius: 8px;
  padding: 7px;
  background: #f8fafc;
  color: #667085;
  font-size: 0.82rem;
}

.mini-metrics strong {
  display: block;
  margin-top: 2px;
  color: #101828;
  font-size: 0.92rem;
}

.suggested-action {
  color: #08796e;
  font-size: 0.94rem;
}

.ranking-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ranking-card {
  display: grid;
  gap: 8px;
}

.ranking-card h4 {
  color: #101828;
  font-size: 0.98rem;
}

.ranking-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #eaecf0;
  padding-top: 8px;
}

.ranking-item > strong {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #e8faf7;
  color: #08796e;
}

.ranking-item span {
  color: #667085;
  font-size: 0.84rem;
  line-height: 1.35;
}

.attention-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.attention-card {
  display: grid;
  gap: 8px;
}

.attention-card > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.attention-card > div > strong {
  color: #101828;
  font-size: 0.94rem;
}

.affiliate-panel {
  display: grid;
  gap: 12px;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  margin: 14px 0;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
}

.bar-chart {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 260px) minmax(120px, 1fr) minmax(90px, auto);
  align-items: center;
  gap: 10px;
}

.bar-row span {
  overflow: hidden;
  color: #344054;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row div {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #eef2f6;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #0f9f8f;
}

.bar-row strong {
  color: #101828;
  text-align: right;
}

.monthly-grid,
.change-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.monthly-card,
.change-card,
.affiliate-card {
  min-width: 0;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.05);
}

.monthly-card span,
.change-card span,
.affiliate-card > span {
  color: #667085;
  font-weight: 700;
}

.monthly-card strong,
.change-card strong {
  display: block;
  margin-top: 8px;
  color: #101828;
  font-size: 1.35rem;
}

.monthly-card small,
.change-card small {
  display: block;
  margin-top: 8px;
  color: #667085;
  line-height: 1.35;
}

.change-card h3,
.affiliate-card h2 {
  display: -webkit-box;
  overflow: hidden;
  color: #101828;
  font-size: 1rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.change-card.positive {
  border-color: #9be4b7;
}

.change-card.positive strong {
  color: #087443;
}

.change-card.negative {
  border-color: #f5aaa4;
}

.change-card.negative strong {
  color: #b42318;
}

.affiliate-card {
  position: relative;
  display: grid;
  gap: 9px;
}

.affiliate-rank {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 10px;
  background: #e8faf7;
  color: #08796e;
  font-weight: 900;
}

.affiliate-card > strong {
  color: #101828;
  font-size: 1.65rem;
  line-height: 1;
}

.affiliate-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.affiliate-card-grid div {
  border: 1px solid #eaecf0;
  border-radius: 8px;
  padding: 9px;
  background: #fbfcfe;
}

.affiliate-card-grid span {
  display: block;
  color: #667085;
  font-size: 0.86rem;
  font-weight: 700;
}

.affiliate-card-grid strong {
  display: block;
  margin-top: 4px;
  color: #101828;
  overflow-wrap: anywhere;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.ad-card {
  overflow: hidden;
  border: 1px solid #dce2ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.07);
}

.card-main {
  display: grid;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.card-header {
  display: grid;
  gap: 10px;
  padding: 14px 14px 10px;
}

.card-header h2 {
  display: -webkit-box;
  min-height: 48px;
  overflow: hidden;
  color: #101828;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-header h2.expanded-title {
  display: block;
  min-height: 0;
  overflow: visible;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.diagnosis-badge,
.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.status-pill {
  border: 1px solid #d0d5dd;
  background: #f8fafc;
  color: #475467;
}

.status-pill.active {
  border-color: #99e1d8;
  background: #e8faf7;
  color: #08796e;
}

.roas-panel {
  display: grid;
  gap: 4px;
  margin: 0 14px 12px;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid transparent;
}

.roas-panel span {
  color: #475467;
  font-size: 0.9rem;
  font-weight: 800;
}

.roas-panel strong {
  color: #101828;
  font-size: 2rem;
  line-height: 1;
}

.roas-panel small {
  color: #475467;
  font-size: 0.9rem;
  line-height: 1.35;
}

.roas-excellent {
  border-color: #81d8a3;
  background: #eafaf0;
}

.roas-excellent strong {
  color: #087443;
}

.roas-good {
  border-color: #b7e6c6;
  background: #f0fbf4;
}

.roas-good strong {
  color: #14804a;
}

.roas-watch {
  border-color: #f5dc87;
  background: #fff8df;
}

.roas-watch strong {
  color: #9a6700;
}

.roas-bad {
  border-color: #f3a29a;
  background: #fff1f0;
}

.roas-bad strong {
  color: #b42318;
}

.roas-no-data {
  border-color: #d0d5dd;
  background: #f2f4f7;
}

.roas-no-data strong {
  color: #667085;
}

.card-metrics,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 14px 14px;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid #eaecf0;
  padding-top: 14px;
  background: #fbfcfe;
}

.card-metrics div,
.detail-grid div {
  min-width: 0;
  border: 1px solid #eaecf0;
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.card-metrics span,
.detail-grid span {
  display: block;
  overflow: hidden;
  color: #667085;
  font-size: 0.86rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-metrics strong,
.detail-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #101828;
  font-size: 1.04rem;
  font-weight: 850;
}

.details-toggle {
  justify-self: start;
  margin: 0 14px 14px;
  color: #08796e;
  font-size: 0.95rem;
  font-weight: 850;
}

.diagnosis-escalar {
  border-color: #9be4b7;
  background: #dff8e9;
  color: #087443;
}

.diagnosis-manter {
  border-color: #b8c9ff;
  background: #e9f0ff;
  color: #2752b8;
}

.diagnosis-observar {
  border-color: #efd56f;
  background: #fff5cf;
  color: #8a5a00;
}

.diagnosis-revisar {
  border-color: #f8bc73;
  background: #fff0dc;
  color: #a14b00;
}

.diagnosis-pausar {
  border-color: #f5aaa4;
  background: #ffe5e5;
  color: #b42318;
}

.diagnosis-poucos-dados {
  border-color: #cbd5e1;
  background: #eef1f5;
  color: #475467;
}

.diagnosis-border-escalar {
  border-color: #9be4b7;
}

.diagnosis-border-manter {
  border-color: #b8c9ff;
}

.diagnosis-border-observar {
  border-color: #efd56f;
}

.diagnosis-border-revisar {
  border-color: #f8bc73;
}

.diagnosis-border-pausar {
  border-color: #f5aaa4;
}

.diagnosis-border-poucos-dados {
  border-color: #cbd5e1;
}

.empty-state {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 44px 16px;
  background: #ffffff;
  color: #667085;
  text-align: center;
}

@media (max-width: 1200px) {
  .controls-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .affiliate-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-control,
  .diagnosis-control {
    min-width: 0;
  }

  .file-picker {
    width: 100%;
  }

  .metrics-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .diagnosis-counts,
  .recommendation-list,
  .attention-list,
  .monthly-grid,
  .change-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1560px);
    padding: 16px 0 24px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-meta {
    justify-content: flex-start;
  }

  .metrics-grid,
  .diagnosis-counts,
  .recommendation-list,
  .attention-list,
  .ranking-grid,
  .monthly-grid,
  .change-list,
  .cards-grid {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .bar-row strong {
    text-align: left;
  }

  .summary-toggle,
  .summary-block-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .ranking-item {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .ranking-item .diagnosis-badge {
    grid-column: 2;
    justify-self: start;
  }

  .controls-panel,
  .file-picker,
  .status-control,
  .diagnosis-control,
  .sort-control,
  .search-control {
    width: 100%;
  }

  .controls-panel {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 78px;
  }
}
