/* ============================================================
   RASTRO — sistema de design
   Tinta carvão + coral-sinal · Bricolage Grotesque / Instrument Sans / IBM Plex Mono
   ============================================================ */

:root {
  --ink-0: #0b0f13;
  --ink-1: #10151b;
  --ink-2: #161d25;
  --ink-3: #1e2731;
  --line: rgba(151, 170, 188, 0.1);
  --line-2: rgba(151, 170, 188, 0.2);
  --tx-0: #edf1f5;
  --tx-1: #a8b3bf;
  --tx-2: #66727f;
  --sinal: #ff5c38;
  --sinal-2: #ff8266;
  --sinal-dim: rgba(255, 92, 56, 0.13);
  --amber: #ffb224;
  --teal: #3bc9a7;
  --blue: #5ca8ff;
  --slate: #45525f;
  --erro: #ff6b6b;
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 7px;
  --f-display: 'Bricolage Grotesque', sans-serif;
  --f-body: 'Instrument Sans', sans-serif;
  --f-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--ink-0);
  color: var(--tx-0);
  font: 15px/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--f-display); letter-spacing: -0.015em; text-wrap: balance; }
p { text-wrap: pretty; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
svg { display: block; }

::selection { background: var(--sinal); color: var(--ink-0); }

/* ---------- marca ---------- */
.marca {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 21px;
  color: var(--tx-0);
}
.marca svg { width: 30px; height: 30px; }
.marca small {
  display: block;
  font-family: var(--f-body);
  font-weight: 400;
  font-size: 11px;
  color: var(--tx-2);
  letter-spacing: 0.02em;
  margin-top: -3px;
}

/* ---------- botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--sinal);
  color: #1a0d08;
  border: 0;
  border-radius: var(--r-sm);
  padding: 11px 20px;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 8px 22px -10px rgba(255, 92, 56, 0.55);
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn:active { transform: translateY(0); filter: brightness(0.96); }
.btn:focus-visible { outline: 2px solid var(--sinal-2); outline-offset: 2px; }
.btn[disabled] { opacity: 0.55; pointer-events: none; }
.btn-bloco { width: 100%; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: var(--tx-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font-size: 13.5px;
  font-weight: 500;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost:hover { color: var(--tx-0); border-color: var(--slate); background: var(--ink-2); }
.btn-ghost svg { width: 15px; height: 15px; }

.btn-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  color: var(--tx-2);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-icone:hover { color: var(--tx-0); background: var(--ink-3); }
.btn-icone.perigo:hover { color: var(--erro); background: rgba(255, 107, 107, 0.1); }
.btn-icone svg { width: 16px; height: 16px; }

/* ---------- formulários ---------- */
.campo { display: block; margin-bottom: 16px; }
.campo span {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--tx-1);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.campo input, .campo select {
  width: 100%;
  background: var(--ink-2);
  color: var(--tx-0);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.campo input::placeholder { color: var(--tx-2); }
.campo input:focus, .campo select:focus {
  outline: none;
  border-color: var(--sinal);
  box-shadow: 0 0 0 3px var(--sinal-dim);
}
.campo .dica { font-size: 12px; color: var(--tx-2); margin-top: 5px; display: block; }

.msg-erro {
  color: var(--erro);
  font-size: 13.5px;
  min-height: 20px;
  margin: 2px 0 12px;
}

/* ============================================================
   LOGIN — foto à esquerda (duotone coral), formulário à direita
   ============================================================ */
.login-grid {
  display: grid;
  grid-template-columns: 1.08fr 1fr;
  min-height: 100vh;
}

.login-foto {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--ink-1);
}
.login-foto img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.1) brightness(0.82);
}
.login-foto .tinta {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, #ff5c38 0%, #d94326 55%, #7a2a18 100%);
  mix-blend-mode: color;
}
.login-foto .veu {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(12deg, rgba(11, 15, 19, 0.92) 0%, rgba(11, 15, 19, 0.35) 42%, rgba(11, 15, 19, 0.12) 100%),
    linear-gradient(90deg, rgba(11, 15, 19, 0) 82%, rgba(11, 15, 19, 0.55) 100%);
}
.login-foto .grao {
  position: absolute;
  inset: 0;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
}
.foto-conteudo {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px 48px;
}
.foto-frase h2 {
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: 700;
  line-height: 1.08;
  margin: 0 0 12px;
  max-width: 480px;
}
.foto-frase h2 em {
  font-style: normal;
  color: var(--sinal-2);
}
.foto-frase p {
  color: rgba(237, 241, 245, 0.78);
  font-size: 15.5px;
  max-width: 400px;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px 32px;
  position: relative;
  background:
    radial-gradient(600px 300px at 85% -5%, rgba(255, 92, 56, 0.06), transparent 70%),
    var(--ink-0);
}
.login-form form {
  width: 100%;
  max-width: 372px;
  animation: surgir 0.5s ease both;
}
.login-form h1 { font-size: 27px; font-weight: 700; margin: 0 0 6px; }
.login-form .sub { color: var(--tx-2); font-size: 14px; margin: 0 0 30px; }
.login-form footer {
  position: absolute;
  bottom: 22px;
  font-size: 12px;
  color: var(--tx-2);
}
.marca-mobile { display: none; margin-bottom: 34px; }

