:root {
  --bg: #f5f6f8; --panel: #ffffff; --text: #1d2330; --muted: #5d6676; --line: #dde1e8;
  --brand: #1f4fa3; --brand-text: #ffffff; --ok: #1a7f4b; --warn: #a15c00; --bad: #b3261e; --info: #1f6a8a;
  --ok-bg: #e3f4eb; --warn-bg: #fdf0d9; --bad-bg: #fbe5e3; --info-bg: #e1f0f6; --gray-bg: #eceef2;
  --radius: 8px; --shadow: 0 1px 2px rgba(20, 30, 50, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --text: #e7eaf0; --muted: #9aa3b2; --line: #2d3340;
    --brand: #6d9cf0; --brand-text: #0e1420; --ok: #5ccb93; --warn: #f0b457; --bad: #f08a83; --info: #6cc4e0;
    --ok-bg: #173325; --warn-bg: #3a2b12; --bad-bg: #3b1d1b; --info-bg: #14303c; --gray-bg: #272c36;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.nowrap { white-space: nowrap; }

/* estrutura */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { font-weight: 700; padding: 0 .5rem 1rem; }
.side a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--text); text-decoration: none; }
.side a:hover { background: var(--gray-bg); }
.side a.active { background: var(--brand); color: var(--brand-text); }
.side .group { margin: 1rem .5rem .25rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.main { min-width: 0; }
.topbar { display: flex; gap: .75rem; align-items: center; padding: .6rem 1.25rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.content { padding: 1.25rem; max-width: 1200px; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 10; height: auto; display: flex; flex-wrap: nowrap; gap: .25rem; overflow-x: auto; padding: .4rem .5rem;
          border-right: 0; border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
  .side .brand, .side .group { display: none; }
  .side a { white-space: nowrap; flex: 0 0 auto; padding: .4rem .7rem; }
  .topbar { padding: .5rem .75rem; }
  .toolbar button, .toolbar .btn { flex: 0 0 auto; }
  .kv { grid-template-columns: 1fr; } .kv dt { margin-top: .4rem; }
  .content { padding: .75rem; }
}

/* componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat b { display: block; font-size: 1.6rem; }
.toolbar { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; margin: .5rem 0 1rem; }
.toolbar .spacer { flex: 1; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: .5rem .65rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--gray-bg); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--gray-bg); }
.tablewrap { overflow-x: auto; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .15rem; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
textarea { min-height: 4.5rem; }
input[type=checkbox] { width: auto; }
input[type=file] { padding: .3rem; }
.field { min-width: 150px; flex: 1; }
.field.narrow { flex: 0 0 140px; min-width: 120px; }
.field.check { flex: 0 0 auto; min-width: 0; }
button, .btn { display: inline-block; padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; }
button:hover { background: var(--gray-bg); }
button.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.small { padding: .2rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--gray-bg); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.alert { padding: .6rem .8rem; border-radius: 6px; margin: .5rem 0; background: var(--info-bg); color: var(--info); }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: end; }
.kv { display: grid; grid-template-columns: 11rem 1fr; gap: .25rem .75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; }
.tabs button.active { border-bottom-color: var(--brand); font-weight: 600; }
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; z-index: 20; }
.modal { background: var(--panel); border-radius: var(--radius); padding: 1.25rem; width: min(640px, 100%); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.modal .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; z-index: 30; max-width: min(420px, 90vw); }
.toast { padding: .65rem .9rem; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.toast.ok { border-left: 4px solid var(--ok); } .toast.bad { border-left: 4px solid var(--bad); }
.login { max-width: 460px; margin: 8vh auto; padding: 0 1rem; }
.pad { padding: 1rem; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.bell { position: relative; }
.bell .n { position: absolute; top: -.35rem; right: -.35rem; background: var(--bad); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .35rem; min-width: 1.1rem; text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.indent-1 { padding-left: 1.2rem; } .indent-2 { padding-left: 2.4rem; } .indent-3 { padding-left: 3.6rem; } .indent-4 { padding-left: 4.8rem; }
.strong { font-weight: 600; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 0; background: var(--panel); padding: .5rem; z-index: 50; }
.topbar select.company { width: auto; max-width: 300px; }
.topbar .small { margin: 0; }
.login .grid { grid-template-columns: 1fr; }
.login button { text-align: left; }
.lines input { min-width: 6rem; }
.lines td { padding: .25rem .35rem; }
.total-row td { font-weight: 600; background: var(--gray-bg); }
a.stat { color: var(--text); text-decoration: none; }
a.stat:hover { border-color: var(--brand); }
a.stat b { color: var(--brand); }
.wrap { word-break: break-all; }
.sug { align-items: center; padding: .4rem 0; border-top: 1px solid var(--line); }
.sug:first-of-type { border-top: 0; }

/* busca de conta nas listas longas */
.acct { display: flex; flex-direction: column; gap: .35rem; }
.acct-q { font-size: .9rem; }

/* impressão / salvar como PDF (relatórios): só o conteúdo, sem menu nem botões */
.print-only { display: none; }
@media print {
  .side, .topbar, .toolbar, .tabs, .toasts, .no-print { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; padding: 0; }
  .print-only { display: block; margin-bottom: .75rem; }
  body { background: #fff; color: #000; }
  table, .card { box-shadow: none; }
  tr { break-inside: avoid; }
}

/* prévia de PDF em popup */
.modal.wide { width: min(1000px, 100%); }
.pdf-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
@media (max-width: 760px) { .pdf-frame { height: 60vh; } }

/* portal do colaborador */
.dash { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
.dash .card { margin-bottom: 0; }
.dash .wide { grid-column: 1 / -1; }
.dash h3 { margin-top: 0; }
.notice { border-left: 4px solid var(--brand); background: var(--gray-bg); border-radius: 6px; padding: .55rem .8rem; margin: .5rem 0; }
.notice.pinned { border-left-color: var(--warn); }
.body { white-space: pre-wrap; overflow-wrap: anywhere; }
.docline, .mini { display: flex; gap: .75rem; justify-content: space-between; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.stats { display: flex; gap: .75rem; margin-bottom: .5rem; }
.stats .stat { flex: 1; }
.req { display: grid; gap: .35rem; }
.reply { background: var(--gray-bg); border-radius: 6px; padding: .5rem .75rem; }
.req-mini { margin: .5rem 0; display: grid; gap: .25rem; }
button.link { background: none; border: 0; color: var(--brand); padding: 0; cursor: pointer; text-decoration: underline; }
