/* SYS IPB — layout conforme o protótipo (prototipo/SYS IPB Cambé.html):
   barra lateral escura com navegação por papel, barra superior com trilha, conteúdo em painéis.
   As fontes do protótipo (Literata e IBM Plex) entram se estiverem instaladas; senão cai em Georgia/Segoe UI,
   sem carregar nada de terceiros (privacidade dos usuários). */
:root {
  --bg: #f3f5f2; --surface: #ffffff; --surface-2: #eaeee9; --line: #d9dfd8; --line-2: #c6cec5;
  --fg: #18221d; --muted: #5a665f; --faint: #86918a;
  --accent: #2b6a56; --accent-ink: #ffffff; --accent-soft: #dbeae3; --accent-strong: #1f5444;
  --side: #17231e; --side-fg: #d7e2dc; --side-muted: #8fa39a; --side-active: #24382f;
  --ok: #2d7a3e; --ok-soft: #e0f0e2; --warn: #a86308; --warn-soft: #fbecd6;
  --bad: #b0362c; --bad-soft: #f8e0dc; --info: #2c5a87; --info-soft: #e0eaf4;
  --shadow: 0 1px 2px rgba(20,35,28,.06), 0 6px 24px rgba(20,35,28,.08);
  --f-display: "Literata", Georgia, "Times New Roman", serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  /* nomes antigos, usados pelas telas anteriores */
  --text: var(--fg); --primary: var(--accent); --primary-ink: var(--accent-ink); --primary-soft: var(--accent-soft);
  --danger: var(--bad); --danger-soft: var(--bad-soft); --radius: 10px; --topbar-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111613; --surface: #18201c; --surface-2: #202a25; --line: #2c3731; --line-2: #3a463f;
    --fg: #e4ebe6; --muted: #9daaa2; --faint: #76837b;
    --accent: #6fc2a6; --accent-ink: #0d1a15; --accent-soft: #1e3a30; --accent-strong: #8fd3bb;
    --side: #0c110e; --side-fg: #d7e2dc; --side-muted: #7f9389; --side-active: #1c2a23;
    --ok: #7ccb8a; --ok-soft: #1b3322; --warn: #e7a54e; --warn-soft: #382a15; --bad: #ee7c70; --bad-soft: #3b1f1b; --info: #86b4e2; --info-soft: #1a2a3b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111613; --surface: #18201c; --surface-2: #202a25; --line: #2c3731; --line-2: #3a463f;
  --fg: #e4ebe6; --muted: #9daaa2; --faint: #76837b;
  --accent: #6fc2a6; --accent-ink: #0d1a15; --accent-soft: #1e3a30; --accent-strong: #8fd3bb;
  --side: #0c110e; --side-fg: #d7e2dc; --side-muted: #7f9389; --side-active: #1c2a23;
  --ok: #7ccb8a; --ok-soft: #1b3322; --warn: #e7a54e; --warn-soft: #382a15; --bad: #ee7c70; --bad-soft: #3b1f1b; --info: #86b4e2; --info-soft: #1a2a3b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; line-height: 1.2; text-wrap: balance; margin: 0 0 .4rem; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; font-family: var(--f-body); }
.mono { font-family: var(--f-mono); font-size: .82em; letter-spacing: .01em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .85rem; } .hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: clamp(210px, 22vw, 256px) minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); color: var(--side-fg); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px; text-decoration: none; color: inherit; }
.brand-mark { width: 36px; height: 36px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); flex: none; }
.brand-mark svg { width: 26px; height: 26px; }
.brand b { font-family: var(--f-display); font-size: 1.05rem; display: block; line-height: 1.1; }
.brand small { color: var(--side-muted); font-size: .75rem; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .68rem; letter-spacing: .09em; text-transform: uppercase; color: var(--side-muted); padding: 0 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; border: 0; background: none; text-align: left; cursor: pointer; color: var(--side-fg); width: 100%; text-decoration: none; }
.nav-item:hover { background: var(--side-active); }
.nav-item[aria-current="page"], .nav-item.on { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav-item .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: .7rem; border-radius: 9px; padding: 0 7px; font-weight: 600; }
.nav-item .count:empty { display: none; }
.side-foot { margin-top: auto; font-size: .72rem; color: var(--side-muted); padding: 0 10px; line-height: 1.45; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 9px 28px; min-height: var(--topbar-h); }
.crumbs { font-size: .85rem; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs b { color: var(--fg); font-weight: 500; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 26px 28px 60px; max-width: 1220px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

/* igreja ativa: sempre em destaque na barra superior */
.igreja-chip { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 4px 12px 4px 5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); border: 0; cursor: pointer; text-align: left; box-shadow: 0 1px 0 rgba(0,0,0,.08); }
.igreja-chip:hover { background: var(--accent-strong); }
.igreja-logo { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: rgba(255,255,255,.92); color: #1f5444; overflow: hidden; }
.igreja-logo img { width: 100%; height: 100%; object-fit: contain; }
.igreja-logo .mark { width: 24px; height: 24px; }
.igreja-txt { display: grid; line-height: 1.1; min-width: 0; }
.igreja-txt small { font-size: .6rem; text-transform: uppercase; letter-spacing: .1em; opacity: .85; }
.igreja-txt strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30ch; }
.igreja-seta { opacity: .8; font-size: .8rem; }
.igreja-op.atual { border-color: var(--accent); background: var(--accent-soft); }
.menu-btn { display: none; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; position: relative; padding: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.dot { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; font-size: .65rem; font-weight: 600; border-radius: 9px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; }
.dot:empty { display: none; }
.drop { position: absolute; right: 0; top: 44px; width: min(400px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 40; max-height: 72vh; overflow-y: auto; }
.drop-host { position: relative; }
.notif { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .86rem; text-decoration: none; color: inherit; }
.notif:hover { background: var(--surface-2); }
.notif.unread { background: var(--accent-soft); }
.notif .when { font-size: .74rem; color: var(--muted); }
.userbtn { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 12px 3px 3px; cursor: pointer; }
.userbtn span.nm { font-size: .85rem; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: block; width: 100%; text-align: left; padding: 10px 14px; background: none; border: 0; color: inherit; text-decoration: none; cursor: pointer; border-bottom: 1px solid var(--line); font-size: .9rem; }
.menu-item:hover { background: var(--surface-2); } .menu-item:last-child { border-bottom: 0; }

/* ---------- componentes ---------- */
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; justify-content: space-between; }
.page-head h1, .page-head h2 { margin-bottom: 0; }
.page-head .sub, .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions, .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.eyebrow { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 7px; padding: 7px 13px; min-height: 36px; cursor: pointer; font-size: .86rem; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--fg); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--bad); } .btn.danger:hover { border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 9px; min-height: 30px; font-size: .8rem; }
.btn[disabled], .btn:disabled { opacity: .45; cursor: not-allowed; }
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card { padding: 16px; }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-h h2 { font-size: 1.02rem; margin: 0; }
.panel-h .r { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.panel-b { padding: 14px 16px; }
.grid, .grid2, .grid3, .grid-side { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.grid { gap: .9rem; }
@media (min-width: 640px) {
  .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 861px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
@media (min-width: 981px) { .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.span2 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip, .badge { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 600; letter-spacing: .02em; border-radius: 999px; padding: 2px 9px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.chip.ok, .badge.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn, .badge.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad, .badge.off, .badge.bad { background: var(--bad-soft); color: var(--bad); } .chip.info { background: var(--info-soft); color: var(--info); }
.chip.acc { background: var(--accent-soft); color: var(--accent); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .76rem; font-weight: 600; flex: none; color: #fff; background: var(--accent); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg, .avatar.xl { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar.xl { width: 96px; height: 96px; font-size: 1.8rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { font-size: .7rem; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); font-weight: 600; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: 0; }
.tabs button, .tab { border: 0; background: none; padding: 9px 13px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button[aria-selected="true"], .tab.on { color: var(--fg); border-bottom-color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; } .list-item .t { font-weight: 500; } .list-item .s { font-size: .82rem; color: var(--muted); }
.list-item.click { cursor: pointer; } .list-item.click:hover { background: var(--surface-2); }
.date-badge { width: 46px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.date-badge .m { font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; background: var(--surface-2); color: var(--muted); padding: 1px 0; }
.date-badge .d { font-family: var(--f-display); font-size: 1.15rem; font-weight: 600; line-height: 1.5; }
.empty { padding: 22px 16px; color: var(--muted); text-align: center; font-size: .88rem; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi, .stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.kpi .v, .stat { font-family: var(--f-display); font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; color: var(--fg); }
.kpi .l { font-size: .78rem; color: var(--muted); }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea, .input { width: 100%; font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px; padding: 8px 10px; min-height: 38px; }
textarea { min-height: 78px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; margin-right: .4rem; accent-color: var(--accent); }
input[type="color"] { padding: 3px; }
.check { display: flex; align-items: center; font-weight: 500; color: var(--fg); font-size: .9rem; }
.field { display: flex; flex-direction: column; gap: 5px; } .field label { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .form-grid .full { grid-column: 1 / -1; }
.callout, .alert { border-radius: 8px; padding: 10px 12px; font-size: .86rem; display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft); color: var(--warn); }
.alert { margin-bottom: .75rem; } .callout.info { background: var(--info-soft); color: var(--info); }
.callout.bad, .alert.error { background: var(--bad-soft); color: var(--bad); } .callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout b { font-weight: 600; }
.field-error { color: var(--bad); font-size: .82rem; margin-top: .2rem; } input.invalid, select.invalid { border-color: var(--bad); }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 7px 14px; font-size: .88rem; margin: 0; }
.kv > div { display: contents; }
.kv dt { color: var(--muted); font-size: .85rem; } .kv dd { margin: 0; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; } .search input { padding-left: 32px; } .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; } .checks label { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 5px 9px; font-size: .84rem; cursor: pointer; margin: 0; font-weight: 500; color: var(--fg); }
.checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.note { border-left: 2px solid var(--line-2); padding: 2px 0 2px 10px; font-size: .86rem; } .note.sys { color: var(--muted); font-style: italic; }
.file { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; font-size: .84rem; }
.locked { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--faint); }
.suggest { position: relative; }
.suggest ul { position: absolute; z-index: 10; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 240px; overflow: auto; }
.suggest li { padding: .55rem .7rem; cursor: pointer; display: flex; gap: .6rem; align-items: center; }
.suggest li:hover { background: var(--accent-soft); }

/* diálogos */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; width: min(620px, 94vw); background: var(--surface); color: var(--fg); box-shadow: var(--shadow); max-height: 92vh; overflow-y: auto; }
dialog.wide { width: min(880px, 96vw); }
dialog::backdrop { background: rgba(10,18,14,.45); }
dialog h2 { font-size: 1.15rem; }
.toast-host { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 100; width: min(92vw, 440px); }
.toast { padding: 10px 16px; border-radius: 8px; background: var(--fg); color: var(--bg); box-shadow: var(--shadow); font-size: .88rem; }
.toast.error { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
.scrim { position: fixed; inset: 0; background: rgba(10,18,14,.35); z-index: 55; }

/* ---------- login e abertura ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.auth-card { width: min(420px, 100%); }
.mark { width: 72px; height: 72px; }
.splash { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; text-align: center; background: var(--side); color: #fff; transition: opacity .5s ease, visibility .5s; }
.splash.done { opacity: 0; visibility: hidden; }
.splash .mark { width: 112px; height: 112px; animation: pop .9s cubic-bezier(.2,.8,.2,1) both; }
.splash h1 { font-size: 2rem; letter-spacing: .08em; margin: 1rem 0 .15rem; animation: rise .8s .25s both; color: #fff; }
.splash p { margin: 0; opacity: .85; animation: rise .8s .4s both; }
.splash .bar { width: 120px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 1.5rem auto 0; overflow: hidden; }
.splash .bar::after { content: ""; display: block; height: 100%; width: 40%; background: #8fd3bb; animation: load 1.4s ease-in-out infinite; }
@keyframes pop { from { opacity: 0; transform: scale(.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .splash *, .splash { animation: none !important; transition: none !important; } * { transition: none !important; } }

/* ---------- responsivo ---------- */
@media (max-width: 980px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .kv { grid-template-columns: minmax(0, 1fr); } .form-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem .4rem; }
  table.stack td::before { content: attr(data-l); color: var(--muted); font-size: .8rem; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 60; transform: translateX(-102%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: grid; }
  .top { padding: 9px 14px; gap: 8px; }
  .content { padding: 18px 14px 50px; }
  .crumbs, .userbtn span.nm { display: none; }
  .igreja-txt strong { max-width: 22ch; }
  .avatar.xl { width: 68px; height: 68px; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
