* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body.modal-open, body.sidebar-open { overflow: hidden; }
a { color: var(--brand-text); text-decoration: none; }
h1, h2, h3 { color: var(--text); font-weight: 650; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (hover: hover) { a:hover { color: var(--brand-hover); } }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Layout ── */
.navbar { position: fixed; top: 0; left: 0; right: 0; height: calc(var(--navbar-h) + var(--safe-top)); padding: var(--safe-top) calc(16px + var(--safe-right)) 0 calc(16px + var(--safe-left)); background: var(--ff-azul); border-bottom: 3px solid var(--ff-dourado); display: flex; align-items: center; gap: 8px; z-index: 100; color: var(--white); }
.navbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .01em; color: var(--white); }
.navbar__brand img { width: 30px; height: auto; }
.navbar__brand span { color: var(--ff-dourado); }
.navbar__spacer { flex: 1; }
.navbar__user { font-size: 13px; opacity: .85; margin-left: 4px; }
.navbar__icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: none; border: 0; color: var(--white); font-size: 17px; cursor: pointer; }
.navbar__icon-btn:hover { background: rgba(255,255,255,.12); }
.navbar__icon-btn .badge { position: absolute; top: 2px; right: 0; }
.navbar__menu-btn { display: none; }
.layout { display: flex; padding-top: calc(var(--navbar-h) + var(--safe-top)); min-height: 100vh; min-height: 100dvh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); position: fixed; top: calc(var(--navbar-h) + var(--safe-top)); bottom: 0; left: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 10px; display: flex; flex-direction: column; z-index: 90; transition: transform 220ms ease; }
.sidebar__user { display: none; }
.sidebar__section { padding: 4px 0; }
.sidebar__label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 10px 12px 4px; }
.sidebar__item { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 12px; margin: 1px 0; background: none; border: 0; border-radius: 8px; color: var(--text); font: inherit; font-weight: 500; text-align: left; cursor: pointer; transition: background var(--transition); }
.sidebar__item i { width: 18px; text-align: center; color: var(--muted); }
.sidebar__item:hover { background: var(--row-hover); }
.sidebar__item.active { background: var(--brand-soft); color: var(--brand-text); font-weight: 600; }
.sidebar__item.active i { color: var(--brand-text); }
.sidebar__item.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar__item .badge { margin-left: auto; }
.sidebar-overlay { display: none; }
.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 28px 32px; min-width: 0; max-width: 1480px; }
.bottom-nav { display: none; }

/* Tablet e celular: menu lateral vira gaveta por cima de tudo. */
@media screen and (max-width: 900px) {
  .navbar__menu-btn { display: inline-flex; margin-left: -8px; }
  .sidebar { top: 0; width: min(300px, 85vw); padding-top: calc(12px + var(--safe-top)); padding-bottom: calc(12px + var(--safe-bottom)); transform: translateX(-105%); z-index: 120; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 110; opacity: 0; pointer-events: none; transition: opacity 220ms ease; }
  body.sidebar-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .sidebar__user { display: flex; align-items: center; gap: 10px; padding: 8px 12px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; word-break: break-all; }
  .sidebar__user i { font-size: 22px; color: var(--brand-text); }
  .sidebar__item { padding: 11px 12px; font-size: 15px; }
  .main-content { margin-left: 0; padding: 20px calc(20px + var(--safe-right)) 20px calc(20px + var(--safe-left)); }
}

