/* MAVT Hub — identidade visual MAVT (dark, minimal, azul tech) */
:root {
  color-scheme: dark;
  --page: #0d0d0f;
  --surface: #16161a;
  --surface-2: #1c1c22;
  --ink: #f5f6f8;
  --ink-2: #b8bac2;
  --muted: #82848d;
  --grid: #26262e;
  --border: rgba(255, 255, 255, 0.08);
  --brand: #3b82f6;
  --brand-2: #2563eb;
  --brand-ink: #7fb0f9;
  --brand-grad: linear-gradient(180deg, #60a5fa, #2563eb);
  --good: #0ca30c;
  --good-text: #4ade80;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #ef4444;
  --sidebar-bg: radial-gradient(circle at 50% 30%, #101014 0%, #060607 100%);
}

* { box-sizing: border-box; margin: 0; }
body {
  font-family: 'Outfit', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: .01em;
}

/* ---------- wordmark MAVT ---------- */
.wordmark {
  font-weight: 600; letter-spacing: .38em; color: #fff;
  text-transform: uppercase; display: inline-flex; align-items: baseline;
}
.wordmark .logo-a { position: relative; display: inline-block; }
.wordmark .logo-a::after {
  content: ''; position: absolute; left: 42%; bottom: .1em;
  transform: translateX(-50%);
  width: .38em; height: .34em;
  background: var(--brand-grad);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.wordmark .marca-txt { font-weight: 700; letter-spacing: .04em; line-height: 1; color: currentColor; }
.wordmark .hub {
  font-weight: 300; letter-spacing: .1em; color: var(--brand-ink);
  margin-left: .5em; text-transform: none;
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 42%, #17171c 0%, #060607 70%);
}
.login-card { width: 360px; padding: 40px 36px; text-align: center; }
.login-card h1 { font-size: 30px; margin-bottom: 10px; }
.login-card .sub { color: var(--muted); margin-bottom: 30px; font-size: 13px; font-weight: 300; letter-spacing: .08em; }
.login-card label { display: block; text-align: left; font-size: 11.5px; color: var(--ink-2); margin: 14px 0 5px; letter-spacing: .06em; text-transform: uppercase; }
.login-card input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--grid); border-radius: 10px;
  background: rgba(255,255,255,.04); color: var(--ink); font-size: 14px; font-family: inherit;
  transition: border-color .15s;
}
.login-card input:focus { outline: none; border-color: var(--brand); }
.login-card button {
  width: 100%; margin-top: 26px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--brand-grad); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit; letter-spacing: .04em;
}
.login-card button:hover { filter: brightness(1.12); }
.login-erro { color: var(--critical); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--ink-2);
  display: flex; flex-direction: column; padding: 22px 0;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border);
}
.logo { padding: 0 22px 24px; font-size: 17px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 22px;
  color: var(--ink-2); text-decoration: none; font-size: 13.5px; font-weight: 400;
  border-left: 2px solid transparent; transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav a.ativa {
  border-left-color: var(--brand); color: #fff;
  background: linear-gradient(90deg, rgba(59,130,246,.14), transparent 80%);
}
.nav .badge {
  margin-left: auto; background: var(--critical); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 7px; font-weight: 600;
}
.sidebar .rodape { margin-top: auto; padding: 16px 22px; font-size: 12px; color: var(--muted); }
.sidebar .rodape button {
  background: none; border: 1px solid var(--grid); color: var(--ink-2);
  border-radius: 8px; padding: 5px 12px; cursor: pointer; font-size: 12px; margin-top: 8px;
  font-family: inherit;
}
.sidebar .rodape button:hover { border-color: var(--brand); color: #fff; }

/* min-width:0 é essencial: sem ele o flex não deixa a área encolher e a tabela
   empurra o layout pra fora da tela em vez de rolar dentro do card */
.main { flex: 1; min-width: 0; padding: 28px 32px; max-width: 1720px; }
.main h2 { font-size: 20px; margin-bottom: 2px; font-weight: 600; letter-spacing: .01em; }
.main .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; font-weight: 300; }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; margin-bottom: 24px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px;
}
.tile.clicavel { cursor: pointer; transition: border-color .15s, transform .15s; }
.tile.clicavel:hover { border-color: var(--brand); transform: translateY(-1px); }
.tile .rotulo { font-size: 12px; color: var(--ink-2); margin-bottom: 7px; font-weight: 300; letter-spacing: .03em; }
.tile .valor { font-size: 25px; font-weight: 600; letter-spacing: .01em; }
.tile .detalhe { font-size: 12px; color: var(--muted); margin-top: 5px; font-weight: 300; }
.tile .valor.bom { color: var(--good-text); }
.tile .valor.ruim { color: var(--critical); }

