/* ══════════ tokens ══════════ */
:root {
  color-scheme: dark;
  --bg: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --border: #302f2d;
  --border-strong: #43423f;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8d8c84;
  --accent: #3987e5;
  --accent-hover: #59a0f2;
  --accent-soft: #1c2a3d;
  --series-1: #3987e5;
  --danger: #ef6b64;
  --good: #35b491;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 2px 4px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.45);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --sidebar-w: 244px;
}


* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -.015em; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ══════════ sidebar ══════════ */

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-mark { color: var(--accent); display: flex; }
.brand-text { font-weight: 660; letter-spacing: -.02em; font-size: 15.5px; }














/* ══════════ layout ══════════ */
.main { width: 100%; max-width: 1220px; margin: 0 auto; padding: 22px 26px 64px; }

/* Cabeçalho enxuto no lugar da barra lateral: a ferramenta é uma tela só. */
.topo {
  /* width:100% é obrigatório: como .topo é item de um flex column (body) e usa
     margin:0 auto, as margens automáticas desligam o stretch do eixo cruzado e
     a barra encolhia para a largura do conteúdo — logo e perfil grudavam no
     centro. Com width:100% + max-width ela volta a ocupar a linha inteira. */
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  /* Mesmo recuo lateral de .main (26px): assim a logo alinha na vertical com
     o título Dashboard, em vez de flutuar deslocada. */
  padding: 18px 26px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

/* As duas seções empilham na mesma página: gerar em cima, salvos embaixo. */
.bloco { display: block; }
.bloco + .bloco { margin-top: 40px; padding-top: 34px; border-top: 1px solid var(--border); }


@keyframes fade { from { opacity: 0; transform: translateY(3px); } }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 25px; }
.page-sub { margin: 5px 0 0; color: var(--text-secondary); font-size: 14px; max-width: 62ch; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.grid-gen { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,420px); gap: 18px; align-items: start; }

/* ══════════ form ══════════ */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.label .opt { font-weight: 400; color: var(--text-muted); }
.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--text-muted); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.row-2 .field { margin-bottom: 0; }

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit; font-size: 14px;
}
.input:focus-visible, .seg-btn:focus-visible, .btn:focus-visible, .nav-item:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.input::placeholder { color: var(--text-muted); }
.input-sm { padding: 7px 10px; font-size: 13.5px; width: auto; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-right: 66px; }
.input-btn {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
  border-radius: 6px; padding: 5px 9px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.input-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }

.color-wrap { display: flex; align-items: center; gap: 8px; }
input[type="color"] {
  width: 40px; height: 38px; padding: 3px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-1); cursor: pointer; flex: 0 0 auto;
}
.color-wrap .input-sm { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; cursor: pointer; }
.check input { accent-color: var(--accent); }

.range { width: 100%; accent-color: var(--accent); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; gap: 3px; }
.seg-btn {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 6px 13px; border-radius: 6px; font: inherit; font-size: 13.5px; cursor: pointer;
}
.seg-btn:hover { color: var(--text-primary); }
.seg-btn.is-active { background: var(--surface-1); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow-sm); }

.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-preview { width: 38px; height: 38px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 3px; }

/* ══════════ buttons ══════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: var(--r-sm);
  padding: 9px 14px;
  font: inherit; font-size: 13.5px; font-weight: 560;
  cursor: pointer;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; }
.btn-danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-save { border-style: dashed; }

/* ══════════ preview ══════════ */
.card-preview { position: sticky; top: 30px; display: flex; flex-direction: column; gap: 14px; }
.preview-stage {
  display: grid; place-items: center;
  min-height: 300px;
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%) 0 0/18px 18px,
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25%, transparent 75%, var(--surface-2) 75%) 9px 9px/18px 18px,
    var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
}
.qr-frame { display: none; line-height: 0; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-md); }
.qr-frame.is-on { display: block; }
#qrCanvas { width: 268px; height: 268px; display: block; }
.preview-empty { color: var(--text-muted); font-size: 13.5px; text-align: center; margin: 0; }
.preview-meta { display: flex; gap: 8px; justify-content: center; font-size: 12.5px; color: var(--text-muted); }
.dot-sep { opacity: .5; }
.dl-block { border-top: 1px solid var(--border); padding-top: 14px; }
.dl-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.dl-actions .btn-primary { flex: 1 1 150px; }

