/* ============================================================
   VELA — App Shell
   Layout de aplicação: sidebar + topbar + área de conteúdo.
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.side {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 16px;
  font-weight: var(--font-weight-extrabold);
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-tight);
}
.side__brand .mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--acc), var(--acc-2));
  display: grid; place-items: center;
  color: #fff;
}
.side__label {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--t2);
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-vela-sm);
  color: var(--t1);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background var(--default-transition-duration) var(--ease-out),
              color var(--default-transition-duration) var(--ease-out);
}
.nav-item:hover { background: var(--bg-3); color: var(--t0); }
.nav-item--active {
  background: var(--acc-soft);
  color: var(--acc-2);
}
.nav-item .v-icon { width: 17px; height: 17px; }
.nav-item__chev { margin-left: auto; width: 15px; height: 15px; opacity: 0.6; }

.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 2px 30px;
  padding-left: 10px;
  border-left: 1px solid var(--line-2);
}
.nav-sub__item {
  padding: 7px 10px;
  border-radius: var(--radius-vela-sm);
  color: var(--t2);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background var(--default-transition-duration) var(--ease-out),
              color var(--default-transition-duration) var(--ease-out);
}
.nav-sub__item:hover { color: var(--t0); background: var(--bg-3); }
.nav-sub__item--active { color: var(--acc-2); font-weight: var(--font-weight-semibold); }

.side__promo {
  margin-top: auto;
  padding: 16px;
  border-radius: var(--radius-vela-md);
  background:
    radial-gradient(120% 120% at 0% 0%, var(--acc-soft), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--line);
}
.side__promo .ic {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--acc); color: #fff;
  display: grid; place-items: center; margin-bottom: 10px;
}
.side__promo h4 { font-size: var(--text-sm); margin-bottom: 3px; }
.side__promo p { font-size: var(--text-xs); color: var(--t2); margin-bottom: 12px; }

/* ---------- Topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 24px;
  background: color-mix(in oklab, var(--bg-0) 80%, transparent);
  backdrop-filter: blur(var(--blur-md));
  border-bottom: 1px solid var(--line);
}
.topbar__search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px;
  background: var(--bg-inset);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-vela-sm);
  color: var(--t2);
  font-size: var(--text-sm);
}
.topbar__search input {
  border: 0; background: transparent; outline: none;
  flex: 1; color: var(--t0); font-size: var(--text-sm);
}
.topbar__kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  color: var(--t2);
}
.topbar__spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-vela-sm);
  background: var(--bg-2);
  color: var(--t1);
  cursor: pointer;
  position: relative;
  transition: background var(--default-transition-duration) var(--ease-out);
}
.icon-btn:hover { background: var(--bg-3); color: var(--t0); }
.icon-btn__dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 999px;
  background: var(--bad);
  border: 2px solid var(--bg-2);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 4px 12px;
}
.user-chip__name { font-size: var(--text-sm); font-weight: var(--font-weight-bold); line-height: 1.2; }
.user-chip__role { font-size: var(--text-xs); color: var(--t2); }
.user-chip .v-avatar { width: 36px; height: 36px; }

/* ---------- Content ---------- */
.content { padding: 26px 24px 64px; max-width: 1360px; width: 100%; margin: 0 auto; }

.crumb { font-size: var(--text-xs); color: var(--t2); font-weight: var(--font-weight-semibold); }
.crumb strong { color: var(--t1); }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin: 10px 0 24px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: var(--text-4xl); letter-spacing: var(--tracking-tight); }
.page-head p { color: var(--t2); font-size: var(--text-sm); margin-top: 4px; }
.page-head__actions { display: flex; gap: 10px; }

/* ---------- Grid do dashboard ---------- */
.dash-grid { display: grid; gap: 16px; }
.row-kpi { grid-template-columns: repeat(4, 1fr); }
.row-2col { grid-template-columns: 1.35fr 1fr; }
.row-3col { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 1180px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .row-2col, .row-3col { grid-template-columns: 1fr; }
  .row-kpi { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .row-kpi { grid-template-columns: 1fr; }
  .page-head h1 { font-size: var(--text-3xl); }
  .content { padding: 18px 14px 48px; }
}

/* A entrada escalonada não pode "prender" transform:none no fim,
   senão o hover de elevação para de funcionar. */
.content .vela-stagger > * { animation-fill-mode: backwards; }

/* ---------- Elevação dos cards no hover ---------- */
.content .v-card {
  transition:
    transform 0.28s var(--ease-out),
    box-shadow 0.28s var(--ease-out),
    border-color 0.28s var(--ease-out);
  will-change: transform;
}
.content .v-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow), 0 0 0 1px var(--line-2);
  border-color: var(--line-2);
}
@media (hover: none) {
  .content .v-card:hover { transform: none; box-shadow: none; }
}

