/* ═══════════════════════════════════════════════════════════════════════
   MELO UI — biblioteca de componentes do design system --m- (26/07/2026)
   Fundação da migração v2 (Onda 1). Requer os TOKENS de static/style.css
   (--m-bg/--m-surface/--m-ink/--m-accent/... claro+escuro automáticos).

   Uso em telas novas:
     <link rel="stylesheet" href="{{ static_v('style.css') }}">
     <link rel="stylesheet" href="{{ static_v('melo-ui.css') }}">
   Componentes extraídos do piloto aprovado (financeiro_comissoes_v2).
   Telas legadas dark (#0f172a) usam o bloco de ALIASES no fim.
   ═══════════════════════════════════════════════════════════════════════ */

.m-body { background: var(--m-bg); color: var(--m-ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px; margin: 0; }

/* pagehead COMPACTO (dono 01/08: "páginas deveriam começar mais acima") —
   !important vence os style="margin-top:16px" inline dos templates */
.pagehead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
            margin-top: 2px !important; margin-bottom: 10px; }
.pagehead h1 { margin: 0; font-size: 18px; color: var(--m-heading); }
.pagehead .crumb { color: var(--m-muted); font-size: 11.5px; }
.pagehead .right { margin-left: auto; display: flex; gap: 8px; }
/* selo "v3 · página nativa" virou ruído pós-flip — some em todas as telas */
.pagehead .eyebrow, .conteudo > .pagehead .eyebrow { display: none !important; }
/* HEADER INTERNO DA V1 (logo + HOME/COM/FIN/.../V2/SAI) NUNCA aparece dentro
   de página v3 (dono 01/08: "menus velhos aparecendo") — os JS compat
   reexibem elementos dele pós-login, por isso o !important. O markup fica no
   DOM (ids user-info/link-*/logout-btn são consultados pelos JS); navegação
   e busca = shell v3 + Ctrl+K. */
body.v3 header.header, body.v3 .header-content { display: none !important; }
.conteudo { padding: 8px 18px 60px; max-width: 1500px; margin: 0 auto; }

.card { background: var(--m-surface); border: 1px solid var(--m-border);
  border-radius: var(--m-radius); box-shadow: var(--m-shadow); padding: 16px 18px; margin-bottom: 16px; }
.card > h2 { margin: 0 0 2px; font-size: 15px; color: var(--m-heading); }
.card .sub { font-size: 12px; color: var(--m-muted); margin-bottom: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--m-border);
  background: var(--m-surface); color: var(--m-ink); border-radius: var(--m-radius);
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--m-accent); color: var(--m-accent); }
.btn.pri { background: var(--m-accent); border-color: var(--m-accent); color: #fff; }
.btn.pri:hover { filter: brightness(1.08); color: #fff; }
.btn.perigo { color: var(--m-danger); }
.btn.perigo:hover { border-color: var(--m-danger); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--m-accent); outline-offset: 1px; }

.pill { display: inline-block; border-radius: 20px; padding: 2px 10px; font-size: 10.5px; font-weight: 700; }
.pill.ok { background: var(--m-ok-soft); color: var(--m-ok); }
.pill.warn { background: var(--m-warn-soft); color: var(--m-warn); }
.pill.bad { background: var(--m-danger-soft); color: var(--m-danger); }
.pill.mut { background: var(--m-accent-soft); color: var(--m-accent); }

.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filtros input[type=text], .filtros input[type=date], .filtros input[type=month], .filtros select {
  border: 1px solid var(--m-border); background: var(--m-bg); color: var(--m-ink);
  border-radius: var(--m-radius); padding: 8px 11px; font-size: 12.5px; }

.twrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--m-muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--m-border); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--m-border); vertical-align: top; }
table.t tr:last-child td { border-bottom: none; }
table.t tbody tr:hover td { background: var(--m-accent-soft); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; font-weight: 700; }
.vazio { text-align: center; color: var(--m-muted); padding: 26px 10px; font-size: 13px; }

.mfundo { display: none; position: fixed; inset: 0; background: rgba(4,12,34,.55); z-index: 90;
  overflow-y: auto; padding: 24px 12px; }
