/* ============================================================
   ConVert · Auditoria de Folha — identidade visual
   navy #0B193C · dourado #C4A55A · Inter
   ============================================================ */
:root {
  --navy: #0b193c;
  --navy-2: #13264f;
  --navy-soft: #e9edf5;
  --gold: #c4a55a;
  --gold-soft: #f1e9d6;
  --paper: #f5f3ee;
  --card: #ffffff;
  --ink: #1b2334;
  --muted: #6b7280;
  --line: #e3e0d8;
  --red: #b3362a;
  --red-soft: #fbe9e6;
  --green: #2e7d5b;
  --green-soft: #e6f2ec;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(11, 25, 60, 0.08), 0 4px 16px rgba(11, 25, 60, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------------- SHELL / SIDEBAR ---------------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--navy); color: #fff;
  display: flex; flex-direction: column; gap: 14px; padding: 20px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .side-logo { height: 30px; filter: brightness(0) invert(1); align-self: flex-start; margin-bottom: 4px; }
.side-btn {
  display: flex; align-items: center; gap: 9px; background: var(--gold); color: var(--navy);
  border: none; border-radius: 9px; padding: 11px 13px; font-weight: 700; font-size: 13.5px;
  width: 100%; text-align: left;
}
.side-btn:hover { filter: brightness(1.06); }
.side-btn-ico { font-size: 15px; }
.side-client { background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 9px; padding: 10px 12px; }
.side-client-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); font-weight: 700; margin-bottom: 4px; }
.side-client-name { font-size: 13px; font-weight: 600; line-height: 1.35; word-break: break-word; }
.side-spacer { flex: 1; }
.side-foot { font-size: 10.5px; color: rgba(255, 255, 255, 0.45); }
.main-col { flex: 1; min-width: 0; }

/* ---------------- Clientes (modal) ---------------- */
.client-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.client-list-item:last-child { border-bottom: none; }
.client-list-item .cl-info { flex: 1; min-width: 0; }
.client-list-item .cl-info b { font-size: 13.5px; display: block; }
.client-list-item .cl-info small { color: var(--muted); font-size: 11.5px; }
.client-list-item.active { background: var(--gold-soft); border-radius: 8px; padding: 10px 8px; }
.divider-txt { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11.5px; margin: 16px 0 12px; }
.divider-txt::before, .divider-txt::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.cnpj-row { display: flex; gap: 8px; }
.cnpj-row input { flex: 1; }
.cnpj-preview { background: var(--navy-soft); border-radius: 9px; padding: 10px 12px; font-size: 12.5px; margin-top: 10px; line-height: 1.6; display: none; }
.cnpj-preview.show { display: block; }

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; gap: 12px; }
  .sidebar .side-logo { height: 24px; margin-bottom: 0; }
  .side-client { display: none; }
  .side-spacer { display: none; }
  .side-foot { display: none; }
  .side-btn { width: auto; }
}

