/* Visual no estilo do ADVBOX: menu lateral branco com ícones, barra no topo com busca e "Adicionar",
   cartões cinza-claros sem borda, abas em pílula e tabelas leves. No celular o menu vira barra inferior. */
:root {
  --bg: #ffffff; --surface: #f5f5f5; --surface-2: #ffffff; --fg: #24292e; --muted: #586069; --faint: #9ca0a9; --line: #e8e8e8; --input-line: #ccd1d5;
  --accent: #2f81f7; --accent-hover: #1f6fe0; --accent-fg: #fff; --accent-soft: #e8f1fe;
  --nav-fg: #7d7d7d; --nav-bg: #ffffff;
  --bad: #c4321f; --bad-bg: #fde7e3; --warn: #b5560b; --warn-bg: #fdecdc; --ok: #127f39; --ok-bg: #e4f6eb; --soft: #ebedf0;
  --sombra: 0 0 4px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.06);
  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, Consolas, "Cascadia Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #1a1f26; --surface-2: #12161b; --fg: #e6e9ed; --muted: #a2abb6; --faint: #6b7480; --line: #2a313a; --input-line: #3a434e;
    --accent: #4b93f8; --accent-hover: #6aa6fa; --accent-fg: #fff; --accent-soft: #1b2b44;
    --nav-fg: #a2abb6; --nav-bg: #12161b;
    --bad: #ff8f80; --bad-bg: #3b1f1b; --warn: #f3b26b; --warn-bg: #3a2814; --ok: #6fd69a; --ok-bg: #16301f; --soft: #262d36;
    --sombra: 0 0 4px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #1a1f26; --surface-2: #12161b; --fg: #e6e9ed; --muted: #a2abb6; --faint: #6b7480; --line: #2a313a; --input-line: #3a434e;
  --accent: #4b93f8; --accent-hover: #6aa6fa; --accent-fg: #fff; --accent-soft: #1b2b44;
  --nav-fg: #a2abb6; --nav-bg: #12161b;
  --bad: #ff8f80; --bad-bg: #3b1f1b; --warn: #f3b26b; --warn-bg: #3a2814; --ok: #6fd69a; --ok-bg: #16301f; --soft: #262d36;
  --sombra: 0 0 4px rgba(0,0,0,.5); color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; font-weight: 500; }
h1 { font-size: 1.35rem; line-height: 1.25; } h2 { font-size: 1rem; color: var(--fg); } h3 { font-size: .95rem; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }

/* ---- estrutura: menu | (topo + conteúdo) */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.coluna { display: flex; flex-direction: column; min-width: 0; }
.nav { background: var(--nav-bg); color: var(--nav-fg); padding: 0 0 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  box-shadow: var(--sombra); z-index: 4; }
.brand { color: var(--fg); font-size: .98rem; line-height: 1.2; font-weight: 600; padding: 18px 20px 22px; min-height: 55px; }
.brand small { display: block; font-size: .68rem; font-weight: 400; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin-top: 3px; }
.nav a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 14px; height: 40px; padding: 0 20px; position: relative; font-size: .95rem; }
.nav a:hover { color: var(--fg); background: var(--surface); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.ico { width: 20px; height: 20px; flex: 0 0 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.who { margin-top: auto; padding: 14px 20px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; font-size: .82rem; color: var(--muted); }
.who b { color: var(--fg); font-weight: 500; }
.who button { align-self: flex-start; margin-top: 6px; }

.topo { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 3; background: var(--bg); min-height: 55px; padding: 8px 24px; display: flex; align-items: center; gap: 16px; justify-content: space-between; }
.busca { position: relative; flex: 0 1 340px; min-width: 0; }
.busca .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.busca input { border-radius: 100px; padding: 8px 16px 8px 40px; background: var(--bg); border: 1px solid var(--input-line); height: 38px; }
.acoes { display: flex; align-items: center; gap: 14px; }
.tema { display: flex; background: var(--surface); border-radius: 100px; padding: 3px; }
.tema button { border: 0; background: none; border-radius: 100px; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; color: var(--faint); }
.tema button .ico { width: 16px; height: 16px; }
.tema button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.add { position: relative; }
.pill-btn { border-radius: 20px !important; height: 36px; padding: 0 14px 0 20px !important; display: inline-flex; align-items: center; gap: 10px; font-weight: 400 !important; }
.pill-btn .ico { width: 16px; height: 16px; }
.menu-add { position: absolute; right: 0; top: 42px; min-width: 220px; background: var(--surface-2); border-radius: 8px; box-shadow: var(--sombra); padding: 6px; display: flex; flex-direction: column; z-index: 6; }
.menu-add button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 6px; }
.menu-add button:hover { background: var(--surface); }
.usuario { display: flex; align-items: center; gap: 8px; color: var(--fg); background: var(--surface); border-radius: 100px; padding: 3px 14px 3px 3px; }
.usuario:hover { text-decoration: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .85rem; }

.main { padding: 12px 24px 56px; display: flex; flex-direction: column; gap: 16px; min-width: 0; max-width: 1240px; width: 100%; }
.head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding-top: 4px; }
.sub { color: var(--muted); margin: 2px 0 0; font-size: .88rem; }

