/* ============================================================
   SHENLONG — Base (reset, tipografia, shell de navegação,
   primitivos compartilhados). Carregar APÓS tokens.css.
   Componentes de módulo (dashboard, kanban, cards por tipo)
   ficam em seus próprios arquivos.
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;                  /* dvh evita "pulo" da barra de endereço no mobile */
  font-variant-numeric: tabular-nums;  /* números alinhados em coluna (dados) — zero limpo da fonte nativa */
  overflow-x: hidden;                  /* sem arrasto horizontal solto (áreas roláveis são internas) */
  overscroll-behavior-y: none;         /* sem "elástico" ao chegar no fim */
  -webkit-text-size-adjust: 100%;      /* iOS não infla a fonte em landscape */
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
::selection { background: var(--brand-bg); }

/* Ícone SVG: tamanho-padrão seguro (selectores específicos sobrescrevem) */
.ic { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- App shell (tela inteira — a "moldura" do protótipo era só mockup) ---------- */
.app {
  display: flex; min-height: 100vh; min-height: 100dvh;
  background: var(--bg);
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 26px 30px 34px; overflow: auto; }
.content-wrap { max-width: 1560px; margin: 0 auto; }

/* ---------- Dock grafite (icon-only, label no hover; ativo = quadrado branco) ---------- */
.rail {
  width: 68px; flex-shrink: 0;
  background: var(--rail);
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 14px 10px;
  position: sticky; top: 0; height: 100vh;
  /* 19/jul: sticky cria stacking context; sem z-index o label de hover
     ("Financeiro") ficava atrás do conteúdo da página. */
  z-index: var(--z-sticky);
}
.rail-logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  margin-bottom: 14px; flex-shrink: 0;
}
.rail-ic {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; cursor: pointer; position: relative;
  color: var(--rail-ic); transition: background .18s var(--ease), color .18s;
}
.rail-ic .ic { width: 19px; height: 19px; }
.rail-ic:hover { background: var(--rail-hover); color: #fff; }
.rail-ic.active { background: #fff; color: var(--brand); }
.rail-ic .badge {
  position: absolute; top: 7px; right: 8px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--late); border: 1.5px solid var(--rail);
}
.rail-ic.active .badge { border-color: var(--brand); }
.rail-ic .rl-label {
  position: absolute; left: 52px; top: 50%;
  transform: translateY(-50%) translateX(-4px);
  background: var(--ink); color: #fff; padding: 6px 11px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease;
  box-shadow: var(--sh-2); z-index: var(--z-tooltip);
}
.rail-ic:hover .rl-label { opacity: 1; transform: translateY(-50%) translateX(0); }
.rail-sep { width: 26px; height: 1px; background: var(--rail-border); margin: 7px 0; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* ---------- Chrome (barra de contexto por módulo — v2) ---------- */
.ctxbar {
  /* SEM overflow:hidden — ele recortava o resultado da busca, que é
     absoluto e sai para fora da barra. O estouro em tela estreita é
     resolvido pelas abas roláveis e pelo min-width:0 da busca. */
  position: sticky; top: 0; z-index: var(--z-sticky); max-width: 100vw;
  background: rgba(248,249,251,.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  min-height: 68px; display: flex; align-items: center; gap: 12px; padding: 10px 22px;
}
.ctx-title { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
a.ctx-title { color: var(--ink); text-decoration: none; border-radius: 8px; padding: 3px 7px; margin-left: -7px; }
a.ctx-title:hover { background: var(--surface-2); }
/* A barra precisa caber em qualquer tela: com 6 abas (Indicadores) ela
   estourava em 1180px e empurrava o sino para fora da janela. As abas
   rolam na horizontal quando faltar espaço; título, busca e ação primária
   nunca são espremidos. */
.ctx-tabs { display: flex; gap: 3px; margin-left: 6px; align-items: center;
            overflow-x: auto; scrollbar-width: none; min-width: 0; flex-shrink: 1; }
.ctx-tabs::-webkit-scrollbar { display: none; }
/* divisor entre as abas de LEITURA e as de manutenção (alimentar/cadastrar):
   seis abas de peso igual escondem a hierarquia do módulo. */
.ctx-sep { width: 1px; height: 16px; background: var(--border); margin: 0 8px; flex: none; }
.ctx-tab {
  display: flex; align-items: center; gap: 7px; min-height: 38px;
  font-size: 14px; color: var(--muted); padding: 0 12px; border-radius: 9px;
  cursor: pointer; white-space: nowrap;
  transition: background .14s, color .14s, box-shadow .14s;
}
.ctx-tab .ic { width: 14px; height: 14px; opacity: .8; }
.ctx-tab:hover { color: var(--brand); background: var(--surface-2); }
.ctx-tab.active, .ctx-tab.active:hover {
  color: #fff; font-weight: 600; background: var(--brand);
  box-shadow: var(--sh-1);
}
.ctx-spacer { flex: 1; }

/* ---------- Busca (⌘K) — pílula branca ---------- */
.kbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: none; border-radius: 11px;
  min-height: 40px; padding: 0 12px; min-width: 300px; max-width: 460px; flex: 1 1 420px;
  color: var(--faint); font-size: 14px; cursor: text; box-shadow: var(--sh-chrome);
}
.kbar .ic { width: 15px; height: 15px; flex-shrink: 0; }
.kbar input { border: none; background: none; outline: none; flex: 1; min-width: 0; font-size: 14px; color: var(--ink); }
/* o Chrome desenha o próprio "x" em input[type=search] e ficavam DOIS
   botões de limpar lado a lado — o nosso (.kbar-x) é o que fica */
.kbar input::-webkit-search-cancel-button,
.kbar input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.kbar .k { font-family: var(--font-mono); font-size: 10.5px; flex-shrink: 0; background: var(--surface-2); border-radius: 4px; padding: 2px 5px; }

/* ---------- Botões ---------- */
.btn {
  font-size: 14px; font-weight: 650; cursor: pointer; border: none;
  border-radius: var(--r-btn); padding: 9px 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap;   /* rótulo do botão em duas linhas: sempre errado */
  transition: background .14s, color .14s, border-color .14s, box-shadow .14s;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: var(--surface-2); color: var(--muted); border: 1px solid transparent; }
.btn.ghost:hover { color: var(--ink); }
/* "quiet" do v2: branco flutuante, sem borda */
.btn.outline { background: var(--surface); color: var(--muted); border: none; box-shadow: var(--sh-chrome); }
.btn.outline:hover { color: var(--ink); }
.btn .ic { width: 15px; height: 15px; }

/* ---------- Icon button (sino etc.) — redondo branco (v2) ---------- */
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--surface); display: grid; place-items: center; color: var(--muted); cursor: pointer; position: relative; flex-shrink: 0; box-shadow: var(--sh-chrome); transition: color .14s; }
.icon-btn:hover { color: var(--ink); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn .nbadge { position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px; background: var(--late); color: #fff; font-size: 9px; font-weight: 700; font-family: var(--font-mono); display: grid; place-items: center; border: 1.5px solid var(--surface); }

/* ---------- Avatar ---------- */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 600; color: #fff;
}
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.lg { width: 30px; height: 30px; font-size: 11px; }

/* ---------- Rótulo de TIPO (neutro — cor é reservada a estado) ---------- */
.typetag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }

/* ---------- Chip genérico (neutro) ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--r-tag); padding: 2px 8px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border-soft);
}
.tag .tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }

/* ---------- Ponto de status (estado/saúde) ---------- */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.late { background: var(--late); } .dot.warn { background: var(--warn); } .dot.ok { background: var(--ok); }
.dot.norm { background: #C7CCD3; } .dot.info { background: var(--brand); }

/* ---------- Painel (v2: sombra no lugar de borda) ---------- */
.panel { background: var(--surface); border: none; box-shadow: var(--sh-1); border-radius: var(--r-card); padding: 16px 18px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-h h3 { font-size: 15.5px; font-weight: 600; }
.panel-h a { font-size: 12px; color: var(--brand); font-weight: 500; cursor: pointer; }

/* ---------- Tipografia utilitária ---------- */
.page-title { font-size: 21px; font-weight: 600; letter-spacing: -.01em; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, #EEF0F3 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- Título editorial de página (v2) ---------- */
.intro { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 26px; }
.intro h1 { font-size: 26px; line-height: 1.16; letter-spacing: -.025em; font-weight: 650; }
.intro p { font-size: 15px; color: var(--muted); margin-top: 7px; max-width: 66ch; }
.intro-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- Responsivo (estrutural) ---------- */
@media (max-width: 720px) {
  /* Rail vira dock inferior; respeita a área do "home indicator" (safe-area).
     Rola na horizontal se houver muitos módulos (nunca quebra em 2 linhas). */
  .rail {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; width: 100%;
    height: calc(58px + env(safe-area-inset-bottom));
    flex-direction: row; justify-content: space-around; align-items: flex-start; gap: 2px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right));
    border-top: 1px solid var(--rail-border); z-index: var(--z-sticky);
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .rail::-webkit-scrollbar { display: none; }
  .rail-logo, .rail-sep { display: none; }
  .rail-foot { margin-top: 0; flex-direction: row; gap: 2px; }
  .rail-ic { width: 42px; height: 42px; flex: 0 0 auto; }
  .rail-ic .ic { width: 21px; height: 21px; }
  .rail-ic .rl-label { display: none; }

  /* Barra de contexto: respeita o notch/Dynamic Island no topo e as laterais;
     abas roláveis na horizontal; some a dica ⌘K; encolhe a busca. */
  .ctxbar {
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    gap: 8px; min-height: calc(58px + env(safe-area-inset-top));
  }
  .ctx-title { font-size: 15.5px; }
  .ctx-tabs { margin-left: 2px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-shrink: 1; min-width: 0; }
  .ctx-tabs::-webkit-scrollbar { display: none; }
  .kbar { min-width: 0; max-width: 150px; padding: 0 10px; }
  .kbar .k { display: none; }                       /* esconde a dica ⌘K (sem teclado no celular) */

  /* Conteúdo: laterais com safe-area (landscape), fundo acima do dock. */
  .content {
    padding: 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
  .content-wrap { max-width: 100%; }
  .intro { display: block; }
  .intro-actions { margin-top: 12px; }
}

/* Faixa intermediária (notebook, janela pela metade): o módulo Indicadores
   tem 6 abas e a barra não cabia — a busca encolhe e o atalho ⌘K some antes
   de qualquer coisa ser empurrada para fora da janela. */
@media (max-width: 1280px) {
  .kbar { min-width: 0; flex: 0 1 clamp(150px, 20vw, 320px); }
  .kbar .k { display: none; }
}
@media (max-width: 1120px) {
  .ctx-tab { padding: 0 9px; font-size: 13.5px; }
  .ctx-sep { margin: 0 5px; }
  .ctxbar { gap: 9px; padding: 10px 16px; }
}
@media (max-width: 1040px) {
  /* vira só a lupa; abre ao receber o foco */
  .kbar { min-width: 0; flex: 0 0 42px; padding: 0 12px; transition: flex-basis .16s var(--ease); }
  .kbar input { width: 0; min-width: 0; padding: 0; }
  .kbar:focus-within { flex-basis: clamp(200px, 32vw, 320px); }
  .kbar:focus-within input { width: auto; flex: 1; }
}

/* Telas bem estreitas: libera espaço — some a busca, encolhe o botão primário */
@media (max-width: 480px) {
  .kbar-wrap { display: none; }
  .ctxbar .btn.primary { padding: 9px 12px; font-size: 13px; flex: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Avatar com FOTO (perfil.php) — a foto substitui a bolinha de iniciais.
   O span mantém as mesmas medidas; a img preenche redonda. */
.avatar.av-img{padding:0;overflow:hidden;background:var(--surface-2);}
.avatar.av-img img{width:100%;height:100%;object-fit:cover;border-radius:inherit;display:block;}
