:root { --bg:#0b132b; --fg:#e8e9f3; --muted:#b0b3c1; --accent:#1c2541; --brand:#3a506b; --ok:#2bb673; --warn:#f5a623; --err:#d64545; --content-width: 960px; }
* { box-sizing: border-box; }
html, body { margin:0; padding:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--fg); }
a { color: inherit; text-decoration: none; }
header, footer { position: sticky; z-index: 10; background: var(--accent); }
header { top:0; padding: 12px 16px; display:flex; align-items:center; gap:12px; }
.back-btn { background: transparent; color: var(--fg); border: 1px solid #2b3f57; border-radius: 8px; padding:6px 10px; display:flex; align-items:center; }
.back-btn:active { transform: scale(0.98); }
.brand { font-weight:600; letter-spacing:.3px; }
.brand a { color: var(--fg); }
.user { font-size: .9rem; color: var(--muted); display:flex; align-items:center; gap:8px; }
.user .logout { color: #ffb3b3; padding: 4px 8px; border:1px solid #5a1f2a; border-radius:8px; }
.menu-toggle { background: transparent; color: var(--fg); border: 1px solid #2b3f57; border-radius:8px; padding:6px 10px; display:flex; align-items:center; }

/* Drawer lateral */
.drawer { position: fixed; top:0; left:0; bottom:0; width: 260px; background: #0e1624; border-right: 1px solid #1a2233; transform: translateX(-100%); transition: transform .25s ease; z-index: 20; display:flex; flex-direction: column; }
.drawer .drawer-header { display:flex; align-items:center; justify-content: space-between; padding: 12px; border-bottom: 1px solid #1a2233; }
.drawer .close { background: transparent; color: var(--fg); border: 1px solid #2b3f57; border-radius:8px; padding:4px 8px; }
.drawer .links { display:flex; flex-direction: column; padding: 8px; }
.drawer .links a { padding: 10px 12px; border-radius: 8px; color: var(--fg); }
.drawer .links a:hover { background:#101826; }
.drawer .links a.active { background: var(--brand); }
.backdrop { position: fixed; inset:0; background: rgba(0,0,0,.5); opacity:0; pointer-events:none; transition: opacity .25s ease; z-index: 15; }
body.menu-open .drawer { transform: translateX(0); }
body.menu-open .backdrop { opacity:1; pointer-events:auto; }

/* Mobile menu */
@media (max-width: 720px) {
  .menu { display:none; position: absolute; top:52px; left:0; right:0; background: var(--accent); border-bottom:1px solid #1a2233; }
  .menu .links { flex-direction: column; padding: 8px; }
  body.menu-open .menu { display:block; }
}
main { padding: 16px; }
.card { background: var(--accent); border-radius: 12px; padding: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
section.card { padding-bottom: 7px; margin-bottom: 12px; }
.form { display:flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.form.inline { flex-direction: row; gap: 8px; align-items:center; flex-wrap: wrap; }
/* Barra de ações fixa nos formulários */
.form .actions { display:flex; justify-content:flex-end; align-items:center; gap:8px; flex-wrap: wrap; margin-top: 8px; }
/* Centralização horizontal padronizada para listagens e formulários */
.container { max-width: var(--content-width); margin-left: auto; margin-right: auto; padding-left: 12px; padding-right: 12px; }
label { display:flex; flex-direction: column; gap:6px; font-size:.9rem; color: var(--muted); }
 input, select, textarea { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid #223; background: #101826; color: var(--fg); }
 /* Tamanhos uniformes para controles */
 :root { --control-height: 40px; --control-radius: 10px; }
 .btn { display:inline-flex; align-items:center; gap:8px; height: var(--control-height); padding: 0 14px; border-radius: var(--control-radius); border: 1px solid transparent; background: var(--brand); color: var(--fg); font-weight:600; line-height: 1; }
 .btn.primary { background: var(--ok); color:#021; }
 .btn.outline { background: transparent; border:1px solid var(--brand); }
 .btn .icon { display:inline-flex; width:18px; height:18px; margin-right:6px; align-items:center; }
 .btn .icon svg { width:100%; height:100%; }
 /* Inputs com altura uniforme */
 input, select { height: var(--control-height); padding: 0 12px; box-sizing: border-box; }
 .form.inline > * { height: var(--control-height); }
.list { display:flex; flex-direction: column; gap: 10px; }
.list-item { padding: 12px; border-bottom: 1px solid #1a2233; display:flex; flex-direction: column; gap: 4px; }
.list-item:hover { background:#101826; }
.title { font-weight:600; }
.subtitle { color: var(--muted); font-size:.9rem; }
.meta { color: var(--muted); font-size:.8rem; }
.alert { padding: 10px 12px; border-radius: 8px; }
.alert.error { background: #221016; color: #ffb3b3; border:1px solid #5a1f2a; }
.empty { text-align:center; padding: 16px; color: var(--muted); }
footer { display:none; }
/* Tabela e responsividade */
.table-responsive { width:100%; overflow-x:auto; }
.table { width: 100%; border-collapse: collapse; border-spacing: 0; font-size: .95rem; }
.table thead th { text-align: left; background: #101826; color: var(--muted); font-weight: 600; border-bottom: 2px solid #1a2233; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid #1a2233; }
.table tbody tr:nth-child(even) { background: #0e1624; }
.table tbody tr:hover { background: #0b1524; }

/* Badges para tipos de agenda */
.badge { display:inline-block; padding: 4px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.badge-red { background: rgba(214,69,69,.18); color: #ffb3b3; border: 1px solid #5a1f2a; }
.badge-blue { background: rgba(58,80,107,.22); color: #c5d9ff; border: 1px solid #2b3f57; }
.badge-green { background: rgba(43,182,115,.18); color: #bdf3d8; border: 1px solid #1b5f45; }

/* Grupos e grids (telas de edição) */
.group { background:#101826; border-left: 4px solid var(--brand); border-radius: 10px; padding: 12px; margin: 12px 0; }
.info-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.row-3 { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.row-2 { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }

/* Grids reutilizáveis (alinhamento como no php2) */
.grid { display:grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* Barra de filtro (agenda) alinhada como no php2) */
.agenda-filter { display:flex; align-items:center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.agenda-filter .group { display:flex; align-items:center; gap: 8px; background: none; border: none; padding: 0; margin: 0; }
.agenda-filter .group label { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.agenda-filter .group label input { width: 210px; }
.agenda-filter .meta { color: var(--muted); font-size: .9rem; }
.agenda-filter .spacer { flex: 1 1 auto; }
.agenda-filter .actions { display:flex; align-items:center; gap: 8px; }

@media (min-width: 640px) { main { max-width: var(--content-width); margin-left: auto; margin-right: auto; } }

/* Searchable select (cliente) */
.agenda-filter.cert-filter { display:flex; flex-direction: column !important; gap: 12px; align-items: stretch !important; }
.agenda-filter.cert-filter > * { width: 100% !important; }
.agenda-filter.cert-filter > .grid { width: 100% !important; }
.agenda-filter.cert-filter > div:first-child { width: 100% !important; }
.agenda-filter.cert-filter label { margin-bottom: 4px; }
.agenda-filter.cert-filter .grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
.searchable-select { position: relative; }
.searchable-select input { width: 100%; box-sizing: border-box; padding-right: 32px; }
.searchable-select .clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted);
}
.searchable-select .dropdown {
  position: absolute; left: 0; right: 0; background: #0e1624; border: 1px solid #1a2233; border-radius: 8px;
  max-height: 240px; overflow-y: auto; margin-top: 4px; display: none; z-index: 10; list-style: none; padding: 0;
}
.searchable-select .dropdown .item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #1a2233; }
.searchable-select .dropdown .item:last-child { border-bottom: none; }
.searchable-select .dropdown .item.active,
.searchable-select .dropdown .item:hover { background: #101826; }
.searchable-select mark { background: #ffb3b3; color: #021; padding: 0 2px; border-radius: 2px; }
/* certificados_novo: espaço entre páginas (cards) */
.cert-page { margin-bottom: 12px; }
.cert-page:last-child { margin-bottom: 0; }