/* ---- cartões (cinza-claro, sem borda) */
.panel { background: var(--surface); border-radius: 6px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h2 { font-size: .95rem; font-weight: 400; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--surface); border-radius: 6px; padding: 15px; display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 6px; min-height: 100px; }
.stat b { display: block; font: 400 1.7rem/1.15 var(--body); font-variant-numeric: tabular-nums; color: var(--fg); }
.stat span { font-size: .9rem; color: var(--muted); }
.stat.bad b { color: var(--bad); } .stat.warn b { color: var(--warn); }

/* ---- formulários e botões */
label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); min-width: 0; }
input, select, textarea { font: inherit; font-size: .9rem; color: var(--fg); background: var(--surface-2); border: 1px solid var(--input-line); border-radius: 6px; padding: 7px 10px; width: 100%; min-width: 0; min-height: 38px; }
.panel input, .panel select, .panel textarea { background: var(--surface-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { min-height: 0; width: auto; accent-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
button { font: inherit; font-size: .88rem; cursor: pointer; border-radius: 6px; border: 1px solid var(--input-line); background: var(--surface-2); color: var(--fg); padding: 0 14px; min-height: 36px; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.small { min-height: 28px; padding: 0 10px; font-size: .8rem; } button.danger { color: var(--bad); }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 14px; align-items: end; }
.form .wide { grid-column: 1 / -1; }
.bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.bar .grow { flex: 1 1 200px; }
.bar > select, .bar > input:not([type=checkbox]) { width: auto; flex: 0 1 auto; max-width: 100%; }
.panel > .bar:first-child select, .panel > .bar:first-child input { background: var(--surface-2); }

/* ---- tabelas leves */
.tablebox { overflow-x: auto; background: var(--surface-2); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th { text-align: left; font-size: .7rem; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); font-weight: 400; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .88rem; color: var(--fg); }
td b { font-weight: 500; }
td.mono, .mono { font-family: var(--mono); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.link { cursor: pointer; } tr.link:hover td { background: var(--accent-soft); }
tr.feito td:not(.act) { color: var(--muted); text-decoration: line-through; }
tr.sel td { background: var(--accent-soft); }

/* ---- etiquetas */
.pill { display: inline-block; border-radius: 20px; padding: 1px 12px; font-size: .74rem; font-weight: 400; white-space: nowrap; background: var(--soft); color: var(--muted); line-height: 1.6; }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.ok { background: var(--ok-bg); color: var(--ok); }
.muted { color: var(--muted); } .small { font-size: .84rem; }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--fg); font-weight: 500; font-size: 1rem; margin-bottom: 4px; }

/* ---- abas em pílula (como "Visão Geral | Lista | Quadro") */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface); border-radius: 8px; padding: 4px; align-self: flex-start; max-width: 100%; }
.tabs button { border: 0; border-radius: 8px; background: none; min-height: 36px; padding: 0 14px; color: var(--fg); }
.tabs button:hover { background: rgba(127,127,127,.08); }
.tabs button[aria-selected="true"] { background: var(--surface-2); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { border-left: 2px solid var(--accent); padding: 0 0 0 12px; }
.timeline time { font: .78rem var(--mono); color: var(--muted); }
.funil { display: flex; flex-direction: column; gap: 10px; }
.funil .row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: .88rem; }
.funil .trk { background: var(--surface-2); border-radius: 3px; height: 12px; overflow: hidden; display: flex; }
.funil .trk i { display: block; height: 100%; min-width: 3px; }
.funil .n { font: .85rem var(--mono); text-align: right; }
.cmd { font: .82rem var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; white-space: pre-wrap; word-break: break-word; }

