/* MedX v5 Admin: platform (MedX team) and clinic admin (owners).
   A fixed side menu puts every area one click away; inside an area: list → item (detail tabs) → wizard (create).
   The dark steel band says "you are in Admin" on every screen. */

body.admin { background: var(--c-bg); min-height: 100vh; }

.adminbar {
  position: sticky; top: 0; z-index: 30; height: 64px;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  background: var(--blue-800); color: #fff;
}
:root[data-theme="dark"] .adminbar { background: #0f2630; }
.adminbar a { color: #fff; }
.adminbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.adminbar__brand:hover { text-decoration: none; }
.adminbar__mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255, 255, 255, .14); }
.adminbar__mark svg { width: 22px; height: 22px; fill: #fff; stroke: none; }
.adminbar__ctx { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: var(--r-full); background: rgba(255, 255, 255, .12); font-size: 14px; font-weight: 650; white-space: nowrap; }
.adminbar__end { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.adminbar__link { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: var(--r-full); font-size: 14.5px; font-weight: 650; border: 1px solid rgba(255, 255, 255, .28); }
.adminbar__link:hover { background: rgba(255, 255, 255, .1); text-decoration: none; }
.adminbar .avatar { background: rgba(255, 255, 255, .16); color: #fff; }
.adminbar .person-chip:hover, .adminbar .menu[open] > .person-chip { background: rgba(255, 255, 255, .1); }
.adminbar .person-chip__text span { color: rgba(255, 255, 255, .8); }

/* ---------- Side menu: every admin area one click away (a row of chips on narrow screens) ---------- */
:root { --anav-w: 248px; }
.adminnav { position: fixed; z-index: 25; top: 64px; bottom: 0; left: 0; width: var(--anav-w); display: flex; flex-direction: column; gap: 2px; padding: 20px 12px; overflow-y: auto; background: var(--c-surface); border-right: 1px solid var(--c-border); }
.adminnav__head { padding: 0 12px 10px; font-size: 13px; font-weight: 700; color: var(--c-text-3); }
.adminnav__item { position: relative; flex: none; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 8px 12px; border-radius: 10px; color: var(--c-text-2); font-size: 15px; font-weight: 650; line-height: 1.3; }
.adminnav__item .icon { flex: none; box-sizing: content-box; width: 20px; height: 20px; padding: 7px; border-radius: 10px; background: var(--c-surface-3); color: var(--c-text-2); } /* same 34px squares as the workforce menu */
.adminnav__item:hover { background: var(--blue-50); color: var(--c-text); text-decoration: none; }
.adminnav__item:focus-visible { outline: 3px solid var(--c-primary); outline-offset: -3px; }
.adminnav__item[aria-current="page"] { background: var(--blue-100); color: var(--c-text); font-weight: 750; }
.adminnav__item[aria-current="page"] .icon { color: var(--c-primary); background: var(--c-surface); }
.adminnav__item[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c-primary); }
.app-wrap:has(> .adminnav) { padding-left: var(--anav-w); }
.app-wrap:has(> .adminnav) > .adminbar { margin-left: calc(-1 * var(--anav-w)); }
@media (max-width: 1000px) {
  .app-wrap:has(> .adminnav) { padding-left: 0; }
  .app-wrap:has(> .adminnav) > .adminbar { margin-left: 0; }
  .adminnav { position: sticky; z-index: 25; top: 64px; bottom: auto; width: auto; flex-direction: row; gap: 6px; padding: 8px 14px; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--c-border); scrollbar-width: none; }
  .adminnav__head { display: none; }
  .adminnav__item { min-height: 40px; padding: 6px 14px 6px 12px; gap: 8px; border: 1px solid var(--c-border); border-radius: var(--r-full); font-size: 14px; white-space: nowrap; }
  .adminnav__item .icon { width: 18px; height: 18px; }
  .adminnav__item[aria-current="page"] { border-color: var(--c-primary); }
  .adminnav__item[aria-current="page"]::before { display: none; }
}
@media print { .adminnav, .skip-link { display: none !important; } .app-wrap:has(> .adminnav) { padding-left: 0; } }

.admin-main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 26px 22px 80px; display: flex; flex-direction: column; gap: 22px; }
.admin-main--narrow { max-width: 1000px; }
.crumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; color: var(--c-text-3); }
.crumb a { color: var(--c-link); font-weight: 650; }
.crumb .icon { width: 14px; height: 14px; }

