:root {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: #192c3c;
  background: #f3f7f8;
  font-synthesis: none;
  --ink: #192c3c;
  --muted: #506675;
  --line: #dae5e9;
  --teal: #086e66;
  --nav: #112b3a;
}
* { box-sizing: border-box; }
body { margin: 0; display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, select, input, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
:focus-visible { outline: 3px solid #2b9f99; outline-offset: 3px; }
.sidebar { background: var(--nav); color: #c3d5de; padding: 30px 17px 22px; display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; align-self: start; }
.brand { display: flex; gap: 11px; align-items: center; color: #fff; font-weight: 750; font-size: 22px; letter-spacing: -.5px; padding-left: 9px; }
.brand-text { display: block; line-height: 1.1; }
.brand-text small { display: block; margin-top: 4px; color: #c3d5de; font-size: 11px; font-weight: 500; letter-spacing: 0; }
.brand-mark { display: block; flex: none; width: 38px; height: 38px; object-fit: contain; }
.workspace-label { color: #a5bac4; font-size: 12px; letter-spacing: .13em; font-weight: 700; margin: 52px 0 12px 12px; }
nav { display: grid; gap: 6px; }
nav a { padding: 11px 12px; display: flex; align-items: center; gap: 12px; border-radius: 8px; font-size: .91rem; font-weight: 600; }
nav a span { width: 19px; text-align: center; font-size: 20px; line-height: 1; }
nav a:hover, nav a[aria-current="page"] { color: #fff; background: #244656; }
nav a[aria-current="page"] span { color: #68e0ca; }
.sidebar-foot { display: flex; align-items: baseline; gap: 9px; margin-top: auto; border-top: 1px solid #385363; padding: 19px 5px 0; font-size: .86rem; }
.sidebar-foot small { display: block; margin-top: 4px; color: #a5bac4; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #65e0c2; }
.topbar { min-height: 66px; padding: 12px clamp(18px, 4vw, 48px); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); background: white; font-size: .9rem; color: var(--muted); }
.topbar strong { color: var(--ink); }
.separator { padding: 0 10px; color: #778e9a; }
.demo-label { background: #e4f4f0; color: #075b53; border: 1px solid #c6e8df; padding: 5px 10px; border-radius: 20px; font-size: .8rem; font-weight: 650; }
main { padding: 38px clamp(18px, 4vw, 48px) 60px; max-width: 1440px; margin: auto; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 2.85rem); letter-spacing: -.05em; line-height: 1.1; }
h2 { font-size: 1.23rem; letter-spacing: -.025em; }
.subtitle { color: var(--muted); margin-top: 9px; line-height: 1.55; }
.hero { padding: 31px; color: white; border-radius: 15px; background: radial-gradient(ellipse at 100% 5%, #226872, transparent 64%), #163c4d; }
.hero .subtitle { color: #d2e5e9; }
.hero-top { display: flex; align-items: center; gap: 9px; color: #8fe6d4; font-weight: 700; font-size: .82rem; margin-bottom: 13px; }
.page-heading { margin-bottom: 24px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; margin: 18px 0 24px; }
.metric, .panel { background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 4px #142c3810; }
.metric { padding: 17px 20px; }
.metric span { display: block; color: var(--muted); font-size: .9rem; font-weight: 600; }
.metric strong { display: block; margin-top: 5px; font-size: 1.7rem; letter-spacing: -.04em; }
.panel { margin-bottom: 17px; overflow: hidden; }
.panel-pad { padding: 21px; }
.panel-head { padding: 20px 21px; display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 15px; }
.fields, .actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: .87rem; font-weight: 650; min-width: 0; }
input, select, textarea { width: 100%; min-width: 0; padding: 9px 11px; min-height: 40px; border: 1px solid #bbced6; border-radius: 7px; background: white; color: var(--ink); font-size: .92rem; }
select { appearance: none; padding-right: 28px; background: linear-gradient(45deg, transparent 50%, #496575 50%) right 14px center / 5px 5px no-repeat, linear-gradient(135deg, #496575 50%, transparent 50%) right 9px center / 5px 5px no-repeat, white; }
textarea { resize: vertical; min-height: 115px; font: .85rem/1.5 ui-monospace, monospace; }
button, .button { padding: 9px 13px; min-height: 40px; border: 1px solid #bbced6; border-radius: 7px; background: white; color: var(--ink); font-weight: 650; font-size: .88rem; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
button:hover, .button:hover { background: #eaf3f4; }
.primary { background: var(--teal); color: white; border-color: var(--teal); }
.primary:hover { background: #065b54; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; text-align: left; white-space: nowrap; font-size: .9rem; }
th, td { padding: 13px 18px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-size: .81rem; font-weight: 700; background: #f5f8fa; }
td small { display: block; color: var(--muted); padding-top: 2px; }
tbody tr:hover { background: #f8fbfc; }
.client-cell { display: flex; gap: 10px; align-items: center; }
.avatar { display: grid; place-items: center; background: #dff2ee; color: #086156; font-weight: 700; width: 34px; height: 34px; border-radius: 9px; }
.pill { padding: 4px 9px; border-radius: 20px; background: #e9f0f4; color: #344e5f; display: inline-block; font-weight: 650; font-size: .78rem; }
.pill.advanced, .pill.good { background: #daf1eb; color: #075b53; }
.pill.attention { background: #fbe9db; color: #863e13; }
.table-action { color: var(--teal); font-weight: 700; }
.table-action:hover { text-decoration: underline; }
.section-heading { display: flex; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.editor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.edit-row { display: grid; grid-template-columns: minmax(100px, 1.2fr) repeat(3, minmax(98px, 1fr)) auto; gap: 9px; align-items: end; margin-top: 11px; }
.edit-row.standard { grid-template-columns: 1fr 1fr; }
.edit-row.pause { grid-template-columns: 1fr 1fr auto; }
.note { color: var(--muted); font-size: .87rem; line-height: 1.5; margin-top: 9px; }
.feedback { min-height: 1.25em; font-weight: 650; color: var(--teal); }
.error { color: #a32c34; }
.replay-config { display: grid; gap: 15px; }
details summary { cursor: pointer; color: var(--teal); font-weight: 650; font-size: .9rem; }
details label { margin-top: 10px; }
.clock { background: #173e50; color: white; }
.clock .note { color: #d1e8ee; }
.clock time { display: block; font: 1.2rem ui-monospace, monospace; margin: 10px 0; }
.clock input { padding: 0; accent-color: #7fddcd; background: transparent; }
.days { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.payload { white-space: pre-wrap; min-width: 230px; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 18px; }
@media (max-width: 850px) {
  body { grid-template-columns: 175px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edit-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 630px) {
  body { display: block; }
  .sidebar { min-height: 0; position: static; padding: 12px; gap: 10px; }
  .workspace-label, .sidebar-foot { display: none; }
  nav { display: flex; flex-wrap: wrap; gap: 3px; }
  nav a { padding: 7px; font-size: .82rem; gap: 5px; }
  main { padding-top: 23px; }
  .hero { padding: 22px; }
  .metric { padding: 11px; }
  .metric span { font-size: .8rem; }
}
.manager-columns { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; margin-top: 18px; align-items: start; }
.manager-form { display: grid; gap: 13px; }
.manager-form h2 { margin-bottom: 2px; }
.manager-form .note { margin-top: 0; }
.manager-form > .feedback { font-size: .9rem; }
.manager-form .editor-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.manager-form .manager-prefs { grid-template-columns: repeat(3,minmax(0,1fr)); }
.manager-check { display: flex; align-items: center; margin: 10px 0; }
.manager-check input { width: auto; min-height: 0; }
.manager-form details .editor-grid { margin-top: 10px; }
.manager-form textarea { min-height: 155px; }
@media (max-width: 1000px) { .manager-columns { grid-template-columns: minmax(0,1fr); } }
.report-navigation { margin-bottom: 1rem; }
.report-choices { border: 1px solid var(--border, #cbd5e1); border-radius: .65rem; padding: 0 .85rem .35rem; }
.report-choices legend { font-weight: 650; padding: 0 .35rem; }
#schedule-reports textarea { min-height: 84px; }
#report-history details { max-width: 510px; white-space: normal; }
#report-history details p { margin: .45rem 0; }
#report-history ul { padding-left: 1rem; }
.client-directory { margin-top: 18px; }
.client-directory .directory-notice:not(:empty) { padding: 0 1.25rem .85rem; }
.enrollment-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(100%, 32rem);
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  color: inherit;
  box-shadow: -12px 0 30px #102a4624;
}
.enrollment-drawer::backdrop { background: #102a4660; }
.enrollment-drawer[open] { animation: enrollment-slide .2s ease-out; }
.enrollment-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
@keyframes enrollment-slide { from { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .enrollment-drawer[open] { animation: none; } }
.client-directory th:has(.sort-heading) { padding: 0; }
button.sort-heading {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
button.sort-heading:hover { background: #e7eff2; }
button.sort-heading:focus-visible { outline-offset: -3px; }
.sort-heading span { font-size: .66rem; }
.sidebar-clients { margin: 22px 0 18px; border-top: 1px solid #385363; padding-top: 14px; }
.sidebar-clients label { color: #e3eef3; }
.sidebar-clients ul { max-height: min(35vh, 18rem); overflow: auto; margin: 7px 0 0; padding: 3px; list-style: none; }
.sidebar-clients li a { display: block; padding: 7px 8px; border-radius: 6px; overflow-wrap: anywhere; }
.sidebar-clients li a:hover { background: #244656; color: white; }
.sidebar-clients small { display: block; color: #a5bac4; }
.sidebar-clients p { margin-top: 6px; font-size: .875rem; }
.sidebar-clients p:empty { display: none; }
.adherence-controls, .adherence-views, .adherence-month {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.adherence-controls { justify-content: space-between; margin: 14px 0; }
.adherence-controls button { background: #e8f0f3; color: #244656; }
.adherence-controls button[aria-pressed="true"] { background: #244656; color: white; }
.adherence-controls button:disabled { opacity: .45; cursor: default; }
.adherence-month strong { min-width: 9em; text-align: center; }
.adherence-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.adherence-calendar > strong { text-align: center; padding: 5px 0; font-size: .85rem; }
.adherence-day { display: flex; flex-direction: column; min-height: 54px; padding: 4px 7px;
  border-radius: 6px; background: #f2f6f8; font-size: .85rem; }
.adherence-day b { align-self: center; font-size: 1rem; }
.adherence-calendar .good, .adherence-legend .good { background: #d2eee7; color: #075c53; }
.adherence-calendar .partial, .adherence-legend .partial { background: #faead3; color: #81470c; }
.adherence-calendar .missed, .adherence-legend .missed { background: #f9dfe4; color: #942c42; }
.adherence-calendar .pending, .adherence-legend .pending { background: #e6eef6; color: #354f6a; }
.adherence-calendar .paused, .adherence-legend .paused { background: #eee6fa; color: #5b4788; }
.adherence-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 12px 0 0;
  list-style: none; padding: 0; font-size: .85rem; color: var(--muted); }
.adherence-legend li { display: flex; align-items: center; gap: 6px; }
.adherence-legend b { border-radius: 4px; padding: 0 5px; background: #f2f6f8; }
.adherence-scroll { overflow-x: auto; }
.adherence-plot { display: block; width: 100%; min-width: 540px; font-size: 13px; }
.adherence-plot text { fill: #435766; }
.adherence-plot line { stroke: #8096a1; stroke-opacity: .24; }
.adherence-plot .plot-area { fill: #f8fbfc; stroke: #d3e0e6; }
.plot-band { --band-color: #deeade; fill: var(--band-color); }
.plot-band.early { --band-color: #d9e8f8; }
.plot-band.dose { --band-color: #a9d9bf; }
.plot-band.reminder-1 { --band-color: #f5d388; }
.plot-band.reminder-2 { --band-color: #efb3a8; }
.plot-band.missed { --band-color: #f5d0d5; }
.plot-legend .plot-band { width: 14px; height: 12px; border-radius: 3px; background: var(--band-color); }
.adherence-plot circle { fill: #2467aa; stroke: white; stroke-width: 1.5; }
.adherence-plot circle:focus, .adherence-plot circle:hover { stroke: #132c46; stroke-width: 2; }

#interventions fieldset {
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid #cbdce3;
  border-radius: 8px;
}
#interventions legend { padding: 0 4px; font-weight: 700; }
#interventions .recipient-dropdown {
  padding: 0 10px;
  border: 1px solid #b5cbd5;
  border-radius: 7px;
}
#interventions .recipient-dropdown + .recipient-dropdown { margin-top: 8px; }
.recipient-dropdown summary { padding: 8px 0; cursor: pointer; }
.recipient-count { float: right; color: var(--muted); font-size: .875rem; font-weight: 400; }
.recipient-options { max-height: 14rem; overflow: auto; }
.recipient-options label { overflow-wrap: anywhere; }

.manager-stack { display: grid; min-width: 0; gap: 16px; }
.intervention-recipients > label { margin-top: 10px; }

nav a[hidden] { display: none; }
.device-allocation { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.device-allocation select { width: auto; max-width: 100%; }
.device-allocation .actions { margin: 0; }
.device-allocation .feedback { flex-basis: 100%; }
.device-allocation .feedback:empty { display: none; }

#end-participation {
  width: min(440px, calc(100% - 32px));
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
}
#end-participation::backdrop, #client-history::backdrop { background: #142c3c70; }
#end-participation button[type="submit"] { background: #942c42; }

#client-history {
  width: min(980px, calc(100% - 32px));
  max-height: 90vh;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
}
#client-history h2 { text-transform: capitalize; }
#client-history .history-results { margin: 12px 0; }

.intake-device-data pre { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 14rem; }

.client-metadata { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 20px; margin: 12px 0 0; }
.client-metadata dt { color: var(--muted); font-size: .875rem; }
.client-metadata dd { margin: 4px 0 0; font-weight: 600; }

.patient-view .sidebar nav, .patient-view #sidebar-clients { display: none; }

.schedule-periods { width: 100%; margin: 4px 0; }
.schedule-periods th, .schedule-periods td { padding: 5px 6px; white-space: normal; }
.schedule-periods td { vertical-align: bottom; }
.schedule-periods td > label { margin: 0; }
.schedule-periods td > select { min-width: 0; }
.schedule-periods .schedule-remind { text-align: center; vertical-align: middle; }
.schedule-remind input { width: auto; min-height: 0; margin: 0; }
.schedule-period-band {
  display: grid; place-items: center; min-height: 42px; padding: 5px 7px;
  border-radius: 6px; background: var(--band-color); color: var(--ink);
  font-size: .82rem; font-weight: 650; font-variant-numeric: tabular-nums; text-align: center;
}

.advanced-schedule-layout { grid-template-columns: minmax(0, 1fr); }
.advanced-schedule-layout > .manager-stack { grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); align-items: start; }
.advanced-editor h3 { margin: 22px 0 8px; }
.advanced-editor h4 { margin: 12px 0 4px; }
.advanced-editor fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.advanced-window + .advanced-window { margin-top: 10px; }
.advanced-editor button { margin: 4px 0; }
.advanced-item { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.advanced-item label { margin: 0; }
.advanced-time-point { display: flex; flex-wrap: wrap; gap: 6px; }
.advanced-block input { width: 7rem; }
.advanced-item .actions { margin: 0; }
.advanced-item [data-resume] { flex: 1 1 15rem; margin: 0; }
.advanced-calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.advanced-calendar strong { text-align: center; font-size: .8rem; }
.advanced-calendar > div { min-height: 48px; padding: 4px; border-radius: 5px; background: #f2f6f8; }
.advanced-calendar small { display: block; font-size: .75rem; overflow-wrap: anywhere; }
.advanced-calendar .dose { background: #d2eee7; color: #075c53; }
.advanced-calendar .rest { color: #435766; }
.advanced-calendar .paused { background: #eee6fa; color: #5b4788; }

.standard-extra-dose { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 8px; }
.standard-extra-dose label { flex: 1 1 10rem; margin: 0; }
.schedule-period-band { white-space: pre-line; }

.adherence-plot .opening-hint { pointer-events: none; }
.adherence-plot .opening-hint rect { fill: #173445; }
.adherence-plot .opening-hint text { fill: #fff; font-size: 12px; }