/* ============================================================
   APP — sidebar + conteúdo
   ============================================================ */
.app-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink-1);
  border-right: 1px solid var(--line);
  padding: 26px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .marca { padding: 0 10px; }

.nav-grupo { display: flex; flex-direction: column; gap: 2px; }
.nav-rotulo {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tx-2);
  padding: 0 12px;
  margin: 0 0 7px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--tx-1);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: background 0.14s, color 0.14s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--ink-2); color: var(--tx-0); }
.nav-item.ativo { background: var(--ink-2); color: var(--tx-0); }
.nav-item.ativo::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--sinal);
}
.nav-item.ativo svg { color: var(--sinal); }

.sidebar-rodape { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar-conta {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--tx-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- conteúdo ---------- */
.conteudo { padding: 30px 36px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }

.topo {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.topo h1 {
  font-size: 25px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topo h1 svg { width: 24px; height: 24px; color: var(--sinal); }
.topo .desc { color: var(--tx-2); font-size: 13.5px; margin: 4px 0 0; }

.filtro-periodo {
  display: inline-flex;
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.filtro-periodo button {
  background: transparent;
  border: 0;
  color: var(--tx-2);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 5px;
  transition: background 0.14s, color 0.14s;
}
.filtro-periodo button:hover { color: var(--tx-0); }
.filtro-periodo button.ativo { background: var(--ink-3); color: var(--tx-0); }

/* ---------- cards ---------- */
.card {
  background: var(--ink-1);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
}
.card h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tx-1);
  margin: 0 0 16px;
  font-family: var(--f-body);
}

.grade-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.kpi { padding: 18px 20px; }
.kpi .rotulo {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tx-2);
}
.kpi .valor {
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: 33px;
  line-height: 1.15;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.kpi.destaque { border-color: rgba(255, 92, 56, 0.35); background: linear-gradient(180deg, rgba(255, 92, 56, 0.07), transparent 60%), var(--ink-1); }
.kpi.destaque .valor { color: var(--sinal-2); }

.grade-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; margin-bottom: 14px; }
.grade-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---------- listas com barra de proporção ---------- */
.lista-metrica { display: flex; flex-direction: column; gap: 4px; }
.lista-metrica .linha {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 7px 2px;
  position: relative;
}
.lista-metrica .nome {
  font-size: 13.5px;
  color: var(--tx-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 1;
}
.lista-metrica .num {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--tx-0);
  z-index: 1;
  font-variant-numeric: tabular-nums;
}
.lista-metrica .trilho {
  grid-column: 1 / -1;
  height: 5px;
  background: var(--ink-3);
  border-radius: 3px;
  overflow: hidden;
}
.lista-metrica .trilho i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--sinal), var(--sinal-2));
  transform-origin: left;
  animation: crescerX 0.6s ease both;
}

