:root {
  --ink: #14213D;          /* azul-noite: texto e navegação */
  --ink-2: #4A5672;
  --line: #DCE2EA;
  --bg: #EEF2F6;
  --panel: #FFFFFF;
  --mussulo: #0E7C66;      /* acento principal (verde-lagoa) */
  --mussulo-2: #D5EFE8;
  --amber: #C98A06;        /* pendente / contingência */
  --amber-2: #FBF1D6;
  --red: #B42318;
  --red-2: #FCE4E1;
  --radius-lg: 14px;
  --radius-sm: 7px;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Sora", "Manrope", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E6ECF5; --ink-2: #9AA8C2; --line: #2A3550; --bg: #0F1729; --panel: #16203A;
    --mussulo: #2FB394; --mussulo-2: #123A35; --amber-2: #3A2E0E; --red-2: #3D1A18;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 14.5px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.02rem; }
a { color: var(--mussulo); }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.error { color: var(--red); min-height: 1.2em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--mussulo); outline-offset: 2px; }

/* Marca: três ondas (ngola = rio/água) */
.brand-mark { display: grid; gap: 4px; width: 46px; margin-bottom: 18px; }
.brand-mark span { height: 6px; border-radius: 6px; background: var(--mussulo); }
.brand-mark span:nth-child(2) { width: 75%; margin-left: 25%; opacity: .7; }
.brand-mark span:nth-child(3) { width: 50%; opacity: .45; }
.brand-mark.sm { width: 24px; gap: 3px; margin: 0; }
.brand-mark.sm span { height: 4px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 500px at 80% -10%, var(--mussulo-2), transparent), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); padding: 32px; border-radius: var(--radius-lg); border: 1px solid var(--line); display: grid; gap: 12px; }
.login-card h1 { margin: 0; }

label { display: grid; gap: 4px; font-size: .86rem; color: var(--ink-2); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--mussulo); outline: none; box-shadow: 0 0 0 3px var(--mussulo-2); }
.btn { text-decoration: none; display: inline-block; font: inherit; font-weight: 700; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; cursor: pointer; }
.btn.primary { background: var(--mussulo); border-color: var(--mussulo); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .side { background: #0A1020; } }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: var(--font-display); font-size: 1.15rem; }
.side nav { display: grid; gap: 2px; }
.side nav a { color: #C9D3E6; text-decoration: none; padding: 8px 10px; border-radius: var(--radius-sm); font-weight: 600; }
.side nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.side nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.side nav a.nav-cta { background: var(--mussulo); color: #fff; margin: 4px 0 8px; }
.side-foot { margin-top: auto; font-size: .78rem; color: #94A2BF; padding: 0 8px; }

main { min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 12px; }
.view { padding: 24px; max-width: 1280px; }
.view:focus { outline: none; }

.pill { font: inherit; font-size: .82rem; font-weight: 700; border-radius: 999px; padding: 4px 12px 4px 26px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); position: relative; cursor: pointer; }
.pill::before { content: ""; position: absolute; left: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--mussulo); }
.pill.warn::before { background: var(--amber); } .pill.bad::before { background: var(--red); }

.banner { margin: 16px 24px 0; padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600; }
.banner.warn { background: var(--amber-2); color: #7A5200; }
.banner.bad { background: var(--red-2); color: var(--red); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner.warn { color: #F5C451; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; min-width: 0; }
label > input, label > select, label > textarea { width: 100%; }
.grid > * { min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head h1 { margin: 0; }

/* Indicadores do painel: valor grande, rótulo discreto por baixo */
.kpi b { display: block; font-family: var(--font-display); font-size: 1.55rem; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--ink-2); font-size: .86rem; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bars div { flex: 1; background: var(--mussulo); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars div:hover { opacity: 1; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8rem; color: var(--ink-2); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; }
.lines td { padding: 4px; } .lines input, .lines select { width: 100%; }

/* O elemento memorável: o percurso fiscal do documento (emitido → assinado → AGT) */
.trail { display: flex; align-items: center; gap: 0; }
.trail i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; }
.trail i.on { background: var(--mussulo); }
.trail i.wait { background: var(--amber); box-shadow: 0 0 0 0 var(--amber); animation: pulse 1.8s infinite; }
.trail i.bad { background: var(--red); }
.trail b { width: 14px; height: 2px; background: var(--line); display: inline-block; }
.trail b.on { background: var(--mussulo); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(201,138,6,.55); } 70% { box-shadow: 0 0 0 7px rgba(201,138,6,0); } 100% { box-shadow: 0 0 0 0 rgba(201,138,6,0); } }
@media (prefers-reduced-motion: reduce) { .trail i.wait { animation: none; } }
.journey { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 8px 0 16px; }
.journey div { border-top: 3px solid var(--line); padding-top: 8px; font-size: .86rem; }
.journey div.on { border-color: var(--mussulo); }
.journey div.wait { border-color: var(--amber); }
.journey div.bad { border-color: var(--red); }
.journey small { display: block; color: var(--ink-2); }

.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); }
.tag.ok { background: var(--mussulo-2); color: var(--mussulo); }
.tag.warn { background: var(--amber-2); color: #8A5D00; }
.tag.bad { background: var(--red-2); color: var(--red); }

.totals { display: grid; gap: 4px; justify-items: end; align-content: start; }
.totals .grand { font-family: var(--font-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }

dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0; background: var(--panel); color: var(--ink); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(20,33,61,.45); }
#modalBody { padding: 20px; display: grid; gap: 12px; }
#modalBody { position: relative; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted, #667); font-size: 16px; cursor: pointer; }
.modal-x:hover { background: rgba(20,33,61,.08); color: var(--ink); }
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: var(--radius-sm); font-weight: 600; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; }
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: var(--red); color: #fff; }
pre { background: var(--bg); padding: 10px; border-radius: var(--radius-sm); overflow: auto; font-size: .8rem; max-height: 360px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { grid-template-columns: repeat(2, 1fr); }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .view { padding: 16px; }
  .side-foot { display: none; }
  .row > label { flex-basis: 100%; }
  .top { padding: 10px 16px; }
}

.company-sel { font: inherit; font-weight: 700; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; max-width: 320px; }
.co-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.co-box legend { padding: 0 4px; font-size: .85rem; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.chk input { width: auto; }

.emp-row { display: grid; grid-template-columns: 130px 1fr 1fr 110px; gap: 6px; }
@media (max-width: 640px) { .emp-row { grid-template-columns: 1fr 1fr; } }
dialog { width: min(720px, calc(100vw - 32px)); }

.bank-row { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 6px; margin-bottom: 6px; }
@media (max-width: 640px) { .bank-row { grid-template-columns: 1fr; } }

.logo-box { width: 160px; height: 64px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: #fff; }
.logo-box img { max-width: 150px; max-height: 56px; }

.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpis .kpi { display: grid; gap: 4px; padding: 14px 16px; }
.kpis .kpi b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kpis .kpi.hl { border-color: var(--mussulo, #0E7C66); }
@media print { .side, header.top, #mapCsv, #mapPrint, #mapMes, #banner, #licBanner { display: none !important; } .shell { display: block; } }

button.panel.kpi { text-align: left; cursor: pointer; font: inherit; color: inherit; }
