:root {
  --bg: #f3f5f8; --card: #fff; --text: #1d2430; --muted: #6b7280; --line: #e3e7ee;
  --primary: #1f5fbf; --primary-d: #17498f; --ok: #1e8e3e; --warn: #c77700; --bad: #c62828; --info: #2563eb;
  --radius: 10px; --shadow: 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.erro { color: var(--bad); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--primary); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.login-card { max-width: 380px; margin: 12vh auto; display: flex; flex-direction: column; gap: 12px; }
.login-card p { margin: 0 0 8px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
input, select { padding: 8px 10px; border: 1px solid #cfd6e0; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus { outline: 2px solid #bcd0f5; border-color: var(--primary); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid #cfd6e0; background: #fff; color: var(--text); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f6f8fb; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #eef1f6; }
.btn.danger { color: var(--bad); border-color: #f1c4c4; }
.btn.danger:hover { background: #fdeeee; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 16px; }
#nav { display: flex; gap: 4px; flex: 1; }
.nav-btn { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px; font: inherit; cursor: pointer; color: var(--muted); }
.nav-btn.active { background: #e9effb; color: var(--primary); font-weight: 600; }
.user { display: flex; align-items: center; gap: 8px; }

main { max-width: 1200px; margin: 0 auto; padding: 18px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.toolbar input { flex: 1; max-width: 420px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi-t { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-v { font-size: 22px; font-weight: 700; margin: 6px 0 4px; }
.kpi-s { font-size: 12px; color: var(--muted); }
.toolbar label { flex-direction: row; align-items: center; gap: 6px; }

.cnpj-card { margin-bottom: 14px; }
.cnpj-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.aviso { background: #fff7e6; border: 1px solid #ffe0a3; color: #7a4d00; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.small th, .tbl.small td { padding: 5px 6px; font-size: 12.5px; }
.tbl tr.sel { background: #eef3fd; }
.tbl tr.inativo { opacity: .6; }
.cert-tbl td.acoes { white-space: nowrap; text-align: right; }
.cert-tbl td.acoes .btn { margin-left: 4px; }
td.acoes { white-space: nowrap; }
td.acoes .btn { margin-right: 4px; }
.ult { max-width: 360px; word-break: break-word; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: #e4f4e8; color: var(--ok); }
.badge.warn { background: #fff1dc; color: var(--warn); }
.badge.bad { background: #fde8e8; color: var(--bad); }
.badge.neutral { background: #eceff3; color: var(--muted); }
.badge.info { background: #e6eefc; color: var(--info); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: #eceff3; color: var(--muted); font-size: 11px; margin-left: 4px; }
.tag.info { background: #e6eefc; color: var(--info); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #b8c0cc; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); } .dot.info { background: var(--info); }

.form-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-inline input { flex: 1; min-width: 120px; }
.form-col { display: flex; flex-direction: column; gap: 12px; min-width: 320px; }
.lista { margin: 6px 0; padding-left: 18px; }

.modal { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; max-width: 980px; width: 100%; max-height: 90vh; overflow: auto; position: relative; }
.modal-close { position: absolute; top: 8px; right: 10px; border: 0; background: transparent; font-size: 24px; cursor: pointer; color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1d2430; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 30; max-width: 90vw; }
.toast.ok { background: var(--ok); } .toast.erro { background: var(--bad); } .toast.info { background: var(--info); }
