:root {
    --navy: #02888f;
    --navy-2: #09305c;
    --navy-3: #03575c;
    --white: #ffffff;
    --bg: #f4f6fb;
    --line: #e3e8f2;
    --text: #1a2340;
    --muted: #6b7794;
    --ok: #137a4b;
    --warn: #b45309;
    --bad: #b42318;
    --radius: 16px;
    --shadow: 0 6px 24px rgba(11, 31, 75, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Buttons & fields ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--white); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
    transition: transform .08s, box-shadow .15s, background .15s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: var(--white); }
.btn.primary:hover { background: var(--navy-3); }
.btn.danger { color: var(--bad); border-color: #f1c4c0; }
.btn.block { width: 100%; padding: 13px; }
.push { margin-left: auto; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 16px; }
input, select, textarea {
    display: block; width: 100%; margin-top: 6px; padding: 11px 14px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--white);
    font: inherit; color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px rgba(29, 67, 144, .15);
}

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.alert.error { background: #fdecea; color: var(--bad); }
.alert.success { background: #e7f6ee; color: var(--ok); }

/* ---------- Login ---------- */
.login-body { background: var(--white); }
.login-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-hero {
    position: relative; overflow: hidden; color: var(--white); padding: 48px;
    background: linear-gradient(145deg, var(--navy) 0%, var(--navy-2) 60%, var(--navy-3) 100%);
    display: flex; flex-direction: column; justify-content: space-between;
}
.hero-brand { display: inline-flex; align-self: flex-start; background: var(--white); border-radius: 18px; padding: 14px 22px; position: relative; z-index: 1; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); }
.hero-brand img { display: block; height: 96px; width: auto; }
.hero-text { position: relative; z-index: 1; max-width: 460px; }
.hero-text h2 { font-size: 40px; line-height: 1.15; margin: 0 0 16px; letter-spacing: -.5px; }
.hero-text p { color: #c9d4ee; font-size: 16px; margin: 0; }
.hero-shapes i { position: absolute; border-radius: 20%; background: rgba(255, 255, 255, .06); }
.hero-shapes i:nth-child(1) { width: 420px; height: 420px; right: -120px; top: -100px; }
.hero-shapes i:nth-child(2) { width: 260px; height: 260px; right: 80px; bottom: -90px; background: rgba(255, 255, 255, .08); }
.hero-shapes i:nth-child(3) { width: 120px; height: 120px; left: 40%; top: 45%; background: rgba(255, 255, 255, .05); }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.3px; }
.login-card .muted { margin: 0 0 28px; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 11px; background: var(--white); color: var(--navy);
    font-weight: 800; font-size: 20px;
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--navy); color: #d6def2; padding: 20px 16px;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.menu-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
    font-weight: 500; color: #d6def2; transition: background .15s, color .15s;
}
.menu-item:hover { background: rgba(255, 255, 255, .08); color: var(--white); }
.menu-item.active { background: var(--white); color: var(--navy); font-weight: 700; }
.menu-item.logout { margin-top: auto; }

.main { min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 14px; padding: 10px 32px; min-height: 68px;
    background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 16px; border-left: 1px solid var(--line); }
