/* Checklist CAT 02 — estilo
   Direção: ferramenta de trabalho de repartição, sóbria e densa.
   Papel claro, tinta azul-marinho, cores de status inequívocas. */

:root {
  --paper: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --line: #e2e0d8;
  --line-strong: #cfccc0;
  --ink: #18202c;
  --ink-2: #4a5363;
  --ink-3: #7a8291;
  --brand: #1d3f6e;
  --brand-2: #2b5a99;
  --brand-soft: #e8eef7;
  --ok: #1d7a4b;
  --ok-soft: #e4f3ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --na: #6b7280;
  --na-soft: #eef0f2;
  --wait: #9a5b00;
  --wait-soft: #fdf1dc;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(24, 32, 44, .06), 0 2px 8px rgba(24, 32, 44, .04);
  --shadow-lg: 0 10px 40px rgba(24, 32, 44, .18);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14.5px/1.5 var(--sans);
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.55rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .98rem; font-weight: 600; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: .92em; }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: .8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stack > * + * { margin-top: .75rem; }
.stack-lg > * + * { margin-top: 1.4rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* --- Barra superior ------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; height: 54px;
  background: var(--brand); color: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-size: 1.02rem; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: #fff; color: var(--brand); font-weight: 800; font-size: .9rem;
}
.nav { display: flex; gap: .25rem; overflow-x: auto; }
.nav a {
  color: rgba(255,255,255,.78); text-decoration: none; padding: .4rem .75rem; border-radius: 6px; white-space: nowrap;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a.active { color: #fff; background: rgba(255,255,255,.16); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.user-name { font-size: .88rem; color: rgba(255,255,255,.8); white-space: nowrap; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.3); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); }
.save-state { font-size: .82rem; color: rgba(255,255,255,.75); min-width: 5.5rem; text-align: right; }
.save-state.err { color: #ffd2cc; font-weight: 600; }

/* --- Layout --------------------------------------------------------------- */
.app { max-width: 1160px; margin: 0 auto; padding: 1.6rem 1.25rem 5rem; outline: none; }
.boot { padding: 4rem; text-align: center; color: var(--ink-3); }
.page-head { display: flex; gap: 1rem; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1.25rem; }
.crumbs { font-size: .86rem; color: var(--ink-3); margin-bottom: .35rem; }
.crumbs a { color: var(--ink-2); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.8rem 0 .7rem; }
.section-title h2 { display: flex; align-items: center; gap: .5rem; }
.count { font-size: .78rem; font-weight: 600; color: var(--ink-2); background: var(--line); border-radius: 999px; padding: .05rem .5rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 1.1rem 1.25rem; }
.empty {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); padding: 2rem 1.25rem;
  text-align: center; color: var(--ink-3); background: var(--surface-2);
}
.empty strong { display: block; color: var(--ink-2); margin-bottom: .25rem; }

/* --- Botões ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm); padding: .48rem .9rem; cursor: pointer; font-weight: 550;
  text-decoration: none; white-space: nowrap; line-height: 1.2;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { color: var(--bad); border-color: #e7b8b3; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: #941f18; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(24,32,44,.06); border-color: transparent; }
.btn-sm { padding: .3rem .6rem; font-size: .86rem; }
.btn-icon { padding: .3rem .45rem; min-width: 30px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand-2); cursor: pointer; text-decoration: underline; font-weight: 500; }

/* --- Formulários ---------------------------------------------------------- */
.field { display: block; }
.field > span { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: .3rem; }
.field > small { display: block; color: var(--ink-3); margin-top: .25rem; font-size: .8rem; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; padding: .5rem .65rem; line-height: 1.35;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand-2); }
.textarea { min-height: 90px; resize: vertical; }
.input-sm { padding: .32rem .5rem; font-size: .88rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: flex-start; gap: .5rem; cursor: pointer; padding: .2rem 0; }
.check input { margin-top: .22rem; accent-color: var(--brand); }
.search { position: relative; }
.search .input { padding-left: 2rem; }
.search::before { content: "⌕"; position: absolute; left: .65rem; top: 50%; transform: translateY(-52%); color: var(--ink-3); font-size: 1.1rem; }

/* --- Chips / badges ----------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 999px; padding: .12rem .6rem; font-size: .8rem; color: var(--ink-2);
}
.chip button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0 0 0 .1rem; font-size: 1rem; line-height: 1; }
.chip button:hover { color: var(--bad); }
.chip-brand { background: var(--brand-soft); border-color: #cddbee; color: var(--brand); }
.badge { display: inline-block; font-size: .74rem; font-weight: 650; border-radius: 4px; padding: .08rem .42rem; letter-spacing: .01em; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-na { background: var(--na-soft); color: var(--na); }
.b-wait { background: var(--wait-soft); color: var(--wait); }
.b-brand { background: var(--brand-soft); color: var(--brand); }

.kv { display: flex; flex-wrap: wrap; gap: .45rem .5rem; }
.kv-item {
  display: inline-flex; align-items: center; gap: .4rem; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .2rem .25rem .2rem .55rem; font-size: .86rem;
}
.kv-item b { font-weight: 600; color: var(--ink-3); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.kv-item .btn { padding: .12rem .35rem; font-size: .78rem; }

/* --- Progresso ------------------------------------------------------------ */
.progress { height: 8px; background: #ebe9e1; border-radius: 99px; overflow: hidden; display: flex; }
.progress > i { display: block; height: 100%; }
.progress .p-ok { background: var(--ok); }
.progress .p-bad { background: var(--bad); }
.progress .p-na { background: #b7bcc4; }
.progress-lg { height: 12px; }
.pct { font-variant-numeric: tabular-nums; font-weight: 650; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .84rem; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: .35rem; vertical-align: 0; }

/* --- Tabela de processos ------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; padding: .6rem .8rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: .7rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: #f7f8fb; }
.table .company { font-weight: 600; }
.table .prog { width: 170px; }
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) { .hide-sm { display: none; } }

/* --- Prazos -------------------------------------------------------------- */
.deadlines { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.deadline {
  display: block; text-decoration: none; color: inherit; border-left: 4px solid var(--brand-2);
  padding: .8rem 1rem;
}
.deadline:hover { box-shadow: var(--shadow-lg); }
.deadline .when { font-weight: 700; font-size: 1.05rem; }
.deadline.overdue { border-left-color: var(--bad); }
.deadline.overdue .when { color: var(--bad); }
.deadline.soon { border-left-color: var(--wait); }
.deadline.soon .when { color: var(--wait); }
.deadline.done { border-left-color: var(--ok); opacity: .7; }
.dl-row { display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); }
.dl-row:last-child { border-bottom: 0; }
.dl-date { min-width: 120px; }

/* --- Checklist do processo ----------------------------------------------- */
.sticky-summary {
  position: sticky; top: 54px; z-index: 10; background: rgba(245,244,239,.94);
  backdrop-filter: blur(6px); padding: .7rem 0; margin: 0 0 .5rem; border-bottom: 1px solid var(--line);
}
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.seg-filter { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.seg-filter button { border: 0; background: none; padding: .35rem .7rem; cursor: pointer; font-size: .86rem; border-right: 1px solid var(--line); color: var(--ink-2); }
.seg-filter button:last-child { border-right: 0; }
.seg-filter button.on { background: var(--brand); color: #fff; }
.seg-filter .n { opacity: .75; font-variant-numeric: tabular-nums; margin-left: .2rem; }

.person { margin-top: 1rem; overflow: hidden; }
.person > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.1rem; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.person > summary::-webkit-details-marker { display: none; }
.person > summary::before { content: "▸"; color: var(--ink-3); transition: transform .15s; }
.person[open] > summary::before { transform: rotate(90deg); }
.person .ptype { font-size: .78rem; color: var(--ink-3); }
.person .pprog { width: 160px; }
@media (max-width: 640px) { .person .pprog { display: none; } }
.person-tools { display: flex; justify-content: flex-end; gap: .4rem; padding: .5rem 1.1rem; border-bottom: 1px solid var(--line); background: #fff; flex-wrap: wrap; }

.item { display: grid; grid-template-columns: 2.4rem 1fr auto; gap: .2rem 1rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); align-items: start; }
.item:last-child { border-bottom: 0; }
.item .num { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--ink-3); font-size: .86rem; padding-top: .15rem; }
.item .txt { white-space: pre-wrap; }
.item .basis { font-size: .84rem; color: var(--ink-2); margin-top: .2rem; }
.item .basis b { font-weight: 600; }
.item .extra { margin-top: .5rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.item .extra label { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.item .extra .input { max-width: 340px; }
.item.st-nao-aplicavel .txt, .item.st-nao-aplicavel .basis { color: var(--ink-3); text-decoration: line-through; }
.item.parent { background: var(--surface-2); }
.item.parent .num { color: var(--brand); }
.item.sub { padding-left: 2.6rem; }
.item.sub .num { font-size: .8rem; }
.item.st-atendido { box-shadow: inset 3px 0 0 var(--ok); }
.item.st-nao-atendido { box-shadow: inset 3px 0 0 var(--bad); }
.item.st-nao-aplicavel { box-shadow: inset 3px 0 0 #b7bcc4; }
@media (max-width: 720px) {
  .item { grid-template-columns: 2rem 1fr; }
  .item .status { grid-column: 1 / -1; }
}

.status { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.status button {
  border: 0; border-right: 1px solid var(--line); background: none; cursor: pointer; padding: .38rem .7rem;
  font-size: .84rem; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.status button:last-child { border-right: 0; }
.status button:hover { background: var(--surface-2); }
.status button[data-st="atendido"].on { background: var(--ok); color: #fff; }
.status button[data-st="nao-atendido"].on { background: var(--bad); color: #fff; }
.status button[data-st="nao-aplicavel"].on { background: var(--na); color: #fff; }

.notice {
  display: flex; gap: .8rem; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border: 1px solid #f0d49a; background: var(--wait-soft); color: #6b4200; border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1rem;
}
.notice-info { border-color: #cddbee; background: var(--brand-soft); color: var(--brand); }

/* --- Editor de modelo ---------------------------------------------------- */
.tpl-item { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: .2rem .9rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); align-items: start; }
.tpl-item:last-child { border-bottom: 0; }
.tpl-item .num { font-weight: 650; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tpl-item .subs { margin: .35rem 0 0; padding-left: 1.1rem; font-size: .88rem; color: var(--ink-2); }
.tpl-item .applies { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.tpl-item .ops { display: flex; gap: .15rem; }
.warn-text { color: var(--bad); font-size: .82rem; }
.types-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .types-grid { grid-template-columns: 1fr; } }
.suggest { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .5rem; }
.suggest button { border: 1px dashed var(--line-strong); background: none; border-radius: 999px; padding: .1rem .55rem; font-size: .78rem; cursor: pointer; color: var(--ink-2); }
.suggest button:hover { border-color: var(--brand-2); color: var(--brand); }
.subitem-row { display: flex; gap: .4rem; align-items: center; margin-top: .4rem; }
.preview-list { max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.preview-list label { display: grid; grid-template-columns: auto 1fr; gap: .5rem; padding: .45rem .7rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.preview-list label:last-child { border-bottom: 0; }

.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .9rem; }
.tpl-card { display: flex; flex-direction: column; gap: .5rem; padding: 1rem 1.15rem; }
.tpl-card p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.tpl-card .row { margin-top: auto; }

/* --- Login ----------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth { width: 100%; max-width: 410px; }
.auth .brand-big { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.4rem; justify-content: center; color: var(--brand); }
.auth .brand-big .brand-mark { width: 38px; height: 38px; font-size: 1.25rem; background: var(--brand); color: #fff; border-radius: 10px; }
.auth .brand-big span:last-child { font-size: 1.35rem; }
.auth .card { padding: 1.6rem; }
.auth h1 { font-size: 1.2rem; margin-bottom: .3rem; }
.auth .alt { text-align: center; margin-top: 1rem; font-size: .9rem; color: var(--ink-2); }

/* --- Modal --------------------------------------------------------------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(18, 24, 33, .45); z-index: 50;
  display: grid; place-items: start center; padding: 6vh 1rem 2rem; overflow-y: auto;
  animation: fade .12s ease-out;
}
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .14s ease-out; }
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head p { margin: .2rem 0 0; color: var(--ink-3); font-size: .88rem; }
.modal-body { padding: 1.1rem 1.25rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 12px 12px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.99); } }
.copy-box { width: 100%; min-height: 300px; font-family: var(--mono); font-size: .85rem; }
.secret { font-family: var(--mono); font-size: 1.05rem; background: var(--surface-2); border: 1px dashed var(--line-strong); padding: .5rem .75rem; border-radius: var(--radius-sm); user-select: all; }

/* --- Avisos rápidos ------------------------------------------------------- */
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 80; display: flex; flex-direction: column; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast {
  background: var(--ink); color: #fff; padding: .7rem .95rem; border-radius: 8px; box-shadow: var(--shadow-lg);
  font-size: .9rem; animation: pop .15s ease-out; display: flex; gap: .7rem; align-items: flex-start;
}
.toast.ok { background: #14532d; }
.toast.err { background: #8c1d16; }
.toast small { display: block; opacity: .8; }
.toast button { margin-left: auto; background: none; border: 0; color: #fff; opacity: .7; cursor: pointer; font-size: 1.05rem; line-height: 1; }

/* --- Telas pequenas ------------------------------------------------------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: .5rem .8rem; gap: .4rem .8rem; }
  .topbar-right { gap: .5rem; }
  .user-name { display: none; }
  .save-state { min-width: 0; }
  .nav { order: 3; width: 100%; margin: 0 -.4rem; }
  .app { padding: 1rem .8rem 4rem; }
  .page-head > .grow, .page-head > div:first-child { flex-basis: 100%; }
  h1 { font-size: 1.3rem; }
  .sticky-summary { position: static; }
  .person > summary { padding: .75rem .8rem; }
  .item { padding: .75rem .8rem; }
  .item.sub { padding-left: 1.4rem; }
  .status { width: 100%; }
  .status button { flex: 1; }
  .dl-row { flex-wrap: wrap; }
  .seg-filter { max-width: 100%; overflow-x: auto; }
  .seg-filter button { white-space: nowrap; }
}

/* --- Impressão----------------------------------------------------------- */
.print-only { display: none; }
@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff; font-size: 11pt; }
  body > *:not(#print) { display: none !important; }
  .print-only { display: block !important; color: #000; }
  .print-only h1 { font-size: 15pt; margin-bottom: 4pt; }
  .print-only h2 { font-size: 12pt; margin: 14pt 0 6pt; border-bottom: 1px solid #000; padding-bottom: 2pt; }
  .print-only h3 { font-size: 11pt; margin: 10pt 0 4pt; }
  .print-only .meta { font-size: 9.5pt; color: #333; margin-bottom: 8pt; }
  .print-only ol { margin: 0 0 6pt 0; padding-left: 18pt; }
  .print-only li { margin: 2pt 0; break-inside: avoid; }
  .print-only .sub { list-style: none; padding-left: 12pt; }
  .print-only .note { font-style: italic; color: #333; }
  .print-only .foot { margin-top: 18pt; font-size: 8.5pt; color: #555; }
}
