:root {
  --paper:#f1f8fc; --white:#fcfeff; --rail:#e5f3fc; --well:#f5fafd;
  --ink:#143149; --muted:#496273; --line:#c7dfed; --input-line:#91b1c3;
  --deep:#006493; --on-accent:#fff; --hover:#e1f2fc; --active:#d6eefb;
  --focus:#0075ab; --accent:#567300; --danger:#982d4d; --grid-line:#d6e8f3;
  --stage:#def1fc; --pane:#f3faff; --trace:#009fdb; --trace-alt:#b7c82c;
  --brand-green:#536c00; --brand-earth:#9e624d; --brand-pink:#f06f83; --brand-gold:#ffd400;
  --radius:13px; --face:"Avenir Next", Avenir, "Segoe UI", system-ui, sans-serif;
  font-size:16px;
}
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#0c1b2b; --white:#14283b; --rail:#102337; --well:#11263a;
  --ink:#edf8ff; --muted:#b2cbd9; --line:#35536a; --input-line:#67839a;
  --deep:#8bdafa; --on-accent:#103448; --hover:#203e56; --active:#244762;
  --focus:#8edfff; --accent:#c5e555; --danger:#ffc1d0; --grid-line:#253f55;
  --stage:#173952; --pane:#152f47; --trace:#37aee4; --trace-alt:#b3d432;
  --brand-green:#c7e75e; --brand-earth:#eab79f; --brand-pink:#fc91ad; --brand-gold:#ffdb50;
}
body { background:var(--paper); }
.shell { grid-template-columns:228px minmax(0,1fr); }
.rail { background:var(--rail); padding-inline:16px; }
.brand { display:grid; justify-items:start; gap:5px; min-width:0; }
.brand img { display:block; width:min(100%,185px); height:auto; padding:4px; border:1px solid var(--line); border-radius:9px; background:white; }
.brand > span { font-size:.75rem; }
.sign-card .brand img { width:min(100%,265px); }
.rail nav { margin-top:38px; gap:5px; }
.nav-button { padding-inline:12px; font-size:.9375rem; border-radius:8px; }
.nav-button:hover,.plain:hover,.icon-button:hover,.config-list button:hover,.patient-choice:hover,.flow-row:hover,.flow-link:hover,.day-head:hover { background:var(--hover); }
.nav-button[aria-current],.switch [aria-pressed=true],.day-head[aria-pressed=true],.patient-choice[aria-pressed=true],.builder-tabs [aria-pressed=true] { background:var(--active); color:var(--deep); border-color:var(--line); }
.top { background:var(--white); justify-content:flex-start; min-height:62px; font-size:.875rem; }
.top .demo { margin-left:auto; }
.demo { color:var(--deep); background:var(--well); border-color:var(--line); white-space:nowrap; }
.theme-setting { border:1px solid var(--line); border-radius:8px; color:var(--muted); background:var(--well); min-height:37px; display:inline-flex; align-items:center; gap:7px; padding:4px 8px; font-size:.8125rem; }
.theme-setting select { background:transparent; color:var(--ink); border:none; max-width:112px; min-height:27px; font-weight:650; }
.theme-setting .icon { width:17px; height:17px; }
.sign-card .theme-setting { margin:18px 0 0; }
.sign-card .plain { width:fit-content; margin-top:12px; }
.sign-card form button { justify-content:center; }
.sign-copy { max-width:38ch; margin-top:30px; }
.sign-art { position:relative; overflow:hidden; background:var(--stage); }
.sign-art::before,.sign-art::after { content:""; position:absolute; width:72%; aspect-ratio:1; outline:1px solid var(--trace); transform:rotate(39deg) skew(12deg); border-radius:0 40% 0 40%; }
.sign-art::after { width:50%; transform:rotate(49deg) skew(10deg); }
.demo-controls { background:var(--well); }
.content { max-width:1620px; }
h1 { font-size:2.375rem; font-weight:750; letter-spacing:-.033em; }
.page-head p { max-width:65ch; }
.primary,.day-head[aria-pressed=true] b { color:var(--on-accent); background:var(--deep); border-color:var(--deep); }
.primary:hover { color:var(--on-accent); background:var(--deep); border-color:var(--ink); }
.plain[href] { text-decoration:none; color:var(--ink); }
input,textarea,select { accent-color:var(--deep); }
form input,form select,.registry-search input,#evolution-form textarea,#patient-form textarea,.agenda-observation,
.model-config textarea,.preview-paper textarea,.preview-paper input:not([type="checkbox"]),.preview-paper select { background:var(--white); border-color:var(--input-line); color:var(--ink); }
input::placeholder,textarea::placeholder { color:var(--muted); opacity:1; }
:focus-visible { outline-color:var(--focus); }
::selection { color:var(--ink); background:var(--active); }
* { scrollbar-color:var(--input-line) transparent; }
.corner,.day-head,.time-axis,.switch,.flow-link,.saved-model,.builder-field,.preview-paper,.schedule-note,.series-info,.weekday-row { background:var(--well); }
.day-column { background:repeating-linear-gradient(to bottom,transparent 0 calc(var(--hour) - 1px),var(--grid-line) calc(var(--hour) - 1px) var(--hour)); }
.day-column.weekend { background-color:var(--well); }
.day-column.selected,.weekday-row:has(input:checked) { background-color:var(--active); border-color:var(--line); }
.avatar,.day-count { background:var(--active); color:var(--deep); }
#drawer { background:var(--white); }
#drawer::backdrop { background:#0c1c28a0; }
#notice:not(:empty) { background:var(--deep); color:var(--on-accent); font-weight:650; }
.form-error { color:var(--danger); }
.clinical-warning { background:var(--well); color:var(--ink); border-color:var(--line); }
.reception-grid { grid-template-columns:repeat(5,minmax(0,1fr)); }
.lane h2 { font-size:.875rem; }
.tag,.event strong,.event-time,.event-service { font-size:.75rem; }
.day-column .event.compact { flex-direction:row; align-items:center; justify-content:flex-start; gap:4px; }
.day-column .event.brief { padding-block:0; }
.day-column .event.brief strong { line-height:1; font-size:.6875rem; }
.day-column .event.compact .event-service,.day-column .event.brief .event-service { display:none; }
.event .overlap-marks { display:flex; align-items:center; gap:3px; flex:none; }
.overlap-marks i { display:block; width:9px; height:7px; border-radius:2px; background:var(--status-ink); }
.day-column .compact .overlap-marks { margin-left:auto; }
.day-column .multi.compact:has(.overlap-marks) .event-time { display:none; }
.move-hint { margin:0; padding:0 12px 10px; color:var(--muted); font-size:.8125rem; }
.day-column .event[data-drag-visit] { cursor:grab; padding-right:22px; }
.drag-grip { position:absolute; inset:0 0 0 auto; width:21px; display:grid; place-items:center; border-left:1px solid var(--tag-border); touch-action:none; }
.drag-grip .icon { width:14px; height:14px; max-height:100%; }
.day-column .drag-origin,.reception-grid .drag-origin { opacity:.46; }
.reception-grid .event[data-drag-reception] { position:relative; cursor:grab; padding-right:37px; }
.reception-grid .drag-grip { width:32px; }
.reception-grid .drag-grip .icon { width:17px; height:17px; }
.reception-grid .lane.can-receive { outline:1px dashed var(--deep); outline-offset:-4px; }
.reception-grid .lane.will-receive { background:var(--active); outline-style:solid; outline-width:2px; }
.reception-grid .lane.will-receive h2 { color:var(--deep); }
.calendar-drop { position:absolute; inset:auto 3px; top:calc(var(--start) * var(--hour) / 60 + 2px); height:max(13px,calc(var(--duration) * var(--hour) / 60 - 4px)); z-index:2; display:grid; place-items:center; padding:0 2px; overflow:hidden; pointer-events:none; border:1px dashed var(--deep); border-radius:7px; background:var(--active); color:var(--deep); font-size:.75rem; font-weight:700; white-space:nowrap; }
.event,.tag { --tag-fill:var(--status-fill,#e4eef6); --tag-ink:var(--status-ink,#204e71); --tag-border:var(--status-edge,#bed1e1); }
.confirmed { --status-fill:#def1fc; --status-ink:#125580; --status-edge:#a6d7ef; }
.arrived { --status-fill:#fff1c4; --status-ink:#644900; --status-edge:#e4cf80; }
.in_progress { --status-fill:#dfedf9; --status-ink:#274a78; --status-edge:#b7cee7; }
.done { --status-fill:#edf6cd; --status-ink:#435b00; --status-edge:#c0d48a; }
.not_evolved { --status-fill:#fff0d7; --status-ink:#76430b; --status-edge:#e2bf8e; }
.cancelled { --status-fill:#fce3eb; --status-ink:#8e2446; --status-edge:#ebb0c4; }
.no_show { --status-fill:#f5e7df; --status-ink:#733b2a; --status-edge:#dfbaa9; }
:root[data-theme="dark"] :is(.event,.tag) { --tag-fill:var(--status-fill,#253e53); --tag-ink:var(--status-ink,#c2defa); --tag-border:var(--status-edge,#4b667d); }
:root[data-theme="dark"] .confirmed { --status-fill:#1d425c; --status-ink:#b9eaff; --status-edge:#4a7f9e; }
:root[data-theme="dark"] .arrived { --status-fill:#4c4227; --status-ink:#ffebac; --status-edge:#7a6936; }
:root[data-theme="dark"] .in_progress { --status-fill:#233c61; --status-ink:#d0e1ff; --status-edge:#5574a0; }
:root[data-theme="dark"] .done { --status-fill:#354720; --status-ink:#e1f49e; --status-edge:#648044; }
:root[data-theme="dark"] .not_evolved { --status-fill:#573a29; --status-ink:#ffd5af; --status-edge:#8a6245; }
:root[data-theme="dark"] .cancelled { --status-fill:#593147; --status-ink:#ffd0df; --status-edge:#985774; }
:root[data-theme="dark"] .no_show { --status-fill:#50362f; --status-ink:#f7d1bf; --status-edge:#8b6353; }
.reason-form { display:grid; gap:8px; padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--well); }
.reason-form label { font-size:.9rem; }
#status-justification:empty { display:none; }
.access-units label,.reason-form .series-scope label { display:flex; align-items:center; gap:8px; min-height:32px; }
.access-units input[type="checkbox"],.reason-form input[type="radio"] { width:18px; height:18px; min-height:18px; margin:0; flex:none; }
.access-list > .form-hint { padding:9px 14px; border-bottom:1px solid var(--line); }
.user-badges,.user-actions { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
.user-badges { justify-content:flex-end; }
.registration-section { display:grid; gap:12px; min-width:0; margin:0; padding:12px; border:1px solid var(--line); border-radius:var(--radius); }
.registration-section legend { padding-inline:5px; color:var(--deep); font-weight:700; }
.registration-cep,.responsible-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:end; }
.responsible-list,.registration-columns { display:grid; gap:8px; }
.registration-columns { grid-template-columns:repeat(2,minmax(0,1fr)); }
.registration-add { justify-self:start; }
.registration-status:empty,.registration-section button[hidden] { display:none; }
@media(max-width:480px) { .registration-columns { grid-template-columns:1fr; } }
#user-form fieldset[hidden],#user-form label[hidden] { display:none; }
.user-section { display:grid; gap:12px; min-width:0; margin:0; padding:12px; border:1px solid var(--line); border-radius:10px; }
.user-section > legend { padding-inline:5px; font-weight:700; color:var(--deep); }
.user-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; align-items:end; }
.user-fields label { min-width:0; }
.user-section input[type=file] { width:100%; max-width:100%; font-size:.8125rem; }
.user-section textarea { min-height:72px; width:100%; padding:8px; border:1px solid var(--input-line); border-radius:8px; resize:vertical; }
.access-check { display:flex; align-items:center; gap:8px; min-height:35px; }
.access-check input[type=checkbox] { width:18px; height:18px; min-height:18px; margin:0; flex:none; }
@media (max-width:540px) { .user-fields { grid-template-columns:1fr; } }
.management-filters { display:grid; grid-template-columns:minmax(205px,1.4fr) repeat(2,minmax(130px,.85fr)) auto; gap:12px; padding:14px; align-items:end; margin-bottom:16px; }
.management-filters label { color:var(--muted); font-size:.875rem; }
.management-stage { overflow:hidden; position:relative; border:1px solid var(--line); border-radius:var(--radius); background:var(--stage); }
.management-title { display:flex; position:relative; overflow:hidden; min-height:106px; align-items:center; padding:20px clamp(16px,3vw,28px); }
.management-title > div:first-child { position:relative; z-index:1; }
.management-title h2,.profile-report h2,.starts-report h2 { font-size:1.25rem; }
.management-title p,.profile-report header p,.starts-report header p { color:var(--muted); font-size:.875rem; margin-top:5px; max-width:68ch; }
.management-title p { color:var(--ink); }
.lightwell { position:absolute; width:min(46%,400px); height:140%; right:-3%; top:-14%; overflow:hidden; pointer-events:none; }
.lightwell::before,.lightwell::after { content:""; position:absolute; inset:5% 5% -40% 5%; background:var(--trace); clip-path:polygon(0 100%,22% 100%,76% 0,54% 0); opacity:.24; }
.lightwell::after { transform:translateX(31%); opacity:.36; background:var(--trace-alt); }
:root[data-theme="dark"] .lightwell::before { opacity:.08; }
:root[data-theme="dark"] .lightwell::after { opacity:.12; }
@keyframes lightwell-reveal { from { clip-path:inset(0 100% 0 0); } to { clip-path:inset(0 0 0 0); } }
@media (prefers-reduced-motion:no-preference) { .lightwell { animation:lightwell-reveal .45s cubic-bezier(.16,1,.3,1) both; } }
.outcome-band { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); margin:0; border-block:1px solid var(--line); background:var(--pane); }
.outcome-choice { min-width:0; padding:16px clamp(10px,2vw,22px); display:grid; gap:4px; background:transparent; border:0; text-align:left; }
.outcome-choice + .outcome-choice { border-left:1px solid var(--line); }
.outcome-choice:hover,.outcome-choice[aria-pressed="true"] { background:var(--hover); }
.outcome-choice:focus-visible { outline-offset:-4px; }
.outcome-label { width:fit-content; max-width:100%; padding:3px 8px; border-radius:6px; background:var(--status-fill); color:var(--status-ink); font-size:.875rem; font-weight:750; }
.outcome-count { font-variant-numeric:tabular-nums; }
.outcome-count strong { font-size:2rem; font-weight:750; line-height:1.15; }
.outcome-count span,.outcome-visits,.management-explain { font-size:.875rem; color:var(--muted); }
.outcome-open { color:var(--deep); text-decoration:underline; text-underline-offset:3px; font-size:.875rem; font-weight:700; margin-top:4px; }
.outcome-choice[aria-pressed="true"] .outcome-open { text-decoration-thickness:2px; }
.management-explain { padding:12px 16px; }
.profile-report,.starts-report { margin-top:16px; }
.profile-report header,.starts-report header { padding:18px; border-bottom:1px solid var(--line); }
.profile-columns { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }
.profile-columns section { min-width:0; padding:15px 18px; }
.profile-columns section + section { border-left:1px solid var(--line); }
.profile-columns h3 { margin:0 0 11px; font-size:.9375rem; }
.measure-list { list-style:none; display:grid; gap:10px; padding:0; margin:0; }
.starts-report > .measure-list { padding:15px 18px; max-width:750px; }
.measure-list li { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:4px 7px; align-items:end; font-size:.875rem; color:var(--muted); }
.measure-list b { color:var(--ink); font-variant-numeric:tabular-nums; }
.measure-track { grid-column:1/-1; display:block; border-radius:2px; background:var(--line); height:6px; }
.measure-track i { display:block; background:var(--deep); width:var(--measure); height:100%; border-radius:2px; }
.outcome-detail { margin-top:15px; min-width:0; }
.outcome-detail-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px; border-bottom:1px solid var(--line); }
.outcome-detail-head h2 { font-size:1.125rem; }
.outcome-detail-head p { margin-top:3px; color:var(--muted); font-size:.875rem; }
.outcome-error { padding:14px 16px; color:var(--danger); }
.outcome-table { width:100%; border-collapse:collapse; text-align:left; font-size:.875rem; table-layout:fixed; }
.outcome-table thead { background:var(--well); }
.outcome-table :is(th,td) { padding:10px 12px; border-bottom:1px solid var(--line); vertical-align:top; overflow-wrap:anywhere; }
.outcome-table :is(th,td):first-child { padding-left:16px; }
.outcome-table th:last-child { width:25%; }
.outcome-table tr:last-child > :is(th,td) { border-bottom:0; }
.outcome-table time { font-variant-numeric:tabular-nums; }
.outcome-justification { white-space:pre-wrap; }
.mobile-cell-label { display:none; }
.schedule-toolbar { position:relative; }
.agenda-chooser { position:relative; min-width:0; }
.agenda-chooser summary { list-style:none; display:flex; align-items:center; gap:7px; min-height:40px; padding:6px 9px; border:1px solid var(--line); border-radius:8px; background:var(--white); cursor:pointer; color:var(--muted); font-size:.875rem; }
.agenda-chooser summary::-webkit-details-marker { display:none; }
.agenda-chooser summary strong { max-width:135px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--ink); }
.agenda-chooser summary:hover,.agenda-chooser[open] summary { background:var(--active); border-color:var(--input-line); }
.agenda-chooser summary .icon:last-child { width:14px; margin-left:auto; }
.chooser-panel { position:absolute; z-index:4; left:0; top:calc(100% + 6px); width:310px; display:grid; gap:8px; padding:12px; background:var(--white); border:1px solid var(--line); border-radius:var(--radius); box-shadow:0 10px 30px #0003; font-size:.875rem; }
.agenda-chooser[data-picker="patients"] .chooser-panel { left:auto; right:0; }
.agenda-chooser:not([open]) .chooser-panel,.chooser-panel [hidden],.clear-picks[hidden] { display:none; }
.chooser-panel > label { font-weight:700; }
.chooser-panel input[type="search"] { width:100%; min-width:0; min-height:40px; padding:7px 9px; background:var(--well); color:var(--ink); border:1px solid var(--input-line); border-radius:7px; }
.chooser-options { padding:0; margin:0; max-height:min(36vh,260px); overflow:auto; list-style:none; }
.chooser-options label { display:flex; align-items:center; gap:8px; min-height:38px; padding:4px 6px; border-radius:6px; cursor:pointer; overflow-wrap:anywhere; }
.chooser-options label:hover,.chooser-options label:has(input:checked) { background:var(--hover); }
.chooser-options input { margin:0; width:17px; height:17px; flex:none; }
.chooser-tools { display:flex; align-items:center; justify-content:space-between; gap:7px; color:var(--muted); }
.chooser-tools .plain,.chooser-done { min-height:34px; padding:5px 8px; font-size:.8125rem; }
.chooser-done { justify-self:end; }
@media(max-width:1050px) {
  .management-filters { grid-template-columns:minmax(0,1.3fr) repeat(2,minmax(0,1fr)); gap:8px; }
  .management-filters button { grid-column:1/-1; justify-self:end; }
  .reception-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .lane:nth-child(n+4) { border-top:1px solid var(--line); }
  .lane:nth-child(4) { border-left:0; }
}
@media(max-width:830px) {
  .shell { grid-template-columns:minmax(0,1fr); }
  .agenda-chooser { position:static; }
  .agenda-chooser .chooser-panel,.agenda-chooser[data-picker="patients"] .chooser-panel { width:auto; left:0; right:0; }
  .rail nav { margin-top:0; }
  .nav-button { white-space:nowrap; padding:6px 8px; font-size:.8125rem; }
  .top { min-height:47px; }
  .reception-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .lane:nth-child(4) { border-left:1px solid var(--line); }
  .lane:nth-child(5) { border-left:0; grid-column:1/-1; min-height:180px; }
}
@media(max-width:720px) {
  .outcome-table,.outcome-table tbody { display:block; }
  .outcome-table thead { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
  .outcome-table tr { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; padding:12px 14px; border-bottom:1px solid var(--line); }
  .outcome-table tr:last-child { border-bottom:0; }
  .outcome-table tbody :is(th,td),.outcome-table tbody :is(th,td):first-child { display:block; border:0; padding:0; width:auto; }
  .outcome-table tbody th:first-child,.outcome-justification { grid-column:1/-1; }
  .mobile-cell-label { display:block; color:var(--muted); font-size:.8125rem; font-weight:600; white-space:normal; }
}
@media(max-width:620px) {
  h1 { font-size:1.875rem; }
  .management-filters { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .management-filters label:first-child,.management-filters button { grid-column:1/-1; }
  .management-filters button { justify-self:stretch; }
  .outcome-band { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .outcome-choice:nth-child(3) { border-left:0; }
  .outcome-choice:nth-child(n+3) { border-top:1px solid var(--line); }
  .profile-columns { grid-template-columns:1fr; }
  .profile-columns section + section { border-left:0; border-top:1px solid var(--line); }
  .user-row { grid-template-columns:minmax(0,1fr) auto; }
  .user-actions { grid-column:1/-1; }
  .top { gap:6px; padding-inline:12px; font-size:.75rem; }
  .top > span:first-child { gap:3px; }
  .top .demo { padding:4px; }
  .top .theme-setting { padding-inline:5px; }
  .top .theme-setting span { display:none; }
  .top .theme-setting .icon { width:13px; }
  .theme-setting select { max-width:90px; }
}
@media(max-width:460px) {
  .rail nav { flex-wrap:wrap; }
  .top { display:grid; grid-template-columns:minmax(0,1fr) auto; padding-block:6px; }
  .top > span:first-child { grid-column:1/-1; }
  .top .demo { margin:0; justify-self:start; }
  .top .theme-setting { justify-self:end; }
}
