:root {
  --bg: #f3f4ef;
  --card: #ffffff;
  --ink: #1f2a1f;
  --muted: #5d665d;
  --line: #d9dfd5;
  --brand: #1f5f3b;
  --brand-soft: #d8eadf;
  --brand-soft-2: #edf5ef;
  --danger: #b5332f;
  --warn: #aa6e20;
}

* {
  box-sizing: border-box;
}

.is-hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 500px at 90% -10%, #d5e8d6 0%, transparent 60%),
    radial-gradient(800px 420px at -10% 0%, #e8dfc8 0%, transparent 65%),
    var(--bg);
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.title {
  flex: 1 1 360px;
}

.title h1 {
  margin: 0;
  font-size: 26px;
}

.title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-filter-bar {
  display: grid;
  gap: 8px;
  min-width: min(460px, 100%);
}

.product-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.product-filter-row > * {
  flex: 0 0 auto;
}

.product-select {
  position: relative;
  min-width: 300px;
  flex: 1 1 320px;
}

.product-select-trigger {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff;
  color: var(--ink);
}

.product-select-trigger::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
}

.product-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 40px rgba(31, 42, 31, 0.16);
}

.product-select-search-wrap input {
  width: 100%;
}

.product-select-options {
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 6px;
}

.product-select-option {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.product-select-option:hover,
.product-select-option.is-active {
  border-color: #bdd2c1;
  background: var(--brand-soft-2);
}

.product-select-meta {
  min-width: 0;
}

.product-select-title {
  display: block;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-select-id {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.product-chip-thumb {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #edf4ee;
}

.product-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
}

.product-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #bdd2c1;
  border-radius: 999px;
  background: var(--brand-soft-2);
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
}

.product-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  min-width: auto;
  font-size: 14px;
  line-height: 1;
}

.view-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8faf7;
}

.view-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.view-toggle-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.view-toggle-btn:hover {
  color: var(--ink);
}

.view-toggle-btn.is-active {
  background: var(--brand);
  color: #fff;
}

select,
input,
button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

button {
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.button-secondary {
  background: var(--brand-soft-2);
  color: var(--brand);
  border-color: #bcd6c3;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card-clickable {
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.card-clickable:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(31, 95, 59, 0.08);
  border-color: #b8cdbd;
}

.card-active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(31, 95, 59, 0.10);
}

.card .label {
  color: var(--muted);
  font-size: 12px;
}

.card .value {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
}

.card .sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.card-rate {
  display: flex;
  flex-direction: column;
  min-height: 128px;
}

.rate-card-foot {
  margin-top: auto;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
}

.rate-card-delta {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.rate-card-delta.is-good {
  color: var(--brand);
}

.rate-card-delta.is-bad {
  color: var(--danger);
}

.rate-card-spark {
  width: 96px;
  height: 34px;
}

.rate-card-spark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}

.layout-charts {
  grid-template-columns: minmax(320px, 1fr) minmax(420px, 2fr);
  align-items: stretch;
}

.panel-chart {
  min-height: 380px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 220px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.container.is-switching .card,
.container.is-switching .panel {
  opacity: 0.72;
  transform: translateY(2px);
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 16px;
}

.panel-note {
  margin: -4px 0 10px;
  font-size: 12px;
}

.checkpoint-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.checkpoint-wide {
  grid-column: span 2;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head h2,
.panel-head p {
  margin: 0;
}

.panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.window-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.window-control select {
  min-width: 110px;
  padding: 8px 10px;
}

.panel-warning {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border-color: #e8d9a5;
  background: #fff7dd;
  color: var(--warn);
  font-weight: 800;
  line-height: 1;
}

.table-wrap {
  overflow: auto;
  max-height: 320px;
}

.table-wrap-tall {
  max-height: 460px;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #f8faf7;
}

.table-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.sort-indicator {
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.anuncio-thumb {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  background: #edf4ee;
  border: 1px solid var(--line);
}

.anuncio-thumb-empty {
  background: linear-gradient(135deg, #eef3ee, #dfe8e0);
}

.performance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #f8faf7;
}

.performance-pill.is-good {
  color: var(--brand);
  border-color: #bcd6c3;
  background: var(--brand-soft-2);
}

.performance-pill.is-bad {
  color: var(--danger);
  border-color: #e6c0be;
  background: #fff1f0;
}

.performance-pill.is-neutral {
  color: var(--muted);
}

.table-row-flash {
  animation: rowFlash 1.8s ease;
}

@keyframes rowFlash {
  0% {
    background: rgba(31, 95, 59, 0.18);
  }
  100% {
    background: transparent;
  }
}

.funnel {
  display: grid;
  gap: 8px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  gap: 8px;
  align-items: center;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--brand);
}

.muted {
  color: var(--muted);
}

.table-link {
  color: var(--brand);
  font-weight: 600;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.status {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.dashboard-alerts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  display: grid;
  gap: 10px;
  max-width: 360px;
}

.dashboard-alert {
  background: rgba(255, 249, 239, 0.98);
  border: 1px solid #ecd2a2;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(37, 46, 37, 0.16);
  padding: 12px 14px;
  backdrop-filter: blur(10px);
  cursor: pointer;
}

.dashboard-alert-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.dashboard-alert h3 {
  margin: 0;
  font-size: 14px;
}

.dashboard-alert p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.dashboard-alert-close {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 999px;
  border: 1px solid #ecd2a2;
  background: #fff7dd;
  color: var(--warn);
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.dashboard-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
}

.dashboard-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 21, 15, 0.36);
  backdrop-filter: blur(4px);
}

.dashboard-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 20px auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 60px rgba(25, 35, 25, 0.22);
}

.dashboard-modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-modal-head h2 {
  margin: 0 0 4px;
}

.dashboard-modal-head p {
  margin: 0;
}

.dashboard-modal-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 999px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.dashboard-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 21, 15, 0.42);
  backdrop-filter: blur(6px);
}

.dashboard-auth-dialog {
  width: min(460px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 28px 70px rgba(25, 35, 25, 0.24);
}

.dashboard-auth-head h2 {
  margin: 0 0 4px;
}

.dashboard-auth-head p {
  margin: 0;
  color: var(--muted);
}

.dashboard-auth-form {
  display: grid;
  gap: 10px;
}

.dashboard-auth-remember,
.dashboard-auth-user-btn {
  font-size: 13px;
}

.dashboard-auth-remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.dashboard-auth-users {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dashboard-auth-user-btn {
  background: var(--brand-soft-2);
  color: var(--brand);
  border-color: #bcd6c3;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .filters {
    width: 100%;
  }

  .filters > * {
    flex: 1 1 140px;
  }

  .product-filter-row > * {
    flex: 1 1 140px;
  }

  .product-select {
    min-width: 0;
  }

  .view-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .view-toolbar {
    width: 100%;
  }

  .view-toggle-btn {
    flex: 1 1 0;
    text-align: center;
  }

  .checkpoint-wide {
    grid-column: span 1;
  }

  .rate-card-foot {
    flex-direction: column;
    align-items: start;
  }

  .rate-card-spark {
    width: 100%;
  }

  .dashboard-alerts {
    left: 12px;
    right: 12px;
    bottom: 12px;
    max-width: none;
  }

  .dashboard-modal-dialog {
    width: calc(100vw - 20px);
    margin: 10px auto;
    max-height: calc(100vh - 20px);
  }
}
