/* Paginas Inicio, Clientes e Insights */

@media (prefers-reduced-motion: no-preference) {
  .view > * {
    animation: rise 0.35s ease-out both;
  }
  .view > *:nth-child(2) { animation-delay: 0.04s; }
  .view > *:nth-child(3) { animation-delay: 0.08s; }
  .view > *:nth-child(4) { animation-delay: 0.12s; }
  .view > *:nth-child(5) { animation-delay: 0.16s; }
  .view > *:nth-child(n + 6) { animation-delay: 0.2s; }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.skeleton {
  display: grid;
  gap: 14px;
}
.skeleton i {
  display: block;
  height: 90px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.skeleton i:first-child {
  height: 44px;
  width: 40%;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- Inicio ---------- */

.hero {
  display: grid;
  gap: 20px;
  padding: 28px;
  border-radius: 20px;
  margin-bottom: 18px;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--border);
  position: relative;
  z-index: 2;
}
.hero-top {
  display: flex;
  align-items: center;
  gap: 16px;
}
.hero-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  object-fit: contain;
  flex: none;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 30%, transparent);
}
.hero h1 {
  font-size: 28px;
  line-height: 1.15;
}
.hero .greet {
  color: var(--muted);
  margin-top: 4px;
}

.search-wrap {
  position: relative;
}
.search-wrap svg.lead {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-big {
  padding: 14px 16px 14px 44px;
  font-size: 16px;
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.search-results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-results .mini-row {
  padding: 10px 14px;
  border-radius: 0;
}
.search-results .foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.search-results .foot a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.quick {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.quick-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.quick-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.quick-card .qi {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.quick-card.wa .qi {
  background: var(--wa-soft);
  color: var(--wa);
}
.quick-card b {
  font-size: 15px;
}
.quick-card span {
  color: var(--muted);
  font-size: 12px;
}

.mini-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.mini-kpis > div {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
}
.mini-kpis .v {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.mini-kpis .l {
  font-size: 12px;
  color: var(--muted);
}

.feed {
  display: grid;
}
.feed-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 4px;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.feed-item:first-child {
  border-top: 0;
}
.feed-item:hover {
  background: var(--surface-2);
  border-radius: 8px;
}
.feed-item .tl-icon {
  width: 30px;
  height: 30px;
}
.feed-item .tl-icon.novo {
  background: color-mix(in srgb, var(--st-lead) 16%, transparent);
  color: var(--st-lead);
}
.feed-item .what {
  font-size: 13px;
  min-width: 0;
}
.feed-item .what .sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-item .when {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- controles segmentados e pilulas ---------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented button {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:hover {
  color: var(--text);
}
.segmented button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

.pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.pill .n {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c, var(--muted));
}
.pill.on {
  border-color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface));
}
.pill.on .n {
  background: var(--c, var(--accent));
  color: var(--surface);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar .grow {
  flex: 1 1 260px;
}
.toolbar select,
.toolbar input:not(.grow) {
  width: auto;
  flex: 0 1 190px;
}

/* ---------- Insights ---------- */

.insights-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.insights-head p {
  margin: 4px 0 0;
}
.summary {
  font-size: 16px;
  line-height: 1.6;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  margin-bottom: 16px;
}
.summary b {
  font-weight: 800;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.kpi .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.kpi .value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 700;
}
.delta.up {
  color: var(--st-cliente);
}
.delta.down {
  color: var(--danger);
}
.delta.flat {
  color: var(--muted);
}
.delta svg {
  width: 14px;
  height: 14px;
}
.delta .vs {
  color: var(--muted);
  font-weight: 500;
}

.chart-card .card-head {
  flex-wrap: wrap;
}
.chart {
  position: relative;
  height: 220px;
  margin: 14px 0 0 52px;
}
.chart .grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--border);
}
.chart .grid span {
  position: absolute;
  right: 100%;
  margin-right: 8px;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.chart .grid.base {
  border-top: 1px solid var(--muted);
  opacity: 0.6;
}
.bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}
.bar-col:hover,
.bar-col.hot {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.bar-col i {
  display: block;
  width: 100%;
  max-width: 34px;
  margin: 0 auto;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  transition: height 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.x-labels {
  display: flex;
  justify-content: space-between;
  margin: 6px 0 0 52px;
  font-size: 11px;
  color: var(--muted);
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}
.tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.tooltip b {
  font-size: 14px;
}

.hbars {
  display: grid;
  gap: 10px;
}
.hbar {
  display: grid;
  grid-template-columns: minmax(80px, 36%) 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.hbar .lbl {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar .track {
  height: 10px;
  background: var(--surface-2);
  border-radius: 5px;
  overflow: hidden;
}
.hbar .track i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  transition: width 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.hbar .val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 64px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.big-num {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
  line-height: 1.1;
}

@media (max-width: 1100px) {
  .quick {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .sidebar .logout,
  .sidebar a.brand {
    display: none;
  }
  .hero {
    padding: 20px;
    border-radius: 16px;
  }
  .hero h1 {
    font-size: 22px;
  }
  .hero-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }
  .quick {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .quick-card {
    padding: 14px;
  }
  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .kpi {
    padding: 14px;
  }
  .kpi .value {
    font-size: 22px;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .mini-kpis .v {
    font-size: 17px;
  }
  .insights-head .segmented,
  .chart-card .segmented,
  .page-head .segmented {
    width: 100%;
  }
  .insights-head .segmented button,
  .chart-card .segmented button,
  .page-head .segmented button {
    flex: 1;
    padding: 7px 6px;
    font-size: 12px;
  }
  .toolbar select,
  .toolbar input:not(.grow) {
    flex: 1 1 45%;
  }
  .chart {
    height: 180px;
    margin-left: 46px;
  }
  .x-labels {
    margin-left: 46px;
  }
  .summary {
    font-size: 15px;
  }
}