/* ── Cabeçalho de página e cartões ── */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { font-size: 24px; line-height: 1.2; }
.page-sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card__title { font-size: 15px; font-weight: 650; color: var(--text); }
.card__sub { color: var(--muted); font-size: 13px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.grid-cards .card { margin-bottom: 0; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.module-card { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition); }
.module-card__icon { flex-shrink: 0; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-text); font-size: 17px; }
.module-card.report .module-card__icon { background: var(--success-soft); color: var(--success-text); }
.module-card.integra .module-card__icon { background: var(--accent-soft); color: var(--accent-text); }
.module-card .card__title { margin-bottom: 2px; }
.module-card p { color: var(--muted); font-size: 13px; }
.module-card:active { transform: scale(.98); }
@media (hover: hover) { .module-card:hover { border-color: var(--brand); box-shadow: var(--shadow-lg); transform: translateY(-2px); } }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis .card { margin-bottom: 0; }
.kpi { display: flex; gap: 12px; align-items: center; min-width: 0; }
.kpi > span:last-child { min-width: 0; }
.kpi__icon { flex-shrink: 0; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: var(--brand-soft); color: var(--brand-text); font-size: 17px; }
.kpi__icon.ok { background: var(--success-soft); color: var(--success-text); }
.kpi__icon.warn { background: var(--accent-soft); color: var(--accent-text); }
.kpi__label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi__value { font-size: clamp(17px, 1.5vw, 21px); white-space: nowrap; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi__hint { font-size: 12px; color: var(--muted); }
a.card.kpi { color: inherit; }

/* Gráfico de barras do painel (SVG/CSS puro) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 8px; }
.bars__col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars__bar { width: 100%; max-width: 38px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--brand-hover), var(--brand)); min-height: 2px; transition: height 400ms ease; position: relative; }
.bars__bar.atual { background: linear-gradient(180deg, #e5c55a, var(--accent)); }
.bars__label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bars__col:hover .bars__tip { opacity: 1; }
.bars__tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.rank { list-style: none; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rank li:last-child { border-bottom: 0; }
.rank__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank__value { font-weight: 600; font-variant-numeric: tabular-nums; }
.rank__bar { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--row-group); overflow: hidden; }
.rank__bar span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* Chips de status */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--row-group); color: var(--muted); }
.chip.ok { background: var(--success-soft); color: var(--success-text); }
.chip.warn { background: var(--warning-soft); color: var(--warning-text); }
.chip.danger { background: var(--danger-soft); color: var(--danger-text); }
.chip.info { background: var(--brand-soft); color: var(--brand-text); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--ff-dourado); color: #1b1b1b; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }

