/* ============================================================================
   CLÍNICA SUPERAÇÃO — PRONTUÁRIO ELETRÔNICO (PEP)
   Usa CSS custom properties injetadas via PHP (wp_add_inline_style):
     --cs-bg, --cs-card, --cs-dark, --cs-sage, --cs-sand, --cs-accent
   ============================================================================ */

/* ---- Reset / base ---- */
.cs-pep { font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--cs-dark); max-width: 1140px; margin: 0 auto; }
.cs-pep * { box-sizing: border-box; }
.cs-pep h2 { font-weight: 600; letter-spacing: .3px; margin: 0 0 4px; }
.cs-pep-sub { color: var(--cs-sage); font-size: 14px; margin: 0 0 22px; }

/* ---- Filtros / seletor de paciente ---- */
.cs-pep-filtros { display: flex; gap: 14px; flex-wrap: wrap; background: var(--cs-card); padding: 20px; border-radius: 14px; box-shadow: 0 2px 14px rgba(61,47,38,.06); margin-bottom: 22px; }
.cs-pep-campo { flex: 1; min-width: 200px; }
.cs-pep-campo label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--cs-sage); margin-bottom: 6px; }
.cs-pep select,
.cs-pep input,
.cs-pep textarea { width: 100%; padding: 11px 13px; border: 1px solid #e6ddd2; border-radius: 9px; font-size: 14px; color: var(--cs-dark); background: var(--cs-bg); transition: .2s; }
.cs-pep select:focus,
.cs-pep input:focus,
.cs-pep textarea:focus { outline: none; border-color: var(--cs-accent); background: var(--cs-card); box-shadow: 0 0 0 3px rgba(176,137,104,.12); }
.cs-pep select:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Painel principal ---- */
.cs-pep-painel { background: var(--cs-card); border-radius: 14px; box-shadow: 0 2px 14px rgba(61,47,38,.06); padding: 0; overflow: hidden; display: none; }
.cs-pep-painel.ativo { display: block; }

/* ---- Cabeçalho do paciente ---- */
.cs-pep-cab { background: linear-gradient(135deg, var(--cs-dark) 0%, #5a463a 55%, var(--cs-sage) 130%); color: #fff; padding: 24px 28px; position: relative; overflow: hidden; }
.cs-pep-cab .cs-pep-marca-img { position: absolute; right: 18px; top: 18px; height: 38px; width: auto; opacity: .92; filter: brightness(0) invert(1); }
.cs-pep-cab h3 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.cs-pep-cab .cs-pep-meta-linha { color: #e8ddd0; font-size: 13px; display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.cs-pep-cab .cs-pep-meta-linha span { display: inline-flex; align-items: center; gap: 5px; }
.cs-pep-pill-pedido { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; background: #fff3df; color: #8a6d2f; padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; border: 1px solid rgba(255,255,255,.4); }

/* ---- Tabs ---- */
.cs-pep-tabs { display: flex; gap: 2px; background: var(--cs-sand); padding: 0 16px; border-bottom: 1px solid #ece3d8; }
.cs-pep-tab { padding: 14px 18px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--cs-sage); border-bottom: 2px solid transparent; }
.cs-pep-tab.ativo { color: var(--cs-dark); border-bottom-color: var(--cs-accent); }
.cs-pep-tab-admin { color: var(--cs-accent); }
.cs-pep-tab-admin.ativo { border-bottom-color: var(--cs-accent); }
.cs-pep-tabconteudo { padding: 22px 20px; }
.cs-pep-tabpane { display: none; }
.cs-pep-tabpane.ativo { display: block; }

/* ---- Grid 2 colunas ---- */
.cs-pep-grid2 { display: grid !important; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; width: 100%; }
.cs-pep-info { background: var(--cs-bg); border-radius: 9px; padding: 12px 14px; height: 100%; box-sizing: border-box; }
.cs-pep-info label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--cs-sage); display: block; margin-bottom: 4px; }
.cs-pep-info span { font-size: 15px; color: var(--cs-dark); display: block; word-break: break-word; }

/* ---- Alertas e mensagens ---- */
.cs-pep-alerta { background: #fff6e6; border: 1px solid #f0d9a8; border-radius: 9px; padding: 10px 14px; font-size: 13px; color: #8a6d2f; margin-bottom: 14px; }
.cs-pep-msg { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 14px; display: none; }
.cs-pep-msg.ok  { background: #e8f0e4; color: #4a6b3d; display: block; }
.cs-pep-msg.erro { background: #f7e4e4; color: #8a3d3d; display: block; }
.cs-pep-vazio { color: var(--cs-sage); font-style: italic; font-size: 14px; }
.cs-pep-abrir-audit { margin-bottom: 18px; }

/* ---- Foto do paciente ---- */
.cs-pep-dados-topo { display: flex !important; flex-direction: row !important; gap: 20px; align-items: flex-start; margin-bottom: 18px; width: 100%; }
.cs-pep-foto-area { display: flex; flex-direction: column; gap: 8px; align-items: center; width: 160px !important; min-width: 160px !important; max-width: 160px !important; flex-shrink: 0 !important; }
.cs-pep-foto-wrap { width: 160px !important; height: 160px !important; border-radius: 12px; overflow: hidden; background: var(--cs-sand); border: 1px solid #efe6da; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cs-pep-foto { width: 160px; height: 160px; object-fit: cover; }
.cs-pep-foto-vazia { color: var(--cs-sage); font-size: 13px; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.cs-pep-foto-acoes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.cs-pep-foto-acoes .cs-pep-btn { padding: 7px 12px; font-size: 12px; }

/* ---- Botões ---- */
.cs-pep-btn { background: var(--cs-accent); color: #fff; border: none; padding: 12px 22px; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; transition: .2s; }
.cs-pep-btn:hover { background: #9a7458; transform: translateY(-1px); }
.cs-pep-btn.sec { background: var(--cs-sand); color: var(--cs-dark); }
.cs-pep-btn.sec:hover { background: #ece0d2; }
.cs-pep-btn-mini { background: var(--cs-sand); border: none; padding: 5px 11px; border-radius: 7px; font-size: 12px; cursor: pointer; color: var(--cs-dark); margin-left: 6px; }
.cs-pep-btn-mini:hover { background: var(--cs-accent); color: #fff; }
.cs-pep-btn-mini[disabled] { opacity: .4; cursor: not-allowed; }
.cs-pep-spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid #fff; border-top-color: transparent; border-radius: 50%; animation: csspin .7s linear infinite; vertical-align: middle; }
@keyframes csspin { to { transform: rotate(360deg); } }

/* ---- Formulários internos ---- */
.cs-pep-form-row { margin-bottom: 14px; }
.cs-pep-form-row label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--cs-dark); }

/* ---- Consentimento LGPD ---- */
.cs-pep-consent { margin-top: 22px; background: var(--cs-bg); border: 1px solid #efe6da; border-radius: 11px; padding: 16px 18px; }
.cs-pep-consent-cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cs-pep-consent-titulo { font-weight: 600; font-size: 14px; color: var(--cs-dark); }
.cs-pep-consent-status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 14px; }
.cs-pep-consent-status.ok   { background: #e8f0e4; color: #3d6b2f; }
.cs-pep-consent-status.pend { background: #f7ece4; color: #8a5a3d; }
.cs-pep-consent-info { font-size: 13px; color: #6b5546; margin-bottom: 10px; }
.cs-pep-consent-texto { font-size: 12.5px; line-height: 1.6; color: #5a4a3d; background: #fff; border: 1px solid #efe6da; border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.cs-pep-consent-check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--cs-dark); margin-bottom: 12px; cursor: pointer; }
.cs-pep-consent-check input { width: auto; margin-top: 2px; }
.cs-pep-consent-acoes { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- CID (atestado) ---- */
.cs-pep-cid-wrap { position: relative; }
.cs-pep-cid-versao { display: flex; gap: 4px; margin-bottom: 6px; }
.cs-pep-cid-vbtn { padding: 4px 12px; border: 1px solid #e6ddd2; background: var(--cs-bg); border-radius: 7px; cursor: pointer; font-size: 12px; }
.cs-pep-cid-vbtn.ativo { background: var(--cs-accent); color: #fff; border-color: var(--cs-accent); }
.cs-pep-cid-results { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #e6ddd2; border-radius: 9px; box-shadow: 0 6px 20px rgba(61,47,38,.15); max-height: 260px; overflow: auto; z-index: 50; display: none; margin-top: 4px; }
.cs-pep-cid-item { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f3ece1; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.cs-pep-cid-item:hover { background: var(--cs-sand); }
.cs-pep-cid-item strong { color: var(--cs-accent); white-space: nowrap; }
.cs-pep-cid-item span { color: var(--cs-dark); flex: 1; }
.cs-pep-cid-v { font-size: 10px; color: var(--cs-sage); white-space: nowrap; }
.cs-pep-cid-desc { font-size: 12px; color: #6b5546; margin-top: 6px; font-style: italic; }

/* ---- Evoluções (flat — convertidas em timeline via JS) ---- */
.cs-pep-evol { border-left: 3px solid var(--cs-accent); background: var(--cs-bg); border-radius: 0 9px 9px 0; padding: 14px 16px; margin-bottom: 12px; }
.cs-pep-evol-head { font-size: 13px; color: var(--cs-dark); margin-bottom: 6px; }
.cs-pep-evol-head .cs-pep-data { color: var(--cs-sage); font-weight: 400; margin-left: 6px; }
.cs-pep-evol-body { font-size: 14px; line-height: 1.6; }
.cs-pep-hip,
.cs-pep-conduta { font-size: 13px; color: #6b5546; margin: 6px 0; }
.cs-pep-badge { background: var(--cs-sage); color: #fff; font-size: 10px; padding: 2px 7px; border-radius: 5px; text-transform: uppercase; }

/* ---- Evoluções timeline (gerada via JS) ---- */
.cs-pep-evol-timeline { position: relative; padding-left: 0; }
.cs-pep-evol-timeline::before { content: ''; position: absolute; left: 52px; top: 0; bottom: 0; width: 2px; background: linear-gradient(to bottom, #e0d5c4 0%, transparent 100%); z-index: 0; }
.cs-pep-evol-item { display: flex; gap: 0; margin-bottom: 14px; position: relative; z-index: 1; }
.cs-pep-evol-data-col { flex-shrink: 0; width: 64px; display: flex; flex-direction: column; align-items: center; padding-top: 2px; }
.cs-pep-evol-data-box { width: 52px; background: var(--cs-dark); border-radius: 8px; color: #fff; text-align: center; padding: 7px 4px 6px; line-height: 1; user-select: none; }
.cs-pep-evol-data-box.retorno { background: var(--cs-accent); }
.cs-pep-evol-data-box.adendo  { background: var(--cs-sage); }
.cs-pep-evol-data-box .ev-dia { font-size: 20px; font-weight: 700; display: block; }
.cs-pep-evol-data-box .ev-mes { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; opacity: .75; display: block; margin-top: 1px; }
.cs-pep-evol-data-box .ev-ano { font-size: 9px; opacity: .6; display: block; }
.cs-pep-evol-dot { width: 10px; height: 10px; background: var(--cs-accent); border: 2px solid #fff; border-radius: 50%; margin-top: 18px; flex-shrink: 0; position: relative; z-index: 2; }
.cs-pep-evol-card { flex: 1; background: #fff; border: 1px solid #efe6da; border-radius: 10px; overflow: hidden; cursor: pointer; transition: box-shadow .2s, transform .2s; margin-left: 12px; }
.cs-pep-evol-card:hover { box-shadow: 0 4px 22px rgba(61,47,38,.13); transform: translateY(-2px); }
.cs-pep-evol-card.retorno { border-left: 3px solid var(--cs-accent); }
.cs-pep-evol-card.adendo  { border-left: 3px solid var(--cs-sage); }
.cs-pep-evol-card-head { padding: 12px 14px 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.cs-pep-evol-card-medico { font-size: 13px; font-weight: 600; color: var(--cs-dark); }
.cs-pep-evol-card-crm { font-weight: 400; color: var(--cs-sage); font-size: 12px; }
.cs-pep-evol-card-hora { font-size: 12px; color: var(--cs-sage); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.cs-pep-evol-card-cid { padding: 0 14px 8px; font-size: 12px; color: var(--cs-accent); font-weight: 600; }
.cs-pep-evol-card-cid span { font-weight: 400; color: #6b5546; }
.cs-pep-evol-badges { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 8px; }
.cs-pep-evol-badge { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 2px 8px; border-radius: 5px; }
.cs-pep-evol-badge.retorno { background: #fff3e0; color: #8a6020; }
.cs-pep-evol-badge.adendo  { background: #e8f0e8; color: #3d6b3d; }
.cs-pep-evol-card-body { max-height: 0; overflow: hidden; transition: max-height .32s cubic-bezier(.4,0,.2,1), padding .22s; padding: 0 14px; }
.cs-pep-evol-card.expandido .cs-pep-evol-card-body { max-height: 600px; padding: 0 14px 14px; }
.cs-pep-evol-card-body-inner { border-top: 1px solid #f0e8de; padding-top: 10px; font-size: 13px; line-height: 1.65; color: var(--cs-dark); }
.cs-pep-evol-card-conduta { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #e0d5c4; font-size: 12px; color: #6b5546; }
.cs-pep-evol-card-conduta strong { color: var(--cs-accent); }
.cs-pep-evol-seta { width: 20px; height: 20px; border-radius: 50%; background: #f3ece1; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: transform .25s, background .15s; }
.cs-pep-evol-card.expandido .cs-pep-evol-seta { transform: rotate(180deg); background: var(--cs-accent); }
.cs-pep-evol-card.expandido .cs-pep-evol-seta svg { stroke: #fff; }
.cs-pep-evol-vazio { color: var(--cs-sage); font-style: italic; font-size: 14px; padding: 20px 0; text-align: center; }

.cs-pep .cs-pep-grid2::before,
.cs-pep .cs-pep-grid2::after {
    display: none !important;
    content: none !important;
    width: 0 !important;
    clear: none !important;
}
/* ---- Histórico (Form 713) ---- */
.cs-pep-hist-intro { font-size: 13px; color: var(--cs-sage); margin-bottom: 16px; line-height: 1.5; }
.cs-pep-hist-card { background: var(--cs-bg); border: 1px solid #efe6da; border-radius: 11px; padding: 16px 18px; margin-bottom: 14px; }
.cs-pep-hist-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #efe6da; }
.cs-pep-hist-terapia { font-weight: 600; color: var(--cs-dark); background: var(--cs-sand); padding: 4px 12px; border-radius: 16px; font-size: 13px; }
.cs-pep-hist-data { font-size: 12px; color: var(--cs-sage); }
.cs-pep-hist-linha { margin-bottom: 10px; font-size: 14px; line-height: 1.55; }
.cs-pep-hist-rot { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--cs-accent); font-weight: 600; margin-bottom: 2px; }
.cs-pep-hist-assin { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed #e0d5c6; }
.cs-pep-hist-assin-img { max-height: 60px; max-width: 200px; width: auto; background: #fff; border: 1px solid #efe6da; border-radius: 6px; padding: 4px; }
.cs-pep-hist-assin-info { display: flex; flex-direction: column; }
.cs-pep-hist-assin-nome { font-weight: 600; font-size: 14px; color: var(--cs-dark); }
.cs-pep-hist-assin-data { font-size: 12px; color: var(--cs-sage); }

/* ---- Documentos ---- */
.cs-pep-doc-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid #f0e8de; font-size: 13px; }
.cs-pep-doc-tipo { font-weight: 600; padding: 3px 9px; border-radius: 6px; font-size: 12px; }
.cs-pep-receita  { background: #e8f0e4; color: #4a6b3d; }
.cs-pep-atestado { background: #e4ebf0; color: #3d566b; }
.cs-pep-doc-cod  { font-family: monospace; color: var(--cs-sage); }

/* ---- Modal documento ---- */
.cs-pep-modal { position: fixed; inset: 0; background: rgba(61,47,38,.55); display: none; align-items: center; justify-content: center; z-index: 99999; padding: 20px; }
.cs-pep-modal.ativo { display: flex; }
.cs-pep-modal-box { background: #fff; border-radius: 14px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; padding: 28px; }
.cs-pep-modal-acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---- Documento impresso (receita / atestado) ---- */
.cs-doc { font-family: 'Georgia', serif; color: var(--cs-dark); }
.cs-doc-cab { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--cs-accent); padding-bottom: 12px; margin-bottom: 20px; }
.cs-doc-logo-img { max-height: 46px; width: auto; display: block; }
.cs-doc-logo-wrap { display: flex; align-items: center; gap: 8px; }
.cs-doc-sub  { font-size: 11px; color: var(--cs-sage); margin-top: 4px; }
.cs-doc-tipo { font-size: 16px; font-weight: bold; color: var(--cs-accent); letter-spacing: 1px; }
.cs-doc-pac  { background: var(--cs-sand); padding: 10px 12px; border-radius: 6px; margin-bottom: 18px; font-size: 14px; }
.cs-doc-atestado-info { margin: -8px 0 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; color: var(--cs-dark); }
.cs-doc-cid-nota { font-size: 10px; color: var(--cs-sage); font-style: italic; }
.cs-doc-corpo { min-height: 160px; line-height: 1.8; font-size: 15px; }
.cs-doc-localdata { text-align: right; margin: 20px 0 6px; font-size: 14px; }
.cs-doc-rodape { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 34px; gap: 20px; }
.cs-doc-assin { text-align: center; flex: 1; }
.cs-doc-linha { border-top: 1px solid var(--cs-dark); width: 80%; margin: 0 auto 6px; }
.cs-doc-data  { font-size: 11px; color: var(--cs-sage); }
.cs-doc-qr    { text-align: center; font-size: 10px; color: var(--cs-sage); max-width: 160px; }
.cs-doc-cod   { margin-top: 4px; font-size: 11px; color: var(--cs-dark); }
.cs-doc-verif { margin-top: 4px; font-size: 9px; word-break: break-all; }
.cs-doc-sigilo { margin-top: 20px; padding-top: 10px; border-top: 1px solid #efe6da; font-size: 9.5px; color: var(--cs-sage); line-height: 1.5; text-align: center; }
.cs-doc-cancelado { background: #b00020; color: #fff; text-align: center; padding: 6px; font-weight: bold; border-radius: 6px; margin-bottom: 12px; }

/* ---- Verificação pública (QR) ---- */
.cs-pep-verif-wrap { max-width: 560px; margin: 0 auto; }
.cs-pep-verif-box { background: var(--cs-card); border-radius: 14px; padding: 30px; box-shadow: 0 2px 18px rgba(61,47,38,.1); font-family: -apple-system, 'Segoe UI', sans-serif; color: var(--cs-dark); }
.cs-pep-verif-status { font-size: 20px; font-weight: 600; text-align: center; padding: 14px; border-radius: 10px; margin-bottom: 20px; }
.cs-pep-verif-status.cs-ok     { background: #e8f0e4; color: #3d6b2f; }
.cs-pep-verif-status.cs-cancel { background: #f7e4e4; color: #8a3d3d; }
.cs-pep-verif-tab { width: 100%; border-collapse: collapse; }
.cs-pep-verif-tab th { text-align: left; padding: 10px; color: var(--cs-sage); font-size: 12px; text-transform: uppercase; width: 130px; vertical-align: top; }
.cs-pep-verif-tab td { padding: 10px; border-bottom: 1px solid #f0e8de; font-size: 14px; }
.cs-pep-verif-nota { font-size: 12px; color: var(--cs-sage); margin-top: 18px; line-height: 1.5; }
.cs-pep-verif-erro h3 { color: #8a3d3d; margin-top: 0; }

/* ---- Auditoria ---- */
.cs-pep-modo-audit .cs-pep-cab { display: none; }
.cs-pep-modo-audit .cs-pep-tab:not([data-pane='auditoria']) { display: none; }
.cs-pep-audit-cab { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.cs-pep-audit-sub { font-size: 12.5px; color: var(--cs-sage); margin: 0; max-width: 480px; line-height: 1.5; }
.cs-pep-cadeia { font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 16px; white-space: nowrap; }
.cs-pep-cadeia.ok   { background: #e8f0e4; color: #3d6b2f; }
.cs-pep-cadeia.erro { background: #f7e4e4; color: #8a3d3d; }
.cs-pep-audit-ferramentas { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cs-pep-audit-ferramentas input { flex: 1; min-width: 200px; }
.cs-pep-audit-tab { width: 100%; border-collapse: collapse; font-size: 13px; }
.cs-pep-audit-tab th { text-align: left; padding: 9px 10px; background: var(--cs-sand); color: var(--cs-dark); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; }
.cs-pep-audit-tab td { padding: 9px 10px; border-bottom: 1px solid #f0e8de; vertical-align: top; }
.cs-pep-audit-tab tr:hover td { background: var(--cs-bg); }
.cs-audit-data { white-space: nowrap; color: var(--cs-sage); font-size: 12px; }
.cs-audit-acao { font-weight: 600; color: var(--cs-dark); }
.cs-audit-det  { color: #6b5546; font-size: 12.5px; }
.cs-audit-ip   { font-family: monospace; font-size: 11px; color: var(--cs-sage); }
.cs-pep-audit-pag { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; }
.cs-audit-pginfo { font-size: 12px; color: var(--cs-sage); }

/* ---- CID cadastral (widget) ---- */
.cs-cid-cad-box { margin-top: 22px; background: var(--cs-bg); border: 1px solid #efe6da; border-radius: 12px; padding: 18px 20px; }
.cs-cid-cad-titulo { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--cs-accent); margin-bottom: 14px; display: flex; align-items: center; gap: 7px; }
.cs-cid-cad-lista { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.cs-cid-cad-tag { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e0d5c4; border-radius: 20px; padding: 6px 10px 6px 14px; font-size: 13px; }
.cs-cid-cad-tag .cod { font-weight: 700; color: var(--cs-accent); white-space: nowrap; }
.cs-cid-cad-tag .desc { flex: 1; color: #6b5546; font-size: 12px; }
.cs-cid-cad-tag .rm { background: none; border: none; cursor: pointer; color: #b5a99a; font-size: 16px; line-height: 1; padding: 0 2px; flex-shrink: 0; }
.cs-cid-cad-tag .rm:hover { color: #b00020; }
.cs-cid-cad-vazio { color: #9ca69c; font-size: 13px; font-style: italic; margin-bottom: 14px; }

/* linha única: especialidade | busca | data | salvar */
.cs-cid-cad-controles { display: flex; gap: 10px; align-items: flex-end; flex-wrap: nowrap; }
.cs-cid-cad-controles .cc-esp    { flex: 1.2; min-width: 0; position: relative; }
.cs-cid-cad-controles .cc-busca  { flex: 2;   min-width: 0; position: relative; }
.cs-cid-cad-controles .cc-data   { flex: 0 0 auto; }
.cs-cid-cad-controles .cc-salvar { flex: 0 0 auto; }
.cs-cid-cad-esp-sel,
.cs-cid-cad-inp { width: 100%; padding: 10px 13px; border: 1px solid #e6ddd2; border-radius: 9px; font-size: 13px; color: var(--cs-dark); background: #fff; box-sizing: border-box; }
.cs-cid-cad-esp-sel:focus,
.cs-cid-cad-inp:focus { outline: none; border-color: var(--cs-accent); box-shadow: 0 0 0 3px rgba(168,149,128,.13); }
.cs-cid-cad-data-inp { padding: 10px 12px; border: 1px solid #e6ddd2; border-radius: 9px; font-size: 13px; background: #fff; color: var(--cs-dark); }
.cs-cid-cad-results,
.cs-cid-cad-lista-drop { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #e6ddd2; border-radius: 9px; box-shadow: 0 6px 22px rgba(61,47,38,.15); max-height: 260px; overflow-y: auto; z-index: 9999; display: none; margin-top: 4px; }
.cs-cid-cad-results.aberto,
.cs-cid-cad-lista-drop.aberto { display: block; }
.cs-cid-cad-result-item,
.cs-cid-cad-lista-item { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid #f3ece1; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.cs-cid-cad-result-item:hover,
.cs-cid-cad-lista-item:hover { background: #faf3ea; }
.cs-cid-cad-result-item strong,
.cs-cid-cad-lista-item strong { color: var(--cs-accent); white-space: nowrap; min-width: 52px; font-size: 12px; }
.cs-cid-cad-result-item span,
.cs-cid-cad-lista-item span   { color: var(--cs-dark); flex: 1; font-size: 12px; line-height: 1.3; }
.cs-cid-cad-result-item em    { font-size: 10px; color: #9ca69c; white-space: nowrap; }
.cs-cid-cad-grupo { padding: 7px 13px 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: #9ca69c; font-weight: 700; background: #fff; position: sticky; top: 0; border-bottom: 1px solid #f3ece1; }

/* badge CID no cabeçalho do paciente */
.cs-pep-cid-badge { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.28); border-radius: 14px; padding: 3px 10px; font-size: 12px; color: #fff; margin-right: 6px; font-weight: 600; }
.cs-pep-cid-badge .bd { font-weight: 400; opacity: .8; font-size: 11px; }

/* ---- Popup retorno ---- */
#csRtModal.cs-rt-modal { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: 100vw !important; height: 100vh !important; background: rgba(61,47,38,.55) !important; display: none; align-items: center !important; justify-content: center !important; z-index: 2147483647 !important; padding: 20px !important; margin: 0 !important; transform: none !important; }
#csRtModal.cs-rt-modal.ativo { display: flex !important; }
#csRtModal .cs-rt-box { background: #fff; border-radius: 14px; max-width: 480px; width: 100%; padding: 26px; font-family: -apple-system, 'Segoe UI', sans-serif; color: var(--cs-dark); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.cs-rt-box h3 { margin: 0 0 6px; font-size: 19px; }
.cs-rt-box p.sub { color: #7d8a7d; font-size: 13px; margin: 0 0 18px; }
.cs-rt-tipo { display: flex; gap: 8px; margin-bottom: 14px; }
.cs-rt-tipo button { flex: 1; padding: 10px; border: 1px solid #e6ddd2; background: var(--cs-bg); border-radius: 9px; cursor: pointer; font-size: 14px; }
.cs-rt-tipo button.ativo { background: var(--cs-accent); color: #fff; border-color: var(--cs-accent); }
.cs-rt-campo { margin-bottom: 14px; }
.cs-rt-campo label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.cs-rt-campo input { width: 100%; padding: 10px 12px; border: 1px solid #e6ddd2; border-radius: 9px; font-size: 14px; box-sizing: border-box; }
.cs-rt-acoes { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.cs-rt-btn { padding: 11px 20px; border: none; border-radius: 9px; font-size: 14px; font-weight: 600; cursor: pointer; }
.cs-rt-btn.sim { background: var(--cs-accent); color: #fff; }
.cs-rt-btn.nao { background: #f3ece1; color: var(--cs-dark); }

/* ---- Painel recepção ---- */
.cs-rec { font-family: -apple-system, 'Segoe UI', sans-serif; color: var(--cs-dark); max-width: 1000px; margin: 0 auto; }
.cs-rec h3 { font-weight: 600; margin: 0 0 4px; }
.cs-rec-sub { color: #7d8a7d; font-size: 13px; margin: 0 0 16px; }
.cs-rec-filtros { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cs-rec-fbtn { padding: 7px 14px; border: 1px solid #e6ddd2; background: var(--cs-bg); border-radius: 8px; cursor: pointer; font-size: 13px; }
.cs-rec-fbtn.ativo { background: var(--cs-accent); color: #fff; border-color: var(--cs-accent); }
.cs-rec-card { background: #fff; border: 1px solid #efe6da; border-left: 4px solid var(--cs-accent); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.cs-rec-card.urgente { border-left-color: #b00020; }
.cs-rec-card.ok { border-left-color: #3d6b2f; }
.cs-rec-info strong { font-size: 15px; }
.cs-rec-meta { font-size: 12px; color: #7d8a7d; margin-top: 3px; }
.cs-rec-data { font-size: 15px; font-weight: 600; text-align: center; min-width: 80px; }
.cs-rec-dias { font-size: 11px; color: #7d8a7d; }
.cs-rec-acoes { display: flex; gap: 6px; flex-shrink: 0; }
.cs-rec-btn { padding: 6px 12px; border: none; border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 600; }
.cs-rec-btn.ag { background: #e8f0e4; color: #3d6b2f; }
.cs-rec-btn.cx { background: #f7e4e4; color: #8a3d3d; }
.cs-rec-vazio { color: #7d8a7d; font-style: italic; padding: 20px; text-align: center; }
.cs-rec-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 5px; margin-left: 6px; }
.cs-rec-tag.pendente  { background: #fff3df; color: #8a6d2f; }
.cs-rec-tag.agendado  { background: #e8f0e4; color: #3d6b2f; }
.cs-rec-tag.cancelado { background: #f7e4e4; color: #8a3d3d; }

/* ---- Responsivo ---- */
@media (min-width: 900px) {
    .cs-pep-tabconteudo { padding: 26px 28px; }
}
@media (max-width: 780px) {
    .cs-cid-cad-controles { flex-wrap: wrap; }
    .cs-cid-cad-controles .cc-esp,
    .cs-cid-cad-controles .cc-busca { flex: 1 1 100%; }
}
@media (max-width: 680px) {
    .cs-pep-grid2 { grid-template-columns: 1fr; }
    .cs-pep-filtros { flex-direction: column; }
    .cs-pep-dados-topo { flex-direction: column !important; }
    .cs-pep-foto-area { width: 100% !important; min-width: unset !important; max-width: unset !important; align-items: center; }
    .cs-pep-foto-wrap { width: 120px; height: 120px; margin: 0 auto; }
    .cs-pep-foto { width: 120px; height: 120px; }
    .cs-pep-evol-timeline::before { left: 44px; }
    .cs-pep-evol-data-col { width: 54px; }
    .cs-pep-evol-data-box { width: 44px; }
    .cs-pep-evol-data-box .ev-dia { font-size: 17px; }
}
@media print {
    .cs-pep-modal { position: static; background: none; }
    .cs-pep-modal-acoes { display: none; }
    .cs-pep-modal-box { box-shadow: none; max-height: none; }
}