:root {
  --bg: #f5f6f8; --surface: #fff; --text: #1c2330; --muted: #667085; --line: #e3e6eb;
  --brand: #1f4e79; --brand-text: #fff; --danger: #b42318; --warn-bg: #fdecea;
  --green: #067647; --amber: #b54708; --red: #b42318; --chip: #eef1f5;
  --radius: 10px;
}
:root { color-scheme: light; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body.busy { cursor: progress; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: .9rem; margin: 1rem 0 .25rem; color: var(--muted); }
small { display: block; color: var(--muted); font-size: .82rem; }
code { background: var(--chip); padding: .1em .4em; border-radius: 4px; word-break: break-all; }


main { max-width: 1100px; margin: 0 auto; padding-block: 1.25rem 4rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1 { margin: 0; }
.back { font-size: .85rem; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.cols .card { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.warn { background: var(--warn-bg); }

.btn { display: inline-block; font: inherit; padding: .5rem .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.btn.danger { color: var(--danger); }
.btn.big { padding: .75rem 1.4rem; font-size: 1.05rem; }
.link, .row-actions button { background: none; border: 0; color: var(--brand); cursor: pointer; font: inherit; font-size: .85rem; padding: .2rem .4rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.form .actions { justify-content: flex-end; }

.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 220px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.filters select { width: auto; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--chip); }
tbody tr:last-child td { border-bottom: 0; }

.tag { display: inline-block; font-size: .75rem; padding: .1rem .55rem; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; font-weight: 500; }
.tag.red { background: var(--warn-bg); color: var(--red); }
.tag.amber { color: var(--amber); }
.st-ativo { color: var(--green); } .st-encerrado { color: var(--muted); } .st-aguardando { color: var(--amber); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li a { flex: 1; min-width: 0; color: var(--text); }
.list li strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs li { flex-wrap: wrap; }
.docs li a, .docs li span:first-child { flex: 1; min-width: 160px; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
.form .wide { grid-column: 1 / -1; }
@media (max-width: 600px) { .form { grid-template-columns: 1fr; } }

.info { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; margin: 0; }
.info dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.info dd { margin: 0; word-break: break-word; }
.pre { white-space: pre-wrap; margin: 0; }

.drop { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 1rem; margin-bottom: .75rem; border: 2px dashed var(--line); border-radius: var(--radius); color: var(--muted); cursor: pointer; text-align: center; }
.drop.over, .drop:hover { border-color: var(--brand); color: var(--text); }
progress { width: 100%; }

.inline { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.inline input[type="date"] { width: auto; }
.inline .grow { flex: 1; min-width: 200px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 90px 1fr auto; gap: .75rem; padding: .6rem 0; border-top: 1px solid var(--line); align-items: start; }
.timeline time { color: var(--muted); font-size: .85rem; padding-top: .1rem; }
.timeline li.done span { text-decoration: line-through; color: var(--muted); }
@media (max-width: 600px) { .timeline li { grid-template-columns: 1fr; gap: .2rem; } }

.cal { width: 100%; height: 75vh; border: 0; }
.steps { color: var(--muted); padding-left: 1.2rem; }
.empty { color: var(--muted); text-align: center; padding: 1.25rem 0; margin: 0; }
.muted { color: var(--muted); }
.err { color: var(--danger); }
.login { max-width: 460px; margin: 10vh auto; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 150%); background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 8px; transition: transform .2s; max-width: 90vw; z-index: 10; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

h2 .more, h2 .btn { margin-left: auto; font-size: .85rem; font-weight: 400; }
h2.day { text-transform: capitalize; }
.events li { align-items: flex-start; }
.events time { min-width: 92px; color: var(--muted); font-size: .85rem; padding-top: .1rem; font-variant-numeric: tabular-nums; }
.events .grow { flex: 1; min-width: 0; }
.events strong { white-space: normal; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.25rem; width: min(560px, 94vw); }
dialog::backdrop { background: rgba(10, 15, 25, .55); }

.ask { margin: 0; color: var(--text); font-size: 1rem; }

/* Número de pasta */
.pasta { display: inline-block; font-variant-numeric: tabular-nums; font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: 0 .4rem; margin-right: .35rem; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); color: var(--text); vertical-align: .05em; white-space: nowrap; }
.pasta.big { font-size: .9rem; padding: .05rem .5rem; }
h1 .pasta { vertical-align: .15em; }
td .pasta { margin: 0; }
.grow { flex: 1; }

/* Barra do calendário */
.agbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.agtitle { flex: 1; min-width: 180px; font-size: 1.15rem; font-weight: 600; }
.agtitle::first-letter { text-transform: uppercase; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; padding: .45rem .85rem; background: var(--surface); color: var(--text); border: 0; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: var(--brand-text); }
.nav { display: inline-flex; gap: .25rem; }

/* Semana: um dia por coluna, compromissos em sequência */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; align-items: stretch; }
.wday { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 320px; display: flex; flex-direction: column; min-width: 0; }
.wday.today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.wday header { display: flex; align-items: baseline; gap: .4rem; padding: .55rem .65rem; border-bottom: 1px solid var(--line); }
.wday .wd { text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; color: var(--muted); }
.wday .dn { font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.wday .wm { font-size: .78rem; color: var(--muted); }
.wday.today .dn { color: var(--brand); }
.wday .add { margin-left: auto; width: 1.7rem; height: 1.7rem; line-height: 1; font: inherit; font-size: 1.1rem; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 6px; cursor: pointer; }
.wday .add:hover { color: var(--brand); border-color: var(--brand); }
.wday .evs { display: flex; flex-direction: column; gap: .4rem; padding: .5rem; flex: 1; }
.wday .none { margin: auto; color: var(--muted); font-size: .8rem; }
.ev { text-align: left; font: inherit; color: var(--text); background: var(--chip); border: 1px solid transparent; border-radius: 8px; padding: .45rem .55rem; cursor: pointer; display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.ev:hover, .ev:focus-visible { border-color: var(--brand); }
.ev .t { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ev strong { font-size: .88rem; overflow-wrap: anywhere; }
.ev .cli { font-size: .78rem; color: var(--text); overflow-wrap: anywhere; }
.ev small { overflow-wrap: anywhere; }
@media (max-width: 900px) { .week { grid-template-columns: 1fr; } .wday { min-height: 0; } .wday .none { margin: 0; } }

/* Mês */
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.month .h { padding: .45rem; text-align: center; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.month .h:nth-child(7n) { border-right: 0; }
.mday { min-height: 112px; padding: .3rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.mday:nth-child(7n) { border-right: 0; }
.mday.out { background: var(--bg); color: var(--muted); }
.mday .num { align-self: flex-start; font: inherit; font-size: .85rem; font-variant-numeric: tabular-nums; background: none; color: inherit; border: 0; cursor: pointer; padding: .05rem .4rem; border-radius: 999px; }
.mday .num:hover { background: var(--chip); }
.mday.today .num { background: var(--brand); color: var(--brand-text); }
.mevs { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mev { text-align: left; font: inherit; font-size: .72rem; color: var(--text); background: var(--chip); border: 0; border-radius: 4px; padding: .1rem .3rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mev:hover { outline: 1px solid var(--brand); }
.mmore { text-align: left; font: inherit; font-size: .72rem; color: var(--brand); background: none; border: 0; padding: .1rem .3rem; cursor: pointer; }
@media (max-width: 700px) {
  .mday { min-height: 58px; padding: .2rem; }
  .mevs { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .mev { font-size: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; background: var(--brand); }
  .mev b, .mmore { display: none; }
}

/* Ano */
.year { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .9rem; }
.ymonth { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .75rem .8rem; min-width: 0; }
.ymonth h3 { margin: 0 0 .4rem; font-size: .95rem; color: var(--text); text-transform: capitalize; }
.ymonth h3 button { font: inherit; font-weight: 600; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.ymonth h3 button:hover { color: var(--brand); }
.ygrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .75rem; }
.yh { color: var(--muted); font-size: .68rem; padding-bottom: .1rem; }
.yd { font: inherit; font-size: .75rem; font-variant-numeric: tabular-nums; color: var(--text); background: none; border: 0; padding: .22rem 0; border-radius: 6px; cursor: pointer; }
.yd:hover { background: var(--chip); }
.yd.has { background: var(--chip); font-weight: 700; color: var(--brand); }
.yd.heavy { background: var(--brand); color: var(--brand-text); }
.yd.today { outline: 2px solid var(--brand); outline-offset: -2px; }

/* Cadastros recebidos */
.badge { display: inline-block; min-width: 1.25rem; padding: 0 .35rem; margin-left: .2rem; border-radius: 999px; background: var(--brand); color: var(--brand-text); font-size: .72rem; font-weight: 600; text-align: center; line-height: 1.3rem; }
.notice { display: block; margin-bottom: 1rem; padding: .7rem .9rem; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: var(--radius); background: var(--surface); color: var(--text); }
a.notice:hover { border-color: var(--brand); }
.tag.green { color: var(--green); }
.entry h2 { flex-wrap: wrap; }
.entry .actions { margin-top: 1rem; }
.dup { margin: 0 0 .75rem; padding: .5rem .7rem; border-radius: 8px; background: var(--warn-bg); color: var(--text); }

[hidden] { display: none !important; }

/* Menu lateral retrátil */
.app { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; }
.side { width: 262px; flex: none; position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: max(14px, env(safe-area-inset-top, 0px)) 12px 12px; background: var(--surface); border-right: 1px solid var(--line); overflow-x: hidden; overflow-y: auto; transition: width .18s ease; z-index: 20; }
.logo { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border: 0; border-radius: 10px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.logo:hover { background: var(--chip); }
.logo:focus-visible, .mlogo:focus-visible, .side nav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.mark { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; display: block; }
.logo .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.logo .who b { font-size: .97rem; font-weight: 600; white-space: nowrap; }
.logo .who span { font-size: .82rem; font-weight: 400; color: var(--muted); }
.logo .chev { margin-left: auto; flex: none; color: var(--muted); }
.newbtn { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; padding: 8px 12px; border-radius: 10px; font-size: .93rem; background: var(--brand); color: var(--brand-text); font-weight: 600; white-space: nowrap; }
.newbtn:hover { filter: brightness(1.12); }
.newbtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.newbtn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.side nav { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; }
.side nav a { position: relative; display: flex; align-items: center; gap: 12px; padding: 9px 11px; border-radius: 9px; color: var(--text); white-space: nowrap; }
.side nav a:hover { background: var(--chip); }
.side nav a.active { background: var(--chip); font-weight: 600; }
.side nav a svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.side nav a.active svg { color: var(--brand); }
.side nav .badge { margin-left: auto; }
.side .foot { margin-top: auto; padding: 10px 6px 2px; border-top: 1px solid var(--line); font-size: .78rem; color: var(--muted); white-space: nowrap; }
.foot .dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.foot .dot.demo { background: var(--amber); }
.mbar, .scrim { display: none; }
.app.nologin .side, .app.nologin .mbar { display: none; }

@media (min-width: 801px) {
  .app.collapsed .side { width: 68px; padding-inline: 8px; }
  .app.collapsed .logo { justify-content: center; padding: 6px 0; }
  .app.collapsed .logo .mark { width: 30px; height: 30px; border-radius: 8px; }
  .app.collapsed .logo .who, .app.collapsed .logo .chev, .app.collapsed .side nav .lbl, .app.collapsed .side .foot { display: none; }
  .app.collapsed .side nav a { justify-content: center; padding: 10px 0; }
  .app.collapsed .newbtn .lbl { display: none; }
  .app.collapsed .newbtn { align-self: center; width: 38px; height: 38px; padding: 0; border-radius: 50%; }
  .app.collapsed .side nav .badge { position: absolute; top: 3px; right: 9px; min-width: 16px; height: 16px; margin: 0; padding: 0 4px; font-size: .62rem; line-height: 16px; }
}

@media (max-width: 800px) {
  .app { display: block; }
  .mbar { display: flex; align-items: center; position: sticky; top: 0; z-index: 10; padding: max(8px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); }
  .mlogo { display: flex; align-items: center; gap: 10px; padding: 2px; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
  .mlogo .mark { width: 32px; height: 32px; border-radius: 8px; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(290px, 86vw); transform: translateX(-100%); transition: transform .2s ease; }
  .app.drawer .side { transform: none; box-shadow: 0 0 40px rgba(10, 15, 25, .3); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(10, 15, 25, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.drawer .scrim { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { .side, .scrim { transition: none; } }

.login .mark { width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 16px; }

/* Processos do cliente */
.procs { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: .75rem; }
.proc { display: flex; flex-direction: column; gap: .5rem; min-width: 0; padding: .85rem .95rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.proc header { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }
.cnj { font-variant-numeric: tabular-nums; letter-spacing: .01em; overflow-wrap: anywhere; }
.proc .sub { margin: 0; font-size: .88rem; color: var(--muted); }
.proc .info { gap: .4rem .8rem; }
.proc-actions { display: flex; flex-wrap: wrap; gap: .1rem; margin-top: auto; padding-top: .4rem; border-top: 1px solid var(--line); }
.proc-actions button { padding: .2rem .45rem; border: 0; background: none; color: var(--brand); font: inherit; font-size: .85rem; cursor: pointer; }
.proc-actions button:hover { text-decoration: underline; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; }
.chip { padding: .2rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: .82rem; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.st-suspenso { color: var(--amber); }
.inline select { width: auto; min-width: 0; max-width: 260px; }
dialog { max-height: 92vh; overflow: auto; }