.mfundo.aberto { display: block; }
.mcaixa { background: var(--m-surface); border: 1px solid var(--m-border); border-radius: 10px;
  max-width: 760px; margin: 0 auto; padding: 20px; box-shadow: var(--m-shadow); }
.mcaixa h3 { margin: 0 0 4px; font-size: 16px; color: var(--m-heading); }

#toast { position: fixed; top: 16px; right: 16px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.tmsg { background: var(--m-heading); color: #fff; border-radius: 8px; padding: 11px 16px;
  font-size: 13px; box-shadow: var(--m-shadow); max-width: 340px; }
.tmsg.ok { background: var(--m-ok); }
.tmsg.erro { background: var(--m-danger); }

/* ── SHELL v3 (30/07): topbar fina + SIDEBAR recolhível ─────────────────
   Portado do mockup aprovado demo_ui_v2_full.html. Uso: body.m-body.v3 +
   include _v3_nav.html. Estado: body.mini (recolhido, persistido) e
   body.menu-aberto (off-canvas mobile). */
:root { --m-sidebar-w: 232px; --m-top-h: 54px; }
.v3top { position: fixed; top: 0; left: 0; right: 0; height: var(--m-top-h);
  z-index: 85; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--m-surface); border-bottom: 1px solid var(--m-border); }
.v3top .hamb { display: none; border: 1px solid var(--m-border); background: var(--m-surface);
  color: var(--m-ink); border-radius: var(--m-radius); padding: 5px 10px;
  font-size: 15px; cursor: pointer; }
