:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #e4e6eb;
  --text: #111318;
  --muted: #5d6471;
  --primary: #1d4ed8;
  --primary-dark: #1e40af;
  --side: #17191f;
  --side-active: #2a2d35;
  --green: #14532d;
  --red: #9b1c1c;
  --radius: 14px;
  --font: 'Inter Variable', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Topo ---------- */
.topbar { height: 58px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 18px; position: sticky; top: 0; z-index: 20; }
.topbar .logo { display: block; height: 34px; width: auto; }
.topbar .divider { width: 1px; height: 28px; background: var(--border); }
.topbar .title { font-size: 15px; font-weight: 600; }

/* ---------- Estrutura com barra lateral ---------- */
.layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 58px); }
.sidebar { background: var(--side); color: #e7e9ee; padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 58px; height: calc(100vh - 58px); }
.sidebar .section { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9aa1ad; padding: 2px 12px 14px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: #c9cdd6; text-decoration: none; padding: 10px 12px; border-radius: 9px; font-weight: 500; }
.sidebar nav a:hover { background: #22252c; }
.sidebar nav a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.sidebar .me { margin-top: auto; border-top: 1px solid #2c2f37; padding: 16px 12px 6px; }
.sidebar .me strong { display: block; color: #fff; font-size: 13.5px; }
.sidebar .me span { display: block; color: #9aa1ad; font-size: 12.5px; margin-bottom: 8px; }
.linklike { background: none; border: 0; padding: 0; color: #9db8ff; text-decoration: underline; cursor: pointer; font-size: 13px; }

.main { padding: 28px 32px 48px; min-width: 0; }
.main-inner { max-width: 1080px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
h1 { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.subtitle { color: var(--muted); margin-top: 4px; }
.back { display: inline-block; margin-bottom: 8px; font-size: 13px; }

/* ---------- Cartões / estatísticas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.stat.pending { background: #fff4dc; border-color: #f1d9a0; }
.stat.pending .value { color: #8a4b08; }
.stat .value.green { color: #14612f; }
.stat .value.red { color: #a31f1f; }
.stat .value.amber { color: #8a4b08; }

/* ---------- Botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: #f6f7f9; }
.btn:focus-visible, .chip input:focus-visible + span, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid #7aa2ff; outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #0f3f22; }
.btn-danger { color: var(--red); border-color: #e9c4c4; background: #fff; }
.btn-danger:hover { background: #fdf3f3; }
.btn-lg { padding: 12px 18px; font-size: 14.5px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Tabelas ---------- */
.toolbar { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.filters .grow { flex: 1; min-width: 220px; }
.field label, .label-sm { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; background: #fff; border: 1px solid #cfd3da; border-radius: 10px; padding: 10px 12px; }
.input::placeholder { color: #8b919c; }
.input[readonly], .input:disabled { background: #eef0f3; color: #4b5260; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #6c7380; pointer-events: none; }
.search .input { padding-left: 36px; }
.pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 18px; }
.pill { border: 1px solid #cfd3da; background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 13px; text-decoration: none; color: var(--text); font-weight: 500; }
.pill.active { background: #111318; border-color: #111318; color: #fff; }
.pills .count { margin-left: auto; color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 12px 18px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fff; white-space: nowrap; }
td { padding: 14px 18px; border-bottom: 1px solid #eceef2; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: #fafbfc; }
th.right, td.right { text-align: right; }
td.muted, .muted { color: var(--muted); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }
tr.inactive td { background: #fafafa; color: #7a808c; }

.person { display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #e6ecff; color: #26469c; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.person strong { display: block; font-weight: 600; }
.person small { color: var(--muted); font-size: 12px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.pendente { background: #fdeed0; color: #8a4b08; }
.badge.aprovada, .badge.ativo { background: #dcf3e3; color: #14612f; }
.badge.rejeitada { background: #fbdcdc; color: #9b1c1c; }
.badge.inativo { background: #e8eaee; color: #5d6471; }
.doc-link { word-break: break-all; }
.more { color: var(--muted); font-size: 12px; margin-left: 4px; }

.pager { display: flex; justify-content: center; gap: 10px; align-items: center; padding: 14px; border-top: 1px solid var(--border); color: var(--muted); }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.footnote { margin-top: 14px; color: var(--muted); font-size: 13px; }

/* ---------- Mensagens ---------- */
.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.flash.success { background: #e8f6ed; border-color: #b9e0c6; color: #14532d; }
.flash.error { background: #fdeeee; border-color: #f0c7c7; color: #8b1a1a; }
.flash.warning { background: #fff4dc; border-color: #f1d9a0; color: #7a4308; }
.field-error { color: #b42318; font-size: 12.5px; margin-top: 6px; }
.input.invalid { border-color: #d4534b; }

/* ---------- Autenticação ---------- */
.auth-main { display: grid; place-items: start center; padding: 70px 16px 48px; }
.auth-card { width: 100%; max-width: 380px; padding: 36px 38px 30px; border-radius: 20px; }
.auth-card.wide { max-width: 400px; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card .subtitle { margin: 0 0 22px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .row { display: flex; justify-content: space-between; align-items: baseline; }
.auth-card .row label { margin-bottom: 6px; }
.auth-card .row a { font-size: 13px; }
.checkbox { display: flex; gap: 10px; align-items: center; margin: 4px 0 18px; color: #3a404c; cursor: pointer; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--primary); flex: none; }
.auth-card .switch { text-align: center; margin-top: 18px; }
.auth-card .switch a { font-weight: 700; }
.demo { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; color: var(--muted); font-size: 13px; }
.pw-wrap { position: relative; }
.pw-wrap .toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 6px; color: #5d6471; cursor: pointer; }
.pw-wrap .input { padding-right: 42px; }
.hints { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }

/* ---------- Formulário de justificação ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; align-items: start; }
.form-card { padding: 26px 28px; }
.form-card h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.form-card section + section { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 22px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field { margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; border: 1px solid #cfd3da; border-radius: 9px; padding: 8px 14px; cursor: pointer; background: #fff; font-weight: 500; }
.chip input:checked + span { background: #e6eeff; border-color: #7aa2ff; color: #1d3f9e; font-weight: 600; }
.side-card { padding: 20px 22px; position: sticky; top: 86px; }
.side-card h3 { font-size: 15px; margin-bottom: 14px; }
.side-card dl { margin: 0; }
.side-card .kv { display: flex; justify-content: space-between; padding: 5px 0; }
.side-card dt { color: var(--muted); }
.side-card dd { margin: 0; font-weight: 700; }
.side-card hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.side-card p { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.pendente-text { color: #8a4b08; font-weight: 700; }

.dropzone { border: 1.5px dashed #bcc3d0; border-radius: 12px; padding: 26px 16px; text-align: center; cursor: pointer; display: block; background: #fcfcfd; }
.dropzone.drag { background: #eef3ff; border-color: #7aa2ff; }
.dropzone svg { color: #1d4ed8; }
.dropzone strong { display: block; color: var(--primary); margin-top: 6px; }
.dropzone small { display: block; color: var(--muted); margin-top: 4px; }
.file-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.file-ext { background: #fde8e8; color: #b42318; font-size: 10.5px; font-weight: 800; border-radius: 6px; padding: 7px 8px; min-width: 40px; text-align: center; }
.file-ext.img { background: #e6f0ff; color: #1d4ed8; }
.file-meta { flex: 1; min-width: 0; }
.file-meta b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta small { color: var(--muted); }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 18px; color: #5d6471; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: #f0f1f4; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.hidden { display: none !important; }

/* ---------- Detalhe ---------- */
.detail { padding: 24px 28px; }
.detail dl { display: grid; grid-template-columns: 180px 1fr; gap: 10px 18px; margin: 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.reject-box { border: 1px solid #f0c7c7; background: #fdf2f2; border-radius: 12px; padding: 14px 16px; margin: 0 0 20px; color: #6f1818; }
.reject-box strong { display: block; margin-bottom: 4px; }
.approved-box { border: 1px solid #b9e0c6; background: #eef9f1; border-radius: 12px; padding: 14px 16px; margin: 0 0 20px; color: #14532d; }
.stack { display: grid; gap: 18px; }

/* ---------- Diálogo ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(480px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(10, 14, 25, .28); }
dialog::backdrop { background: rgba(15, 18, 28, .5); }
dialog form { padding: 24px; }
dialog h3 { font-size: 18px; margin-bottom: 6px; }
dialog p { color: var(--muted); margin-bottom: 14px; }
dialog textarea { min-height: 110px; resize: vertical; }
dialog .form-actions { margin-top: 16px; }

.error-page { display: grid; place-items: center; min-height: 60vh; text-align: center; padding: 24px; }
.error-page .code { font-size: 56px; font-weight: 800; color: #c5cad4; line-height: 1; }
.error-page h1 { margin: 10px 0 6px; font-size: 22px; }
.error-page p { color: var(--muted); margin-bottom: 18px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 10px; }
  .sidebar .section { display: none; }
  .sidebar nav { flex-direction: row; }
  .sidebar .me { margin: 0 0 0 auto; border: 0; padding: 0; text-align: right; }
  .main { padding: 20px 16px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .side-card { position: static; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .detail dl { grid-template-columns: 1fr; gap: 2px; }
  .detail dt { margin-top: 10px; }
  .topbar { padding: 0 14px; }
  .topbar .title { font-size: 13px; }
}

td.muted { white-space: nowrap; }
.doc-link { word-break: normal; overflow-wrap: anywhere; }

td .actions { flex-wrap: nowrap; }
td strong { white-space: nowrap; }

.ms-btn { gap: 12px; background: #fff; border-color: #8c8f99; color: #2f2f2f; font-weight: 600; margin-top: 6px; }
.ms-btn:hover { background: #f3f3f3; }