/* ══════════ kpis ══════════ */
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 3px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 560; }
.kpi-value { font-size: 30px; font-weight: 660; letter-spacing: -.03em; line-height: 1.15; }
.kpi-value-sm { font-size: 23px; color: var(--good); }
.kpi-foot { font-size: 12px; color: var(--text-muted); }

/* ══════════ chart ══════════ */
.chart-card { margin-bottom: 18px; }
.chart-head { display: flex; align-items: baseline; gap: 9px; margin-bottom: 16px; }
.chart-title { font-size: 15px; font-weight: 620; }
.chart-sub { font-size: 12.5px; color: var(--text-muted); }
.chart-wrap { position: relative; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 168px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; cursor: default; }
.bar-track { flex: 1; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; border-bottom: 1px solid var(--border); }
.bar-value { font-size: 11px; font-weight: 620; color: var(--text-secondary); line-height: 1; }
.bar {
  width: 62%; max-width: 34px; min-height: 2px;
  background: var(--series-1);
  border-radius: 4px 4px 0 0;
  transition: opacity .12s;
}
.bar.is-zero { background: var(--border); }
.bar-col:hover .bar { opacity: .75; }
.bar-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow-md);
  padding: 7px 10px; font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, -100%);
}
.chart-tip b { display: block; font-size: 13px; }
.chart-tip span { color: var(--text-secondary); }

/* ══════════ table ══════════ */
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.table-tools { display: flex; gap: 8px; }
.table-tools #searchInput { width: 240px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 640; padding: 0 12px 9px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.col-thumb { width: 56px; }
.col-date { width: 130px; }
.col-act { width: 290px; }
.thumb { width: 40px; height: 40px; border-radius: 6px; border: 1px solid var(--border); background: #fff; display: block; }
.cell-name { font-weight: 560; }
.cell-url { color: var(--text-secondary); max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.cell-url a { color: inherit; }
.cell-date { color: var(--text-muted); white-space: nowrap; }
.act-row { display: flex; gap: 5px; flex-wrap: wrap; }
.act {
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  border-radius: 6px; padding: 4px 8px; font: inherit; font-size: 12px; cursor: pointer;
}
.act:hover { background: var(--surface-1); color: var(--text-primary); border-color: var(--border-strong); }
.act-del:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.empty { text-align: center; padding: 34px 16px; color: var(--text-secondary); }
.empty p { margin: 0 0 4px; }

/* ══════════ prose ══════════ */
.prose { max-width: 78ch; }
.prose h2 { font-size: 16px; margin: 22px 0 7px; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--text-secondary); font-size: 14.5px; margin: 0 0 9px; }
.prose ul { padding-left: 20px; margin: 0; }
.prose b { color: var(--text-primary); }

/* ══════════ toast ══════════ */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px);
  background: var(--text-primary); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 13.5px; font-weight: 560;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
  z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ══════════ responsive ══════════ */