/* ---------- Blocos específicos do CRM ---------- */
.kpi-tile {
  width: 42px; height: 42px;
  border-radius: var(--radius-vela-sm);
  display: grid; place-items: center;
  background: var(--acc-soft); color: var(--acc-2);
}
.kpi-tile--ok { background: var(--ok-soft); color: var(--ok); }
.kpi-tile--warn { background: var(--warn-soft); color: var(--warn); }
.kpi-tile--info { background: var(--info-soft); color: var(--info); }

.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }

.stage-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.stage-row:last-child { border-bottom: 0; }
.stage-row__head {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-sm); font-weight: var(--font-weight-semibold);
  margin-bottom: 8px;
}
.stage-row__head .num { margin-left: auto; color: var(--t2); font-weight: var(--font-weight-medium); font-size: var(--text-xs); }
.stage-row__head .amt { color: var(--t0); font-weight: var(--font-weight-bold); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 999px; flex: none; }

.bar { height: 7px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transform-origin: left; }

/* Carregamento: barras crescem da esquerda quando o dash está "pronto" */
.dash-ready .bar > i {
  animation: velaGrowX 0.85s var(--ease-out) both;
  animation-delay: var(--bar-delay, 0.15s);
}

.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 8px 0; }
.donut {
  --vela-arc-end: 216deg;            /* 60% => 0.6 * 360 */
  --vela-arc: var(--vela-arc-end);   /* fallback sem @property/JS */
  width: 168px; height: 168px; border-radius: 999px;
  display: grid; place-items: center;
  position: relative;
  background: conic-gradient(
    var(--ok) 0 var(--vela-arc),
    var(--bad) var(--vela-arc) 360deg
  );
}
.donut::after {
  content: ""; position: absolute; inset: 22px;
  background: var(--bg-1); border-radius: 999px;
  transition: background 0.15s var(--ease-out);
}
.donut__label { position: relative; z-index: 1; text-align: center; }
.donut__label b { display: block; font-size: var(--text-2xl); font-weight: var(--font-weight-extrabold); }
.donut__label span { font-size: var(--text-xs); color: var(--t2); }

/* Carregamento: o anel "varre" de 0 até o valor final */
.dash-ready .donut {
  animation: velaArc 1.05s var(--ease-out) 0.2s both;
}

/* ---------- Sparklines dos KPIs ---------- */
.kpi-spark { width: 100%; height: 40px; display: block; margin: 14px 0 2px; overflow: visible; }
.kpi-spark .line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.kpi-spark .area { opacity: 0; transition: opacity 0.4s var(--ease-out); }
.dash-ready .kpi-spark .line {
  stroke-dasharray: 240;
  stroke-dashoffset: 240;
  animation: velaDraw 1.15s var(--ease-out) 0.25s forwards;
}
.dash-ready .kpi-spark .area { opacity: 1; transition-delay: 0.8s; }

.legend-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-vela-sm);
  font-size: var(--text-sm);
}
.legend-row .amt { margin-left: auto; font-weight: var(--font-weight-bold); }

.act-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.act-row:last-child { border-bottom: 0; }
.act-row__ic {
  width: 38px; height: 38px; border-radius: var(--radius-vela-sm);
  display: grid; place-items: center; flex: none;
  background: var(--bg-3); color: var(--t1);
}
.act-row__big { font-size: var(--text-lg); font-weight: var(--font-weight-extrabold); font-variant-numeric: tabular-nums; }
.act-row__cap { font-size: var(--text-xs); color: var(--t2); }

.rep-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; }
.rep-row__rank { width: 16px; color: var(--t2); font-weight: var(--font-weight-bold); font-size: var(--text-sm); }
.rep-row__body { flex: 1; min-width: 0; }
.rep-row__top { display: flex; justify-content: space-between; font-size: var(--text-sm); font-weight: var(--font-weight-semibold); }
.rep-row__amt { font-variant-numeric: tabular-nums; }
.rep-row__meta { font-size: var(--text-xs); color: var(--t2); margin: 3px 0 6px; }

.spark { width: 100%; height: 56px; display: block; }