/* ---------------- LOGIN ---------------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(196, 165, 90, 0.18), transparent 60%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.login-card img.logo { height: 52px; display: block; margin: 0 auto 8px; }
.login-card .sys-name {
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 28px;
}
.login-card h1 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fbfaf7;
  transition: border-color 0.15s;
}
.field input:focus { outline: none; border-color: var(--gold); background: #fff; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 18px;
  border-radius: 9px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  transition: filter 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; width: 100%; }
.btn-primary:hover { filter: brightness(1.25); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--gold); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 7px; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.msg { font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }
.login-foot { text-align: center; font-size: 11px; color: var(--muted); margin-top: 24px; }

/* ---------------- APP SHELL ---------------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar img.logo { height: 36px; }
.topbar .sys-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  border-left: 1px solid var(--line);
  padding-left: 14px;
  line-height: 1.35;
}
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: var(--muted); text-align: right; line-height: 1.3; }
.topbar .who b { color: var(--ink); display: block; }

.tabs {
  background: var(--navy);
  display: flex;
  gap: 2px;
  padding: 0 14px;
  overflow-x: auto;
  position: sticky;
  top: 62px;
  z-index: 49;
}
.tabs button {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.65);
  padding: 13px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs button.active { color: #fff; border-bottom-color: var(--gold); }
.tabs button:hover { color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }
.view { display: none; }
.view.active { display: block; }

h2.section { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
p.section-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }

/* ---------------- TRILHO DA AUDITORIA (assinatura) ---------------- */
.rail { display: flex; gap: 5px; margin: 18px 0 26px; }
.rail .seg { flex: 1; min-width: 0; cursor: pointer; }
.rail .seg .bar {
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
  position: relative;
}
.rail .seg .bar i {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: 5px;
  transition: width 0.4s ease;
}
.rail .seg.done .bar i { background: var(--navy); }
.rail .seg.late .bar { background: var(--red-soft); }
.rail .seg.late .bar i { background: var(--red); }
.rail .seg .lbl { font-size: 10.5px; color: var(--muted); margin-top: 6px; text-align: center; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .seg.late .lbl { color: var(--red); }

/* ---------------- CARDS / KPI ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.kpi .k-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 8px; }
.kpi .k-value { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi .k-foot { font-size: 12.5px; color: var(--muted); margin-top: 7px; }
.kpi.alert { border-left: 4px solid var(--red); }
.kpi.alert .k-value { color: var(--red); }
.kpi.next { border-left: 4px solid var(--gold); }

.progress { height: 8px; background: var(--navy-soft); border-radius: 4px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--gold); border-radius: 4px; transition: width 0.4s; }
.progress.full i { background: var(--green); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.phase-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.phase-row:last-child { border-bottom: none; }
.phase-row .nm { flex: 1; font-size: 13.5px; font-weight: 600; min-width: 0; }
.phase-row .nm small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.phase-row .progress { width: 130px; flex-shrink: 0; }
.phase-row .pct { width: 42px; text-align: right; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.04em; }
.badge.late { background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.prog { background: var(--gold-soft); color: #8a6d2c; }
.badge.wait { background: var(--navy-soft); color: var(--navy); }
@keyframes pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .badge.late { animation: none; } }

.evt-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.evt-item:last-child { border-bottom: none; }
.evt-item .dt {
  flex-shrink: 0; width: 46px; text-align: center; background: var(--navy); color: #fff;
  border-radius: 9px; padding: 6px 0; line-height: 1.15;
}
.evt-item .dt b { display: block; font-size: 17px; }
.evt-item .dt span { font-size: 10px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.evt-item .tx { min-width: 0; }
.evt-item .tx b { font-size: 13.5px; display: block; }
.evt-item .tx span { font-size: 12px; color: var(--muted); }
.evt-item.past { opacity: 0.5; }

/* ---------------- FASES ---------------- */
.phase-card { margin-bottom: 14px; overflow: hidden; padding: 0; }
.phase-head {
  display: flex; align-items: center; gap: 14px; padding: 16px 20px; cursor: pointer;
  user-select: none;
}
.phase-head:hover { background: #fbfaf6; }
.phase-head .ph-title { flex: 1; min-width: 0; }
.phase-head .ph-title b { font-size: 15px; display: block; }
.phase-head .ph-title small { color: var(--muted); font-size: 12px; }
.phase-head .ph-prog { width: 150px; flex-shrink: 0; }
.phase-head .chev { color: var(--muted); transition: transform 0.2s; font-size: 12px; }
.phase-card.open .chev { transform: rotate(90deg); }
.phase-card.late-card { border-left: 4px solid var(--red); }
.phase-body { display: none; border-top: 1px solid var(--line); padding: 6px 20px 16px; }
.phase-card.open .phase-body { display: block; }
.phase-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0 4px; border-top: 1px dashed var(--line); margin-top: 8px; }

.act { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid #f0eee7; align-items: flex-start; }
.act:last-of-type { border-bottom: none; }
.act .chk {
  flex-shrink: 0; width: 22px; height: 22px; border: 2px solid #c9c4b6; border-radius: 6px;
  background: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: transparent; margin-top: 1px; transition: all 0.15s;
}
.act .chk:hover { border-color: var(--gold); }
.act.done .chk { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.act .a-main { flex: 1; min-width: 0; }
.act .a-title { font-size: 13.5px; line-height: 1.45; }
.act.done .a-title { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(107, 114, 128, 0.5); }
.act .a-meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.act .a-meta .att-pill {
  display: inline-flex; align-items: center; gap: 4px; background: var(--gold-soft); color: #8a6d2c;
  border-radius: 20px; padding: 1px 9px; font-weight: 600; margin-right: 6px; cursor: pointer;
}
.act .a-tools { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 7px; width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--muted);
}
.icon-btn:hover { border-color: var(--gold); color: var(--navy); }
.notes-box { width: 100%; margin-top: 8px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 8px; resize: vertical; min-height: 54px; font-size: 13px; background: #fbfaf7; }
.notes-box:focus { outline: none; border-color: var(--gold); }

/* ---------------- CONTROLE DE DOCUMENTOS ---------------- */
.doc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.st-btn {
  flex-shrink: 0; border: none; border-radius: 20px; padding: 6px 13px; font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; min-width: 96px;
  transition: filter 0.15s;
}
.st-btn:hover { filter: brightness(0.95); }
.st-btn.pendente { background: var(--navy-soft); color: var(--navy); }
.st-btn.solicitado { background: var(--gold-soft); color: #8a6d2c; border: 1px solid var(--gold); }
.st-btn.recebido { background: var(--green-soft); color: var(--green); }
.st-btn.atrasado { background: var(--red); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.doc-cat-head { display: flex; align-items: center; gap: 12px; margin: 0 0 4px; }
.doc-cat-head h3 { font-size: 15px; flex: 1; }
.doc-cat-head .progress { width: 140px; }
.doc-cat-head .pct { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; width: 40px; text-align: right; }

/* ---------------- CALENDÁRIO ---------------- */
.cal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.cal-month { padding: 16px 18px 20px; }
.cal-month h3 { font-size: 15px; font-weight: 800; margin-bottom: 12px; text-transform: capitalize; }
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-table th { font-size: 10.5px; text-transform: uppercase; color: var(--muted); padding-bottom: 8px; font-weight: 700; }
.cal-table td { text-align: center; padding: 2px; }
.cal-day {
  position: relative; width: 100%; aspect-ratio: 1; max-height: 44px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; border-radius: 9px; font-size: 13px;
  font-variant-numeric: tabular-nums; cursor: default;
}
.cal-day.has-evt { background: var(--navy); color: #fff; font-weight: 700; cursor: pointer; }
.cal-day.has-prazo { background: var(--gold-soft); color: #8a6d2c; font-weight: 700; cursor: pointer; }
.cal-day.has-evt.has-prazo { background: linear-gradient(135deg, var(--navy) 55%, var(--gold) 55%); }
.cal-day.late-day { background: var(--red); color: #fff; font-weight: 700; }
.cal-day.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0 20px; font-size: 12.5px; color: var(--muted); }
.cal-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

/* ---------------- TABELAS ---------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid #f0eee7; vertical-align: middle; }
.tbl tr:hover td { background: #fbfaf6; }
.tbl .file-nm { font-weight: 600; word-break: break-all; }

/* ---------------- MODAL / TOAST ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(11, 25, 60, 0.55); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.overlay.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 26px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto; }
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal .m-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--navy); color: #fff; padding: 12px 22px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); transition: transform 0.25s; z-index: 200;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

.loading { text-align: center; padding: 60px 0; color: var(--muted); }

@media (max-width: 640px) {
  .topbar .sys-tag { display: none; }
  .phase-head .ph-prog { display: none; }
  .rail .seg .lbl { display: none; }
}
@media print { .topbar, .tabs { display: none; } }
