
/* ── tokens ─────────────────────────────────────────────────────────────── */
[data-theme="osso"] {
  --bg:#F1EFEA; --surface:#FFFFFF; --side:#FBFAF7; --raised:#F7F5F1; --hover:#F5F3EF;
  --line:#E6E2DA; --line-2:#D8D2C7; --ink:#1A1915; --ink-2:#45413A; --muted:#6C6559;
  --dim:#8B8375; --faint:#B3AB9C; --accent:#C2410C; --accent-h:#A8380A; --accent-ink:#FFFFFF;
  --soft-bg:#FDF1E9; --soft-line:#F0C9AC; --soft-ink:#8A3409;
  --pos:#15803D; --pos-bg:#E9F3EC; --neg:#B42318; --neg-bg:#FCEDEB;
  --warn:#B45309; --warn-bg:#FDF4E7;
  --overlay:rgba(26,25,21,.36);
  --shadow:0 1px 2px rgba(26,25,21,.05), 0 10px 28px -18px rgba(26,25,21,.18);
  --shadow-lg:0 24px 60px -20px rgba(26,25,21,.30), 0 2px 6px rgba(26,25,21,.08);
  --paper:#FFFFFF; --desk:#DCD8CE; --skel:#E9E5DD;
}
[data-theme="grafite"] {
  --bg:#14161A; --surface:#1A1E24; --side:#171A1F; --raised:#1E2229; --hover:#22272F;
  --line:#262C35; --line-2:#333B46; --ink:#EAEDF2; --ink-2:#C3CBD6; --muted:#98A2AF;
  --dim:#7C8694; --faint:#5C6673; --accent:#ED8936; --accent-h:#F79E5E; --accent-ink:#14161A;
  --soft-bg:#2A1D12; --soft-line:#7A4520; --soft-ink:#F3B183;
  --pos:#34D399; --pos-bg:#16302A; --neg:#F87171; --neg-bg:#33201F;
  --warn:#FBBF24; --warn-bg:#2E2410;
  --overlay:rgba(6,8,11,.62);
  --shadow:none;
  --shadow-lg:0 24px 60px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.03);
  --paper:#F7F5F1; --desk:#0E1013; --skel:#DDD8CF;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Archivo, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
.ms {
  font-family: "Material Symbols Outlined"; font-weight: normal; font-style: normal;
  line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block;
  white-space: nowrap; word-wrap: normal; direction: ltr; font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased; user-select: none;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

/* ── primitivos ─────────────────────────────────────────────────────────── */
.eyebrow { font-family: "IBM Plex Mono", monospace; font-size: 9px; letter-spacing: .16em; color: var(--dim); white-space: nowrap; }
.card { border: 1px solid var(--line); background: var(--surface); border-radius: 9px; box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; border-radius: 7px;
  padding: 8px 13px; font-size: 12.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--hover); }