/* ---------- tabelas ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; margin-bottom: 20px;
}
.card .card-titulo { padding: 14px 18px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--grid); }
.tabela-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 10px 15px; border-bottom: 1px solid var(--grid);
  font-weight: 500; white-space: normal; /* títulos longos quebram em 2 linhas em vez de alargar a tabela */
}
td { padding: 9px 15px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(59,130,246,.05); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.num { text-align: right; }
td .cod { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--brand-ink); cursor: pointer; }
td .cod:hover { text-decoration: underline; }
.nome-loja { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* nome com chip ao lado: corta só o texto, o chip fica sempre visível */
.nome-loja.com-chip .nome-txt { display: inline-block; max-width: calc(100% - 80px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.nome-loja.com-chip .chip { vertical-align: middle; }

/* ---------- chips de status (ícone + texto, nunca só cor) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500;
  padding: 2.5px 10px; border-radius: 20px; white-space: nowrap;
}
.chip::before { font-size: 10px; }
.chip.pago      { background: rgba(12,163,12,.16);  color: var(--good-text); }
.chip.pago::before      { content: "✓"; }
.chip.a-pagar   { background: rgba(130,132,141,.16); color: var(--ink-2); }
.chip.a-pagar::before   { content: "○"; }
.chip.atrasado  { background: rgba(239,68,68,.16);  color: #f87171; }
.chip.atrasado::before  { content: "!"; }
.chip.acordo    { background: rgba(250,178,25,.15); color: var(--warning); }
.chip.acordo::before    { content: "◆"; }
.chip.cancelamento { background: rgba(236,131,90,.15); color: var(--serious); }
/* produtos da loja (ID puro = iFood, -99 = 99Food, -K = Keeta, -G = Google) */
.chip.prod::before { content: none; }
.chip.prod-ifood  { background: rgba(234,29,44,.16);  color: #ff7b85; }
.chip.prod-99food { background: rgba(255,140,0,.16);  color: #ffb45c; }
.chip.prod-keeta  { background: rgba(255,214,0,.14);  color: #ffe066; }
.chip.prod-google { background: rgba(66,133,244,.16); color: #8ab4f8; }
td.produtos { white-space: nowrap; }
.chip.cancelamento::before { content: "⤫"; }

.chip.cresce { background: rgba(12,163,12,.16); color: var(--good-text); }
.chip.cresce::before { content: "▲"; }
.chip.queda  { background: rgba(239,68,68,.16); color: #f87171; }
.chip.queda::before  { content: "▼"; }
.chip.estavel { background: rgba(130,132,141,.16); color: var(--ink-2); }
.chip.estavel::before { content: "●"; }
.chip.neutro { background: rgba(130,132,141,.16); color: var(--ink-2); }
.chip.nova { background: rgba(59,130,246,.16); color: var(--brand-ink); }
.chip.nova::before { content: "✦"; }

/* ---------- filtros ---------- */
.filtros { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filtros input, .filtros select {
  padding: 8px 12px; border: 1px solid var(--grid); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 13px; font-family: inherit;
}
.filtros input:focus, .filtros select:focus { outline: none; border-color: var(--brand); }
.filtros input[type="text"] { width: 270px; }

/* ---------- botões ---------- */
.btn-pri, .btn-sec, .btn-perigo {
  padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap; font-family: inherit;
  letter-spacing: .02em;
}
.btn-pri { background: var(--brand-grad); color: #fff; }
.btn-pri:hover { filter: brightness(1.12); }
.btn-sec { background: var(--surface-2); color: var(--ink); border-color: var(--grid); }
.btn-sec:hover { border-color: var(--brand); }
.btn-perigo { background: var(--critical); color: #fff; }
.btn-perigo:hover { filter: brightness(1.12); }
.btn-sucesso { background: linear-gradient(180deg, #22c55e, #15803d); color: #fff; padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent; white-space: nowrap; font-family: inherit; letter-spacing: .02em; }
.btn-sucesso:hover { filter: brightness(1.12); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 26px; width: 540px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
.modal h3 { font-size: 17px; margin-bottom: 2px; font-weight: 600; }
.modal .modal-sub { color: var(--muted); font-size: 13px; font-weight: 300; }
.modal-acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.modal input { font-family: inherit; }
.modal input:focus { outline: none; border-color: var(--brand) !important; }

/* ---------- ficha da loja ---------- */
.voltar { color: var(--brand-ink); cursor: pointer; font-size: 13px; margin-bottom: 12px; display: inline-block; }
.voltar:hover { text-decoration: underline; }
.ficha-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 4px 24px; padding: 16px 18px; }
.ficha-grid div { padding: 5px 0; font-size: 13px; }
.ficha-grid .rotulo { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 500; }

/* ---------- relatório ---------- */
.rel-cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.rel-marca { font-size: 15px; margin-bottom: 10px; }
.rel-rodape { color: var(--muted); font-size: 11.5px; margin-top: 8px; font-weight: 300; }

/* ---------- linha do tempo (ficha da loja) ---------- */
.tl-linha { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grid); align-items: baseline; }
.tl-quando { min-width: 120px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-tipo { min-width: 92px; }
.tl-texto { flex: 1; }
.tl-quem { min-width: 90px; font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- gráfico de nichos ---------- */
.nicho-linha { display: grid; grid-template-columns: 170px 1fr 110px; gap: 12px; align-items: center; }
.nicho-nome { font-size: 12.5px; color: var(--ink-2); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nicho-barra { background: var(--surface-2); border-radius: 4px; height: 18px; overflow: hidden; }
.nicho-barra > div { height: 100%; background: linear-gradient(90deg, #2a78d6, #60a5fa); border-radius: 4px; }
.nicho-valor { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.gd-click { cursor: pointer; }
.gd-click:hover { background: var(--surface-2); border-radius: 6px; }
.nicho-click { cursor: pointer; border-radius: 6px; padding: 1px 4px; margin: -1px -4px; }
.nicho-click:hover { background: var(--surface-2); }
.nicho-click:hover .nicho-nome { color: var(--brand-ink); }

/* ---------- gráfico de recebimentos por dia ---------- */
.gd-grafico { display: flex; gap: 3px; align-items: flex-end; padding: 16px 14px 10px; min-width: 940px; }
.gd-col { flex: 1; min-width: 26px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.gd-valor { font-size: 9.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; height: 13px; white-space: nowrap; }
.gd-area { width: 100%; height: 120px; display: flex; align-items: flex-end; }
.gd-pilha { width: 100%; display: flex; flex-direction: column; border-radius: 3px 3px 0 0; overflow: hidden; }
.gd-pago { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.gd-pendente { background: rgba(250, 178, 25, .55); }
.gd-dia { font-size: 10px; color: var(--muted); border-top: 1px solid var(--grid); width: 100%; text-align: center; padding-top: 4px; font-variant-numeric: tabular-nums; }
.gd-cli { font-size: 9.5px; color: var(--good-text); height: 13px; font-variant-numeric: tabular-nums; }
.gd-legenda { padding: 4px 16px 12px; font-size: 11px; color: var(--muted); font-weight: 300; }

/* ---------- responsivo: aproveita a tela que existe ---------- */
.shell { max-width: 100vw; }
.tabela-wrap { max-width: 100%; }
.topbar-mobile { display: none; }

/* notebooks / telas médias: tabela mais compacta pra caber mais coluna */
@media (max-width: 1500px) {
  .main { padding: 24px 22px; }
  th, td { padding-left: 10px; padding-right: 10px; }
  td { font-size: 13px; }
  .nome-loja { max-width: 190px; }
}
@media (max-width: 1250px) {
  .sidebar { width: 178px; }
  .logo { padding: 0 16px 20px; font-size: 15px; }
  .nav a { padding: 10px 16px; font-size: 12.5px; }
  .main { padding: 20px 16px; }
  th { font-size: 10.5px; letter-spacing: .04em; }
  th, td { padding-left: 8px; padding-right: 8px; }
  td { font-size: 12.5px; }
  .nome-loja { max-width: 150px; }
  .filtros input[type="text"] { width: 200px; }
}

/* ---------- CELULAR / TABLET ---------- */
@media (max-width: 860px) {
  /* barra superior fixa com hambúrguer */
  .topbar-mobile {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 70;
    background: var(--sidebar-bg); border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .btn-menu {
    background: rgba(255,255,255,.06); border: 1px solid var(--grid); color: var(--ink);
    font-size: 18px; line-height: 1; padding: 7px 12px; border-radius: 10px; cursor: pointer;
  }

  /* menu lateral vira gaveta */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100dvh; width: 250px; z-index: 80;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.5);
  }
  .sidebar.aberta { transform: none; }
  .backdrop { display: none; }
  .backdrop.ativo {
    display: block; position: fixed; inset: 0; z-index: 75;
    background: rgba(0,0,0,.55); backdrop-filter: blur(2px);
  }
  .nav a { padding: 13px 20px; font-size: 14px; }

  .main { padding: 16px 12px; max-width: 100%; }
  .main h2 { font-size: 17px; }
  .main .sub { font-size: 12px; margin-bottom: 16px; }

  /* cards e filtros empilham */
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .tile { padding: 12px 13px; }
  .tile .valor { font-size: 19px; }
  .tile .rotulo, .tile .detalhe { font-size: 11px; }
  .filtros { flex-direction: column; align-items: stretch; }
  .filtros input, .filtros select, .filtros button { width: 100% !important; }

  /* tabelas: rolam dentro do card, com dica visual */
  .card { border-radius: 12px; }
  .tabela-wrap { -webkit-overflow-scrolling: touch; }
  th { font-size: 10px; padding: 8px 9px; }
  td { font-size: 12px; padding: 8px 9px; }
  .nome-loja { max-width: 130px; }

  /* ficha da loja, linha do tempo e nichos em coluna única */
  .ficha-grid { grid-template-columns: 1fr; padding: 12px 14px; }
  .tl-linha { flex-direction: column; align-items: flex-start; gap: 5px; }
  .tl-quem { text-align: left; min-width: 0; }
  .tl-quando, .tl-tipo { min-width: 0; }
  .nicho-linha { grid-template-columns: 108px 1fr 76px; gap: 8px; }
  .nicho-nome, .nicho-valor { font-size: 11.5px; }

  /* modais ocupam a tela */
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal { width: 100%; padding: 20px 16px; max-height: 88vh; border-radius: 16px 16px 12px 12px; }
  .modal > div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .modal-acoes { flex-direction: column-reverse; }
  .modal-acoes button { width: 100%; }

  /* botões de ação da ficha ocupam a largura */
  .btn-pri, .btn-sec, .btn-perigo, .btn-sucesso { font-size: 12.5px; padding: 9px 14px; }

  .login-card { width: 100%; max-width: 360px; padding: 30px 22px; }
  .rel-cabecalho { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .tiles { grid-template-columns: 1fr; }
  .nicho-linha { grid-template-columns: 92px 1fr 68px; }
}

.aviso {
  background: rgba(250,178,25,.10); border: 1px solid rgba(250,178,25,.35);
  border-radius: 10px; padding: 11px 15px; font-size: 13px; margin-bottom: 16px;
}
.aviso a { color: var(--brand-ink); }
.vazio { padding: 34px; text-align: center; color: var(--muted); font-weight: 300; }

/* ---------- impressão (relatório sai claro no papel) ---------- */
@media print {
  .sidebar, .nao-imprime { display: none !important; }
  body { background: #fff; color: #111; }
  .main { padding: 0; max-width: none; }
  .card, .tile { background: #fff; border-color: #ccc; break-inside: avoid; }
  .card .card-titulo, .main h2, .tile .valor, td, th { color: #111; }
  .tile .rotulo, .tile .detalhe, .main .sub, .rel-rodape { color: #555; }
  .chip { border: 1px solid #bbb; background: none !important; color: #333 !important; }
  .wordmark { color: #111; }
  .wordmark .hub { color: #2563eb; }
  tbody tr:hover { background: none; }
}