/* ---- calendário (grade com linhas, dia de hoje em círculo azul) */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; border-left: 1px solid var(--line); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.cal .dow { font-size: .85rem; color: var(--fg); text-align: center; padding: 8px 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); }
.cal button.day { min-height: 92px; text-align: left; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; background: var(--surface-2); border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); border-radius: 0; }
.cal button.day:hover { background: var(--accent-soft); }
.cal button.day.out { visibility: hidden; } .cal button.day.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.cal .num { font: .85rem var(--body); color: var(--muted); align-self: flex-end; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal button.day.today .num { background: var(--accent); color: #fff; font-weight: 600; }
.cal .dot { font-size: .72rem; border-radius: 4px; padding: 1px 6px; background: var(--warn-bg); color: var(--warn); width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .dot.bad { background: var(--bad-bg); color: var(--bad); }

/* ---- login e telas sem menu */
.anon .nav, .anon .topo { display: none; }
.anon .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 0; }
.anon .main { margin-inline: auto; }
.anon { background: var(--surface); }
.auth { max-width: 400px; width: 100%; margin: 8vh auto 0; background: var(--surface-2); border-radius: 10px; box-shadow: var(--sombra); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth button.primary { min-height: 40px; border-radius: 20px; }
.erro { color: var(--bad); margin: 0; min-height: 1.3em; font-size: .9rem; }
.panel.aviso { background: var(--warn-bg); }
.badge { display: inline-block; min-width: 1.5em; padding: 0 6px; border-radius: 999px; background: #f04438; color: #fff; font: 600 .7rem/1.6 var(--body); text-align: center; margin-left: auto; }
.cmd.texto { max-height: 360px; overflow: auto; font-family: var(--body); font-size: .9rem; }
.stack h3 { margin: 0; }
p.big { font-size: 1.15rem; margin: 4px 0; }
details > summary { cursor: pointer; color: var(--accent); margin: 6px 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.perfis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.perfil { display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--surface-2); border-radius: 6px; }
input:disabled, select:disabled, textarea:disabled { opacity: .7; cursor: not-allowed; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; background: var(--fg); color: var(--bg); padding: 10px 18px; border-radius: 8px; z-index: 9; max-width: 90vw; box-shadow: var(--sombra); }
.toast.err { background: var(--bad); color: #fff; }

/* ---- celular: menu vira barra inferior com ícones */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 64px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; justify-content: space-around; overflow-x: auto;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); z-index: 5; }
  .brand, .who { display: none; }
  .nav a { flex: 1 0 56px; flex-direction: column; gap: 2px; height: auto; padding: 6px 2px; font-size: .68rem; justify-content: center; }
  .nav a[aria-current="page"]::before { left: 20%; right: 20%; top: 0; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .badge { position: absolute; top: 2px; right: 18%; margin: 0; }
  .topo { padding: 8px 16px; gap: 10px; }
  .busca { flex: 1 1 auto; }
  .tema, .ola { display: none; }
  .usuario { padding: 3px; }
  .pill-btn { padding: 0 10px 0 14px !important; }
  .auth { margin-top: 2vh; padding: 20px; }
  .main { padding: 8px 16px 40px; } .grid2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } h1 { font-size: 1.2rem; }
  .funil .row { grid-template-columns: 110px minmax(0, 1fr) 34px; }
  .cal button.day { min-height: 56px; padding: 4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* processos: arvore de vinculos e dados em leitura */
.pill.soft { opacity: .85; }
.arvore { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
dl.dados { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 14px; margin: 0; }
dl.dados dt { color: var(--muted); }
dl.dados dd { margin: 0; white-space: pre-wrap; }
.bar.feito > span.grow { color: var(--muted); text-decoration: line-through; }

/* processos: campo com opcoes + "Outro (digitar)" e vara com numero */
.escolha { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vara { display: flex; gap: 8px; align-items: flex-start; }
.vara select.num { flex: 0 0 6.5em; width: 6.5em; }
.vara .escolha { flex: 1 1 auto; }

/* clientes: telefones */
.tel-linha { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tel-linha .tel-num { flex: 0 1 12em; }
.tel-linha .tel-tipo { flex: 0 1 9em; width: auto; }
.tel-linha .tel-obs { flex: 1 1 14em; }

/* copia de seguranca: codigo de recuperacao */
.codigo-rec { font-size: 1.25rem; letter-spacing: .08em; padding: 10px 12px; border: 1px dashed var(--input-line); border-radius: 6px; overflow-wrap: anywhere; }

/* processos: pedidos (varios marcados) */
.pedidos { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 14px; margin: 6px 0; }
.pedidos label.ped { display: flex; flex-direction: row; gap: 6px; align-items: flex-start; font-size: .88rem; color: var(--fg); }
.pedidos label.ped input { width: auto; margin-top: 3px; }
.wide > .rot { display: block; font-size: .8rem; color: var(--muted); }

/* processos: acao em massa */
.lote { position: sticky; top: calc(55px + env(safe-area-inset-top, 0px)); z-index: 2; background: var(--accent-soft); border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
td.selcol, th:first-child input[type=checkbox] { width: 2em; }
td.selcol input, th input[type=checkbox] { width: auto; }