/* ---------- tabela de links ---------- */
.tabela { width: 100%; border-collapse: collapse; }
.tabela th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tx-2);
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
}
.tabela td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
.tabela tr:last-child td { border-bottom: 0; }
.tabela tr { transition: background 0.12s; }
.tabela tbody tr:hover { background: rgba(151, 170, 188, 0.03); }
.td-num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.td-acoes { display: flex; gap: 4px; justify-content: flex-end; }

.link-curto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--sinal-2);
  background: var(--sinal-dim);
  border: 1px solid rgba(255, 92, 56, 0.22);
  border-radius: 6px;
  padding: 4px 9px;
  white-space: nowrap;
}
.destino {
  color: var(--tx-2);
  font-size: 12.5px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ---------- interruptor ---------- */
.chave {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: var(--ink-3);
  border: 1px solid var(--line-2);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  flex: none;
}
.chave::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--tx-2);
  transition: transform 0.18s ease, background 0.18s;
}
.chave.ligada { background: rgba(255, 92, 56, 0.35); border-color: var(--sinal); }
.chave.ligada::after { transform: translateX(16px); background: var(--sinal-2); }

/* ---------- resultado do link gerado ---------- */
.gerado {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--sinal-dim);
  border: 1px dashed rgba(255, 92, 56, 0.45);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-top: 16px;
  animation: surgir 0.35s ease both;
}
.gerado code {
  font-family: var(--f-mono);
  font-size: 14px;
  color: var(--sinal-2);
  word-break: break-all;
}
.gerado .rotulo-ok {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--tx-1);
  display: block;
  margin-bottom: 3px;
}

/* ---------- vazio ---------- */
.vazio {
  border: 1px dashed var(--line-2);
  border-radius: var(--r-md);
  padding: 34px 20px;
  text-align: center;
  color: var(--tx-2);
  font-size: 13.5px;
}
.vazio svg { width: 26px; height: 26px; margin: 0 auto 10px; opacity: 0.5; }
.vazio strong { display: block; color: var(--tx-1); font-weight: 600; margin-bottom: 3px; }

/* ---------- gráficos ---------- */
.grafico-svg { width: 100%; height: auto; }
.barra-dia { fill: var(--sinal); opacity: 0.85; transition: opacity 0.12s; }
.barra-dia:hover { opacity: 1; }
.barra-hora { fill: var(--slate); transition: fill 0.12s; }
.barra-hora.pico { fill: var(--amber); }
.eixo-texto { fill: var(--tx-2); font-family: var(--f-mono); font-size: 9.5px; }

.donut-legenda { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.donut-legenda .item { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--tx-1); }
.donut-legenda .ponto { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.donut-legenda .pct { margin-left: auto; font-family: var(--f-mono); font-size: 12.5px; color: var(--tx-0); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--ink-3);
  border: 1px solid var(--line-2);
  color: var(--tx-0);
  font-size: 13.5px;
  padding: 10px 18px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 99;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.6);
}
#toast.visivel { opacity: 1; transform: translate(-50%, 0); }

/* ---------- animações ---------- */
@keyframes surgir {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes crescerX {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.surge { animation: surgir 0.4s ease both; }
.surge:nth-child(2) { animation-delay: 0.05s; }
.surge:nth-child(3) { animation-delay: 0.1s; }
.surge:nth-child(4) { animation-delay: 0.15s; }

/* ---------- responsivo ---------- */
@media (max-width: 980px) {
  .grade-kpi { grid-template-columns: 1fr 1fr; }
  .grade-2, .grade-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .login-grid { grid-template-columns: 1fr; }
  .login-foto { display: none; }
  .marca-mobile { display: inline-flex; }

  .app-grid { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .sidebar .marca small, .nav-rotulo, .sidebar-conta { display: none; }
  .nav-grupo { flex-direction: row; }
  .nav-item { padding: 8px 10px; white-space: nowrap; }
  .nav-item.ativo::before { display: none; }
  .sidebar-rodape { margin: 0 0 0 auto; flex-direction: row; }
  .conteudo { padding: 22px 16px 50px; }
}
