/* ═══ Logica Mail — painel ═══
   Tokens do Rovemark Brand System v1. NÃO reinventar cores.
   Sovereign Blue = ação/marca. Graphite/Ivory = superfícies.
   O Mail é infraestrutura da casa: usa o azul institucional, não cor de módulo. */

@font-face {
  font-family: 'Manrope';
  src: url('/fontes/manrope.woff2') format('woff2');
  font-weight: 400 700; font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/fontes/ibm-plex-mono.woff2') format('woff2');
  font-weight: 400 500; font-display: swap;
}

:root {
  --graphite: #111318;
  --ivory: #f4f1ea;
  --blue: #3455e8;
  --steel: #a7afbd;

  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf8f2;
  --ink: #111318;
  --muted: #5f636e;
  --faint: #9aa0ac;
  --line: #e6e2d8;
  --line-soft: #efece3;
  --hair: #e9e6dc;
  --glass: rgba(244, 241, 234, .82);
  --grid-line: rgba(17, 19, 24, .024);

  --brand: #3455e8;
  --brand-soft: rgba(52, 85, 232, .10);
  --brand-ink: #2440c9;

  --danger: #c0392b;  --danger-soft: rgba(192, 57, 43, .10);
  --warn:   #b8860b;  --warn-soft:   rgba(184, 134, 11, .12);
  --ok:     #1a7f5a;  --ok-soft:     rgba(26, 127, 90, .12);
  --on-ok: #fff; --on-danger: #fff; --on-warn: #0d0f13;

  --sh-1: 0 1px 2px rgb(17 19 24 / 4%), 0 1px 3px rgb(17 19 24 / 5%);
  --sh-2: 0 1px 2px rgb(17 19 24 / 4%), 0 8px 20px -6px rgb(17 19 24 / 9%);
  --sh-3: 0 2px 4px rgb(17 19 24 / 4%), 0 18px 40px -12px rgb(17 19 24 / 16%);
  --ring: 0 0 0 3px rgba(52, 85, 232, .18);

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px;

  --font-sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

:root[data-theme="dark"] {
  --graphite: #e8eaee; --ivory: #15181e;
  --bg: #0d0f13; --surface: #15181e; --surface-2: #1b1f27;
  --ink: #eaecf0; --muted: #a3aab6; --faint: #6b7280;
  --line: #272c35; --line-soft: #20242c; --hair: #232830; --steel: #7b8494;
  --brand: #5b78ff; --brand-soft: rgba(91,120,255,.16); --brand-ink: #7d94ff;
  --ring: 0 0 0 3px rgba(91,120,255,.30);
  --danger: #ef5b4d; --danger-soft: rgba(239,91,77,.15);
  --warn: #e0b04a;   --warn-soft: rgba(224,176,74,.15);
  --ok: #2ec48c;     --ok-soft: rgba(46,196,140,.15);
  --on-ok: #0d0f13; --on-danger: #0d0f13; --on-warn: #0d0f13;
  --sh-1: 0 1px 2px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.02);
  --sh-2: 0 2px 8px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.03);
  --sh-3: 0 12px 32px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.04);
  --glass: rgba(13,15,19,.82);
  --grid-line: rgba(255,255,255,.022);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font-sans);
  background: var(--bg); color: var(--ink);
  line-height: 1.5; font-size: 14.5px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
