:root {
  --primaria: #0f3d5e;
  --primaria-2: #155a8a;
  --primaria-clara: #e8f1f8;
  --texto: #1f2937;
  --suave: #6b7280;
  --borda: #e5e7eb;
  --fundo: #f4f6f9;
  --card: #ffffff;
  --verde: #15803d; --verde-bg: #dcfce7;
  --azul: #1d4ed8; --azul-bg: #dbeafe;
  --amarelo: #a16207; --amarelo-bg: #fef3c7;
  --cinza: #4b5563; --cinza-bg: #e5e7eb;
  --vermelho: #b91c1c; --vermelho-bg: #fee2e2;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--texto); background: var(--fundo); font-size: 15px; line-height: 1.5; }
a { color: var(--primaria-2); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--suave); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .mt0 { margin-top: 0; }
.hidden { display: none !important; }

/* ---------- Estrutura ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--primaria); color: #fff; }
.brand { color: #fff; text-decoration: none; font-weight: 800; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--primaria); font-size: .8rem; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.topbar-user form { margin: 0; }
.btn-link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.menu-toggle { position: absolute; opacity: 0; pointer-events: none; }
.hamburger { display: none; flex-direction: column; gap: 4px; cursor: pointer; padding: 6px; }
.hamburger span { width: 20px; height: 2px; background: #fff; border-radius: 2px; }
.shell { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 240px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--borda); padding: 12px 8px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--texto); text-decoration: none; font-size: .92rem; }
.sidebar a:hover { background: var(--fundo); }
.sidebar a.active { background: var(--primaria-clara); color: var(--primaria); font-weight: 600; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.backdrop { display: none; }
.content { flex: 1; min-width: 0; padding: 24px; max-width: 1280px; }
.content-solo { max-width: 100%; padding: 0; }

@media (max-width: 860px) {
  .hamburger { display: flex; }
  .sidebar { position: fixed; left: 0; top: 56px; z-index: 25; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--sombra); }
  .menu-toggle:checked ~ .shell .sidebar { transform: none; }
  .menu-toggle:checked ~ .shell .backdrop { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,.3); z-index: 20; }
  .content { padding: 16px; }
  .user-name { display: none; }
}

/* ---------- Componentes ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 20px; box-shadow: var(--sombra); margin-bottom: 16px; }
.card.narrow { max-width: 560px; margin-left: auto; margin-right: auto; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--primaria); background: var(--primaria); color: #fff; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primaria-2); }
.btn-sec { background: #fff; color: var(--primaria); }
.btn-sec:hover { background: var(--primaria-clara); }
.btn-perigo { background: var(--vermelho); border-color: var(--vermelho); }
.btn-perigo:hover { background: #991b1b; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
form.inline { display: inline; margin: 0; }

label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-weight: 400; color: var(--suave); font-size: .8rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=number], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--texto);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primaria-2); outline-offset: 0; border-color: var(--primaria-2); }
.req::after { content: " *"; color: var(--vermelho); }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; }
.check input { margin-top: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; flex: 1; }
.filters .field.grow { flex: 2; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.alert-sucesso { background: var(--verde-bg); border-color: #86efac; color: #14532d; }
.alert-erro { background: var(--vermelho-bg); border-color: #fca5a5; color: #7f1d1d; }
.alert-aviso { background: var(--amarelo-bg); border-color: #fcd34d; color: #713f12; }
.alert-info { background: var(--azul-bg); border-color: #93c5fd; color: #1e3a8a; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.s-agendado, .s-pendente { background: var(--azul-bg); color: var(--azul); }
.s-confirmado, .s-realizado, .s-aprovado, .s-ativa, .s-disponivel, .s-ok, .s-enviado { background: var(--verde-bg); color: var(--verde); }
.s-cancelado_fornecedor, .s-cancelado_empresa, .s-nao_compareceu, .s-recusado, .s-bloqueado-usr, .s-erro, .s-conflito { background: var(--vermelho-bg); color: var(--vermelho); }
.s-reagendado, .s-encerrada, .s-removida, .s-bloqueado, .s-passado, .s-encerrado, .s-simulado { background: var(--cinza-bg); color: var(--cinza); }
.s-reduzida, .s-feriado { background: var(--amarelo-bg); color: var(--amarelo); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); background: #fafbfc; }
tr:hover td { background: #fafcff; }
td.acoes { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--suave); padding: 28px 12px; }

dl.info { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; margin: 0; }
dl.info dt { color: var(--suave); font-size: .88rem; }
dl.info dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 640px) { dl.info { grid-template-columns: 1fr; gap: 2px; } dl.info dd { margin-bottom: 8px; } }

/* KPIs */
.kpi { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); text-decoration: none; color: inherit; display: block; }
.kpi .v { font-size: 1.8rem; font-weight: 800; line-height: 1.1; color: var(--primaria); }
.kpi .l { color: var(--suave); font-size: .85rem; }
.kpi.alerta .v { color: var(--vermelho); }
a.kpi:hover { border-color: var(--primaria-2); }
.bar-row { display: grid; grid-template-columns: 160px 1fr 40px; gap: 8px; align-items: center; margin: 6px 0; font-size: .88rem; }
.bar { height: 12px; background: var(--primaria-clara); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primaria-2); border-radius: 6px; }
.colunas { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 10px; }
.colunas .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; font-size: .75rem; color: var(--suave); }
.colunas .pilha { width: 100%; max-width: 44px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.colunas .pilha span { display: block; }
.c-ativos { background: #60a5fa; } .c-realizados { background: var(--verde); } .c-cancelados { background: #f87171; }
.legenda { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--suave); margin-top: 8px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.progress { height: 10px; border-radius: 6px; background: var(--cinza-bg); overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; background: var(--verde); }

/* ---------- Calendário ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; }
.cal { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.cal th { background: none; text-align: center; padding: 4px; }
.cal td { border: 1px solid var(--borda); border-radius: 8px; height: 104px; padding: 6px; background: #fff; vertical-align: top; position: relative; }
.cal td.vazio { background: transparent; border-color: transparent; }
.cal td.hoje { outline: 2px solid var(--primaria-2); }
.cal td.sel { box-shadow: inset 0 0 0 2px var(--primaria); background: var(--primaria-clara); }
.cal .num { font-weight: 700; font-size: .85rem; display: flex; justify-content: space-between; gap: 4px; }
.cal a.dia { position: absolute; inset: 0; border-radius: 8px; }
.cal td.d-disponivel { background: #f0fdf4; border-color: #86efac; }
.cal td.d-reduzida { background: #fffbeb; border-color: #fcd34d; }
.cal td.d-lotado, .cal td.d-agendado { background: #fef2f2; border-color: #fca5a5; }
.cal td.d-bloqueado { background: #f3f4f6; border-color: #d1d5db; }
.cal td.d-passado { background: #fafafa; color: var(--suave); }
.cal td.d-agendado { background: #eff6ff; border-color: #93c5fd; }
.chip { display: block; font-size: .7rem; line-height: 1.25; padding: 2px 5px; border-radius: 4px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: normal; max-height: 2.6em; overflow-wrap: anywhere; position: relative; z-index: 1; text-decoration: none; }
span.chip { pointer-events: none; }
.chip.disponivel { background: var(--verde-bg); color: var(--verde); }
.chip.agendado { background: var(--azul-bg); color: var(--azul); }
.chip.bloqueado { background: var(--cinza-bg); color: var(--cinza); }
.chip.encerrado { background: #f3f4f6; color: var(--suave); }
.chip.propria { background: var(--azul); color: #fff; }
.feriado-tag { font-size: .65rem; color: var(--amarelo); font-weight: 600; }
.legend-cal { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; margin-top: 10px; }
.legend-cal span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -2px; border: 1px solid; }
.lg-disponivel::before { background: #f0fdf4; border-color: #86efac !important; }
.lg-agendado::before { background: #eff6ff; border-color: #93c5fd !important; }
.lg-reduzida::before { background: #fffbeb; border-color: #fcd34d !important; }
.lg-bloqueado::before { background: #f3f4f6; border-color: #d1d5db !important; }
.lg-lotado::before { background: #fef2f2; border-color: #fca5a5 !important; }
@media (max-width: 760px) {
  .cal { border-spacing: 2px; }
  .cal td { height: 58px; padding: 3px; }
  .cal .chip { display: none; }
  .cal .feriado-tag { display: none; }
  .cal .marcador { display: block; text-align: center; font-size: .65rem; font-weight: 700; margin-top: 4px; }
}
@media (min-width: 761px) { .cal .marcador { display: none; } }

.janela-opcao { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid var(--borda); border-radius: 8px; padding: 12px 14px; margin-bottom: 8px; background: #fff; }
.janela-opcao .turmas { color: var(--suave); font-size: .88rem; }

/* Etapas do assistente */
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; padding: 0; list-style: none; counter-reset: s; }
.steps li { flex: 1; min-width: 120px; padding: 8px 10px; border-radius: 8px; background: #fff; border: 1px solid var(--borda); font-size: .82rem; color: var(--suave); counter-increment: s; }
.steps li::before { content: counter(s) ". "; font-weight: 700; }
.steps li.on { border-color: var(--primaria); color: var(--primaria); font-weight: 700; background: var(--primaria-clara); }
.steps li.ok { color: var(--verde); }

.informativo { white-space: pre-wrap; background: #fff7e6; border: 1px solid #f5c26b; border-radius: 8px; padding: 14px 16px; font-size: .9rem; }
.resumo-lista { columns: 2; column-gap: 24px; }
@media (max-width: 640px) { .resumo-lista { columns: 1; } }

/* ---------- Telas de acesso ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero { background: linear-gradient(140deg, var(--primaria), #1b6aa3); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 2.2rem; letter-spacing: .06em; margin-bottom: 8px; }
.auth-hero p { opacity: .9; max-width: 420px; }
.auth-hero ul { padding-left: 18px; opacity: .9; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .brand-mark { width: 44px; height: 44px; font-size: 1rem; background: var(--primaria); color: #fff; margin-bottom: 12px; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: .9rem; margin-top: 14px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-hero { padding: 28px 20px; } .auth-hero h1 { font-size: 1.6rem; } .auth-hero ul { display: none; } }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--borda); position: relative; font-size: .88rem; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--primaria-2); }
details.acao { border: 1px solid var(--borda); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; background: #fff; }
details.acao summary { cursor: pointer; font-weight: 600; }
details.acao[open] summary { margin-bottom: 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
iframe.email { width: 100%; height: 520px; border: 1px solid var(--borda); border-radius: 8px; background: #fff; }
.paginacao { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }
@media print { .sidebar, .topbar, .actions, form { display: none !important; } .content { padding: 0; } }