/* Admin home tiles reuse .tile from app.css; a compact variant */
.tiles--admin { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles--admin .tile { min-height: 150px; }
.tile__sub { font-size: 14px; font-weight: 500; color: var(--c-text-3); line-height: 1.4; margin-top: -8px; }

/* Setup checklist */
.checklist { display: flex; flex-direction: column; }
.check-item { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--c-border); }
.check-item:last-child { border-bottom: 0; }
.check-item__mark { width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--c-border-strong); font-weight: 700; color: var(--c-text-3); }
.check-item.is-done .check-item__mark { background: var(--st-ok); border-color: var(--st-ok); color: var(--c-surface); }
.check-item.is-next { background: var(--blue-50); box-shadow: inset 4px 0 0 var(--c-primary); }
.check-item.is-next .check-item__mark { border-color: var(--c-primary); color: var(--c-link); }
.check-item__body { flex: 1; min-width: 0; }
.check-item__body b { display: block; font-size: 16px; }
.check-item__body small { display: block; font-size: 14px; color: var(--c-text-3); }
.check-item.is-done .check-item__body b { color: var(--c-text-2); }
.progress-ring { --p: 40; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--c-primary) calc(var(--p) * 1%), var(--c-surface-3) 0); }
.progress-ring b { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--c-surface); font-size: 15px; }

/* Status pills for clinics and people */
.st { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 99px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st--live { background: var(--st-ok-bg); color: var(--st-ok); }
.st--trial { background: var(--st-info-bg); color: var(--st-info); }
.st--setup { background: var(--st-pending-bg); color: var(--st-pending); }
.st--warn { background: var(--st-warn-bg); color: var(--st-warn); }
.st--off { background: var(--c-surface-3); color: var(--c-text-3); }

/* Wizard */
.wizard { display: flex; flex-direction: column; gap: 20px; }
.wizard__nav { display: flex; gap: 8px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.wizard__nav li { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-full); background: var(--c-surface); border: 1px solid var(--c-border); font-size: 14px; font-weight: 650; color: var(--c-text-3); }
.wizard__nav li b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--c-surface-3); font-size: 13px; }
.wizard__nav li.is-done b { background: var(--st-ok); color: var(--c-surface); }
.wizard__nav li.is-on { border-color: var(--c-primary); color: var(--c-text); }
.wizard__nav li.is-on b { background: var(--c-primary); color: var(--c-on-primary); }
/* Finished steps are links: one tap back to any earlier step */
.wizard__nav li:has(> a) { padding: 0; }
.wizard__nav li > a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: inherit; color: var(--c-text-2); }
.wizard__nav li > a:hover { background: var(--blue-50); color: var(--c-text); text-decoration: none; }
.wizard__nav li.is-done:has(> a:hover) { border-color: var(--c-primary); }

/* Template / role cards */
.tpl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tpl-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--r-lg); background: var(--c-surface); border: 1px solid var(--c-border-strong); cursor: pointer; color: var(--c-text); }
.tpl-card:hover { border-color: var(--c-primary); text-decoration: none; }
.tpl-card input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-card:has(input:checked) { border-color: var(--c-primary); background: var(--blue-50); box-shadow: inset 0 0 0 1px var(--c-primary); }
.tpl-card:has(input:focus-visible) { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.tpl-card .tile__icon { width: 64px; height: 64px; }
.tpl-card .tile__icon svg { width: 44px; height: 44px; }
.tpl-card b { font-size: 17px; }
.tpl-card p { font-size: 14px; color: var(--c-text-3); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.mchip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-full); background: var(--c-surface-3); font-size: 13px; font-weight: 650; color: var(--c-text-2); }
.mchip svg { width: 18px; height: 18px; }

/* Access editor: tiles you switch on, and their home screen preview */
.access { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
.access__groups { display: flex; flex-direction: column; gap: 16px; }
.access__group { border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); padding: 0 8px 8px; margin: 0; min-width: 0; }
/* Floated legend = a header inside the card instead of a label cutting the border */
.access__group legend { float: left; width: 100%; padding: 14px 8px 6px; font-size: 14px; font-weight: 700; color: var(--c-text-2); }
.access__group legend + * { clear: both; }
.tab-panel .access { margin-top: 20px; }
.cap { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r-md); cursor: pointer; }
.cap:hover { background: var(--blue-50); }
.cap .tile__icon { width: 44px; height: 44px; border-radius: 12px; }
.cap .tile__icon svg { width: 30px; height: 30px; }
.cap__text { flex: 1; min-width: 0; }
.cap__text b { display: block; font-size: 15.5px; }
.cap__text small { display: block; font-size: 13.5px; color: var(--c-text-3); }
.cap__new { font-size: 12.5px; font-weight: 700; color: var(--st-pending); margin-left: 6px; }
.cap input[type="checkbox"] { appearance: none; position: relative; width: 46px; height: 28px; flex: none; border-radius: 99px; background: var(--c-border-strong); cursor: pointer; margin: 0; }
.cap input[type="checkbox"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform var(--t-med) var(--ease); }
.cap input[type="checkbox"]:checked { background: var(--c-primary); }
.cap input[type="checkbox"]:checked::after { transform: translateX(18px); }
.cap input[type="checkbox"]:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 12px; }

