/* =========================================================
   Seção Dashboard: mockup grande do painel
   ========================================================= */

.dash {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.dash__chrome {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.dash__chrome .code__dots i {
  background: var(--gray-300);
}

.dash__address {
  padding: 4px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  background: var(--white);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
}

.dash__body {
  display: grid;
}

@media (min-width: 900px) {
  .dash__body {
    grid-template-columns: 232px minmax(0, 1fr);
  }
}

/* ---------- Menu lateral (faixa horizontal no mobile) ---------- */

.dash__sidebar {
  min-width: 0;
  border-bottom: 1px solid var(--gray-200);
  /* Esmaece a borda direita para indicar que a faixa rola na horizontal */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}

.dash__brand {
  display: none;
}

.dash__menu {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.dash__menu::-webkit-scrollbar {
  display: none;
}

.dash__menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
}

.dash__menu li.is-active {
  background: var(--brand-100);
  color: var(--black);
  font-weight: 600;
}

@media (min-width: 900px) {
  .dash__sidebar {
    padding: 24px 16px;
    border-right: 1px solid var(--gray-200);
    border-bottom: 0;
    background: var(--gray-50);
    -webkit-mask-image: none;
    mask-image: none;
  }

  .dash__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 24px;
  }

  .dash__brand .logo__img {
    height: 26px;
  }

  .dash__menu {
    flex-direction: column;
    padding: 0;
    overflow: visible;
  }
}

/* ---------- Área principal ---------- */

.dash__main {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 16px;
}

@media (min-width: 640px) {
  .dash__main {
    gap: 20px;
    padding: 28px;
  }
}

.dash__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dash__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dash__subtitle {
  font-size: 0.8125rem;
  color: var(--gray-500);
}

.dash__tools {
  display: flex;
  gap: 8px;
}

.dash__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
}

.dash__chip--icon {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

/* ---------- Indicadores ---------- */

.dash__kpis {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .dash__kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

.kpi {
  padding: 18px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
}

.kpi:first-child {
  background: var(--black);
  border-color: var(--black);
  color: var(--white);
}

.kpi__label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-500);
}

.kpi:first-child .kpi__label {
  color: var(--gray-400);
}

.kpi__value {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi__delta {
  display: inline-block;
  margin-top: 10px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--success-soft);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--success);
}

.kpi:first-child .kpi__delta {
  background: var(--brand-500);
  color: var(--black);
}

/* ---------- Cards internos ---------- */

.dash__card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
}

@media (min-width: 640px) {
  .dash__card {
    padding: 22px 24px;
  }
}

.dash__card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dash__card-head p {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
}

.dash__legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--gray-500);
  white-space: nowrap;
}

.dash__legend::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
  border: 1.5px solid var(--black);
}

.dash__legend--plain::before {
  border: 0;
  background: var(--primary);
}

/* ---------- Gráfico ---------- */

.chart {
  --chart-gutter: 44px; /* coluna dos valores do eixo Y */
  --chart-height: 170px;
}

@media (min-width: 640px) {
  .chart {
    --chart-height: 240px;
  }
}

@media (min-width: 1100px) {
  .chart {
    --chart-height: 280px;
  }
}

.chart__plot {
  position: relative;
  height: var(--chart-height);
  margin-left: var(--chart-gutter);
}

.chart__svg {
  width: 100%;
  height: 100%;
}

.chart__line {
  fill: none;
  stroke: var(--black);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/* Valor do eixo Y + linha de grade */
.chart__y {
  position: absolute;
  left: calc(var(--chart-gutter) * -1);
  right: 0;
  display: flex;
  align-items: center;
  font-size: 0.6875rem;
  line-height: 1;
  color: var(--gray-400);
  transform: translateY(-50%);
  pointer-events: none;
}

.chart__y span {
  flex-shrink: 0;
  width: var(--chart-gutter);
}

.chart__y::after {
  content: "";
  flex: 1;
  border-top: 1px dashed var(--gray-200);
}

.chart__clip {
  position: relative;
  height: 100%;
}

.chart__dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2.5px solid var(--black);
  border-radius: 50%;
  background: var(--brand-500);
  transform: translate(-50%, -50%);
}

.chart__tip {
  position: absolute;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--black);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  transform: translate(-82%, calc(-100% - 12px));
}

.chart__x {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-top: 8px;
  margin-left: var(--chart-gutter);
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* Animação: o gráfico é revelado da esquerda para a direita
   (só com JS e sem movimento reduzido; disparada pelo reveal da seção) */
@media (prefers-reduced-motion: no-preference) {
  .js .chart__clip {
    clip-path: inset(-10px 100% -10px 0);
  }

  .js .chart__dot,
  .js .chart__tip {
    opacity: 0;
  }

  .js .is-visible .chart__clip {
    animation: chart-reveal 1.6s 0.3s var(--ease) forwards;
  }

  .js .is-visible .chart__dot,
  .js .is-visible .chart__tip {
    animation: chart-fade 0.4s 1.7s ease forwards;
  }
}

@keyframes chart-reveal {
  to { clip-path: inset(-10px 0 -10px 0); }
}

@keyframes chart-fade {
  to { opacity: 1; }
}

/* ---------- Tabela ---------- */

.dash__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.dash__table th {
  padding: 0 12px 10px 0;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.75rem;
  font-weight: 500;
  text-align: left;
  color: var(--gray-500);
}

.dash__table td {
  padding: 12px 12px 12px 0;
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dash__table th:last-child,
.dash__table td:last-child {
  padding-right: 0;
}

.dash__table tr:last-child td {
  padding-bottom: 0;
  border-bottom: 0;
}

.dash__table td:first-child {
  font-weight: 500;
}

.dash__table td:nth-child(2) {
  font-weight: 600;
}

.dash__table .col-md {
  display: none;
}

.dash__table td.col-md {
  color: var(--gray-600);
}

.avatar {
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--brand-100);
  font-size: 0.6875rem;
  font-weight: 700;
  vertical-align: middle;
}

@media (min-width: 640px) {
  .dash__table .col-md {
    display: table-cell;
  }

  .avatar {
    display: inline-grid;
  }
}

/* Mobile: cada linha vira um item de lista em duas linhas
   (cliente + valor em cima, data + status embaixo), sem cortar nada */
@media (max-width: 639px) {
  .dash__table,
  .dash__table tbody {
    display: block;
  }

  .dash__table thead {
    display: none;
  }

  .dash__table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
  }

  .dash__table tr:first-child {
    padding-top: 0;
  }

  .dash__table tr:last-child {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .dash__table td {
    padding: 0;
    border: 0;
  }

  .dash__table td:nth-child(1) {
    grid-area: 1 / 1;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dash__table td:nth-child(2) {
    grid-area: 1 / 2;
    text-align: right;
  }

  .dash__table td:nth-child(4) {
    grid-area: 2 / 2;
    justify-self: end;
  }

  .dash__table td:nth-child(5) {
    display: block;
    grid-area: 2 / 1;
    font-size: 0.75rem;
    color: var(--gray-500);
  }
}
