/* Portal and admin shell (from the template): a dark brand-blue sidebar and top bar around the content area. */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--t) var(--ease); }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--nav-bg); color: var(--nav-ink); border-right: 1px solid var(--nav-line); z-index: 50; overflow: hidden; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; height: 58px; border-bottom: 1px solid var(--nav-line); color: var(--nav-ink); }
.side-brand:hover { text-decoration: none; color: var(--nav-ink); }
.side-brand img { width: 32px; height: 32px; flex: none; object-fit: contain; transition: transform .4s var(--ease-out); }
.side-brand:hover img { transform: rotate(-8deg) scale(1.06); }
.side-brand strong { display: block; font-size: 1rem; letter-spacing: .06em; color: #fff; white-space: nowrap; }
.side-brand span { display: block; font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--nav-ink-3); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.side-ws { margin: 10px 12px 4px; padding: 8px 10px; border-radius: 9px; background: var(--p); color: #fff; font-size: .7rem; display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.side-ws .icon { width: 16px; height: 16px; }
.side-ws b { display: block; font-size: .84rem; }
.side-ws span { opacity: .85; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; }
.side-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 2px 10px 14px; scrollbar-width: thin; scrollbar-color: var(--nav-line) transparent; }
.side-group { margin: 14px 8px 4px; font-size: .64rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--nav-ink-3); white-space: nowrap; }
.side-link { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--nav-ink-2); font-weight: 600; font-size: .86rem; white-space: nowrap; transition: background var(--t-fast), color var(--t-fast), transform var(--t) var(--ease-out); }
.side-link:hover { background: var(--nav-hover); color: #fff; text-decoration: none; transform: translateX(3px); }
.side-link .icon { color: var(--c); width: 17px; height: 17px; transition: transform .3s var(--ease-out); }
.side-link:hover .icon { transform: scale(1.12); }
.side-link.active { background: var(--nav-active); color: #fff; font-weight: 700; }
.side-link.active .icon { color: #fff; }
.side-link .count { margin-left: auto; font-size: .68rem; padding: 0 6px; border-radius: 4px; background: var(--c); color: #fff; font-weight: 700; }
.side-foot { padding: 8px 10px 12px; border-top: 1px solid var(--nav-line); display: flex; flex-direction: column; gap: 2px; }
.side-collapse { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; background: none; color: var(--nav-ink-3); font-weight: 600; font-size: .82rem; border-radius: 8px; white-space: nowrap; }
.side-collapse:hover { background: var(--nav-hover); color: #fff; }
.side-collapse .icon { transition: transform var(--t) var(--ease); }

/* Collapsed (desktop): icons only */
.shell.collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.shell.collapsed .side-brand { padding: 14px 17px; }
.shell.collapsed .side-brand div, .shell.collapsed .side-group, .shell.collapsed .side-link span, .shell.collapsed .side-ws div, .shell.collapsed .side-collapse span, .shell.collapsed .side-link .count { display: none; }
.shell.collapsed .side-ws { justify-content: center; padding: 8px 0; margin-inline: 12px; }
.shell.collapsed .side-link { justify-content: center; padding: 9px 0; }
.shell.collapsed .side-collapse { justify-content: center; }
.shell.collapsed .side-collapse .icon { transform: rotate(180deg); }
.shell.collapsed .side-nav { padding-top: 8px; }
.shell.collapsed .side-group + .side-link { margin-top: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 22px; background: var(--nav-bg-2); color: var(--nav-ink); border-bottom: 1px solid var(--nav-line); }
.top .crumb { font-weight: 700; color: #fff; font-size: .95rem; }
.top .crumb small { color: var(--nav-ink-3); font-weight: 600; margin-right: 6px; }
.top .clock { font-variant-numeric: tabular-nums; color: var(--nav-ink-2); font-weight: 600; font-size: .82rem; padding: 5px 10px; border-radius: 6px; background: var(--nav-hover); }
.top .icon-btn { color: var(--nav-ink-2); }
.top .icon-btn:hover { background: var(--nav-hover); color: #fff; }
.top .icon-btn[data-action="theme"] .icon { transition: transform .5s var(--ease-out); }
.top .icon-btn[data-action="theme"]:hover .icon { transform: rotate(40deg) scale(1.1); }
.top-user { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 8px; border: 1px solid transparent; background: none; position: relative; color: var(--nav-ink); }
.top-user:hover { background: var(--nav-hover); border-color: var(--nav-line); }
.top-user .avatar { background: var(--c); color: #fff; }
.top-user .who { text-align: left; line-height: 1.2; }
.top-user .who b { display: block; font-size: .84rem; } .top-user .who span { font-size: .7rem; color: var(--nav-ink-3); }
.top .menu { color: var(--ink); }
.dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: .62rem; font-weight: 700; display: grid; place-items: center; }
.duty { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 6px; font-size: .78rem; font-weight: 700; border: 1px solid var(--nav-line); background: transparent; color: var(--nav-ink-2); transition: all var(--t-fast); }
.duty:hover { text-decoration: none; border-color: var(--c); color: #fff; }
.duty.on { background: rgba(92, 214, 165, .16); border-color: rgba(92, 214, 165, .3); color: #8EE6C1; }
.content { padding: 22px; width: 100%; max-width: 1560px; margin: 0 auto; flex: 1; }
.menu-toggle { display: none; }
.pop { position: relative; }
.notif { display: block; padding: 9px 10px; border-radius: 6px; color: var(--ink); }
.notif:hover { background: var(--pale); text-decoration: none; color: var(--ink); }
.notif.unread { background: var(--ice); }
.notif b { display: block; font-size: .84rem; } .notif span { font-size: .76rem; color: var(--ink-3); }

@media (max-width: 980px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 272px; transform: translateX(-102%); transition: transform var(--t) var(--ease); box-shadow: var(--shadow-3); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(6, 10, 30, .5); z-index: 45; animation: fade .16s both; }
  .menu-toggle { display: inline-grid; }
  .side-collapse { display: none; }
  .top { padding: 0 12px; } .content { padding: 16px 14px 40px; }
  .top .clock, .top-user .who { display: none; }
}

/* Fusion Force additions */
.side-brand strong { letter-spacing: .02em; }
.side-link.ext .icon { color: var(--nav-ink-3); }
.top .site-back { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--nav-line); color: var(--nav-ink-2); font-size: .78rem; font-weight: 700; }
.top .site-back:hover { border-color: var(--c); color: #fff; text-decoration: none; }
.content .page-head h1 { font-size: 1.35rem; }
.page-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--p); color: #fff; }
.page-icon .icon { width: 18px; height: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.welcome { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 22px 24px; border-radius: 16px; background: var(--p); color: #fff; margin-bottom: 16px; }
.welcome::before { content: ''; position: absolute; right: -60px; top: -90px; width: 260px; height: 260px; border-radius: 50%; background: var(--c); opacity: .5; }
.welcome > * { position: relative; }
.welcome h2 { font-size: 1.35rem; color: #fff; }
.welcome p { color: var(--ice); margin-top: 4px; max-width: 60ch; }
.welcome .btn { background: #fff; border-color: #fff; color: var(--d); }
.appt { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.appt:last-child { border-bottom: 0; }
.appt-date { flex: none; display: grid; justify-items: center; width: 56px; padding: 6px 0; border-radius: 10px; background: var(--ice); color: var(--d); line-height: 1.1; }
.appt-date b { font-size: 1.3rem; color: var(--p); } .appt-date small { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.appt-main { flex: 1; min-width: 0; }
.appt-main b { display: block; } .appt-main span { color: var(--ink-3); font-size: .8rem; }
.appt-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 10px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart-bar { width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px; background: var(--p); min-height: 2px; transition: height .6s var(--ease-out); position: relative; }
.chart-bar.alt { background: var(--sky); }
.chart-bar:hover::after { content: attr(data-v); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); padding: 2px 6px; border-radius: 4px; background: var(--nav-bg); color: #fff; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.chart-col small { font-size: .62rem; color: var(--ink-3); font-weight: 700; white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: .74rem; color: var(--ink-3); font-weight: 700; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--p); margin-right: 5px; vertical-align: -1px; }
.legend i.alt { background: var(--sky); }
.day-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.media-item { border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.media-item .thumb { aspect-ratio: 4 / 3; background: var(--pale); display: grid; place-items: center; overflow: hidden; }
.media-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-item .meta { padding: 8px 10px; font-size: .74rem; display: grid; gap: 6px; }
.media-pick { cursor: pointer; transition: border-color .2s, box-shadow .2s; }
.media-pick:hover { border-color: var(--p); box-shadow: var(--ring); }
.img-field { display: flex; gap: 10px; align-items: center; }
.img-field .prev { width: 64px; height: 64px; border-radius: 10px; background: var(--pale); border: 1px solid var(--line-2); overflow: hidden; display: grid; place-items: center; flex: none; color: var(--ink-3); }
.img-field .prev img { width: 100%; height: 100%; object-fit: cover; }
.hours-grid { display: grid; gap: 8px; }
.hours-row { display: grid; grid-template-columns: 130px 90px 1fr 1fr; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 8px; background: var(--pale); border: 1px solid var(--line-2); }
.timeline-mini { display: grid; gap: 6px; font-size: .78rem; }
.timeline-mini div { display: flex; gap: 8px; color: var(--ink-2); }
.timeline-mini b { color: var(--ink); }
@media (max-width: 980px) {
  .hours-row { grid-template-columns: 1fr 1fr; }
  .top .site-back span { display: none; }
}

/* ══ Small screens: admin and portal ═══════════════════════════════════ */
@media (max-width: 760px) {
  .content .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .content .page-head h1 { font-size: 1.15rem; }
  .content .page-head .lede { font-size: .8rem; }
  .content .page-head > .row { width: 100%; }
  .content .page-head > .row > .btn { flex: 1 1 auto; }
  .toolbar { padding: 10px; gap: 8px; }
  .toolbar .search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .toolbar .select, .toolbar .input:not(.search .input) { flex: 1 1 140px; min-width: 0; width: auto; }
  .toolbar .grow { display: none; }
  .tabs { scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .card-head { flex-wrap: wrap; padding: 10px 12px; }
  .card-body { padding: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { min-height: 64px; padding: 10px 12px; }
  .stat-value { font-size: 1.2rem; }
  .welcome { padding: 18px; border-radius: 14px; }
  .welcome h2 { font-size: 1.15rem; }
  .appt { flex-wrap: wrap; padding: 12px; }
  .appt-actions { width: 100%; justify-content: flex-start; }
  .hours-row { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }

  /* Tables become stacked cards; each value is labelled with its column (data-label, set in main.js). */
  .table-wrap { overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody tr { padding: 10px 12px; border-bottom: 1px solid var(--line-2); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; font-size: .84rem; min-width: 0; }
  .table td::before { content: attr(data-label); flex: none; color: var(--ink-3); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; text-align: left; }
  .table td:not([data-label])::before, .table td[data-label=""]::before { display: none; }
  .table td:first-child { justify-content: flex-start; text-align: left; font-size: .9rem; padding-bottom: 6px; }
  .table td:first-child::before { display: none; }
  .table td.right, .table td:last-child:has(.btn) { justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; }
  .table td:last-child:has(.btn)::before { display: none; }
  .table td > * { min-width: 0; }
  .table-foot { flex-wrap: wrap; gap: 8px; }

  /* Modals become bottom sheets */
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal, .modal.sm, .modal.lg, .modal.xl { width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0; animation: sheetUp .3s var(--ease-out) both; }
  .modal-backdrop.closing .modal { animation: sheetUp .2s var(--ease) reverse both; }
  .modal-body { padding: 14px; }
  .modal-head { padding: 12px 14px; }
  .modal-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-radius: 0; }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .spacer { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}
@keyframes sheetUp { from { transform: translateY(100%); } }
@media (max-width: 420px) {
  .top { gap: 6px; }
  .top .crumb { font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .top .site-back { padding: 0 9px; }
  .stats { grid-template-columns: 1fr 1fr; }
}

/* ── Patient profile: photo header and share card ── */
.pf-hero { margin-bottom: 16px; padding: 20px; border-radius: 16px; background: var(--p); color: #fff; position: relative; overflow: hidden; }
.pf-hero::before { content: ''; position: absolute; right: -70px; top: -110px; width: 280px; height: 280px; border-radius: 50%; background: var(--c); opacity: .45; }
.pf-photo { position: relative; display: flex; align-items: center; gap: 18px; }
.pf-avatar { flex: none; display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%; background: #fff; color: var(--p); font-size: 1.8rem; font-weight: 700; overflow: hidden; box-shadow: 0 0 0 4px rgba(255, 255, 255, .35); }
.pf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pf-photo-copy b { display: block; font-size: 1.25rem; }
.pf-photo-copy > span { color: var(--ice); font-size: .82rem; font-weight: 600; }
.pf-hero .btn-primary { background: #fff; border-color: #fff; color: var(--d); }
.pf-hero .btn-ghost { color: #fff; }
.pf-hero .btn-ghost:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.share-link { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border-radius: 10px; background: var(--pale); border: 1px dashed var(--sky); }
.share-link span { color: var(--p); display: inline-flex; }
.share-link input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.share-link input:focus { outline: none; }
@media (max-width: 520px) {
  .pf-photo { flex-direction: column; text-align: center; }
  .pf-photo .row { justify-content: center; }
  .pf-avatar { width: 88px; height: 88px; }
}