.btn .ms { font-size: 17px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn--primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--hover); color: var(--ink); }
.btn--sm { padding: 6px 10px; font-size: 11.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 20px;
  padding: 3px 9px; font-size: 10.5px; font-weight: 500; white-space: nowrap;
  border: 1px solid var(--line-2); color: var(--muted);
}
.chip .ms { font-size: 13px; }
.chip--pos { background: var(--pos-bg); border-color: transparent; color: var(--pos); }
.chip--warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.chip--neg { background: var(--neg-bg); border-color: transparent; color: var(--neg); }
.chip--soft { background: var(--soft-bg); border-color: var(--soft-line); color: var(--soft-ink); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.field input, .field select {
  border: 1px solid var(--line-2); background: var(--raised); border-radius: 7px;
  padding: 9px 11px; font-size: 13px; width: 100%; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.seg button { padding: 6px 11px; font-size: 11.5px; color: var(--muted); border-left: 1px solid var(--line-2); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--hover); color: var(--ink); font-weight: 500; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 46px 20px; color: var(--muted); text-align: center; }
.empty .ms { font-size: 30px; color: var(--faint); }

/* ── shell ──────────────────────────────────────────────────────────────── */
#app { height: 100%; }
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; }
.side { border-right: 1px solid var(--line); background: var(--side); display: flex; flex-direction: column; min-height: 0; }
.side__brand { padding: 15px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.side__logo { width: 26px; height: 26px; flex-shrink: 0; border-radius: 6px; background: var(--ink); color: var(--surface); display: grid; place-items: center; }
.side__logo .ms { font-size: 16px; color: var(--accent); }
.side__word { font-size: 15px; font-weight: 600; letter-spacing: -.015em; }
.side__word em { font-style: normal; color: var(--accent); }
.side__tag { font-family: "IBM Plex Mono", monospace; font-size: 9px; letter-spacing: .26em; color: var(--dim); margin-left: 1px; }
.side__nav { flex: 1 1 auto; overflow: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.side__sec { padding: 14px 6px 6px; }
.nav {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  font-size: 12.5px; color: var(--ink-2); width: 100%; text-align: left;
}
.nav:hover { background: var(--hover); }
.nav .ms { font-size: 18px; color: var(--dim); flex-shrink: 0; }
.nav b { margin-left: auto; font-family: "IBM Plex Mono", monospace; font-size: 10px; font-weight: 500; color: var(--dim); }
.nav[aria-current="page"] { background: var(--hover); color: var(--ink); font-weight: 500; }
.nav[aria-current="page"] .ms { color: var(--accent); }
.side__foot { border-top: 1px solid var(--line); padding: 11px 12px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; background: var(--soft-bg); color: var(--soft-ink); border: 1px solid var(--soft-line); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top {
  height: 54px; flex-shrink: 0; border-bottom: 1px solid var(--line); background: var(--surface);
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
}
.top__crumb { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; white-space: nowrap; overflow: hidden; }
.top__crumb strong { color: var(--ink); font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.top__crumb a, .top__crumb > span:not(.ms) { overflow: hidden; text-overflow: ellipsis; }
.top__crumb .ms { font-size: 15px; color: var(--faint); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--raised); border-radius: 7px; padding: 7px 10px; width: 270px; }
.search input { border: 0; background: none; outline: none; width: 100%; font-size: 12.5px; }
.search .ms { font-size: 16px; color: var(--dim); }
.view { flex: 1 1 auto; overflow: auto; min-height: 0; }
.pad { padding: 22px 24px 34px; display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.sub { font-size: 12.5px; color: var(--muted); }

/* ── métricas ───────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 12px; }
.kpi { padding: 13px 15px; display: flex; flex-direction: column; gap: 7px; }
.kpi__n { font-size: 25px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }
.kpi__l { font-size: 11.5px; color: var(--muted); }
.kpi__d { font-family: "IBM Plex Mono", monospace; font-size: 9.5px; color: var(--dim); }

/* ── pastas ─────────────────────────────────────────────────────────────── */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 12px; }
.folder { padding: 14px 15px; display: flex; flex-direction: column; gap: 11px; text-align: left; transition: border-color .12s ease; }
.folder:hover { border-color: var(--line-2); background: var(--hover); }
.folder__top { display: flex; align-items: flex-start; gap: 10px; }
.folder__ic { width: 30px; height: 30px; border-radius: 7px; background: var(--raised); border: 1px solid var(--line); display: grid; place-items: center; flex-shrink: 0; }
.folder__ic .ms { font-size: 17px; color: var(--dim); }
.folder__n { font-size: 13px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.folder__m { font-family: "IBM Plex Mono", monospace; font-size: 9.5px; color: var(--dim); margin-top: 3px; }
.folder__bar { height: 4px; border-radius: 3px; background: var(--line); overflow: hidden; display: flex; }
.folder__bar i { display: block; height: 100%; }
.folder__legend { display: flex; gap: 12px; font-size: 10.5px; color: var(--muted); }
.folder__legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── tabela ─────────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  text-align: left; padding: 9px 14px; background: var(--raised); border-bottom: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace; font-size: 9px; letter-spacing: .12em; font-weight: 500; color: var(--dim);
  position: sticky; top: 0; z-index: 1;
}
.tbl tbody tr { border-bottom: 1px solid var(--line); cursor: pointer; }
.tbl tbody tr:last-child { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl td { padding: 11px 14px; vertical-align: middle; }
.tbl .doc { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl .doc .ms { font-size: 18px; color: var(--dim); flex-shrink: 0; }
.tbl .doc span { font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .doc small { display: block; font-family: "IBM Plex Mono", monospace; font-size: 9.5px; color: var(--dim); font-weight: 400; }
.tbl .who { display: flex; gap: -6px; }
.stack-av { display: flex; }
.stack-av .avatar { width: 22px; height: 22px; font-size: 9px; margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.stack-av .avatar:first-child { margin-left: 0; }

/* ── envio ──────────────────────────────────────────────────────────────── */
.drop {
  border: 1.5px dashed var(--line-2); border-radius: 11px; background: var(--surface);
  padding: 46px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; transition: border-color .14s ease, background .14s ease;
}
.drop[data-over="true"] { border-color: var(--accent); background: var(--soft-bg); }
.drop__ic { width: 48px; height: 48px; border-radius: 11px; background: var(--raised); border: 1px solid var(--line); display: grid; place-items: center; }
.drop__ic .ms { font-size: 24px; color: var(--dim); }
.filecard { display: flex; align-items: center; gap: 13px; padding: 13px 15px; }
.filecard__ic { width: 34px; height: 42px; border-radius: 5px; background: var(--soft-bg); border: 1px solid var(--soft-line); display: grid; place-items: center; flex-shrink: 0; }
.filecard__ic .ms { font-size: 18px; color: var(--accent); }
.steps { display: flex; align-items: center; gap: 0; }
.step { display: flex; align-items: center; gap: 8px; padding-right: 14px; }
.step__n { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-family: "IBM Plex Mono", monospace; font-size: 10px; color: var(--dim); flex-shrink: 0; }
.step__l { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.step[data-on="true"] .step__n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.step[data-on="true"] .step__l { color: var(--ink); font-weight: 500; }
.step__sep { width: 26px; height: 1px; background: var(--line-2); margin-right: 14px; }

/* ── editor ─────────────────────────────────────────────────────────────── */
.editor { position: relative; display: grid; grid-template-columns: 230px minmax(0, 1fr) 252px; height: 100%; min-height: 0; }
.pane { border-right: 1px solid var(--line); background: var(--side); overflow: auto; min-height: 0; }
.pane--right { border-right: 0; border-left: 1px solid var(--line); }
.pane__h { padding: 12px 14px 9px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--side); z-index: 2; }
.pane__b { padding: 12px 12px 22px; display: flex; flex-direction: column; gap: 9px; }
.signer { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px 11px; display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%; }
.signer[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.signer__sw { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.signer__n { font-size: 12px; font-weight: 600; line-height: 1.3; }
.signer__q { font-size: 10.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.signer__c { font-family: "IBM Plex Mono", monospace; font-size: 9px; color: var(--dim); margin-top: 4px; }
.tools { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.tool { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px 8px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.tool .ms { font-size: 18px; color: var(--dim); }
.tool span { font-size: 10.5px; color: var(--ink-2); }
.tool[aria-pressed="true"] { border-color: var(--accent); background: var(--soft-bg); }
.tool[aria-pressed="true"] .ms, .tool[aria-pressed="true"] span { color: var(--soft-ink); }

.stagewrap { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.stage { background: var(--desk); overflow: auto; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; padding: 20px 0 40px; gap: 16px; }
.stage__bar {
  flex-shrink: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 8px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.stage__bar > .btn { flex-shrink: 0; }
/* ações que só aparecem quando o painel direito é recolhido */
.stage__bar [data-compacto] { display: none; }
.drawer {
  position: absolute; right: 0; top: 0; bottom: 0; width: 262px; z-index: 6;
  border-left: 1px solid var(--line); background: var(--side); overflow: auto;
  box-shadow: var(--shadow-lg);
}
.page {
  position: relative; background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.10), 0 14px 34px -20px rgba(0,0,0,.45);
  flex-shrink: 0; cursor: crosshair; overflow: hidden;
}
.page__label { position: absolute; top: 8px; right: 10px; font-family: "IBM Plex Mono", monospace; font-size: 8px; letter-spacing: .1em; color: #B3AB9C; pointer-events: none; }
/* mock esquemático — TODO PDF: substituir por <canvas> do PDF.js */
.mockdoc { position: absolute; inset: 0; padding: 8% 10%; color: #1A1915; pointer-events: none; }
.mockdoc h4 { margin: 0 0 3.4% 0; font-size: 1.05em; font-weight: 600; letter-spacing: -.01em; }
.mockdoc .cl { font-family: "IBM Plex Mono", monospace; font-size: .62em; letter-spacing: .1em; color: #8B8375; margin-bottom: 1.4%; }
.mockdoc .ln { height: .62em; background: var(--skel); border-radius: 2px; margin-bottom: .68em; }
.mockdoc .gp { margin-bottom: 3.2%; }
.mockdoc .sig { position: absolute; left: 10%; right: 10%; bottom: 9%; display: flex; gap: 8%; }
.mockdoc .sig > div { flex: 1; border-top: 1px solid #B3AB9C; padding-top: .5em; font-size: .56em; color: #8B8375; }

.fld { position: absolute; border-radius: 5px; border: 1.5px solid; display: flex; align-items: center; justify-content: center; cursor: grab; user-select: none; }
.fld[data-sel="true"] { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px currentColor; z-index: 4; }
.fld__in { display: flex; align-items: center; gap: 5px; padding: 0 7px; min-width: 0; pointer-events: none; }
.fld__in .ms { font-size: 14px; }
.fld__in span { font-size: 10px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fld__rz { position: absolute; right: -4px; bottom: -4px; width: 10px; height: 10px; border-radius: 2px; background: var(--paper); border: 1.5px solid currentColor; cursor: nwse-resize; }
.fld__x { position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-2); display: none; place-items: center; box-shadow: var(--shadow); }
.fld[data-sel="true"] .fld__x { display: grid; }
.fld__x .ms { font-size: 12px; color: var(--neg); }

.fldrow { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 9px 10px; display: flex; align-items: center; gap: 9px; text-align: left; width: 100%; }
.fldrow[aria-pressed="true"] { border-color: var(--accent); }
.fldrow__t { font-size: 11.5px; font-weight: 500; }
.fldrow__m { font-family: "IBM Plex Mono", monospace; font-size: 9px; color: var(--dim); margin-top: 2px; }

/* ── ficha do documento ─────────────────────────────────────────────────── */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 322px; gap: 18px; align-items: start; }
.dl { display: grid; grid-template-columns: 1fr; }
.dl > div { display: flex; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.dl > div:last-child { border-bottom: 0; }
.dl dt { margin: 0; width: 42%; flex-shrink: 0; font-size: 11.5px; color: var(--muted); }
.dl dd { margin: 0; min-width: 0; font-size: 11.5px; word-break: break-word; }
.trail { display: flex; flex-direction: column; }
.trail__i { display: flex; gap: 12px; padding: 11px 15px; border-bottom: 1px solid var(--line); }
.trail__i:last-child { border-bottom: 0; }
.trail__d { width: 22px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trail__d i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 4px; }
.trail__d s { flex: 1; width: 1px; background: var(--line-2); text-decoration: none; }
.trail__i:last-child .trail__d s { display: none; }
.trail__t { font-size: 12px; line-height: 1.45; }
.trail__m { font-family: "IBM Plex Mono", monospace; font-size: 9.5px; color: var(--dim); margin-top: 3px; }

/* ── acesso ─────────────────────────────────────────────────────────────── */
.gate { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 40px 24px; }
.gate__card { width: 100%; max-width: 396px; overflow: hidden; }
.gate__h { padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--side); display: flex; align-items: center; gap: 10px; }
.gate__b { padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 15px; }

/* ── modal ──────────────────────────────────────────────────────────────── */
.mask { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 24px; z-index: 40; }
.modal { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal__h { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal__b { padding: 17px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal__f { padding: 12px 16px; border-top: 1px solid var(--line); background: var(--side); display: flex; gap: 9px; justify-content: flex-end; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 8px; padding: 10px 15px;
  font-size: 12.5px; box-shadow: var(--shadow-lg); z-index: 60; display: flex; align-items: center; gap: 9px;
}
.toast .ms { font-size: 16px; color: var(--accent); }

@media (max-width: 1180px) {
  .editor { grid-template-columns: 200px minmax(0,1fr); }
  .editor > .pane--right:not(.drawer) { display: none; }
  .stage__bar [data-compacto] { display: inline-flex; }
  .split { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 64px minmax(0,1fr); }
  .side__word, .side__tag, .nav span, .nav b, .side__foot div { display: none; }
  .side__brand, .nav { justify-content: center; }
  .search { width: 150px; }
}