.access__preview { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.access__preview > p { font-size: 14px; color: var(--c-text-3); text-align: center; }
.phone { width: 320px; border-radius: 34px; padding: 12px; background: #14303b; box-shadow: var(--shadow-lg); }
.phone__screen { border-radius: 24px; overflow: hidden; background: var(--c-bg); min-height: 520px; }
.phone__bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--c-surface); border-bottom: 1px solid var(--c-border); font-size: 13px; font-weight: 700; }
.phone__bar .appbar__mark { width: 28px; height: 28px; border-radius: 8px; font-size: 11px; }
.phone__hello { padding: 14px 14px 6px; font-size: 18px; font-weight: 700; }
.phone__hello small { display: block; font-size: 12.5px; font-weight: 500; color: var(--c-text-3); }
.phone__search { margin: 6px 14px 10px; height: 34px; border-radius: 99px; background: var(--c-surface); border: 1px solid var(--c-border-strong); font-size: 12.5px; color: var(--c-text-3); display: flex; align-items: center; padding: 0 12px; }
.mini-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0 14px 16px; }
.mini-tile { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; background: var(--c-surface); border: 1px solid var(--c-border); font-size: 13px; font-weight: 700; line-height: 1.25; min-height: 86px; }
.mini-tile .tile__icon { width: 36px; height: 36px; border-radius: 10px; }
.mini-tile .tile__icon svg { width: 24px; height: 24px; }
.mini-tile--more { border-style: dashed; color: var(--c-text-3); }

/* Activity log written as sentences */
.log { display: flex; flex-direction: column; }
.log__item { display: flex; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--c-border); }
.log__item:last-child { border-bottom: 0; }
.log__time { width: 92px; flex: none; font-size: 14px; color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.log__text { flex: 1; font-size: 15px; color: var(--c-text); }
.log__text .muted { font-size: 14px; }
.log__item--flag { background: color-mix(in srgb, var(--st-warn-bg) 60%, transparent); box-shadow: inset 4px 0 0 var(--st-warn); }

/* Plans */
.plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.plan { display: flex; flex-direction: column; gap: 12px; padding: 22px; border-radius: var(--r-lg); background: var(--c-surface); border: 1px solid var(--c-border); }
.plan--pick { border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary); }
.plan__price { font-size: 30px; font-weight: 700; }
.plan__price small { font-size: 15px; font-weight: 500; color: var(--c-text-3); }
.plan ul { display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--c-text-2); }
.plan li { display: flex; gap: 8px; }
.plan li .icon { color: var(--st-ok); margin-top: 3px; }

/* Support banner (vendor view-as) */
.support-banner { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--r-md); background: var(--st-warn-bg); color: var(--c-text); border: 1px solid color-mix(in srgb, var(--st-warn) 35%, transparent); font-size: 15px; }

@media (max-width: 1100px) {
  .access { grid-template-columns: minmax(0, 1fr); }
  .access__preview { position: static; }
  .tiles--admin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .plans { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .adminbar { padding: 0 12px; gap: 8px; }
  .adminbar__ctx, .adminbar__link span, .adminbar .person-chip__text { display: none; }
  .admin-main { padding: 18px 14px 60px; }
  .tiles--admin { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .limits { grid-template-columns: minmax(0, 1fr); }
  .phone { width: 100%; max-width: 320px; }
}

/* Role list: each role opens to its access editor */
.role-list { display: flex; flex-direction: column; gap: 10px; }
.role-row { border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
.role-row > summary { display: flex; align-items: center; gap: 16px; padding: 16px 20px; cursor: pointer; list-style: none; }
.role-row > summary::-webkit-details-marker { display: none; }
.role-row[open] > summary { border-bottom: 1px solid var(--c-border); background: var(--blue-50); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.role-row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.role-row__main b { font-size: 16.5px; }
.role-row__main small { font-size: 14px; color: var(--c-text-3); }
.role-row__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; min-width: 150px; }
.role-row__body { padding: 20px; } /* carries id edit-<role>: a link to it opens the role */
.role-row { scroll-margin-top: 84px; } /* clears the sticky admin band */
.tpl-list { margin: 4px 0 0; padding-left: 18px; list-style: disc; color: var(--c-text-2); }
@media (max-width: 760px) { .role-row > summary { flex-wrap: wrap; } .role-row__meta { align-items: flex-start; text-align: left; } }