/* ── Botões ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background var(--transition), border-color var(--transition), color var(--transition), transform 80ms ease, box-shadow var(--transition); touch-action: manipulation; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--brand); color: var(--white); box-shadow: 0 1px 2px rgba(1,55,121,.25); }
.btn-success { background: var(--success); color: var(--white); box-shadow: 0 1px 2px rgba(21,128,61,.25); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost i { color: var(--muted); }
.btn-danger { background: var(--surface); border-color: var(--border); color: var(--danger-text); }
.btn-text { background: none; color: var(--brand-text); padding-left: 6px; padding-right: 6px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-sm.btn-icon { width: 32px; height: 32px; }
@media (hover: hover) {
  .btn-primary:hover { background: var(--brand-hover); color: var(--white); }
  .btn-success:hover { filter: brightness(1.08); color: var(--white); }
  .btn-ghost:hover { border-color: var(--brand); color: var(--brand-text); background: var(--surface); }
  .btn-ghost:hover i { color: var(--brand-text); }
  .btn-danger:hover { background: var(--danger); border-color: var(--danger); color: var(--white); }
  .btn-text:hover { background: var(--brand-soft); }
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.is-loading { pointer-events: none; opacity: .8; }
.btn.is-loading::after { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

/* ── Formulários ── */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-control { width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--text); transition: border-color var(--transition), box-shadow var(--transition); }
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-control::placeholder { color: var(--muted); opacity: .8; }
textarea.form-control { resize: vertical; min-height: 70px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.filters { margin-bottom: 16px; }
.filters .form-group { margin-bottom: 0; }
.filters__toggle { display: none; }
.filters__actions { display: flex; gap: 6px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; }
.alert-danger { background: var(--danger-soft); color: var(--danger-text); }
.alert-info { background: var(--brand-soft); color: var(--brand-text); }
.alert-warn { background: var(--warning-soft); color: var(--warning-text); }

/* ── Select com busca (js/lib/search-select.js) ──
   O <select> original continua no formulário (escondido) e é a fonte da verdade. */
.ss { position: relative; }
.ss > select { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.ss__btn { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; cursor: pointer; }
.ss__btn .ss__value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss__btn .ss__value.is-placeholder { color: var(--muted); }
.ss__btn i { color: var(--muted); font-size: 12px; transition: transform var(--transition); }
.ss.is-open .ss__btn { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ss.is-open .ss__btn i { transform: rotate(180deg); }
.ss__panel { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 600; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column; max-height: 320px; }
.ss__panel.drop-up { top: auto; bottom: calc(100% + 4px); }
.ss__head { display: none; }
.ss__search-wrap { position: relative; padding: 8px; border-bottom: 1px solid var(--border); }
.ss__search-wrap i { position: absolute; left: 19px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.ss__search { padding-left: 32px !important; }
.ss__list { list-style: none; overflow-y: auto; overscroll-behavior: contain; padding: 4px; }
.ss__opt { position: relative; padding: 8px 30px 8px 10px; border-radius: 6px; cursor: pointer; }
.ss__opt.is-active { background: var(--row-hover); }
.ss__opt[aria-selected="true"] { color: var(--brand-text); font-weight: 600; }
.ss__opt[aria-selected="true"]::after { content: '\f00c'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 12px; }
.ss__opt.is-placeholder { color: var(--muted); }
.ss__opt mark { background: var(--accent-soft); color: inherit; border-radius: 2px; }
.ss__opt small { color: var(--muted); font-weight: 400; }
.ss__empty { padding: 14px; text-align: center; color: var(--muted); }

/* ── Tabelas ── */
.dt-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dt-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.dt-search { max-width: 280px; order: 2; padding-left: 34px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' fill='%2394a3b8'%3E%3Cpath d='M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z'/%3E%3C/svg%3E") no-repeat 12px center / 14px; }
.dt-sort { display: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
thead th { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; border-bottom: 1px solid var(--border); }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
thead th.sortable::after { content: ' ↕'; opacity: .35; }
thead th.sort-asc::after { content: ' ↑'; opacity: 1; color: var(--brand-text); }
thead th.sort-desc::after { content: ' ↓'; opacity: 1; color: var(--brand-text); }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--row-hover); }
tfoot th, tfoot td { background: var(--foot); font-weight: 700; border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 4px; }
tr.group-row { background: var(--row-group) !important; color: var(--brand-text); font-weight: 600; cursor: pointer; }
tr.sub-row td:first-child { padding-left: 28px; }
tr.is-muted td { color: var(--muted); }
.neg { color: var(--danger-text); }
.pos { color: var(--success-text); }
.dt-pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.empty-state { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty-state i { font-size: 30px; margin-bottom: 10px; display: block; opacity: .6; }
.empty-state strong { display: block; color: var(--text); margin-bottom: 4px; }

/* Relatórios em matriz (mês a mês, projetado × realizado): a 1ª coluna fica fixa
   enquanto o resto rola de lado — essencial no celular, ajuda no desktop com muitos meses. */
.table-pivot th:first-child, .table-pivot td:first-child { position: sticky; left: 0; z-index: 1; min-width: 180px; box-shadow: 1px 0 0 var(--border); }
.table-pivot thead th:first-child { background: var(--surface-2); z-index: 2; }
.table-pivot tbody td:first-child { background: var(--surface); }
.table-pivot tbody tr:hover td:first-child { background: var(--row-hover); }
.table-pivot tr.group-row td:first-child { background: var(--row-group); }
.table-pivot tfoot td:first-child { background: var(--foot); }
.toggle { display: inline-block; width: 14px; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; z-index: 500; overflow-y: auto; overscroll-behavior: contain; animation: fade-in 150ms ease-out; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 580px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop-in 180ms ease-out; }
.modal.modal-lg { max-width: 860px; }
.modal.modal-sm { max-width: 420px; }
.modal__header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__title { font-size: 17px; color: var(--text); font-weight: 650; }
.modal__close { display: grid; place-items: center; width: 36px; height: 36px; margin: -6px -8px -6px 0; background: none; border: 0; border-radius: 8px; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal__close:hover { background: var(--row-hover); }
.modal__body { padding: 20px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.confirm__icon { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 50%; background: var(--danger-soft); color: var(--danger-text); font-size: 20px; }
.confirm__icon.info { background: var(--brand-soft); color: var(--brand-text); }
.resumo-list p { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; margin: 0; border-bottom: 1px solid var(--border); text-align: right; overflow-wrap: anywhere; }
.resumo-list p strong { flex-shrink: 0; color: var(--muted); font-weight: 500; text-align: left; }
.resumo-list p:last-child { border-bottom: 0; }

/* ── Login ── */
.login-page { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom)); background: radial-gradient(1200px 600px at 10% -10%, #0a4a9a 0%, transparent 60%), linear-gradient(160deg, var(--ff-azul) 0%, #001c3d 100%); }
.login-box { background: var(--surface); width: 100%; max-width: 400px; border-radius: 18px; padding: 32px 28px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-logo { display: block; width: 200px; max-width: 70%; height: auto; margin: 4px auto 18px; }
.logo-tema-escuro { display: none; }
:root[data-theme="dark"] .logo-tema-claro { display: none; }
:root[data-theme="dark"] .logo-tema-escuro { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-tema-claro { display: none; }
  :root:not([data-theme="light"]) .logo-tema-escuro { display: block; }
}
.login-title { text-align: center; font-size: 22px; }
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 22px; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon > .form-control { padding-left: 38px; }
.input-icon > .input-icon__end { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* ── Skeleton, spinner ── */
.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--row-group) 0%, var(--row-hover) 50%, var(--row-group) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-page { display: grid; gap: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.loading { display: flex; justify-content: center; padding: 40px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }

/* ── Avisos ── */
#toast-container { position: fixed; top: calc(70px + var(--safe-top)); right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: var(--white); background: #1e293b; box-shadow: var(--shadow-lg); max-width: 380px; pointer-events: auto; animation: pop-in 180ms ease-out; }
.toast i { font-size: 16px; }
.toast.success i { color: #4ade80; }
.toast.error { background: #b91c1c; }
.toast.warning i { color: #fbbf24; }
.toast__action { margin-left: auto; background: none; border: 0; color: #93c5fd; font: inherit; font-weight: 700; cursor: pointer; padding: 2px 4px; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
#gantt_here { width: 100%; height: 480px; }
#offline-banner { position: fixed; left: 50%; top: calc(var(--navbar-h) + var(--safe-top) + 10px); transform: translateX(-50%); z-index: 1001; display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: #1e293b; color: #fff; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; }
#offline-banner i { color: #fbbf24; }

/* ════════════════════════════════════════════════════════════════════════════
   Celular (≤720px)
   ════════════════════════════════════════════════════════════════════════════ */
@media screen and (max-width: 720px) {
  body { font-size: 15px; }
  .navbar__user { display: none; }
  .navbar__menu-btn { display: none; } /* o "Menu" fica na barra de baixo, ao alcance do polegar */
  .navbar__brand { font-size: 17px; }

  /* Barra de navegação inferior */
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--bottom-nav-h) + var(--safe-bottom)); padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(0,0,0,.06); z-index: 95; }
  .bottom-nav__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; background: none; border: 0; font: inherit; font-size: 11px; font-weight: 500; color: var(--muted); cursor: pointer; touch-action: manipulation; }
  .bottom-nav__item i { font-size: 19px; }
  .bottom-nav__item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav__item .badge { position: absolute; top: 6px; left: calc(50% + 6px); font-size: 10px; line-height: 16px; min-width: 16px; padding: 0 4px; }
  .bottom-nav__item.active { color: var(--brand-text); font-weight: 600; }
  .bottom-nav__item.active::before { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .bottom-nav__item:active { background: var(--row-group); }

  /* Espaço pro conteúdo não ficar atrás da barra inferior e do botão flutuante */
  .main-content { padding: 14px calc(12px + var(--safe-right)) calc(var(--bottom-nav-h) + var(--safe-bottom) + 88px) calc(12px + var(--safe-left)); }

  .page-header { margin-bottom: 14px; align-items: flex-start; }
  .page-title { font-size: 21px; }
  .card { padding: 14px; margin-bottom: 12px; }

  /* Ação principal da tela ("Novo …") vira botão flutuante */
  .btn-fab { position: fixed; right: calc(16px + var(--safe-right)); bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px); z-index: 96; width: 56px; height: 56px; padding: 0; border-radius: 18px; font-size: 22px; box-shadow: 0 8px 20px rgba(21,128,61,.4); }
  .btn-fab .btn-label { display: none; }

  /* Alvos de toque ≥44px e campos com 16px (abaixo disso o iPhone dá zoom ao focar) */
  .btn { min-height: 44px; padding: 10px 16px; }
  .btn-sm { min-height: 40px; padding: 8px 12px; font-size: 14px; }
  .btn-icon, .btn-sm.btn-icon { width: 44px; height: 44px; }
  .form-control { min-height: 44px; padding: 10px 12px; font-size: 16px; }
  input[type="date"].form-control { -webkit-appearance: none; appearance: none; display: block; }
  input[type="date"]::-webkit-date-and-time-value { text-align: left; }
  textarea.form-control { min-height: 88px; }
  .form-label { font-size: 14px; }

  /* Select com busca: no celular abre como folha de tela cheia */
  .ss__panel { position: fixed; inset: auto 0 0 0; top: auto; max-height: 82dvh; min-width: 0; border-radius: 16px 16px 0 0; z-index: 700; animation: sheet-up 200ms ease-out; padding-bottom: var(--safe-bottom); }
  .ss__panel.drop-up { bottom: 0; }
  .ss__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; font-weight: 650; }
  .ss__backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: 690; animation: fade-in 150ms ease-out; }
  .ss__opt { padding: 13px 12px; font-size: 16px; }

  /* Filtros recolhíveis */
  .filters--collapsible { padding: 8px; }
  .filters--collapsible .filters__toggle { display: flex; width: 100%; justify-content: flex-start; border-color: transparent; }
  .filters--collapsible .filters__chevron { margin-left: auto; transition: transform var(--transition); }
  .filters--collapsible.is-open .filters__chevron { transform: rotate(180deg); }
  .filters--collapsible.is-open .filters__toggle { margin-bottom: 8px; }
  .filters--collapsible:not(.is-open) > .form-row { display: none; }
  .filters--collapsible > .form-row { padding: 0 4px 4px; }
  .filters .form-row { gap: 10px; }
  .filters__actions .btn { flex: 1; }

  /* KPIs em 2 colunas; o último sozinho ocupa a linha inteira */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpis .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi__icon { width: 36px; height: 36px; font-size: 15px; }
  .kpi__value { font-size: 17px; overflow-wrap: anywhere; }
  .grid-cards { gap: 10px; }
  .bars { height: 150px; gap: 3px; }
  .bars__label { font-size: 10px; }

  /* Barra das tabelas: busca e ordenação em cima, exportação só com ícone */
  .dt-toolbar { gap: 8px; }
  .dt-search { order: 0; flex: 1 1 100%; max-width: none; }
  .dt-sort, .dt-toolbar > .ss { display: block; flex: 1 1 0; min-width: 0; order: 1; }
  .dt-export { order: 2; }
  .dt-buttons { gap: 6px; flex-wrap: nowrap; }
  .dt-buttons .btn { min-width: 44px; padding: 8px 10px; }
  .dt-buttons .btn-label { display: none; }
  .dt-pager { flex-direction: column; align-items: stretch; text-align: center; }
  .dt-pager__btns { display: flex; gap: 8px; }
  .dt-pager__btns .btn { flex: 1; }

  /* Tabela de dados → lista de cartões */
  .card:has(> .table-wrap > .dt-table) { background: transparent; border: 0; box-shadow: none; padding: 0; }
  /* Cabeçalho some da tela mas fica pro leitor de tela (cada célula mantém seu título). */
  .dt-table thead { display: block; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dt-table, .dt-table tbody, .dt-table tfoot, .dt-table tr, .dt-table td { display: block; width: 100%; }
  .dt-table tr { background: var(--surface) !important; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
  .dt-table td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .dt-table td::before { content: attr(data-label); flex-shrink: 0; max-width: 45%; color: var(--muted); font-size: 13px; font-weight: 400; text-align: left; }
  .dt-table td.num { white-space: normal; font-weight: 600; }
  .dt-table td.dt-title { display: block; padding: 0 0 6px; color: var(--brand-text); font-size: 16px; font-weight: 650; text-align: left; }
  .dt-table td.dt-title::before, .dt-table td.actions::before, .dt-table td.empty-state::before { display: none; }
  .dt-table td.is-empty { display: none; }
  .dt-table td.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
  .dt-table td.actions .btn { flex: 1 1 auto; }
  .dt-table td.actions .btn + .btn { margin-left: 0; }
  .dt-table td.empty-state { display: block; padding: 32px 12px; text-align: center; }
  .dt-table tfoot tr { background: var(--brand-soft) !important; border-color: transparent; }
  .dt-table tfoot td { background: none; font-weight: 600; }
  .dt-table tfoot td.num { color: var(--brand-text); font-size: 16px; }
  .table-wrap:has(> .dt-table) { overflow: visible; }

  /* Matriz: compacta, 1ª coluna fixa mais estreita */
  .table-pivot { font-size: 13px; }
  .table-pivot th, .table-pivot td { padding: 8px; }
  .table-pivot th:first-child, .table-pivot td:first-child { min-width: min(150px, 42vw); max-width: 42vw; white-space: normal; overflow-wrap: break-word; }
  tr.sub-row td:first-child { padding-left: 14px; }
  tr.group-row td { padding-top: 12px; padding-bottom: 12px; }

  /* Modal vira folha que sobe de baixo */
  .modal-backdrop { align-items: flex-end; padding: 0; overflow: hidden; }
  .modal, .modal.modal-lg, .modal.modal-sm { max-width: none; max-height: calc(100dvh - var(--safe-top) - 24px); border-radius: 18px 18px 0 0; animation: sheet-up 220ms ease-out; }
  .modal__header { position: relative; padding: 20px 16px 12px; }
  .modal__header::before { content: ''; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border); }
  .modal__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; }
  .modal__body:last-child { padding-bottom: calc(16px + var(--safe-bottom)); }
  .modal__footer { padding: 12px 16px calc(12px + var(--safe-bottom)); }
  .modal__footer .btn { flex: 1; }

  /* Avisos embaixo, acima da barra inferior */
  #toast-container { top: auto; left: 12px; right: 12px; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px); align-items: stretch; }
  .toast { max-width: 100%; }

  .login-box { padding: 28px 20px; }
  #gantt_here { height: max(380px, calc(100dvh - 330px)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ── Impressão / PDF ── */
.print-only { display: none; }
@media print {
  :root { color-scheme: light; --text: #000; --surface: #fff; --bg: #fff; --border: #ccc; --muted: #444; --foot: #e9edf3; --row-group: #eef3f9; --brand-text: #013779; }
  .navbar, .sidebar, .bottom-nav, .btn-fab, .no-print, .dt-toolbar, .dt-pager, .filters, td.actions, th.actions, #toast-container { display: none !important; }
  .main-content { margin: 0; padding: 0; max-width: none; }
  .layout { padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .print-only { display: block; }
  thead th { background: #e9edf3 !important; color: #000 !important; }
  body { font-size: 11pt; background: #fff; }
  tr.sub-row { display: table-row !important; }
  .table-pivot th:first-child, .table-pivot td:first-child { position: static; box-shadow: none; }
}
.btn-danger-solid { background: var(--danger); color: var(--white); }
@media (hover: hover) { .btn-danger-solid:hover { filter: brightness(1.08); color: var(--white); } }

/* Controle segmentado (abas compactas) */
.segmented { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 14px; border-radius: 10px; background: var(--row-group); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; }
.segmented button { padding: 6px 14px; border: 0; border-radius: 8px; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--brand-text); box-shadow: var(--shadow); }
@media screen and (max-width: 720px) { .segmented { display: flex; } .segmented button { flex: 1; min-height: 40px; } }

/* WhatsApp */
.wa-conectado { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.wa-avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: #e7f8ee; color: #128c4b; font-size: 24px; }
.wa-qr { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.wa-qr img { background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--border); width: 260px; height: 260px; }
.wa-qr ol { padding-left: 20px; display: grid; gap: 10px; max-width: 360px; }

/* Aprovações (sugestões da IA) */
.sug-card { padding: 0; overflow: hidden; transition: opacity 250ms ease, transform 250ms ease; }
.sug-card.is-leaving { opacity: 0; transform: translateX(24px); }
.sug-card__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.sug-card__valor { margin-left: auto; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sug-card__body { display: grid; grid-template-columns: minmax(240px, 2fr) 3fr; }
.sug-card__origem { padding: 14px 16px; border-right: 1px solid var(--border); display: grid; gap: 10px; align-content: start; background: var(--row-alt); }
.sug-card__form { padding: 14px 16px; }
.sug-card__form .form-group { margin-bottom: 10px; }
.sug-card__acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.sug-msg { background: var(--surface); border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; padding: 9px 11px; }
.sug-msg__meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.sug-msg__texto { white-space: pre-wrap; overflow-wrap: anywhere; }
.sug-msg__texto + .sug-msg__texto { margin-top: 6px; }
.sug-thumb { display: block; width: 100%; max-width: 260px; height: 180px; margin-top: 6px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: zoom-in; background: var(--row-group); }
.sug-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sug-just { display: flex; gap: 8px; padding: 9px 11px; margin-bottom: 12px; border-radius: 8px; background: var(--brand-soft); color: var(--brand-text); font-size: 13px; }
.sug-just i { margin-top: 3px; }
@media (max-width: 900px) {
  .sug-card__body { grid-template-columns: 1fr; }
  .sug-card__origem { border-right: 0; border-bottom: 1px solid var(--border); }
}
@media screen and (max-width: 720px) {
  .sug-card__acoes .btn { flex: 1; }
  .sug-card__valor { font-size: 17px; }
}

/* Claude (MCP) */
.copy-field { display: flex; gap: 8px; }
.copy-field .form-control { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.passos { padding-left: 20px; margin-top: 8px; display: grid; gap: 6px; }
pre.code, code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--row-group); border-radius: 6px; }
pre.code { padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; word-break: break-all; }
code { padding: 1px 5px; }
@media screen and (max-width: 720px) { .copy-field { flex-direction: column; } }
.bars-skeleton { height: 216px; }
@media screen and (max-width: 720px) { .bars-skeleton { height: 174px; } }
.page-sub .chip { margin-left: 6px; vertical-align: 1px; }
#gantt_here .gantt_side_content { color: var(--text); font-size: 12px; }
/* Gantt: barra de período + escala, linhas de obra, fim de semana e marcador de hoje */
.gantt-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.gantt-toolbar .segmented { margin-bottom: 0; }
.gantt-toolbar__right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gantt-toolbar .segmented button { padding: 5px 11px; font-size: 13px; }
#gantt_here .gantt_row.gantt-obra-row, #gantt_here .gantt_task_row.gantt-obra-row { background: var(--row-group); }
#gantt_here .gantt-obra-row .gantt_cell { font-weight: 700; }
#gantt_here .gantt_task_line.gantt-obra { opacity: .5; border-radius: 3px; }
#gantt_here .gantt_task_cell.gantt-fds, #gantt_here .gantt_scale_cell.gantt-fds { background: rgba(127, 127, 127, .09); }
#gantt_here .gantt_marker.gantt-hoje { background: var(--accent); width: 2px; }
#gantt_here .gantt_marker.gantt-hoje .gantt_marker_content { background: var(--accent); color: #1f1300; font-weight: 700; font-size: 11px; padding: 1px 5px; border-radius: 0 4px 4px 0; }
#gantt_here .gantt_task_line, #gantt_here .gantt_row { cursor: pointer; }
/* Modal de detalhes da etapa/obra */
.gantt-detalhe h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 2px; }
.gantt-detalhe__sub { color: var(--muted); margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gantt-detalhe__nota { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.gantt-detalhe__acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.gantt-meter { height: 6px; border-radius: 999px; background: var(--row-group); overflow: hidden; margin: 4px 0 6px; }
.gantt-meter span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.gantt-neg { color: var(--danger-text); font-weight: 600; }
.gantt-etapas { font-size: 13px; }
.gantt-etapas th, .gantt-etapas td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.gantt-etapas th { color: var(--muted); font-weight: 600; font-size: 12px; }
.gantt-etapas td:first-child { white-space: normal; min-width: 140px; }
.gantt-etapas .num { text-align: right; font-variant-numeric: tabular-nums; }
#gantt-vazio { padding: 40px 16px; text-align: center; color: var(--muted); }
#gantt-vazio i { font-size: 28px; margin-bottom: 8px; display: block; }
@media screen and (max-width: 720px) {
  .gantt-toolbar, .gantt-toolbar__right { width: 100%; }
  .gantt-toolbar__right .segmented { flex: 1 1 100%; }
}
/* Exportar Gantt (PDF): imprime só o gráfico montado em SVG, numa folha */
#gantt-print { display: none; }
@media print {
  body.print-gantt > *:not(#gantt-print) { display: none !important; }
  body.print-gantt #gantt-print { display: block; }
  #gantt-print svg { display: block; width: 100%; height: auto; }
}