.top-logo { display: block; flex: 0 0 auto; min-width: 0; }
.user { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar {
    display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
    border-radius: 50%; background: var(--navy); color: var(--white); font-weight: 700; font-size: 14px;
}
.avatar.lg { width: 52px; height: 52px; font-size: 20px; margin-bottom: 6px; }
.burger { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; background: none; border: 0; border-radius: 10px; cursor: pointer; color: var(--navy); flex: 0 0 auto; }
.burger:hover { background: #eef2fb; }
.side-backdrop { display: none; }
@media (min-width: 861px) {
    html.side-collapsed .app { grid-template-columns: 1fr; }
    html.side-collapsed .sidebar { display: none; }
}
.content { padding: 28px 32px 96px; }
.lead { color: var(--muted); margin: 0 0 22px; }
.section-title { font-size: 17px; margin: 34px 0 14px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card {
    display: flex; flex-direction: column; gap: 4px; padding: 20px; background: var(--white);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--navy-3); box-shadow: 0 12px 30px rgba(11, 31, 75, .14); }
.card strong { font-size: 16px; }
.card-icon {
    display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px;
    border-radius: 12px; background: #e8eefc; color: var(--navy); font-size: 24px; font-weight: 600; margin-bottom: 8px;
}
.card.add, .card.action { justify-content: center; }
.card.add { border-style: dashed; border-color: #b8c5e6; background: transparent; box-shadow: none; align-items: center; text-align: center; min-height: 170px; }
.card.stat { background: linear-gradient(150deg, var(--navy), var(--navy-3)); color: var(--white); border: 0; }
.card.stat .stat-label { color: #c9d4ee; font-size: 14px; }
.card.stat .stat-value { font-size: 40px; font-weight: 700; line-height: 1.1; margin: 6px 0 10px; }
.card.stat .card-link { font-size: 13px; color: #dfe7fb; font-weight: 600; }
.card.person { align-items: flex-start; }
.tag { display: inline-block; align-self: flex-start; margin-top: 8px; padding: 4px 10px; background: #eef2fb; color: var(--navy-2); border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.when { font-weight: 600; color: var(--navy-2); }
.status { align-self: flex-start; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.status.scheduled { background: #e8eefc; color: var(--navy-3); }
.status.completed { background: #e7f6ee; color: var(--ok); }
.status.cancelled { background: #fdecea; color: var(--bad); }

.toolbar { display: flex; gap: 10px; margin-bottom: 22px; max-width: 520px; }
.toolbar input { margin: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.chip { padding: 8px 16px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.chip.on { background: var(--navy); color: var(--white); border-color: var(--navy); }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; max-width: 640px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-hero { padding: 32px; min-height: 220px; }
    .hero-text h2 { font-size: 28px; }
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; z-index: 20; width: 260px; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; }
    .side-backdrop { position: fixed; inset: 0; background: rgba(11, 31, 75, .45); z-index: 15; }
    html.side-open .side-backdrop { display: block; }
    .top-logo img { height: 32px !important; }
    .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
    .topbar h1 { font-size: 16px; padding-left: 10px; }
    .topbar, .content { padding-left: 18px; padding-right: 18px; }
    .row { grid-template-columns: 1fr; }
}

/* ---------- Treatments ---------- */
.menu { overflow-y: auto; min-height: 0; }
.menu-group .group-head { padding: 0; justify-content: space-between; }
.menu-group .group-link { display: flex; align-items: center; gap: 12px; padding: 12px 0 12px 14px; flex: 1; color: inherit; }
.menu-group .group-toggle {
    background: none; border: 0; color: inherit; cursor: pointer; font-size: 16px;
    padding: 12px 14px; transition: transform .2s;
}
.menu-group.open .group-toggle { transform: rotate(180deg); }
.menu-group .submenu { display: none; flex-direction: column; gap: 2px; margin: 2px 0 6px 26px; padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, .18); }
.menu-group.open .submenu { display: flex; }
.sub-item { padding: 8px 12px; border-radius: 9px; font-size: 14px; color: #b9c6e6; }
.sub-item:hover { background: rgba(255, 255, 255, .08); color: var(--white); }
.sub-item.active { background: rgba(255, 255, 255, .16); color: var(--white); font-weight: 600; }

.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.crumbs a { color: var(--navy-3); font-weight: 600; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 22px; letter-spacing: -.2px; }

.card.part { min-height: 120px; }
.card.part .count { color: var(--muted); font-size: 13.5px; }

.cards.wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card.exercise { padding: 0; overflow: hidden; }
.card.exercise .thumb {
    overflow: hidden; aspect-ratio: 1 / 1; background: linear-gradient(145deg, var(--navy-2), var(--navy-3));
    display: grid; align-items: center; justify-content: center; color: rgba(255, 255, 255, .85); font-size: 20px;
}
.card.exercise .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.exercise .body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 4px; }
.card.exercise .body p { margin: 0; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.exercise-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.video-box { background: #0a1630; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 16 / 9; }
.video-box video, .video-box iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.video-box.empty { display: flex; align-items: center; justify-content: center; color: #8ea0cc; font-weight: 600; }
.exercise-info h2 { margin: 18px 0 8px; font-size: 24px; letter-spacing: -.3px; }
.how-to { white-space: pre-line; color: var(--text); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.how-to h3 { margin: 0 0 8px; font-size: 16px; }
.instruction-panel { max-width: none; position: sticky; top: 90px; }
.instruction-panel h3 { margin: 0 0 4px; font-size: 18px; }
.instruction-panel .muted { margin: 0 0 18px; }
.perform-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; margin-bottom: 16px; }
.perform-row span { padding-bottom: 12px; color: var(--muted); font-weight: 600; }
.perform-row label { margin-bottom: 0; }
.summary { background: #e8eefc; color: var(--navy-2); padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; font-weight: 600; }
.thumb-preview { max-width: 220px; border-radius: 12px; border: 1px solid var(--line); display: block; margin: 8px 0 10px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 14px; }
.check input { width: auto; margin: 0; }
.radios { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 14px; }
.radios label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; }
.radios input { width: auto; margin: 0; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }

@media (max-width: 960px) {
    .exercise-layout { grid-template-columns: 1fr; }
    .instruction-panel { position: static; }
}

/* ---------- Sent instructions ---------- */
.panel.share { max-width: 680px; }
.panel.share h3 { margin: 0 0 6px; font-size: 20px; }
.copy-row { display: flex; gap: 10px; }
.copy-row input { margin: 6px 0 0; font-size: 14px; }
.copy-row .btn { margin-top: 6px; }
.actions.wrap { flex-wrap: wrap; margin: 4px 0 16px; align-items: center; }
.btn.wa { background: #1a9f56; border-color: #1a9f56; color: var(--white); }
.btn.wa:hover { background: #158247; }
.notes { margin: 0 0 20px; padding-left: 20px; color: var(--muted); font-size: 14px; }
.notes li { margin-bottom: 4px; }
.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
.small-btn { padding: 6px 12px; font-size: 13px; }

/* ---------- Patient page (rx.php) ---------- */
.rx-body { background: var(--bg); }
.rx-top { background: var(--white); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; }
.rx-site { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; color: var(--navy); font-weight: 600; font-size: 14px; text-decoration: none; text-align: right; line-height: 1.25; }
.rx-site:hover { background: #eef2fb; }
@media (max-width: 520px) { .rx-top { padding: 8px 12px; } .rx-site { font-size: 12.5px; padding: 7px 11px; } }
.rx-notice { display: flex; align-items: flex-start; gap: 12px; background: #fff7e6; border: 1px solid #f5d79a; color: #7a4b06; border-radius: 12px; padding: 12px 14px; margin: 0 0 16px; font-weight: 600; }
.rx-notice span { flex: 1; }
.rx-notice button { background: none; border: 0; padding: 0 2px; font-size: 22px; line-height: 1; cursor: pointer; color: inherit; }
.rx-top img { display: block; height: 64px; width: auto; }
.rx-wrap { max-width: 760px; margin: 0 auto; padding: 22px 16px 48px; }
.rx-hello { font-size: 17px; font-weight: 600; color: var(--navy-2); margin: 0 0 14px; }
.rx-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-top: 18px; }
.rx-card.center { text-align: center; margin-top: 80px; }
.rx-card h1 { margin: 10px 0 18px; font-size: 24px; letter-spacing: -.3px; }
.rx-card h2 { margin: 22px 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.rx-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rx-grid div { background: var(--navy); color: var(--white); border-radius: 14px; padding: 14px 8px; text-align: center; }
.rx-grid strong { display: block; font-size: 24px; line-height: 1.1; }
.rx-grid span { font-size: 12px; color: #c9d4ee; }
.how-to.plain { border: 0; box-shadow: none; padding: 0; background: none; }
.rx-foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 22px; }
@media (max-width: 520px) { .rx-grid { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Filters ---------- */
.treat-layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 24px; align-items: start; }
.filter-toggle { display: none; }
.filter-pane {
    position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow-y: auto;
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 14px 12px;
}
.pane-search { display: flex; gap: 6px; margin-bottom: 6px; }
.pane-search input[type=search] { margin: 0; flex: 1; min-width: 0; padding: 8px 10px; font-size: 14px; }
.pane-group { border-top: 1px solid var(--line); padding: 8px 0; }
.pane-group:first-of-type { margin-top: 8px; }
.pane-group summary {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; list-style: none;
    font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--navy-2); padding: 4px 0;
}
.pane-group summary::-webkit-details-marker { display: none; }
.pane-group summary::after { content: '▾'; color: var(--muted); font-size: 12px; margin-left: auto; }
.pane-group:not([open]) summary::after { content: '▸'; }
.pane-group summary em { font-style: normal; font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--navy-3); background: #eef2fb; border-radius: 999px; padding: 1px 8px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips.compact { gap: 5px; margin: 8px 0 4px; }
.filter-pane .chip { padding: 4px 10px; font-size: 12.5px; }
.pane-foot { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
/* 4 columns x 4 rows per page on wide screens (see $perPage in treatments.php) */
.treat-results .cards.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.treat-results .card.exercise .body { padding: 12px 14px 14px; }
.treat-results .card.exercise .body strong { font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 1240px) and (min-width: 861px) { .treat-results .cards.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) { .treat-results .cards.wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .treat-results .cards.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (max-width: 360px) { .treat-results .cards.wide { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
    .treat-layout { grid-template-columns: 1fr; gap: 14px; }
    .filter-toggle { display: inline-flex; }
    .filter-pane { display: none; position: static; max-height: none; }
    .filter-pane.open { display: block; }
}
.result-count { color: var(--muted); font-weight: 600; margin: 0 0 14px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tags .tag { margin-top: 0; }
a.tag:hover { background: #dbe5fb; }
.stack { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.filter-panel { max-width: none; scroll-margin-top: 90px; }
.filter-panel h3 { margin: 0 0 4px; font-size: 18px; }
.opt-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; }
.opt-row input[type=text] { margin: 0; flex: 1; }
.opt-row .count { min-width: 84px; text-align: right; }
.opt-row.add-row { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.field-group { margin-bottom: 18px; }
@media (max-width: 700px) {
    .opt-row { flex-wrap: wrap; }
    .opt-row .count { text-align: left; min-width: 0; flex-basis: 100%; order: 3; }
}

@media (max-width: 520px) { .user-name { display: none; } }

/* ---------- Send by email (instruction_sent.php) ---------- */
.email-box { margin: 0 0 16px; }
.email-box code { background: #eef2fb; padding: 1px 6px; border-radius: 5px; }
.btn[disabled] { opacity: .6; cursor: wait; }

/* ---------- Treatments: header buttons and pagination ---------- */
.head-actions { display: flex; gap: 10px; align-items: center; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 26px 0 4px; }
.pager .pg {
    min-width: 38px; padding: 8px 12px; text-align: center; border-radius: 10px; font-weight: 600; font-size: 14px;
    background: var(--white); border: 1px solid var(--line); color: var(--navy-2);
}
.pager a.pg:hover { border-color: var(--navy-3); box-shadow: var(--shadow); }
.pager .pg.on { background: var(--navy); border-color: var(--navy); color: var(--white); }
.pager .pg.off, .pager .pg.gap { color: var(--muted); background: transparent; border-color: transparent; }
.pager .pg.off { opacity: .55; }

/* ---------- Exercise page carousel ---------- */
.carousel { outline: none; }
.carousel:focus-visible .car-stage { box-shadow: 0 0 0 3px #b8c5e6; }
.car-stage { position: relative; background: #0a1630; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 16 / 9; }
.car-slide { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; }
.car-slide.active { display: flex; }
.car-slide img, .car-slide video, .car-slide iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.car-slide img { object-fit: contain; background: #0a1630; }
.car-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 40px; height: 40px; border-radius: 50%;
    border: 0; background: rgba(11, 31, 75, .68); color: var(--white); font-size: 28px; line-height: 1; padding: 0 0 4px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s;
}
.car-nav:hover { background: rgba(11, 31, 75, .92); }
.car-nav.prev { left: 10px; }
.car-nav.next { right: 10px; }
.car-count {
    position: absolute; top: 10px; right: 10px; z-index: 2; background: rgba(11, 31, 75, .68); color: var(--white);
    font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; pointer-events: none;
}
.car-thumbs { display: flex; gap: 10px; overflow-x: auto; padding: 12px 2px 6px; position: relative; scroll-behavior: smooth; }
.car-thumb {
    flex: 0 0 auto; width: 76px; height: 76px; padding: 0; overflow: hidden; border-radius: 10px; cursor: pointer;
    border: 2px solid transparent; background: #0a1630; color: var(--white); opacity: .7;
    display: flex; align-items: center; justify-content: center; transition: opacity .15s, border-color .15s;
}
.car-thumb:hover { opacity: 1; }
.car-thumb.active { border-color: var(--navy); opacity: 1; box-shadow: 0 0 0 2px #dbe5fb; }
.car-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.car-thumb .vid { font-size: 22px; }
@media (max-width: 520px) { .car-thumb { width: 62px; height: 62px; } }

/* ---------- Add / edit exercise: pictures and videos ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; margin: 10px 0 16px; }
.media-grid:empty { display: none; }
.media-tile { border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--white); display: flex; flex-direction: column; gap: 6px; }
.media-tile.is-cover { border-color: var(--navy-3); box-shadow: 0 0 0 2px #dbe5fb; }
.media-tile.is-removed { opacity: .45; }
.media-tile .mt-thumb {
    aspect-ratio: 1 / 1; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, var(--navy-2), var(--navy-3)); color: rgba(255, 255, 255, .9); font-size: 28px;
}
.media-tile .mt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 500; cursor: pointer; }
.media-tile label.rm { color: var(--bad); }
.media-tile input[type=radio], .media-tile input[type=checkbox] { width: auto; margin: 0; }
.file-list { list-style: none; margin: 8px 0 16px; padding: 0; font-size: 14px; }
.file-list:empty { display: none; }
.file-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; background: #eef2fb; border-radius: 8px; margin-bottom: 6px; }
.file-x { background: none; border: 0; color: var(--bad); cursor: pointer; font-size: 15px; padding: 2px 6px; }

/* ---------- Prescription: fields shared by the exercise page, the modal and the prescription page ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rx-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.rx-fields > label { margin-bottom: 14px; }
.rx-fields .perform-row { grid-column: 1 / -1; }
.rx-fields .hint { font-size: 12px; }

/* menu badge + the bar that follows you while you add exercises */
.menu-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: #1a9f56; color: var(--white); font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.menu-badge[hidden] { display: none; }
.rx-bar {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 16px;
    background: var(--navy); color: var(--white); padding: 8px 8px 8px 22px; border-radius: 999px; box-shadow: 0 12px 34px rgba(11, 31, 75, .35);
    max-width: calc(100% - 24px); white-space: nowrap;
}
.rx-bar[hidden] { display: none; }
.rx-bar .btn.primary { background: var(--white); color: var(--navy); border-color: var(--white); padding: 9px 18px; }
.rx-bar .btn.primary:hover { background: #e8eefc; }
.rx-bar-msg { overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.rx-bar-last { color: #b9c6e6; }
.rx-bar.pulse { animation: rxpulse .5s ease; }
@keyframes rxpulse { 0% { transform: translateX(-50%) scale(.96); } 60% { transform: translateX(-50%) scale(1.03); } 100% { transform: translateX(-50%) scale(1); } }
@media (max-width: 520px) { .rx-bar { gap: 10px; padding-left: 16px; font-size: 14px; } .rx-bar .btn.primary { padding: 8px 12px; } .rx-bar-last { display: none; } }

/* Treatments: hover button on each exercise */
.thumb-wrap { position: relative; }
.card.exercise .thumb { display: grid; }
.card.exercise a.body { color: inherit; }
.add-rx {
    position: absolute; left: 10px; right: 10px; bottom: 10px; padding: 9px 10px; border: 0; border-radius: 10px; cursor: pointer;
    background: var(--navy); color: var(--white); font: inherit; font-weight: 700; font-size: 13px; white-space: nowrap; box-shadow: 0 6px 18px rgba(11, 31, 75, .35);
    opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .15s, transform .15s, background .15s;
}
.card.exercise:hover .add-rx, .card.exercise:focus-within .add-rx { opacity: 1; transform: none; pointer-events: auto; }
.add-rx:hover { background: var(--navy-3); }
.add-rx .when-in { display: none; }
.card.in-rx .add-rx { background: #137a4b; }
.card.in-rx .add-rx .when-new { display: none; }
.card.in-rx .add-rx .when-in { display: inline; }
.in-rx-badge { display: none; position: absolute; top: 10px; left: 10px; background: #137a4b; color: var(--white); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.card.in-rx .in-rx-badge { display: inline-block; }
@media (hover: none) { .add-rx { opacity: 1; transform: none; pointer-events: auto; padding: 7px 8px; font-size: 12.5px; } }

/* modal */
dialog.rx-modal { border: 0; border-radius: var(--radius); padding: 0; width: calc(100% - 32px); max-width: 460px; box-shadow: 0 24px 70px rgba(11, 31, 75, .35); color: var(--text); }
dialog.rx-modal::backdrop { background: rgba(11, 31, 75, .5); }
dialog.rx-modal form { padding: 24px; margin: 0; }
dialog.rx-modal h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.2px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* the prescription page */
.rx-build { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.patient-panel { max-width: none; position: sticky; top: 90px; }
.patient-panel h3 { margin: 0 0 4px; font-size: 18px; }
.patient-panel > .muted { margin: 0 0 18px; }
.rx-item { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px 6px; margin-bottom: 14px; }
.rx-item-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.rx-num { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; }
.rx-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; flex: 0 0 auto; background: linear-gradient(145deg, var(--navy-2), var(--navy-3)); color: rgba(255, 255, 255, .85); display: flex; align-items: center; justify-content: center; }
.rx-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rx-item-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rx-item-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-item .rx-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rx-item .rx-fields .perform-row { grid-column: 1 / -1; max-width: 460px; }
@media (max-width: 960px) { .rx-build { grid-template-columns: 1fr; } .patient-panel { position: static; } }
@media (max-width: 520px) { .rx-item .rx-fields { grid-template-columns: 1fr 1fr; } }
.rx-list { margin: 0 0 18px; padding-left: 22px; }
.rx-list li { margin-bottom: 8px; }
.rx-list li .small { display: block; }

/* patient page: one exercise per accordion panel */
.rx-intro { color: var(--muted); margin: -6px 0 14px; }
.rx-acc { display: flex; flex-direction: column; gap: 12px; }
.rx-ex { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; scroll-margin-top: 12px; }
.rx-ex[open] { border-color: var(--navy-3); }
.rx-ex summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.rx-ex summary::-webkit-details-marker { display: none; }
.rx-ex summary:focus-visible { outline: 3px solid #b8c5e6; outline-offset: -3px; }
.rx-ex-num { width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: var(--white); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.rx-ex[open] .rx-ex-num { background: var(--navy-3); }
.rx-ex-head { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rx-ex-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.rx-ex-sum { color: var(--muted); font-size: 13px; }
.rx-ex-chev { width: 10px; height: 10px; flex: 0 0 auto; margin: 0 4px 3px 0; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s; }
.rx-ex[open] .rx-ex-chev { transform: rotate(-135deg); margin-bottom: -3px; }
.rx-ex-body { padding: 0 16px 20px; }
.rx-ex-body .carousel { margin-bottom: 14px; }
.rx-ex-body .tag { margin: 0 0 2px; }
.rx-ex-body h2 { margin: 20px 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }


/* active dates on the sent-instruction page */
.dates-box { margin: 0 0 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #f8faff; }
.dates-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.dates-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.dates-row input { margin: 0; }
.dates-box p { margin: 10px 0 0; }

/* editing a sent prescription */
.move-btns { display: inline-flex; gap: 4px; }
.add-filter { margin: 6px 0 8px; }
#add-ex { width: 100%; margin-bottom: 14px; }
.edit-panel-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* staff registration */
.login-alt { text-align: center; margin: 18px 0 0; color: var(--muted); font-size: 14px; }
.login-alt a { color: var(--navy); font-weight: 600; text-decoration: underline; }
.login-card.wide { max-width: 420px; }
.login-card .hint-line { margin: -6px 0 14px; font-size: 12.5px; color: var(--muted); }
.otp-input { text-align: center; font-size: 26px; letter-spacing: 8px; font-weight: 700; }
.reg-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; }
.reg-links form { margin: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--navy); font-weight: 600; font-size: 14px; text-decoration: underline; cursor: pointer; font-family: inherit; }

/* templates */
.tpl-picker { max-height: calc(100vh - 120px); overflow-y: auto; }
.tpl-sub { display: block; margin: 4px 0 8px; }
.tpl-search { display: flex; gap: 8px; align-items: center; }
.tpl-search input { flex: 1; margin: 0; min-width: 0; }
.tpl-results { max-height: 260px; overflow-y: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; }
.tpl-opt { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.tpl-opt:last-child { border-bottom: 0; }
