/* =============================================================================
   ERP Contábil — tema visual (DM Sans + Tabler Icons, verde da marca,
   cartões brancos com borda #e0e0e0, portal de módulos e login sóbrio).
   ============================================================================= */
:root {
  --bg: #f5f5f0; --card: #fff; --ink: #1a1a1a; --muted: #777; --line: #e0e0e0;
  --brand: #2d6a4f; --brand-d: #245a42; --brand-dd: #1a5a3e; --brand-l: #e8f5e9; --login: #00704f;
  --accent: #e07b00; --ok: #2d6a4f; --warn: #b45309; --bad: #d32f2f; --dark: #1a1a1a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
body::before { content: ''; position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 200;
  background: linear-gradient(90deg, #0d3b26 0%, #1a5a3e 25%, #2d7a55 50%, #4ade80 75%, #0d3b26 100%); }
body.is-login::before { display: none; }
a { color: var(--brand-dd); }
code { font-family: 'DM Mono', ui-monospace, monospace; background: #f0f0ea; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* ---------- Shell ---------- */
#app { display: flex; min-height: 100vh; }
.side { width: 236px; background: #fff; border-right: 1px solid #e2e8f0; padding: 18px 10px 24px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; text-decoration: none; }
.logo { background: var(--brand); color: #fff; padding: 4px 12px; border-radius: 4px; font-weight: 700; font-size: 13px; letter-spacing: 1px; white-space: nowrap; }
.brand .sub { font-size: 11px; color: #94a3b8; line-height: 1.2; }
.side .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; margin: 16px 10px 4px; font-weight: 600; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #475569; text-decoration: none; font-weight: 500; }
.side a.nav i { font-size: 18px; color: #94a3b8; width: 20px; text-align: center; }
.side a.nav:hover { background: #f1f5f2; color: var(--ink); }
.side a.nav.on { background: var(--brand-l); color: var(--brand-dd); box-shadow: inset 3px 0 0 var(--brand); }
.side a.nav.on i { color: var(--brand); }
.main { flex: 1; min-width: 0; padding: 26px 30px 70px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top h2 { margin: 0; font-size: 22px; font-weight: 600; }
.top .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 10px; background: #fff3e0; color: #b45309; border: 1px solid #fcd9a8; font-weight: 600; }
.badge.ok { background: var(--brand-l); color: var(--brand-dd); border-color: #b9dfc5; }
.badge.bad { background: #ffebee; color: #a02a1d; border-color: #f4b8b1; }
.spacer { flex: 1; }

/* ---------- Cards, KPIs ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 500; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pos { color: var(--ok); } .neg { color: var(--bad); } .mut { color: var(--muted); }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); border-bottom: 1px solid var(--line); padding: 8px 8px; white-space: nowrap; font-weight: 600; }
td { padding: 8px 8px; border-bottom: 1px solid #efefea; vertical-align: middle; }
tr:hover td { background: #fafaf7; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.sint td { font-weight: 600; background: #f6f8f5; }
tr.tot td { font-weight: 700; border-top: 2px solid var(--ink); background: #eef4ef; }
tr.sub td { font-weight: 600; background: #f6f8f5; }
.tbl-wrap { overflow-x: auto; }

/* ---------- Botões, campos ---------- */
button, .btn { font: inherit; font-weight: 500; border: 1px solid #ddd; background: #fff; color: var(--ink); padding: 7px 14px; border-radius: 8px; cursor: pointer; }
button:hover { background: #f5f5f0; }
button.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
button.pri:hover { background: var(--brand-d); }
button.dng { color: var(--bad); }
button.dng:hover { background: #ffebee; border-color: #ef9a9a; }
button.sm { padding: 3px 9px; font-size: 12.5px; border-radius: 6px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 8px 12px; border: 1.5px solid #ddd; border-radius: 8px; background: #fff; color: var(--ink); min-width: 0; transition: border-color .2s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
label { font-size: 12.5px; color: #555; display: block; margin-bottom: 4px; font-weight: 500; }
.filtros { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tabs button { border-radius: 8px; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 4px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; background: #f0f0ea; color: #555; }
.pill.ok { background: var(--brand-l); color: var(--brand-dd); }
.pill.bad { background: #ffebee; color: #b3261e; }
.pill.warn { background: #fff3e0; color: #b45309; }
.empty { text-align: center; color: #999; padding: 32px; }
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid; }
.alert.ok { background: #eaf6ee; border-color: #b9dfc5; color: var(--brand-dd); }
.alert.bad { background: #fff4f2; border-color: #f3c4bb; color: #8f1d10; }
.alert.info { background: #eef4fb; border-color: #c4d8ee; color: #1a3d63; }

/* ---------- Modal / formulário ---------- */
.ov { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow: auto; z-index: 1000; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 880px; }
.modal h3 { margin: 0 0 18px; font-size: 18px; font-weight: 600; }
.frm { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.frm .full { grid-column: 1 / -1; }
.frm input, .frm select, .frm textarea { width: 100%; }
.acts { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--dark); color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 1100; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }

/* ---------- Gráfico ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding-top: 8px; }
.bars .g { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bars .b { width: 18px; border-radius: 3px 3px 0 0; min-height: 1px; }
.b.rec { background: var(--brand); } .b.des { background: var(--accent); }
.bars .lb { font-size: 11px; color: var(--muted); }
.leg { font-size: 12px; color: var(--muted); display: flex; gap: 14px; margin-top: 6px; }
.leg i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }

/* ---------- Portal (início): grade de sistemas + lista de relatórios ---------- */
.portal-title { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.portal-subtitle { color: #666; margin: 0 0 28px; }
.sec-tit { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin-bottom: 32px; }
.sys-card { background: #fff; border-radius: 12px; padding: 22px; border: 1px solid var(--line); cursor: pointer; transition: all .2s; text-decoration: none; color: inherit; display: block; position: relative; overflow: hidden; }
.sys-card:hover { border-color: var(--brand); box-shadow: 0 4px 12px rgba(45,106,79,.12); transform: translateY(-2px); }
.sys-card.featured { border-color: var(--brand); background: linear-gradient(160deg, #fff 0%, #f4f9f5 100%); }
.sys-card .new-badge { position: absolute; top: 12px; right: 12px; background: linear-gradient(135deg, #1a5a3e 0%, #2d6a4f 100%); color: #fff; font-size: 9px; font-weight: 800; letter-spacing: 1.5px; padding: 3px 9px; border-radius: 10px; text-transform: uppercase; }
.sys-card .icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.icon.orange { background: #fff3e0; color: #e07b00; } .icon.blue { background: #e3f2fd; color: #1565c0; }
.icon.green { background: #e8f5e9; color: #2d6a4f; } .icon.purple { background: #f3e5f5; color: #7b1fa2; }
.icon.red { background: #ffebee; color: #d32f2f; } .icon.emerald { background: #e8f1ea; color: #1a5a3e; }
.icon.amber { background: #fef3c7; color: #b45309; } .icon.teal { background: #e0f2f1; color: #00695c; }
.sys-card h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.sys-card p { font-size: 13px; color: #888; margin: 0; }
.rel-lista { display: flex; flex-direction: column; gap: 10px; margin-bottom: 32px; }
.rel-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; transition: border-color .15s; text-decoration: none; color: inherit; }
.rel-item:hover { border-color: var(--brand); }
.rel-item .ri-ic { width: 40px; height: 40px; border-radius: 9px; background: #e8f1ea; color: #1a5a3e; display: flex; align-items: center; justify-content: center; font-size: 20px; flex: none; }
.rel-item .ri-tx { flex: 1; min-width: 0; }
.rel-item .ri-t { font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.rel-item .ri-d { font-size: 12.5px; color: #666; margin-top: 2px; }
.rel-item .ri-btn { background: var(--brand); color: #fff; border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13.5px; white-space: nowrap; }

/* ---------- Login (sóbrio: barra branca, caixa 440px, rodapé escuro) ---------- */
.lg-page { display: flex; flex-direction: column; flex: 1 1 100%; width: 100%; min-width: 0; min-height: 100vh; background: #f4f4f4; }
.lg-top { display: flex; align-items: center; gap: 16px; height: 64px; padding: 0 32px; background: #fff; border-bottom: 1px solid #e0e0e0; flex-shrink: 0; }
.lg-top-sep { width: 1px; height: 22px; background: #bdbdbd; }
.lg-top-title { font-size: 17px; font-weight: 500; color: var(--login); }
.lg-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px 72px; }
.lg-box { background: #fff; border: 1px solid #bdbdbd; border-radius: 4px; padding: 32px 32px 36px; width: 100%; max-width: 440px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.lg-h1 { font-size: 26px; font-weight: 600; line-height: 1.25; margin: 0 0 28px; }
.lg-sub { color: #666; margin: -16px 0 24px; font-size: 14px; }
.lg-field { position: relative; margin-bottom: 22px; }
.lg-field label { position: absolute; top: -8px; left: 9px; padding: 0 4px; background: #fff; font-size: 12px; color: #404040; line-height: 16px; margin: 0; font-weight: 400; }
.lg-field input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #8c8c8c; border-radius: 3px; font-size: 15px; }
.lg-field input:focus { border-color: var(--login); box-shadow: 0 0 0 1px var(--login); }
.lg-btn { display: inline-block; padding: 10px 20px; background: var(--login); color: #fff; border: none; border-radius: 3px; font-size: 15px; font-weight: 600; cursor: pointer; }
.lg-btn:hover { background: #005c41; }
.lg-btn:disabled { opacity: .6; cursor: wait; }
.lg-err { color: #b3261e; font-size: 13px; margin: -8px 0 16px; line-height: 1.4; min-height: 0; }
.lg-err:empty { display: none; }
.lg-err.ok { color: var(--ok); }
.lg-help { margin-top: 22px; font-size: 14px; color: #404040; text-align: center; }
.lg-help a { color: #0b62c4; }
.lg-foot { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; background: #262626; color: #d9d9d9; padding: 16px 32px; font-size: 13px; flex-shrink: 0; }

/* ---------- Impressão / responsivo ---------- */
.print-h { display: none; }
@media print {
  body::before { display: none; }
  .side, .top button, .filtros, .acts, .no-print, .tabs { display: none !important; }
  .main { padding: 0; } body { background: #fff; }
  .card { border: none; padding: 0; box-shadow: none; } .print-h { display: block; margin-bottom: 10px; }
}
@media (max-width: 800px) {
  #app { flex-direction: column; } .side { width: 100%; height: auto; position: static; } .frm { grid-template-columns: 1fr; }
  .main { padding: 18px 14px 60px; }
}
@media (max-width: 640px) {
  .lg-top { padding: 0 16px; gap: 12px; height: 56px; } .lg-body { padding: 32px 16px; } .lg-box { padding: 24px 20px 28px; } .lg-h1 { font-size: 22px; }
  .lg-foot { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
}

ul.check{list-style:none;padding:0;margin:0}
ul.check li{padding:4px 0}

/* ---- Assistente de IA ---- */
#ia-fab { position: fixed; right: 20px; bottom: 20px; z-index: 900; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; font-size: 24px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; }
#ia-fab:hover { background: var(--brand-d); }
#ia-panel { position: fixed; right: 20px; bottom: 84px; z-index: 900; width: min(400px, calc(100vw - 24px)); height: min(600px, calc(100vh - 110px)); background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.22); display: flex; flex-direction: column; overflow: hidden; }
#ia-panel[hidden] { display: none; }
.is-login #ia-fab, .is-login #ia-panel { display: none; }
.ia-top { display: flex; align-items: center; gap: 6px; padding: 10px 12px; background: var(--brand); color: #fff; }
.ia-top .spacer { flex: 1; } .ia-top button { background: rgba(255,255,255,.18); color: #fff; border: 0; }
.ia-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ia-m { display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.ia-m.user { align-self: flex-end; } .ia-m.assistant { align-self: flex-start; }
.ia-b { padding: 8px 12px; border-radius: 10px; line-height: 1.45; }
.ia-m.user .ia-b { background: var(--brand-l); } .ia-m.assistant .ia-b { background: #f1f1ec; }
.ia-b p { margin: 0 0 6px; } .ia-b p:last-child { margin: 0; } .ia-b ul { margin: 4px 0; padding-left: 18px; }
.ia-ac { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; font-size: 13px; }
.ia-acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.ia-vazio { color: var(--muted); } .ia-vazio p { margin: 6px 0; }
.ia-sug { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; } .ia-sug button { text-align: left; }
.ia-form { display: flex; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); }
.ia-form textarea { flex: 1; resize: none; }
.ia-nota { padding: 0 12px 8px; font-size: 11px; }
@media print { #ia-fab, #ia-panel { display: none !important; } }

/* ---- Consulta IBS/CBS ---- */
.ibs-lista { max-height: 380px; overflow-y: auto; margin-top: 8px; }
.ibs-nbs { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.ibs-op { display: block; padding: 6px 4px; border-top: 1px dashed var(--line); cursor: pointer; font-size: 13px; }
.ibs-op:hover { background: var(--brand-l); }