.v3top .brand { font-weight: 800; color: var(--m-heading); font-size: 15px;
  white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.v3top .brand img { height: 24px; }
.v3top .brand small { color: var(--m-muted); font-weight: 400; }
.v3top .search { flex: 1; max-width: 560px; display: flex; align-items: center;
  gap: 8px; border: 1px solid var(--m-border); background: var(--m-bg);
  border-radius: var(--m-radius); padding: 7px 12px; color: var(--m-muted);
  font-size: 13px; cursor: pointer; }
.v3top .kbd { font-family: var(--m-mono); font-size: 10px; border: 1px solid var(--m-border);
  border-radius: 4px; padding: 1px 5px; margin-left: auto; }
.v3top .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.v3top .quem { font-size: 12px; color: var(--m-muted); white-space: nowrap; }

/* sidebar AUTO-HIDE (dono 30/07): 54px só-ícones por padrão; expande no
   HOVER sobrepondo o conteúdo (não empurra o layout). Mobile: off-canvas. */
.v3side { position: fixed; top: var(--m-top-h); bottom: 0; left: 0;
  width: 54px; z-index: 80; background: var(--m-surface);
  border-right: 1px solid var(--m-border); padding: 8px 0 14px;
  overflow-y: auto; overflow-x: hidden;
  transition: width .16s ease, transform .2s ease; }
.v3side:hover { width: var(--m-sidebar-w); box-shadow: var(--m-shadow); }
.v3side .grp { text-transform: uppercase; letter-spacing: .08em; font-size: 10px;
  font-weight: 700; color: var(--m-muted); padding: 12px 16px 4px;
  white-space: nowrap; display: none; }
.v3side .it { display: flex; align-items: center; gap: 9px; padding: 9px 0;
  justify-content: center; font-size: 13px; color: var(--m-ink); cursor: pointer;
  text-decoration: none; border-left: 3px solid transparent; white-space: nowrap; }
.v3side .it:hover { background: var(--m-accent-soft); }
.v3side .it.on { background: var(--m-accent-soft); border-left-color: var(--m-accent);
  color: var(--m-accent); font-weight: 700; }
.v3side .it .ico { flex: 0 0 20px; text-align: center; }
.v3side .txt, .v3side .badge-n { display: none; }
.v3side:hover .grp { display: block; }
.v3side:hover .txt { display: inline; }
.v3side:hover .it { justify-content: flex-start; padding: 8px 16px; }
.v3side:hover .badge-n { display: inline-block; margin-left: auto;
  background: var(--m-danger); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; padding: 1px 7px; }
/* submenus (accordion espelhando o menu v2) */
.v3side .seta { margin-left: auto; font-size: 10px; color: var(--m-muted);
  display: none; transition: transform .15s ease; }
.v3side:hover .seta { display: inline; }
.v3side .g.open .seta { transform: rotate(90deg); }
.v3side .subs { display: none; }
.v3side:hover .g.open + .subs { display: block; }
.v3side .subs a { display: block; padding: 6px 14px 6px 42px; font-size: 12.5px;
  color: var(--m-muted); text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.v3side .subs a:hover { color: var(--m-accent); background: var(--m-accent-soft); }
.v3side .subs a.on { color: var(--m-accent); font-weight: 700; }
@media (max-width: 820px) {
  .v3side .seta { display: inline !important; }
  body.menu-aberto .v3side .g.open + .subs { display: block; }
}

body.v3 .conteudo { margin-left: 54px; margin-top: var(--m-top-h); }
.v3overlay { display: none; position: fixed; inset: var(--m-top-h) 0 0 0;
  background: rgba(0, 0, 0, .4); z-index: 75; }
/* barra inferior mobile (mockup demo_ui_v2_full: .mob-nav) */
.v3mob { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 82;
  grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--m-border);
  background: var(--m-surface); padding: 7px 0 10px; font-size: 10px;
  text-align: center; color: var(--m-muted); }
.v3mob .mi { text-decoration: none; color: var(--m-muted); cursor: pointer; }
.v3mob .mi.on { color: var(--m-accent); font-weight: 700; }
.v3mob .ico { font-size: 19px; display: block; }

@media (max-width: 820px) {
  .v3top .hamb { display: inline-flex; }
  .v3top .search { display: none; }
  .v3mob { display: grid; }
  body.v3 .conteudo { padding-bottom: 86px; }
  .v3side { transform: translateX(-100%); width: var(--m-sidebar-w) !important; }
  .v3side .grp, .v3side .txt { display: block !important; }
  .v3side .txt { display: inline !important; }
  .v3side .it { justify-content: flex-start !important; padding: 8px 16px !important; }
  body.menu-aberto .v3side { transform: translateX(0); }
  body.menu-aberto .v3overlay { display: block; }
  body.v3 .conteudo { margin-left: 0 !important; }
}

/* ── TOPNAV v3 (30/07): menu padrão das páginas nativas ──────────────── */
.topnav { position: sticky; top: 0; z-index: 80; background: var(--m-surface);
  border-bottom: 1px solid var(--m-border); box-shadow: var(--m-shadow); }
.topnav-in { max-width: 1500px; margin: 0 auto; display: flex; align-items: center;
  gap: 4px; padding: 8px 18px; flex-wrap: wrap; }
.topnav .brand { display: flex; align-items: center; gap: 8px; font-weight: 800;
  color: var(--m-heading); font-size: 14px; margin-right: 10px; white-space: nowrap; }
.topnav .brand img { height: 24px; }
.topnav a.navlk { color: var(--m-muted); text-decoration: none; font-size: 12.5px;
  font-weight: 600; padding: 6px 10px; border-radius: var(--m-radius); white-space: nowrap; }
.topnav a.navlk:hover { color: var(--m-accent); background: var(--m-accent-soft); }
.topnav a.navlk.ativo { color: var(--m-accent); background: var(--m-accent-soft); }
.topnav .sp { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topnav .quem { font-size: 12px; color: var(--m-muted); white-space: nowrap; }
.topnav .btn { padding: 5px 10px; font-size: 12px; }

.mlist { display: none; }
.mcard { background: var(--m-surface); border: 1px solid var(--m-border); border-radius: var(--m-radius);
  padding: 13px 15px; margin-bottom: 10px; box-shadow: var(--m-shadow); }
@media (max-width: 780px) {
  .conteudo { padding: 12px 10px 70px; }
  .m-esconde-mobile { display: none; }
  .mlist { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── ALIASES p/ telas migradas da paleta dark #0f172a (Onda 1) ──────────
   Telas que usavam --bg/--card/--border/--tx/--mut hardcoded passam a
   seguir os tokens (claro/escuro automático) só trocando o :root local
   por estas variáveis. */
.m-compat { --bg: var(--m-bg); --card: var(--m-surface); --border: var(--m-border);
  --tx: var(--m-ink); --mut: var(--m-muted); }