@media (max-width: 1080px) {
  .grid-gen { grid-template-columns: 1fr; }
  .card-preview { position: static; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  body { flex-direction: column; }

  .brand-text { display: none; }
  .main { padding: 20px 16px 50px; }
  .row-2 { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .bar-label { font-size: 9.5px; }
}
@media print {
  .sidebar, .dl-block, .head-actions, .toast { display: none !important; }
}

/* ══════════ modal do gerador ══════════ */
/*
 * A lista é a tela; criar um QR é uma ação pontual, então o gerador mora
 * aqui dentro em vez de ocupar metade da página o tempo todo.
 */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(2px);
}

.modal-caixa {
  position: relative;
  width: 100%;
  max-width: 1080px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  animation: sobe .16s ease;
}

@keyframes sobe {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.modal-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  z-index: 2;
}

.modal-topo h2 { font-size: 17px; }

.modal-fechar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.modal-fechar:hover { background: var(--surface-2); color: var(--text-primary); }

.modal-corpo { padding: 20px 22px 24px; }

/* Dentro do modal os cartões já estão delimitados pela própria caixa. */
.modal-corpo .card { box-shadow: none; }

@media (max-width: 720px) {
  .modal { padding: 0; }
  .modal-caixa { border-radius: 0; min-height: 100vh; border: 0; }
  .modal-topo { border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-caixa { animation: none; }
}

/* ══════════ tela fixa, sem rolagem de página ══════════ */
/*
 * A janela do navegador não rola: cabeçalho, indicadores e gráfico ficam
 * sempre visíveis, e só a lista rola por dentro do próprio quadro. Assim o
 * botão de criar e os números nunca saem da vista.
 */

html, body { height: 100%; overflow: hidden; }

body { display: flex; flex-direction: column; }

.topo { flex: 0 0 auto; }

/* O traço embaixo do cabeçalho atravessa a janela inteira; o conteúdo é que
   fica na coluna centralizada. */
.topo-faixa { border-bottom: 1px solid var(--border); }

.main {
  flex: 1 1 auto;
  min-height: 0;          /* sem isto o filho que rola estoura a altura */
  display: flex;
  flex-direction: column;
  padding-top: 20px;
  padding-bottom: 22px;
  overflow: hidden;
}

#view-dashboard {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* O quadro da lista ocupa a sobra e guarda a rolagem dentro dele. */
#view-dashboard > .table-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#view-dashboard > .table-card > .table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* Cabeçalho da tabela fica preso ao rolar a lista. */
#view-dashboard .table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  z-index: 1;
}

/* O modal rola sozinho quando o formulário é maior que a tela. */
.modal { max-height: 100vh; }

/* Em tela baixa, o gráfico é o primeiro a ceder espaço. */
@media (max-height: 780px) {
  .chart-card { display: none; }
}

@media (max-width: 720px) {
  html, body { overflow: auto; }
  .main, #view-dashboard, #view-dashboard > .table-card { overflow: visible; min-height: auto; }
  #view-dashboard > .table-card > .table-scroll { overflow-x: auto; }
}

/* ══════════ perfil no cabeçalho ══════════ */

.perfil { position: relative; }

.perfil-botao {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.perfil-botao:hover { background: var(--surface-2); }

.perfil-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
}

.perfil-nome { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.perfil-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 236px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 50;
}

.perfil-menu[hidden] { display: none; }

.perfil-cabeca {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 10px 11px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.perfil-cabeca strong { font-size: 14px; }
.perfil-cabeca span { font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }

.perfil-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
}

.perfil-item:hover { background: var(--surface-2); color: var(--text-primary); }
.perfil-sair { color: var(--danger); }
.perfil-sair:hover { color: var(--danger); background: var(--surface-2); }

/* ══════════ telas de acesso e de perfil ══════════ */

/* Login e perfil rolam normalmente — só o painel é que fica preso à tela. */
body.tela-acesso, body.pagina-rolavel { overflow: auto; display: block; height: auto; }
body.tela-acesso { min-height: 100%; }

.acesso {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 40px 20px;
}

.acesso-marca { display: flex; align-items: center; gap: 11px; }
.acesso-card { width: 100%; max-width: 400px; padding: 26px; }
.acesso-card h1 { font-size: 21px; }
.acesso-form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.acesso-troca { margin-top: 18px; font-size: 14px; color: var(--text-muted); text-align: center; }
.acesso-troca a { color: var(--accent); }

.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.alerta {
  background: rgba(201, 52, 47, .12);
  border: 1px solid rgba(201, 52, 47, .34);
  color: #f0a09c;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  margin-top: 16px;
}

.sucesso {
  background: rgba(18, 128, 99, .13);
  border: 1px solid rgba(18, 128, 99, .36);
  color: #6fd6b6;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
}

.perfil-grade {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  align-items: start;
}

.perfil-grade .card { padding: 20px; }
.card-perigo { border-color: rgba(201, 52, 47, .3); }

.btn-perigo { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-perigo:hover { filter: brightness(1.08); }

@media (max-width: 560px) {
  .perfil-nome { display: none; }
}
