:root{--j-bg:#fff;--j-card:#fff;--j-border:#e5e7eb;--j-text:#111827;--j-muted:#6b7280;--j-soft:#f8fafc;--j-accent:var(--apn-primary,#7c3aed)}
html.dark,:root[data-theme="dark"],body.dark{--j-bg:#0b0f17;--j-card:#111827;--j-border:#263244;--j-text:#f8fafc;--j-muted:#a7b0c0;--j-soft:#0f172a}
.apn-journey-overlay{position:fixed;inset:0;z-index:10040;background:rgba(15,23,42,.5);display:flex;align-items:stretch;justify-content:flex-end;backdrop-filter:blur(3px)}
.apn-journey-app{width:min(1180px,100%);height:100%;overflow:auto;background:var(--j-bg);color:var(--j-text);box-shadow:-18px 0 45px rgba(0,0,0,.18)}
.apn-journey-head{position:sticky;top:0;z-index:4;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:18px 24px;border-bottom:1px solid var(--j-border);background:color-mix(in srgb,var(--j-bg) 94%,transparent);backdrop-filter:blur(12px)}
.apn-journey-head h1{margin:0;font-size:24px}.apn-journey-head p{margin:3px 0 0;color:var(--j-muted);font-size:13px}.apn-journey-head button,.apn-journey-btn{border:0;border-radius:10px;padding:10px 14px;font-weight:700;cursor:pointer}.apn-journey-close{background:var(--j-soft);color:var(--j-text)}
.apn-journey-body{padding:22px 24px 34px;max-width:1120px;margin:auto}.apn-journey-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:18px}.apn-journey-tabs{display:flex;gap:8px;flex-wrap:wrap}.apn-journey-tabs button{border:1px solid var(--j-border);background:var(--j-card);color:var(--j-text);border-radius:999px;padding:9px 14px;font-weight:700;cursor:pointer}.apn-journey-tabs button.active{background:var(--j-accent);border-color:var(--j-accent);color:#fff}.apn-journey-primary{background:var(--j-accent);color:#fff}.apn-journey-secondary{background:var(--j-soft);color:var(--j-text);border:1px solid var(--j-border)}
.apn-journey-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(270px,1fr));gap:14px}.apn-journey-card{border:1px solid var(--j-border);background:var(--j-card);border-radius:16px;padding:16px}.apn-journey-card h3{margin:0 0 5px}.apn-journey-card p{margin:0;color:var(--j-muted);font-size:13px}.apn-journey-card-foot{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:15px}.apn-journey-chip{display:inline-flex;align-items:center;border-radius:999px;padding:5px 9px;font-size:12px;background:var(--j-soft);border:1px solid var(--j-border);color:var(--j-muted)}
.apn-journey-form{display:grid;gap:18px}.apn-journey-field{display:grid;gap:6px}.apn-journey-field label{font-size:12px;font-weight:800;color:var(--j-muted);text-transform:uppercase;letter-spacing:.05em}.apn-journey-field input,.apn-journey-field select,.apn-journey-field textarea{width:100%;box-sizing:border-box;border:1px solid var(--j-border);background:var(--j-card);color:var(--j-text);border-radius:10px;padding:10px 11px;font:inherit}.apn-journey-field textarea{min-height:76px;resize:vertical}.apn-journey-duration{display:flex;gap:8px;flex-wrap:wrap}.apn-journey-duration button{border:1px solid var(--j-border);background:var(--j-card);color:var(--j-text);border-radius:12px;padding:11px 16px;font-weight:800;cursor:pointer}.apn-journey-duration button.active{border-color:var(--j-accent);box-shadow:0 0 0 2px color-mix(in srgb,var(--j-accent) 18%,transparent)}
.apn-checkpoint{border:1px solid var(--j-border);border-radius:16px;overflow:hidden;background:var(--j-card)}.apn-checkpoint-head{display:flex;align-items:center;justify-content:space-between;padding:13px 15px;background:var(--j-soft)}.apn-checkpoint-head strong{font-size:15px}.apn-checkpoint-body{padding:14px;display:grid;gap:12px}.apn-question-row{display:grid;grid-template-columns:1fr 170px auto;gap:9px;align-items:start;padding:10px;border:1px solid var(--j-border);border-radius:12px}.apn-question-row textarea{min-height:58px}.apn-question-options{grid-column:1/-1}.apn-question-remove{border:0;background:transparent;color:#b91c1c;font-size:20px;cursor:pointer;padding:4px 7px}.apn-question-add{border:1px dashed var(--j-border);background:transparent;color:var(--j-text);border-radius:10px;padding:10px;font-weight:700;cursor:pointer}.apn-question-add:disabled{opacity:.45;cursor:not-allowed}
.apn-journey-actions{display:flex;justify-content:flex-end;gap:10px;position:sticky;bottom:0;padding:14px 0;background:linear-gradient(transparent,var(--j-bg) 25%)}
.apn-journey-list{display:grid;gap:10px}.apn-enrollment-row,.apn-response-row{display:grid;grid-template-columns:minmax(180px,1.3fr) repeat(3,minmax(100px,.7fr)) auto;gap:10px;align-items:center;border:1px solid var(--j-border);background:var(--j-card);border-radius:13px;padding:12px}.apn-enrollment-row small,.apn-response-row small{color:var(--j-muted)}
.apn-patient-picker{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:8px;max-height:380px;overflow:auto;padding:4px}.apn-patient-pick{display:flex;align-items:center;gap:9px;border:1px solid var(--j-border);border-radius:11px;padding:10px;background:var(--j-card)}.apn-patient-pick input{width:18px;height:18px}.apn-journey-empty{padding:28px;border:1px dashed var(--j-border);border-radius:14px;text-align:center;color:var(--j-muted)}
.apn-journey-modal{position:fixed;inset:0;z-index:10060;background:rgba(15,23,42,.55);display:grid;place-items:center;padding:18px}.apn-journey-modal-card{width:min(680px,100%);max-height:88vh;overflow:auto;background:var(--j-card);color:var(--j-text);border-radius:18px;padding:20px;box-shadow:0 24px 70px rgba(0,0,0,.25)}.apn-journey-modal-card header{display:flex;align-items:start;justify-content:space-between;gap:12px;margin-bottom:14px}.apn-journey-modal-card h2{margin:0}.apn-journey-modal-card header button{border:0;background:var(--j-soft);color:var(--j-text);border-radius:9px;padding:8px 10px;cursor:pointer}
.apn-journey-answer{border:1px solid var(--j-border);border-radius:12px;padding:12px;margin-top:10px}.apn-journey-answer b{display:block;margin-bottom:6px}.apn-journey-answer span{color:var(--j-muted)}
.apn-patient-journey-summary{margin:12px 0 18px;border:1px solid var(--j-border);background:var(--j-card);color:var(--j-text);border-radius:14px;padding:13px 15px;display:flex;justify-content:space-between;gap:12px;align-items:center}.apn-patient-journey-summary strong{display:block}.apn-patient-journey-summary small{color:var(--j-muted)}
.portal .tabs .apn-patient-journey-tab{position:relative}.apn-journey-patient-panel{display:grid;gap:14px}.apn-patient-journey-card{border:1px solid var(--j-border);border-radius:15px;padding:14px;background:var(--j-card)}.apn-patient-journey-card header{display:flex;justify-content:space-between;gap:10px}.apn-patient-journey-card h3{margin:0}.apn-patient-journey-card p{margin:4px 0;color:var(--j-muted)}.apn-patient-journey-progress{height:8px;background:var(--j-soft);border-radius:999px;overflow:hidden;margin:10px 0}.apn-patient-journey-progress i{display:block;height:100%;background:var(--j-accent);border-radius:inherit}.apn-patient-journey-question{display:grid;gap:8px;padding:12px 0;border-top:1px solid var(--j-border)}.apn-patient-journey-question:first-of-type{border-top:0}.apn-patient-journey-question label{font-weight:750}.apn-patient-journey-question textarea{width:100%;box-sizing:border-box;min-height:74px;border:1px solid var(--j-border);background:var(--j-bg);color:var(--j-text);border-radius:10px;padding:10px}.apn-scale5,.apn-yesno,.apn-mchoice{display:flex;gap:8px;flex-wrap:wrap}.apn-scale5 label,.apn-yesno label,.apn-mchoice label{display:flex;gap:6px;align-items:center;border:1px solid var(--j-border);border-radius:999px;padding:8px 10px;font-weight:600;cursor:pointer}.apn-patient-journey-submit{width:100%;margin-top:8px;background:var(--j-accent);color:#fff;border:0;border-radius:11px;padding:11px;font-weight:800;cursor:pointer}
@media(max-width:720px){.apn-journey-head{padding:14px 15px}.apn-journey-body{padding:15px}.apn-question-row{grid-template-columns:1fr}.apn-question-options{grid-column:auto}.apn-enrollment-row,.apn-response-row{grid-template-columns:1fr 1fr}.apn-enrollment-row>:first-child,.apn-response-row>:first-child{grid-column:1/-1}.apn-journey-toolbar{align-items:flex-start;flex-direction:column}.apn-patient-journey-summary{align-items:flex-start;flex-direction:column}}

/* Jornadas embutidas usam o espaco principal do painel profissional. */
.apn-journey-overlay.apn-embedded-module{box-sizing:border-box}

/* Jornadas V4 — editor premium e app do paciente */
.apn-journey-editor-modal{width:min(900px,100%)!important}
.apn-checkpoints-list{display:grid;gap:14px}
.apn-question-editor,.apn-question-card{border:1px solid var(--j-border);border-radius:14px;background:color-mix(in srgb,var(--j-card) 96%,var(--j-soft));padding:13px;margin-bottom:10px;box-shadow:0 5px 15px rgba(15,23,42,.04)}
.apn-question-editor-top,.apn-question-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:10px}
.apn-question-editor-top strong,.apn-question-card-head small{font-size:11px;letter-spacing:.07em;text-transform:uppercase;color:var(--j-muted)}
.apn-question-editor-top button,.apn-question-card-actions button{border:0;background:transparent;color:var(--j-muted);font:inherit;font-size:12px;font-weight:750;cursor:pointer;padding:3px 5px}
.apn-question-card-actions{display:flex;gap:5px;flex:0 0 auto}.apn-question-card-actions button:last-child{color:#b42318}
.apn-question-editor textarea{width:100%;box-sizing:border-box;min-height:72px;border:1px solid var(--j-border);border-radius:10px;background:var(--j-bg);color:var(--j-text);padding:10px 11px;font:inherit;resize:vertical}
.apn-question-editor-bottom{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:9px}.apn-question-editor-bottom select{min-width:150px;border:1px solid var(--j-border);border-radius:10px;background:var(--j-card);color:var(--j-text);padding:9px 10px;font:inherit}.apn-question-confirm{border:0;border-radius:10px;padding:9px 13px;background:var(--j-accent);color:#fff;font:inherit;font-weight:800;cursor:pointer}
.apn-question-card-head strong{display:block;margin-top:3px;font-size:14px;line-height:1.35;color:var(--j-text)}
.apn-question-preview-options{display:flex;gap:7px;flex-wrap:nowrap}.apn-question-preview-options span,.apn-question-preview-text{border:1px solid var(--j-border);border-radius:999px;padding:6px 10px;background:var(--j-bg);color:var(--j-muted);font-size:12px;font-weight:700}.apn-question-preview-text{display:inline-flex;border-radius:9px;font-weight:600}.apn-question-preview-scale span{min-width:28px;text-align:center;padding-inline:7px}
.apn-journey-patient-action-wrap{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin:18px 0}.apn-journey-launch-card{min-width:0;max-width:100%;overflow:hidden}.apn-journey-launch-card .apn-patient-action{width:100%;min-width:0;border:0;border-radius:14px;padding:15px 18px;display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--brand-gradient,linear-gradient(135deg,#6d28d9,#4c1d95));color:#fff;font:inherit;cursor:pointer;box-shadow:0 8px 20px #0000001f}.apn-journey-launch-card .apn-action-icon{width:22px;height:22px;display:grid;place-items:center}.apn-journey-launch-card .apn-action-icon svg{width:22px;height:22px}.apn-journey-launch-card .apn-action-copy{display:grid;gap:4px;min-width:0;flex:1;text-align:left}.apn-journey-launch-card .apn-action-copy>span{font-weight:400;font-size:.82em;line-height:1.3}
.apn-journey-modal-card:has(.apn-journey-patient-panel){width:min(590px,calc(100vw - 28px))!important;max-height:86vh;padding:17px}.apn-journey-modal-card:has(.apn-journey-patient-panel) h2{font-size:24px}.apn-journey-modal-card:has(.apn-journey-patient-panel) header p{font-size:14px}.apn-patient-journey-card{padding:12px}.apn-patient-journey-card h3{font-size:18px}.apn-patient-journey-card p{font-size:13px}.apn-patient-journey-question{gap:6px;padding:10px 0}.apn-patient-journey-question>label{font-size:14px;line-height:1.3}.apn-patient-journey-question textarea{min-height:62px;font-size:14px}.apn-scale5{display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px!important;flex-wrap:nowrap!important}.apn-scale5 label{justify-content:center;gap:4px!important;padding:7px 5px!important;font-size:13px;min-width:0}.apn-scale5 input{width:16px;height:16px}.apn-yesno{flex-wrap:nowrap!important}.apn-yesno label{padding:7px 12px!important;font-size:13px}
@media(max-width:720px){.apn-question-editor-bottom{align-items:stretch;flex-direction:column}.apn-question-editor-bottom select,.apn-question-confirm{width:100%}.apn-question-card-head{gap:6px}.apn-question-card-actions{flex-direction:column;align-items:flex-end}.apn-journey-modal-card:has(.apn-journey-patient-panel){padding:14px}.apn-journey-modal-card:has(.apn-journey-patient-panel) h2{font-size:22px}.apn-journey-launch-card .apn-patient-action{padding:14px 16px}.apn-scale5 label{padding:7px 3px!important}.apn-scale5 label input{margin:0}}

/* V8 - itens liberados no resumo do paciente */
.apn-patient-journey-summary{display:block}.apn-summary-journey-head{display:flex;justify-content:space-between;gap:12px;align-items:center}.apn-summary-released{margin-top:14px;padding-top:12px;border-top:1px solid var(--j-border)}.apn-summary-released-label{display:block;margin-bottom:7px;color:var(--j-muted);font-weight:700}.apn-summary-released-list{display:grid;gap:7px}.apn-summary-released-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 11px;border:1px solid var(--j-border);border-radius:11px}.apn-summary-released-row>div{min-width:0}.apn-summary-released-row>div>span{display:block;color:var(--j-muted);font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.04em}.apn-summary-released-row strong,.apn-summary-released-row small{display:block}.apn-summary-released-row small{margin-top:2px;color:var(--j-muted)}@media(max-width:720px){.apn-summary-journey-head,.apn-summary-released-row{align-items:flex-start;flex-direction:column}}

/* V9 — resumo clínico: Jornada, Check-in e QPC seguem a cor da plataforma */
.apn-patient-journey-summary{
  border-color:var(--brand-primary,var(--apn-primary,#7c3aed));
}
.apn-summary-released{
  border-top-color:color-mix(in srgb,var(--brand-primary,var(--apn-primary,#7c3aed)) 32%,transparent);
}
.apn-summary-released-row{
  border-color:var(--brand-primary,var(--apn-primary,#7c3aed));
}

/* V10: vínculos reutilizáveis e exclusão explícita */
.apn-enrollment-actions{display:flex;gap:7px;justify-content:flex-end;flex-wrap:wrap}.apn-journey-danger{background:var(--j-card);color:#b91c1c;border:1px solid rgba(220,38,38,.35)}.apn-journey-pick{width:100%;text-align:left;border:1px solid var(--j-border);background:var(--j-card);color:var(--j-text);cursor:pointer}.apn-journey-pick:hover{border-color:var(--j-accent)}
@media(max-width:720px){.apn-enrollment-actions{grid-column:1/-1;justify-content:stretch}.apn-enrollment-actions .apn-journey-btn{flex:1}}

/* Exclusão e seleção de respostas */
.apn-journey-card-actions{display:flex;gap:7px;justify-content:flex-end;flex-wrap:wrap}
.apn-response-tools{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 12px;padding:10px 12px;border:1px solid var(--j-border);border-radius:12px;background:var(--j-card)}
.apn-response-select-all,.apn-response-check{display:flex;align-items:center;gap:8px;color:var(--j-text);font-weight:700}.apn-response-select-all input,.apn-response-check input{width:18px;height:18px;accent-color:var(--j-accent);cursor:pointer}
.apn-response-row{grid-template-columns:auto minmax(180px,1.3fr) repeat(3,minmax(100px,.7fr)) auto}
.apn-response-check{justify-content:center}
@media(max-width:720px){.apn-response-tools{align-items:stretch;flex-direction:column}.apn-response-row{grid-template-columns:auto 1fr}.apn-response-row>:nth-child(n+3){grid-column:2}.apn-response-check{grid-row:1/span 2;align-self:start;padding-top:3px}}

/* checkpoint duplication helpers */
.apn-checkpoint-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.apn-checkpoint-actions .apn-question-add{flex:1 1 180px}.apn-checkpoint-copy{border:1px solid var(--j-border);background:var(--j-card);color:var(--j-text);border-radius:10px;padding:10px 12px;font:inherit;font-size:12px;font-weight:750;cursor:pointer;white-space:nowrap}.apn-checkpoint-copy:hover{border-color:var(--j-accent);color:var(--j-accent)}html[data-theme=dark] .apn-checkpoint-copy{background:#15171a}@media(max-width:720px){.apn-checkpoint-actions{display:grid;grid-template-columns:1fr}.apn-checkpoint-actions .apn-question-add,.apn-checkpoint-copy{width:100%}}

/* V13 — hierarquia do app paciente: Dieta/Avaliações primeiro; Jornada e personalizados abaixo */
html[data-theme] body main.portal > .apn-journey-patient-action-wrap,
html[data-theme] body main.portal > .apn-custom-patient-actions{margin:12px 0 0!important;gap:12px!important;}
html[data-theme] body main.portal > .apn-journey-patient-action-wrap + .apn-custom-patient-actions,
html[data-theme] body main.portal > .apn-custom-patient-actions + .apn-journey-patient-action-wrap{margin-top:12px!important;}
html[data-theme] body main.portal > .apn-journey-patient-action-wrap .apn-compact-action,
html[data-theme] body main.portal > .apn-custom-patient-actions .apn-compact-action{margin:0!important;}