/* grade de papel-milimetrado: ambiente, não decoração */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px),
                    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
}
::selection { background: var(--blue); color: #fff; }
:where(a,button,input,select,textarea,[tabindex]):focus-visible {
  outline: none; box-shadow: var(--ring); border-radius: var(--r-sm);
}
.mono { font-family: var(--font-mono); }
.tabular { font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
}

/* ═══ shell ═══ */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.shell.colapsada { grid-template-columns: 64px 1fr; }

.lateral {
  border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; padding: 14px 10px;
  position: sticky; top: 0; height: 100vh; z-index: 30;
}
.marca { display: flex; align-items: center; gap: 9px; padding: 2px 6px 16px; }
.marca-sigla {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11.5px;
  font-family: var(--font-mono); flex: none; letter-spacing: .02em;
  border: 0; padding: 0; font-family: var(--font-mono);
}
.marca-sigla .marca-lm { grid-area: 1/1; }
.marca-sigla .marca-abrir { grid-area: 1/1; display: none; }
/* com o menu fechado, a própria marca abre — e o ícone só aparece no hover,
   como no Shell do sistema: a identidade fica em repouso, a ação em intenção */
.marca-botao { cursor: pointer; transition: background .16s; }
.marca-botao:hover { background: var(--brand-ink); }
.marca-botao:hover .marca-lm { display: none; }
.marca-botao:hover .marca-abrir { display: block; }
.marca-txt { min-width: 0; overflow: hidden; }
.marca-nome { font-weight: 700; letter-spacing: -.015em; font-size: 14.5px; white-space: nowrap; }
.marca-sub { font-family: var(--font-mono); font-size: 9px; color: var(--faint); letter-spacing: .11em; text-transform: uppercase; white-space: nowrap; }
.btn-colapsar {
  margin-left: auto; display: grid; place-items: center; width: 26px; height: 26px;
  border-radius: 6px; border: 0; background: none; color: var(--faint); cursor: pointer;
  opacity: .5; transition: opacity .16s, background .16s;
}
.marca:hover .btn-colapsar { opacity: 1; }
.btn-colapsar:hover { background: var(--line-soft); color: var(--ink); }

.nav-secao { padding: 10px 8px 5px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; height: 34px;
  border-radius: var(--r-sm); color: var(--muted); text-decoration: none;
  font-size: 13px; font-weight: 500; cursor: pointer; border: 0; background: none;
  width: 100%; text-align: left; font-family: inherit; position: relative;
  transition: background .16s ease, color .16s ease;
}
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
/* ícone em quadradinho, como nos módulos do sistema */
.nav-ico-caixa {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  flex: none; background: var(--line-soft); color: var(--muted); transition: background .16s, color .16s;
}
.nav-item[aria-current="page"] .nav-ico-caixa { background: var(--brand); color: #fff; }
.nav-item:hover .nav-ico-caixa { background: var(--hair); }
.nav-item[aria-current="page"]:hover .nav-ico-caixa { background: var(--brand); }
.nav-rotulo { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-conta {
  margin-left: auto; font-family: var(--font-mono); font-size: 9.5px;
  color: var(--faint); font-weight: 500; flex: none;
}
.nav-item[aria-current="page"] .nav-conta { color: var(--brand); }

/* colapsada: só o quadradinho, com dica ao passar o mouse */
.shell.colapsada .nav-rotulo,
.shell.colapsada .nav-conta,
.shell.colapsada .marca-txt,
.shell.colapsada .nav-secao,
.shell.colapsada .pe-rotulo { display: none; }
.shell.colapsada .nav-item { justify-content: center; padding: 6px; }
.shell.colapsada .marca { justify-content: center; padding-bottom: 14px; }
.shell.colapsada .btn-colapsar { display: none; }
.shell.colapsada .nav-item::after {
  content: attr(data-dica); position: absolute; left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%); background: var(--ink); color: var(--surface);
  padding: 4px 9px; border-radius: 6px; font-size: 11.5px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .14s; z-index: 60;
}
.shell.colapsada .nav-item:hover::after { opacity: 1; }

.lateral-pe { margin-top: auto; display: flex; flex-direction: column; gap: 3px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.pe-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 8px; height: 32px;
  border-radius: var(--r-sm); color: var(--muted); font-size: 12.5px; cursor: pointer;
  border: 0; background: none; width: 100%; text-align: left; font-family: inherit;
  text-decoration: none; transition: background .16s;
}
.pe-item:hover { background: var(--line-soft); color: var(--ink); }
.pe-quem { cursor: default; }
.pe-quem:hover { background: none; }
.pe-sair { color: var(--muted); }
.pe-sair:hover { background: var(--danger-soft); color: var(--danger); }
.pe-sair:hover .nav-ico-caixa { background: transparent; color: var(--danger); }
/* com o menu fechado, o sair também ganha dica */
.shell.colapsada .pe-item { justify-content: center; padding: 6px; position: relative; }
.shell.colapsada .pe-sair::after {
  content: attr(data-dica); position: absolute; left: calc(100% + 8px); top: 50%;
  transform: translateY(-50%); background: var(--ink); color: var(--surface);
  padding: 4px 9px; border-radius: 6px; font-size: 11.5px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .14s; z-index: 60;
}
.shell.colapsada .pe-sair:hover::after { opacity: 1; }
.pe-avatar { width: 22px; height: 22px; border-radius: 50%; flex: none; background: var(--line-soft); object-fit: cover; }

/* ═══ switcher de workspace ═══ */
.switcher { position: relative; padding: 0 2px 4px; }
.ws-botao {
  width: 100%; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px;
  border-radius: var(--r-sm); border: 0; background: var(--line-soft); color: var(--ink);
  font-family: inherit; font-size: 13px; cursor: pointer; transition: background .16s;
}
.ws-botao:hover { background: var(--hair); }
.ws-botao[aria-expanded="true"] { background: var(--brand-soft); }
.ws-quadrado {
  width: 20px; height: 20px; border-radius: 5px; background: var(--brand); color: #fff;
  display: grid; place-items: center; flex: none;
  font-family: var(--font-mono); font-size: 8.5px; font-weight: 600;
}
.ws-nome { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-seta { margin-left: auto; flex: none; color: var(--faint); transition: transform .18s; }
.ws-botao[aria-expanded="true"] .ws-seta { transform: rotate(180deg); }

.ws-menu {
  position: absolute; left: 2px; top: calc(100% + 2px); z-index: 50; width: 248px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh-3); padding: 4px; max-height: 340px; overflow-y: auto;
}
.ws-menu[hidden] { display: none; }
.ws-opcao {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 7px 8px;
  border-radius: 7px; border: 0; background: none; color: var(--ink);
  font-family: inherit; font-size: 13px; cursor: pointer; text-align: left;
  transition: background .14s;
}
.ws-opcao:hover { background: var(--line-soft); }
.ws-opcao-txt { min-width: 0; }
.ws-opcao-txt > span:first-child { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-check { margin-left: auto; color: var(--brand); font-weight: 700; flex: none; }
.ws-sep { height: 1px; background: var(--line-soft); margin: 4px 0; }

/* menu fechado: o switcher vira só o quadrado, e a lista abre ao lado */
.shell.colapsada .switcher { display: flex; justify-content: center; }
.shell.colapsada .ws-nome, .shell.colapsada .ws-seta { display: none; }
.shell.colapsada .ws-botao { width: 32px; padding: 0; justify-content: center; }
.shell.colapsada .ws-menu { left: calc(100% + 6px); top: 0; }

/* ═══ header ═══ */
.principal { display: flex; flex-direction: column; min-width: 0; }
.header {
  height: 60px; position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 0 26px;
  background: var(--glass); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.trilha { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-width: 0; }
.trilha .sep { color: var(--faint); }
.trilha .atual { font-weight: 600; color: var(--ink); white-space: nowrap; }
.header-acoes { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.busca {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 11px;
  border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line);
  color: var(--faint); font-size: 13px; cursor: pointer; font-family: inherit;
  transition: border-color .16s;
}
.busca:hover { border-color: var(--hair); }
.busca .tecla {
  font-family: var(--font-mono); font-size: 9.5px; padding: 2px 5px; border-radius: 4px;
  background: var(--line-soft); color: var(--faint);
}
.icone-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; transition: border-color .16s, color .16s;
}
.icone-btn:hover { border-color: var(--hair); color: var(--ink); }

/* O botao de expandir so existe com o menu fechado. Precisa vir DEPOIS de
   .icone-btn e com especificidade maior: `.icone-btn { display: grid }` tem o
   mesmo peso e venceria pela ordem, deixando o botao visivel sempre. */
.header .btn-expandir { display: none; }
.shell.colapsada .header .btn-expandir { display: grid; }

/* ═══ conteúdo ═══ */
.conteudo { padding: 24px 26px 60px; max-width: 1180px; width: 100%; }
.topo { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topo h1 { margin: 3px 0 0; font-size: 23px; font-weight: 700; letter-spacing: -.025em; }
.topo p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-hover { transition: transform .2s cubic-bezier(.16,1,.3,1), box-shadow .24s ease, border-color .2s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--hair); }

.grade { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.kpi { padding: 14px 16px; }
.kpi .n { font-size: 27px; font-weight: 700; letter-spacing: -.03em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.kpi .rodape { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.kpi.destaque .n { color: var(--brand); }
.kpi.risco .n { color: var(--danger); }

.track { background: var(--line-soft); border-radius: 999px; overflow: hidden; height: 5px; margin-top: 9px; }
.track > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .5s cubic-bezier(.16,1,.3,1); }

/* ═══ lista ═══ */
.lista { overflow: hidden; }
.lista-cab, .linha {
  display: grid; align-items: center; gap: 12px; padding: 10px 16px;
  grid-template-columns: var(--cols, 1fr);
}
.lista-cab {
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--faint);
}
.linha { border-top: 1px solid var(--line-soft); font-size: 13px; transition: background .14s ease; }
.linha:first-of-type { border-top: 0; }
.linha:hover { background: var(--surface-2); }
.linha.clicavel { cursor: pointer; }

.selo {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  background: var(--line-soft); color: var(--muted); white-space: nowrap; font-weight: 500;
}
.selo.ok     { background: var(--ok-soft);     color: var(--ok); }
.selo.risco  { background: var(--danger-soft); color: var(--danger); }
.selo.espera { background: var(--warn-soft);   color: var(--warn); }
.selo.marca  { background: var(--brand-soft);  color: var(--brand); }

.vazio { padding: 44px 20px; text-align: center; color: var(--faint); }
.vazio .t { font-weight: 600; color: var(--muted); margin-bottom: 4px; }

/* ═══ controles ═══ */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1px solid transparent;
  transition: background .16s ease, border-color .16s, transform .12s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--hair); }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .5; cursor: not-allowed; }

.inp {
  width: 100%; padding: 8px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: inherit; font-size: 13.5px;
}
.inp:focus { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.inp.mono { font-family: var(--font-mono); font-size: 12.5px; }

.filtros { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font-size: 12px; cursor: pointer;
  font-family: inherit; transition: all .14s ease;
}
.chip:hover { border-color: var(--hair); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: transparent; color: var(--brand); font-weight: 600; }

/* ═══ modal ═══ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(17,19,24,.42); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--sh-3); width: min(620px, 100%); max-height: 85vh; overflow: auto;
}
.modal-cab { padding: 18px 22px 12px; border-bottom: 1px solid var(--line-soft); }
.modal-corpo { padding: 18px 22px 22px; }

/* ═══ estados ═══ */
.skeleton { position: relative; overflow: hidden; background: var(--line-soft); border-radius: var(--r-sm); height: 14px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: brilho 1.4s infinite;
}
@keyframes brilho { to { transform: translateX(100%); } }
.revelar { animation: sobe .34s cubic-bezier(.16,1,.3,1) both; }
@keyframes sobe { from { opacity: 0; transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.aviso { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--r-md); font-size: 13px; margin-bottom: 16px; }
.aviso.espera { background: var(--warn-soft); color: var(--warn); }
.aviso.risco  { background: var(--danger-soft); color: var(--danger); }

/* ═══ linha do tempo de eventos ═══ */
.tempo { display: grid; gap: 0; margin-top: 6px; }
.tempo-item { display: grid; grid-template-columns: 15px 1fr auto; gap: 11px; align-items: start; padding: 7px 0; }
.tempo-marca { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-top: 6px; justify-self: center; position: relative; }
.tempo-item:not(:last-child) .tempo-marca::after {
  content: ''; position: absolute; top: 11px; left: 3px; width: 1px; height: calc(100% + 10px); background: var(--line);
}

/* ═══ entrar ═══ */
.entrar { display: grid; place-items: center; min-height: 100vh; padding: 20px; position: relative; z-index: 1; }
.entrar-card { width: min(410px, 100%); padding: 30px; }
.entrar h1 { margin: 14px 0 5px; font-size: 20px; letter-spacing: -.02em; }
.entrar p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; flex-direction: row; align-items: center; gap: 10px; overflow-x: auto; padding: 10px 12px; }
  .marca { padding: 0 10px 0 4px; }
  .nav { flex-direction: row; }
  .lateral-pe { display: none; }
  .conteudo { padding: 18px 16px 50px; }
}
