:root {
  --bg: #f8f8fb;
  --surface: #ffffff;
  --surface-soft: #f5f3fb;
  --ink: #23233b;
  --muted: #727287;
  --muted-2: #9b9bab;
  --primary: #755eb8;
  --primary-strong: #654ca8;
  --primary-soft: #efecfb;
  --border: #e8e7ef;
  --success: #32825a;
  --success-bg: #eaf7f0;
  --warning: #a86620;
  --warning-bg: #fff5e8;
  --danger: #b84d54;
  --danger-bg: #fcebed;
  --shadow-sm: 0 1px 2px rgba(31, 29, 54, .03), 0 3px 12px rgba(31, 29, 54, .035);
  --shadow-lg: 0 22px 60px rgba(31, 29, 54, .18);
  --radius: 12px;
  --sidebar: 224px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "DM Sans", system-ui, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(117,94,184,.25); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 20px; height: 20px; display: inline-block; flex: 0 0 auto; vertical-align: middle; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; fill: none; pointer-events: none; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--sidebar); display: flex; flex-direction: column; background: #fbfaff; border-right: 1px solid var(--border); }
.brand { height: 92px; padding: 0 23px; display: flex; align-items: center; gap: 13px; background: #272440; color: #fff; text-decoration: none; font-size: 13px; line-height: 1.35; }
.brand strong { display: block; font-size: 14px; }
.brand-icon { display: grid; place-items: center; width: 40px; height: 40px; }
.brand-icon .icon { width: 39px; height: 39px; stroke-width: 1.55; }
.main-nav { padding: 13px 10px 8px; overflow-y: auto; scrollbar-width: thin; }
.nav-item { width: 100%; min-height: 44px; padding: 0 13px; border: 0; border-radius: 8px; display: flex; align-items: center; gap: 12px; background: transparent; color: #49475f; text-align: left; font-size: 12.5px; transition: background .16s, color .16s, transform .16s; }
.nav-item .icon { width: 18px; height: 18px; color: #6f6990; }
.nav-item:hover { color: var(--primary-strong); background: #f3f0fc; }
.nav-item:active { transform: scale(.985); }
.nav-item.active { color: var(--primary-strong); background: #ece8fa; font-weight: 600; }
.nav-item.active .icon { color: var(--primary); stroke-width: 2.1; }
.sidebar-footer { margin-top: auto; padding: 10px; border-top: 1px solid rgba(232,231,239,.75); }
.profile-wrap, .notification-wrap { position: relative; }
.profile-button { width: 100%; padding: 10px; border: 0; border-radius: 9px; display: flex; align-items: center; gap: 10px; background: #f0eef8; color: var(--ink); text-align: left; }
.profile-button:hover { background: #e9e5f7; }
.avatar { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.avatar-user { color: #fff; background: linear-gradient(145deg, #a47c6c, #d2a58f); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
.profile-copy { min-width: 0; flex: 1; }
.profile-copy strong, .profile-copy small { display: block; }
.profile-copy strong { font-size: 12.5px; }
.profile-copy small { margin-top: 3px; color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.profile-button > .icon { width: 16px; height: 16px; color: var(--muted); }
.settings-item { margin-top: 4px; }

.main { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; padding: 0 32px; display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.search { width: min(500px, 55vw); height: 42px; padding: 0 11px; display: flex; align-items: center; gap: 8px; color: var(--muted-2); background: var(--surface); border: 1px solid #dedde7; border-radius: 9px; transition: border .18s, box-shadow .18s; }
.search:focus-within { border-color: #a796d5; box-shadow: 0 0 0 3px rgba(117,94,184,.1); }
.search .icon { width: 18px; height: 18px; }
.search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12.5px; }
.search input::placeholder { color: #9695a6; }
.search button { flex: 0 0 38px; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 7px; color: var(--primary); background: transparent; }
.search button:hover, .search button:focus-visible { background: var(--primary-soft); }
.search kbd { padding: 3px 6px; border: 1px solid #dedde7; border-bottom-width: 2px; border-radius: 5px; color: #767587; background: #fafafd; font-family: inherit; font-size: 10px; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; }
.icon-button { position: relative; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 8px; display: grid; place-items: center; color: #5e5d70; background: transparent; transition: background .16s, color .16s, transform .16s; }
.icon-button:hover { color: var(--primary); background: var(--primary-soft); }
.icon-button:active { transform: scale(.94); }
.notification-dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: #e34b59; }
.menu-button { display: none; }

.page-content { max-width: 1480px; margin: 0 auto; padding: 25px 32px 34px; }
.page-heading { margin-bottom: 18px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.eyebrow { display: none; }
.page-heading h1 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -.35px; }
.page-heading h1 span { font-size: 20px; }
.page-heading p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.mobile-new-case { display: none; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 348px; gap: 22px; align-items: start; }
.dashboard-main { min-width: 0; }
.stats-grid { margin-bottom: 16px; display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 9px; }
.stat-card { min-height: 142px; padding: 19px 17px 16px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s, border-color .18s; }
.stat-card:hover { transform: translateY(-2px); border-color: #dcd7ed; box-shadow: 0 8px 24px rgba(31,29,54,.07); }
.stat-top { display: flex; align-items: flex-start; gap: 12px; }
.stat-icon { flex: 0 0 auto; width: 39px; height: 39px; border-radius: 10px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.stat-icon .icon { width: 22px; height: 22px; }
.stat-value { display: block; font-size: 22px; line-height: 1; font-weight: 700; letter-spacing: -.4px; }
.stat-label { display: block; margin-top: 5px; color: var(--muted); font-size: 10.5px; line-height: 1.25; }
.stat-footer { margin-top: auto; padding-top: 14px; display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10.5px; }
.stat-footer.positive { color: var(--success); }
.stat-footer .icon { width: 13px; height: 13px; }
.progress { height: 4px; margin-top: 12px; overflow: hidden; background: #e7e3f1; border-radius: 99px; }
.progress span { display: block; width: 86%; height: 100%; background: linear-gradient(90deg, var(--primary), #947fd0); border-radius: inherit; }

.card { margin-bottom: 16px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { min-height: 66px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid #eeedf3; }
.card-header h2 { margin: 0; font-size: 15px; letter-spacing: -.1px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 10.5px; }
.card-header.compact { padding: 17px 18px 13px; border-bottom: 0; }
.button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; font-weight: 600; transition: transform .16s, background .16s, box-shadow .16s; }
.button:active { transform: scale(.97); }
.button .icon { width: 16px; height: 16px; }
.button-primary { color: #fff; background: var(--primary); box-shadow: 0 4px 12px rgba(117,94,184,.22); }
.button-primary:hover { background: var(--primary-strong); box-shadow: 0 6px 16px rgba(117,94,184,.28); }
.button-soft { color: var(--primary-strong); background: var(--primary-soft); }
.button-soft:hover { background: #e5dff7; }
.button-secondary { color: #5f5d70; background: #fff; border: 1px solid var(--border); }
.button-secondary:hover { background: #f7f6fa; }
.table-tools { min-height: 45px; padding: 7px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10.5px; border-bottom: 1px solid #f1f0f5; }
.segmented { padding: 3px; display: flex; gap: 2px; background: #f4f3f8; border-radius: 7px; }
.segmented button { padding: 5px 9px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 10px; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { color: var(--primary-strong); background: #fff; box-shadow: 0 1px 4px rgba(31,29,54,.1); font-weight: 600; }
.table-wrap { position: relative; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 9px 14px; color: var(--muted-2); background: #fcfcfd; text-align: left; font-size: 9px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td { padding: 9px 14px; border-top: 1px solid #f0eff4; color: #555469; font-size: 10.5px; white-space: nowrap; }
tbody tr { transition: background .14s; }
tbody tr:hover { background: #faf9fd; }
.patient { display: flex; align-items: center; gap: 10px; }
.pet-avatar { position: relative; width: 36px; height: 36px; display: grid; place-items: center; color: #615982; background: linear-gradient(145deg, #eee9df, #d8cfc3); font-size: 11px; }
.pet-avatar .icon { width: 18px; height: 18px; }
.patient strong, .patient small { display: block; }
.patient strong { color: var(--ink); font-size: 11.5px; }
.patient small { margin-top: 3px; color: var(--muted); font-size: 9.5px; }
.species { display: inline-flex; align-items: center; gap: 6px; }
.species .icon { width: 14px; height: 14px; color: #9a7948; }
.status { padding: 5px 9px; display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; font-size: 9.5px; font-weight: 600; }
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status.ongoing { color: var(--warning); background: var(--warning-bg); }
.status.done { color: var(--success); background: var(--success-bg); }
.row-menu { width: 30px; height: 30px; border: 0; border-radius: 6px; display: grid; place-items: center; color: var(--muted); background: transparent; }
.row-menu:hover { color: var(--primary); background: var(--primary-soft); }
.row-menu .icon { width: 17px; height: 17px; }
.empty-state { padding: 42px 20px; display: flex; flex-direction: column; align-items: center; color: var(--muted); text-align: center; }
.empty-state > .icon { width: 30px; height: 30px; margin-bottom: 10px; color: #a9a3bb; }
.empty-state strong { color: var(--ink); }
.empty-state p { margin: 5px 0 0; font-size: 11px; }
.card-link { min-height: 45px; margin: 0 auto; padding: 0 15px; border: 0; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--primary); background: transparent; font-size: 10.5px; font-weight: 500; }
.card-link:hover { color: var(--primary-strong); }
.card-link .icon { width: 14px; height: 14px; transition: transform .16s; }
.card-link:hover .icon { transform: translateX(3px); }

.quick-grid { padding: 12px; display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 9px; }
.quick-action { min-height: 112px; padding: 12px 8px; border: 1px solid var(--border); border-radius: 9px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--ink); background: #fff; text-align: center; font-size: 10.5px; line-height: 1.3; transition: transform .18s, border-color .18s, background .18s, box-shadow .18s; }
.quick-action:hover { transform: translateY(-2px); border-color: #d7d0eb; background: #fbfaff; box-shadow: 0 7px 18px rgba(31,29,54,.06); }
.quick-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.quick-icon .icon { width: 23px; height: 23px; }
.quick-action:nth-child(3n+2) .quick-icon { color: #a56b2f; background: #fff4e7; }
.quick-action:nth-child(3n) .quick-icon { color: #356f78; background: #e8f4f5; }
.quote-card { min-height: 46px; margin: 0; padding: 9px 20px; display: flex; align-items: center; gap: 12px; color: #74649f; background: linear-gradient(90deg, #f5f2ff, #f0edfc); border-radius: 9px; font-size: 10.5px; }
.quote-card p { margin: 0; flex: 1; }
.quote-card > .icon { width: 18px; height: 18px; }
.quote-mark { font-family: Georgia, serif; font-size: 28px; line-height: 1; }

.dashboard-side { min-width: 0; }
.side-card { margin-bottom: 14px; }
.subtle { width: 30px; height: 30px; color: var(--primary); background: var(--primary-soft); }
.reminder-item { min-height: 55px; padding: 8px 18px; display: flex; align-items: flex-start; gap: 10px; }
.check { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 1px; padding: 0; border: 1.5px solid #a9a6b4; border-radius: 4px; display: grid; place-items: center; color: #fff; background: #fff; appearance: none; cursor: pointer; }
.check.checked { border-color: var(--primary); background: var(--primary); }
.check.checked::after { content: ""; width: 7px; height: 4px; margin-top: -2px; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.reminder-copy { flex: 1; min-width: 0; }
.reminder-copy strong, .reminder-copy small { display: block; }
.reminder-copy strong { font-size: 10.5px; font-weight: 500; }
.reminder-copy small { margin-top: 4px; color: var(--muted); font-size: 9.5px; }
.reminder-item.completed .reminder-copy strong { color: var(--muted-2); text-decoration: line-through; }
.review-item { min-height: 58px; padding: 8px 18px; display: flex; align-items: center; gap: 10px; }
.review-icon { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.review-icon .icon { width: 16px; height: 16px; }
.review-copy { flex: 1; min-width: 0; }
.review-copy strong, .review-copy small { display: block; }
.review-copy strong { overflow: hidden; color: #4d4b5d; font-size: 10px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.review-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.review-tag { padding: 5px 8px; border: 0; border-radius: 99px; color: var(--danger); background: var(--danger-bg); font-size: 9px; white-space: nowrap; }
.review-tag:hover { color: #fff; background: var(--danger); }
.activity-list { padding: 4px 18px 5px; }
.activity-item { position: relative; min-height: 48px; padding: 6px 0 6px 24px; color: #5d5b6f; font-size: 10px; }
.activity-item::before { content: ""; position: absolute; top: 10px; left: 3px; width: 7px; height: 7px; border: 2px solid #8772bb; border-radius: 50%; background: #fff; }
.activity-item::after { content: ""; position: absolute; top: 22px; bottom: -4px; left: 7px; width: 1px; background: #ddd8eb; }
.activity-item:last-child::after { display: none; }
.activity-item small { display: block; margin-top: 4px; color: var(--muted-2); font-size: 9px; }

.popover { position: absolute; z-index: 60; padding: 7px; background: #fff; border: 1px solid var(--border); border-radius: 11px; box-shadow: 0 12px 36px rgba(31,29,54,.14); animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-5px) scale(.98); } }
.profile-popover { bottom: 58px; left: 0; width: 204px; }
.profile-popover a, .profile-popover button { width: 100%; min-height: 36px; padding: 0 9px; border: 0; border-radius: 6px; display: flex; align-items: center; gap: 9px; color: #504e62; background: transparent; text-align: left; text-decoration: none; font-size: 11px; }
.profile-popover a:hover, .profile-popover button:hover { background: var(--surface-soft); }
.profile-popover form { margin: 0; }
.profile-popover .icon { width: 15px; height: 15px; }
.notification-popover { top: 46px; right: 0; width: 330px; padding: 0; overflow: hidden; }
.popover-head { min-height: 49px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.popover-head strong { font-size: 12px; }
.popover-head button { border: 0; color: var(--primary); background: transparent; font-size: 9.5px; }
.notification-item { padding: 12px 14px; display: flex; gap: 10px; border-bottom: 1px solid #f0eff4; }
.notification-item:last-child { border: 0; }
.notification-icon { flex: 0 0 auto; width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.notification-icon.success { color: var(--success); background: var(--success-bg); }
.notification-icon .icon { width: 16px; height: 16px; }
.notification-item strong, .notification-item small { display: block; }
.notification-item strong { font-size: 10.5px; }
.notification-item small { margin-top: 4px; color: var(--muted); font-size: 9.5px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; padding: 20px; display: grid; place-items: center; background: rgba(28,26,49,.52); backdrop-filter: blur(4px); animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(480px, 100%); overflow: hidden; background: #fff; border: 1px solid rgba(255,255,255,.5); border-radius: 14px; box-shadow: var(--shadow-lg); animation: modal-in .2s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-header { padding: 20px; display: flex; align-items: flex-start; gap: 12px; border-bottom: 1px solid var(--border); }
.modal-header > div:nth-child(2) { flex: 1; }
.modal-header h2 { margin: 1px 0 0; font-size: 16px; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 10.5px; }
.modal-title-icon { flex: 0 0 auto; width: 39px; height: 39px; border-radius: 10px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.modal-title-icon .icon { width: 20px; height: 20px; }
.modal form { padding: 18px 20px 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: block; }
.field-full { grid-column: 1 / -1; }
.field > span, .field > label { display: block; margin-bottom: 6px; color: #4e4c5f; font-size: 10.5px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #dedde7; border-radius: 8px; color: var(--ink); background: #fff; font-size: 12px; transition: border .16s, box-shadow .16s; }
.field input, .field select { height: 40px; padding: 0 11px; }
.field textarea { padding: 10px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #a796d5; outline: 0; box-shadow: 0 0 0 3px rgba(117,94,184,.1); }
.field-error { display: none; margin-top: 5px; color: var(--danger); font-size: 9px; }
.field.invalid .field-error { display: block; }
.field.invalid input, .field.invalid textarea { border-color: #d98186; }
.field ul { margin: 5px 0 0; padding: 0; color: var(--danger); font-size: 9px; list-style: none; }
.database-empty, .side-empty { padding: 24px 18px !important; color: var(--muted) !important; text-align: center !important; font-size: 10.5px !important; }
.reminder-item { border: 0; width: 100%; background: transparent; text-align: left; }
.review-item { border: 0; width: 100%; background: transparent; text-align: left; }
.modal-actions { margin-top: 20px; display: flex; justify-content: flex-end; gap: 9px; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 200; pointer-events: none; }
.toast { min-width: 260px; padding: 12px 15px; display: flex; align-items: center; gap: 10px; color: #fff; background: #292641; border: 1px solid rgba(255,255,255,.1); border-radius: 10px; box-shadow: 0 12px 32px rgba(31,29,54,.22); opacity: 0; transform: translateY(20px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon { color: #9ae1bc; }
.toast-icon .icon { width: 18px; height: 18px; }
#toastMessage { font-size: 11px; }
.auth-page { min-height: 100vh; padding: 36px 20px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(circle at 15% 15%, #f0ecff 0, transparent 32%), radial-gradient(circle at 85% 85%, #f6eee8 0, transparent 30%), var(--bg); }
.auth-brand { margin-bottom: 22px; display: flex; align-items: center; gap: 11px; color: #2d294b; text-decoration: none; font-size: 12px; line-height: 1.25; }
.auth-brand strong { display: block; font-size: 14px; }
.auth-brand-icon { width: 42px; height: 42px; display: grid; place-items: center; color: #fff; background: #292641; border-radius: 12px; box-shadow: 0 8px 22px rgba(41,38,65,.18); }
.auth-brand-icon .icon { width: 27px; height: 27px; }
.auth-card { width: min(480px, 100%); padding: 30px; background: rgba(255,255,255,.96); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 22px 60px rgba(31,29,54,.12); }
.auth-heading { margin-bottom: 24px; text-align: center; }
.auth-kicker { color: var(--primary); font-size: 10px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.auth-heading h1 { margin: 7px 0 8px; font-size: 23px; letter-spacing: -.4px; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.auth-form { display: grid; gap: 15px; }
.auth-form .field, .settings-form .field { margin: 0; }
.auth-form .field input, .auth-form .field select, .settings-form .field input, .settings-form .field select { height: 44px; }
.auth-form-meta { margin-top: -4px; display: flex; justify-content: flex-end; }
.auth-form a, .auth-switch a { color: var(--primary-strong); font-weight: 600; text-decoration: none; }
.auth-form a:hover, .auth-switch a:hover { text-decoration: underline; }
.auth-submit { width: 100%; min-height: 44px; }
.auth-switch { margin: 22px 0 0; color: var(--muted); text-align: center; font-size: 11.5px; }
.auth-foot { margin: 18px 0 0; color: var(--muted-2); font-size: 10px; text-align: center; }
.alert { margin-bottom: 17px; padding: 11px 13px; border-radius: 8px; font-size: 11px; line-height: 1.45; }
.alert-success { color: var(--success); background: var(--success-bg); border: 1px solid #ccebd9; }
.alert-danger { color: var(--danger); background: var(--danger-bg); border: 1px solid #f2cdd0; }
.password-group { display: grid; gap: 13px; }
.password-group > div { display: grid; gap: 6px; }
.password-group label { color: #4e4c5f; font-size: 10.5px; font-weight: 600; }
.password-group input { width: 100%; height: 44px; padding: 0 11px; border: 1px solid #dedde7; border-radius: 8px; }
.password-group ul, .auth-form ul, .settings-form ul { margin: 5px 0 0; padding: 0; color: var(--danger); font-size: 9.5px; list-style: none; }
.password-hint { margin: -5px 0 0; color: var(--muted); font-size: 9.5px; line-height: 1.45; }
.settings-page { max-width: 1120px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.settings-card { overflow: visible; }
.settings-form { padding: 20px; display: grid; gap: 15px; }
.settings-form .button { justify-self: start; }
.error-page { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: var(--bg); }
.error-card { width: min(440px, 100%); padding: 42px 32px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.error-code { color: var(--primary); font-size: 52px; font-weight: 700; letter-spacing: -2px; }
.error-card h1 { margin: 8px 0; font-size: 21px; }
.error-card p { margin: 0 auto 24px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.sidebar-scrim { display: none; }

@media (max-width: 1240px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-side { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
  .side-card { margin: 0; }
  .stats-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 1024px) {
  :root { --sidebar: 214px; }
  .sidebar { transform: translateX(-100%); transition: transform .24s ease; box-shadow: 8px 0 30px rgba(31,29,54,.16); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(28,26,49,.38); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
  .sidebar-scrim.show { opacity: 1; visibility: visible; }
  .main { margin-left: 0; }
  .menu-button { display: grid; }
  .dashboard-side { grid-template-columns: 1fr 1fr; }
  .activity-card { grid-column: 1 / -1; }
  .quick-grid { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 640px) {
  .topbar { height: 64px; padding: 0 14px; gap: 8px; }
  .search { width: auto; flex: 1; }
  .search kbd, #calendarButton { display: none; }
  .page-content { padding: 20px 14px 28px; }
  .page-heading { align-items: center; }
  .page-heading h1 { font-size: 20px; }
  .eyebrow { display: block; margin: 0 0 4px !important; color: var(--primary) !important; font-size: 9px !important; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
  .mobile-new-case { display: inline-flex; width: 44px; min-width: 44px; flex: 0 0 44px; padding: 0; }
  .desktop-new-case { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 130px; padding: 15px; }
  .stat-card:last-child { grid-column: 1 / -1; }
  .dashboard-side { display: block; }
  .side-card { margin-bottom: 12px; }
  .quick-grid { grid-template-columns: repeat(2,1fr); }
  .table-tools { align-items: flex-start; flex-direction: column; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  table { min-width: 650px; }
  .quote-card { padding: 12px 15px; }
  .notification-popover { position: fixed; top: 60px; right: 10px; width: calc(100vw - 20px); }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .modal-header, .modal form { padding-left: 16px; padding-right: 16px; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; }
  .toast { min-width: 0; width: 100%; }
  .auth-page { padding: 22px 13px; justify-content: flex-start; }
  .auth-card { padding: 24px 18px; }
  .auth-heading h1 { font-size: 21px; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Agenda et notifications */
.agenda-page { max-width: 1500px; }
.agenda-card { overflow: hidden; }
.agenda-toolbar { min-height: 72px; padding: 14px 18px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); }
.agenda-toolbar h2 { margin: 0; font-size: 17px; text-align: center; }
.agenda-navigation { display: flex; align-items: center; gap: 7px; }
.agenda-toolbar .segmented { justify-self: end; }
.agenda-toolbar .segmented a { padding: 6px 11px; border-radius: 5px; color: var(--muted); font-size: 10px; text-decoration: none; }
.agenda-toolbar .segmented a.active { color: var(--primary-strong); background: #fff; box-shadow: 0 1px 4px rgba(31,29,54,.1); font-weight: 600; }
.month-weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.month-weekdays { border-bottom: 1px solid var(--border); background: #fcfcfd; }
.month-weekdays span { padding: 10px 12px; color: var(--muted); font-size: 10px; font-weight: 700; text-align: center; text-transform: uppercase; }
.month-day { position: relative; min-height: 128px; padding: 9px 7px 27px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #fff; }
.month-day:nth-child(7n) { border-right: 0; }
.month-day.outside { background: #fafafd; }
.month-day.outside .month-number { color: var(--muted-2); }
.month-number { width: 26px; height: 26px; margin: 0 0 5px auto; display: grid; place-items: center; border-radius: 50%; color: var(--ink); font-size: 11px; font-weight: 600; text-decoration: none; }
.month-day.today .month-number { color: #fff; background: var(--primary); }
.month-events { display: grid; gap: 4px; }
.calendar-event { min-width: 0; padding: 5px 6px; display: flex; align-items: center; gap: 5px; border-left: 3px solid var(--primary); border-radius: 5px; color: #4f456d; background: var(--primary-soft); font-size: 9px; text-decoration: none; }
.calendar-event time { flex: 0 0 auto; font-weight: 700; }
.calendar-event span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event.type-case_deadline, .agenda-event-detail.type-case_deadline { border-color: #c66b53; background: #fff0eb; }
.calendar-event.type-patient_follow_up, .agenda-event-detail.type-patient_follow_up { border-color: #32825a; background: #edf8f2; }
.calendar-event.type-study, .agenda-event-detail.type-study { border-color: #397b93; background: #edf7fa; }
.calendar-event.type-appointment, .agenda-event-detail.type-appointment { border-color: #755eb8; }
.day-add { position: absolute; right: 8px; bottom: 5px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--primary); text-decoration: none; opacity: 0; }
.month-day:hover .day-add, .day-add:focus-visible { opacity: 1; background: var(--primary-soft); }
.agenda-list { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); overflow-x: auto; }
.agenda-list.single-day { grid-template-columns: 1fr; }
.agenda-day { min-height: 420px; border-right: 1px solid var(--border); }
.agenda-day:last-child { border-right: 0; }
.agenda-day > header { min-height: 58px; padding: 10px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); }
.agenda-day > header span { color: var(--muted); font-size: 10px; }
.agenda-day > header strong { font-size: 12px; }
.agenda-day > header a { margin-left: auto; color: var(--primary); font-size: 18px; text-decoration: none; }
.agenda-day.today > header { background: var(--primary-soft); }
.agenda-day-events { padding: 9px; display: grid; gap: 8px; }
.agenda-event-detail { padding: 10px; border-left: 3px solid var(--primary); border-radius: 7px; background: var(--primary-soft); }
.agenda-event-detail h3 { margin: 4px 0; font-size: 11px; }
.agenda-event-detail h3 a { color: var(--ink); text-decoration: none; }
.agenda-event-detail p, .agenda-event-time { margin: 0; color: var(--muted); font-size: 9px; }
.agenda-event-detail form { margin-top: 9px; }
.agenda-event-detail .button { min-height: 29px; padding: 0 9px; font-size: 9px; }
.agenda-empty { margin: 18px 6px; color: var(--muted-2); font-size: 10px; text-align: center; }
.agenda-timezone { color: var(--muted); font-size: 10.5px; text-align: right; }
.agenda-timezone a { color: var(--primary); }
.agenda-form-page { max-width: 920px; }
.agenda-form-page .settings-card { overflow: hidden; }
.agenda-form { padding-bottom: 16px; }
.agenda-form-actions { display: flex; gap: 9px; }
.agenda-delete { padding: 0 20px 20px; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { background: #9f3f46; }
.checkbox-field > div { display: flex; align-items: center; gap: 9px; }
.checkbox-field input { width: 18px; height: 18px; accent-color: var(--primary); }
.notification-item { color: inherit; text-decoration: none; }
.notification-item.is-read { opacity: .62; }
.notification-empty { margin: 0; padding: 24px 14px; color: var(--muted); text-align: center; font-size: 10.5px; }
.notification-center { overflow: visible; }
.notification-row { padding: 16px 18px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; border-bottom: 1px solid var(--border); }
.notification-row:last-child { border-bottom: 0; }
.notification-row.is-read { opacity: .66; }
.notification-row.is-unread { box-shadow: inset 3px 0 var(--primary); }
.notification-row h2 { margin: 0; font-size: 13px; }
.notification-row h2 a { color: var(--ink); text-decoration: none; }
.notification-row p { margin: 5px 0 0; color: var(--muted); font-size: 10.5px; }

/* Cours, flashcards et quiz */
.quick-action { text-decoration: none; }
.learning-page { max-width: 1480px; }
.learning-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.learning-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.learning-sidebar { position: sticky; top: 90px; }
.subject-list { padding: 8px; display: grid; gap: 3px; }
.subject-link { min-height: 40px; padding: 7px 9px; display: flex; align-items: center; gap: 9px; border-radius: 7px; color: #535166; font-size: 11px; text-decoration: none; }
.subject-link:hover, .subject-link.active { color: var(--primary-strong); background: var(--primary-soft); }
.subject-link span:nth-child(2) { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-link small { color: var(--muted); }
.subject-dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; }
.subject-dot.all { background: linear-gradient(135deg, #755eb8 0 33%, #32825a 33% 66%, #397b93 66%); }
.subject-create { padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.subject-create summary { color: var(--primary); font-size: 11px; font-weight: 600; cursor: pointer; }
.subject-create form { padding-top: 12px; display: grid; gap: 10px; }
.attempt-row { padding: 10px 15px; display: flex; align-items: center; gap: 10px; border-top: 1px solid #f1f0f5; }
.attempt-row > span { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--subject-color); font-size: 10px; font-weight: 700; }
.attempt-row strong, .attempt-row small { display: block; }
.attempt-row strong { font-size: 10.5px; }
.attempt-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.learning-overview { margin-bottom: 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; }
.learning-stat { min-height: 76px; padding: 13px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.learning-stat > span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); }
.learning-stat > span .icon { width: 19px; }
.learning-stat strong, .learning-stat small { display: block; }
.learning-stat strong { font-size: 19px; }
.learning-stat small { color: var(--muted); font-size: 9.5px; }
.learning-overview > .button { align-self: stretch; }
.learning-section { overflow: visible; }
.note-grid { padding: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.note-card { min-height: 168px; padding: 15px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 9px; background: #fff; }
.note-card-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.note-card-meta span { width: 8px; height: 8px; border-radius: 50%; }
.note-card h3 { margin: 11px 0 7px; font-size: 13px; }
.note-card h3 a { color: var(--ink); text-decoration: none; }
.note-card p { margin: 0 0 10px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.note-card > small { margin-top: auto; color: var(--muted-2); font-size: 8.5px; }
.tag-list { margin-bottom: 9px; display: flex; flex-wrap: wrap; gap: 5px; }
.tag-list span { padding: 3px 6px; border-radius: 99px; color: #5d527f; background: var(--primary-soft); font-size: 8.5px; }
.flashcard-list { padding: 14px; display: grid; gap: 12px; }
.study-card { padding: 17px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.study-card.needs-review { border-left: 4px solid var(--danger); }
.study-card-head { display: flex; align-items: center; gap: 8px; }
.study-card-head > a { margin-left: auto; color: var(--primary); font-size: 9.5px; }
.subject-pill, .review-pill { padding: 5px 8px; border-radius: 99px; font-size: 9px; font-weight: 600; }
.subject-pill { color: var(--subject-color); background: color-mix(in srgb, var(--subject-color) 12%, white); }
.review-pill { color: var(--danger); background: var(--danger-bg); }
.study-card h3 { margin: 14px 0; font-size: 13px; line-height: 1.55; }
.study-card details { border-radius: 8px; background: #f8f7fb; }
.study-card summary { padding: 10px 12px; color: var(--primary); font-size: 10px; font-weight: 600; cursor: pointer; }
.study-answer { padding: 0 12px 12px; color: #4f4d61; font-size: 11px; line-height: 1.6; }
.study-card-foot { margin-top: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.study-card-foot > small { margin-left: auto; color: var(--muted); font-size: 9px; }
.review-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.review-buttons span { margin-right: 3px; color: var(--muted); font-size: 9px; }
.review-buttons button { padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; color: #5b596d; background: #fff; font-size: 8.5px; }
.review-buttons button:hover { color: #fff; border-color: var(--primary); background: var(--primary); }
.button-link { padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 9px; }
.subject-progress-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.progress-card { padding: 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.progress-card > div:first-child { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 7px; }
.progress-card > div:first-child span { grid-row: 1 / 3; width: 10px; height: 28px; border-radius: 99px; }
.progress-card strong, .progress-card small { display: block; }
.progress-card strong { font-size: 11px; }
.progress-card small { color: var(--muted); font-size: 9px; }
.progress-card .progress { grid-column: 1 / -1; margin: 0; }
.progress-card b { font-size: 12px; }
.learning-form-page { max-width: 900px; }
.learning-form-page .settings-card { overflow: hidden; }
.learning-form-actions { display: flex; gap: 9px; }
.learning-delete { padding: 0 20px 20px; }
.quiz-page { max-width: 900px; }
.quiz-subject-picker { padding: 15px 18px; }
.quiz-subject-picker form { display: flex; align-items: center; gap: 10px; }
.quiz-subject-picker label { font-weight: 600; }
.quiz-subject-picker select { height: 38px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; }
.quiz-question { padding: 20px; }
.quiz-question > span { color: var(--primary); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.quiz-question h2 { margin: 10px 0 16px; font-size: 15px; line-height: 1.55; }
.quiz-question label { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 600; }
.quiz-question textarea { width: 100%; padding: 11px; border: 1px solid #dedde7; border-radius: 8px; resize: vertical; }
.quiz-submit { display: flex; align-items: center; gap: 14px; }
.quiz-submit p { color: var(--muted); font-size: 9.5px; }

/* Bibliothèque */
.library-page { max-width: 1480px; }
.library-layout { display: grid; grid-template-columns: 235px minmax(0,1fr); gap: 18px; align-items: start; }
.library-layout > aside { position: sticky; top: 90px; }
.library-folders nav { padding: 8px; display: grid; gap: 3px; }
.library-folders nav a { min-height: 39px; padding: 8px 10px; display: flex; align-items: center; gap: 9px; border-radius: 7px; color: #535166; font-size: 10.5px; text-decoration: none; }
.library-folders nav a:hover, .library-folders nav a.active { color: var(--primary-strong); background: var(--primary-soft); }
.library-folders nav .icon { width: 16px; }
.folder-create { padding: 12px 15px 15px; border-top: 1px solid var(--border); }
.folder-create summary { color: var(--primary); font-size: 10.5px; font-weight: 600; cursor: pointer; }
.folder-create form { padding-top: 11px; display: grid; gap: 9px; }
.library-filters { padding: 14px; display: grid; grid-template-columns: minmax(180px,1fr) 180px auto auto; align-items: end; gap: 10px; overflow: visible; }
.filter-check { min-height: 40px; display: flex; align-items: center; gap: 7px; color: #555368; font-size: 10.5px; white-space: nowrap; }
.filter-check input { accent-color: var(--primary); }
.library-summary { margin: 5px 0 12px; color: var(--muted); font-size: 10.5px; }
.resource-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.resource-card { min-height: 255px; padding: 16px; display: flex; flex-direction: column; overflow: visible; }
.resource-head { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.resource-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: var(--primary-soft); }
.resource-icon .icon { width: 19px; }
.resource-head small { color: var(--muted); font-size: 8.5px; }
.resource-head h2 { margin: 3px 0 0; font-size: 12px; line-height: 1.25; }
.resource-head h2 a { color: var(--ink); text-decoration: none; }
.favorite-button { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 7px; color: #aaa7b5; background: transparent; font-size: 19px; }
.favorite-button.active, .favorite-button:hover { color: #d29531; background: #fff7e7; }
.resource-card > p { color: var(--muted); font-size: 10px; line-height: 1.5; }
.resource-card blockquote { margin: 4px 0 12px; padding: 8px 10px; border-left: 3px solid #d7d0e9; color: #666376; background: #faf9fd; font-size: 9px; line-height: 1.45; }
.resource-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.resource-actions .button { min-height: 32px; padding: 0 9px; font-size: 9px; }
.resource-empty { grid-column: 1 / -1; }
.library-form-page { max-width: 900px; }
.library-form-page .settings-card { overflow: hidden; }
.existing-file { padding: 0 20px; color: var(--muted); font-size: 10px; }
.resource-form-actions { display: flex; gap: 9px; }

/* Atlas anatomique */
.anatomy-page { max-width: 1480px; }
.anatomy-filters { padding: 14px; display: grid; grid-template-columns: minmax(180px,1fr) 150px 230px auto auto; gap: 10px; align-items: end; overflow: visible; }
.anatomy-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 13px; }
.anatomy-card { min-height: 300px; }
.anatomy-card-preview { height: 105px; padding: 16px; display: flex; align-items: center; justify-content: space-between; color: #6c5c99; background: radial-gradient(circle at 70% 30%, #fff 0, transparent 35%), linear-gradient(135deg,#eeeafa,#e8f3f4); }
.anatomy-card-preview > span { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid rgba(108,92,153,.18); border-radius: 50%; background: rgba(255,255,255,.65); }
.anatomy-card-preview .icon { width: 31px; height: 31px; }
.anatomy-card-preview small { font-size: 9px; }
.anatomy-card-body { padding: 16px; }
.anatomy-card-body .subject-pill { display: inline-block; margin-right: 4px; --subject-color: var(--primary); }
.anatomy-card-body h2 { margin: 12px 0 7px; font-size: 14px; }
.anatomy-card-body h2 a { color: var(--ink); text-decoration: none; }
.anatomy-card-body > p { min-height: 46px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.anatomy-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 9px; }
.anatomy-card-foot span { color: var(--warning); font-size: 9px; }
.anatomy-card-foot span.mastered { color: var(--success); }
.anatomy-card-foot a { display: flex; align-items: center; gap: 4px; color: var(--primary); font-size: 9.5px; text-decoration: none; }
.anatomy-card-foot .icon { width: 13px; }
.anatomy-empty { grid-column: 1 / -1; }
.anatomy-show-page { max-width: 1200px; }
.anatomy-actions { display: flex; gap: 8px; }
.anatomy-actions form { margin: 0; }
.anatomy-detail-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(310px,.65fr); gap: 16px; }
.anatomy-visual { padding: 18px; }
.anatomy-visual > p { margin: 9px 0 0; color: var(--muted); font-size: 9px; text-align: center; }
.anatomy-figure { position: relative; min-height: 420px; overflow: hidden; border-radius: 10px; background: linear-gradient(145deg,#fbfaff,#f0f5f7); }
.anatomy-figure svg { width: 100%; height: 420px; display: block; }
.anatomy-marker { position: absolute; width: 29px; height: 29px; display: grid; place-items: center; border: 3px solid #fff; border-radius: 50%; color: #fff; background: var(--primary); box-shadow: 0 4px 12px rgba(44,36,73,.25); font-size: 10px; font-weight: 700; text-decoration: none; transform: translate(-50%,-50%); }
.anatomy-marker:hover { transform: translate(-50%,-50%) scale(1.12); }
.anatomy-legend > div:last-child { padding: 8px 16px; }
.anatomy-legend article { padding: 12px 0; display: grid; grid-template-columns: auto 1fr; gap: 10px; border-bottom: 1px solid var(--border); scroll-margin-top: 95px; }
.anatomy-legend article:last-child { border: 0; }
.anatomy-legend article > span { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-size: 9px; font-weight: 700; }
.anatomy-legend h3 { margin: 2px 0 5px; font-size: 11px; }
.anatomy-legend p { margin: 0; color: var(--muted); font-size: 9.5px; line-height: 1.5; }
.anatomy-summary > div:last-child, .anatomy-sources { padding: 20px; color: #504e61; font-size: 11px; line-height: 1.7; }
.anatomy-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.anatomy-pathologies > a { padding: 13px 17px; display: grid; grid-template-columns: 1fr auto; gap: 3px 8px; color: var(--ink); border-top: 1px solid var(--border); text-decoration: none; }
.anatomy-pathologies > a small { color: var(--muted); font-size: 9px; }
.anatomy-pathologies > a .icon { grid-column: 2; grid-row: 1 / 3; align-self: center; width: 15px; color: var(--primary); }
.anatomy-progress-box { padding: 20px; }
.anatomy-progress-box h2, .anatomy-sources h2 { margin-top: 0; font-size: 14px; }
.anatomy-progress-box p, .anatomy-sources p { color: var(--muted); font-size: 10px; line-height: 1.6; }
.anatomy-form-page { max-width: 1000px; }
.anatomy-form-page .settings-card { overflow: visible; }
.anatomy-form-page .dynamic-collection { margin: 10px 0; padding: 15px; border: 1px solid var(--border); border-radius: 9px; }
.anatomy-form-page .collection-row > div { display: grid; grid-template-columns: 90px 1fr 2fr 150px 150px; gap: 8px; }
.anatomy-form-page .collection-row label { display: block; margin-bottom: 5px; font-size: 9px; font-weight: 600; }
.anatomy-form-page .collection-row input, .anatomy-form-page .collection-row textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; }

@media (max-width: 900px) {
  .agenda-toolbar { grid-template-columns: 1fr 1fr; }
  .agenda-toolbar h2 { grid-column: 1 / -1; grid-row: 1; }
  .agenda-navigation { grid-row: 2; }
  .agenda-toolbar .segmented { grid-row: 2; }
  .month-day { min-height: 105px; }
  .learning-layout { grid-template-columns: 1fr; }
  .learning-sidebar { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .learning-overview { grid-template-columns: repeat(3, 1fr); }
  .learning-overview > .button { grid-column: 1 / -1; }
  .library-layout { grid-template-columns: 1fr; }
  .library-layout > aside { position: static; }
  .resource-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .library-filters, .anatomy-filters { grid-template-columns: 1fr 1fr; }
  .anatomy-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .anatomy-detail-grid { grid-template-columns: 1fr; }
  .anatomy-form-page .collection-row > div { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .agenda-page .page-heading { align-items: flex-start; flex-direction: column; }
  .agenda-page .page-heading .button { width: 100%; }
  .agenda-toolbar { grid-template-columns: 1fr; }
  .agenda-toolbar h2, .agenda-navigation, .agenda-toolbar .segmented { grid-column: 1; grid-row: auto; justify-self: stretch; justify-content: center; }
  .agenda-toolbar .segmented a { flex: 1; text-align: center; }
  .month-grid, .month-weekdays { min-width: 720px; }
  .agenda-card { overflow-x: auto; }
  .month-day { min-height: 112px; }
  .day-add { opacity: 1; }
  .notification-row { grid-template-columns: auto 1fr; }
  .notification-row form { grid-column: 2; }
  .notification-page .page-heading { align-items: flex-start; flex-direction: column; }
  .learning-page .page-heading { align-items: flex-start; flex-direction: column; }
  .learning-heading-actions { width: 100%; }
  .learning-heading-actions .button { flex: 1; }
  .learning-sidebar { display: block; }
  .note-grid, .subject-progress-grid { grid-template-columns: 1fr; }
  .learning-overview { grid-template-columns: 1fr 1fr; }
  .learning-stat:nth-child(3) { grid-column: 1 / -1; }
  .study-card-foot, .quiz-submit { align-items: flex-start; flex-direction: column; }
  .study-card-foot > small { margin-left: 0; }
  .resource-grid, .anatomy-grid, .anatomy-bottom-grid { grid-template-columns: 1fr; }
  .library-filters, .anatomy-filters { grid-template-columns: 1fr; }
  .anatomy-show-page .page-heading { align-items: flex-start; flex-direction: column; }
  .anatomy-figure { min-height: 300px; }
  .anatomy-figure svg { height: 300px; }
  .anatomy-form-page .collection-row > div { grid-template-columns: 1fr; }
}
:root { --patient-border: #e7e5ef; }
.patient-page .patient-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.patient-filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.patient-filters .field { flex: 1 1 170px; }
.patient-table-scroll { overflow-x: auto; }
.patient-table { width: 100%; border-collapse: collapse; text-align: left; }
.patient-table th, .patient-table td { padding: 16px; border-bottom: 1px solid var(--patient-border); }
.patient-table a { font-weight: 700; color: #51438c; }
.patient-alert-label { display: block; color: #8c3f17; margin-top: 6px; }
.patient-pagination { display: flex; justify-content: center; gap: 20px; align-items: center; padding: 20px; }
.patient-details { padding: 24px; margin-bottom: 24px; overflow-wrap: anywhere; }
.patient-details dt { font-weight: 700; margin-top: 18px; }
.patient-details dd { margin: 6px 0; white-space: normal; }
.patient-alert { background: #fff3df; border: 1px solid #bd7427; border-left: 5px solid #bd7427; padding: 20px; border-radius: 12px; margin-bottom: 24px; overflow-wrap: anywhere; }
.patient-alert h3 { margin-top: 12px; }
.patient-consultation { border-top: 1px solid var(--patient-border); padding: 18px 0; }
.patient-consultation p { margin-top: 8px; }
.nav-item { text-decoration: none; }
@media (max-width: 700px) {
    .patient-page .page-heading { flex-direction: column; align-items: start; gap: 16px; }
    .patient-page .form-grid { grid-template-columns: 1fr; }
    .patient-page .settings-grid { grid-template-columns: 1fr; }
    .patient-table th, .patient-table td { padding: 12px; min-width: 130px; }
}

.case-badge { display: inline-block; padding: 5px 10px; border-radius: 20px; background: #eeebfa; color: #51438c; font-size: 12px; font-weight: 600; }
.case-sections { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 24px; }
.case-sections a, .case-details a { color: #51438c; }
.case-form h2 { margin-top: 16px; font-size: 18px; }
.case-form p, .patient-details p { line-height: 1.65; }
.case-form .field textarea { width: 100%; min-height: 90px; }
.case-details dl { display: grid; grid-template-columns: minmax(150px, 1fr) 3fr; column-gap: 24px; }
.case-details dt, .case-details dd { margin: 0; padding: 14px 0; border-bottom: 1px solid var(--patient-border); }
.patient-details summary { cursor: pointer; padding: 14px 0; color: #51438c; }
.patient-details .settings-form { padding: 20px 0 0; }
.patient-details input[type="file"] { max-width: 100%; height: auto; }
@media (max-width: 700px) { .case-details dl { display: block; } .case-details dt { border-bottom: 0; padding-bottom: 0; } }

.section-heading, .medical-entry-head, .exam-results-head, .prescription-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-heading { margin-bottom: 8px; }
.section-heading h2, .section-heading p, .medical-entry-head h3, .medical-entry-head p { margin-top: 0; }
.medical-entry-head > div, .prescription-row > div:first-child { min-width: 0; flex: 1; }
.medical-entry .patient-actions { margin-top: 16px; }
.medical-document { padding: 9px 12px; border-radius: 8px; background: var(--surface-soft); }
.medical-document a { color: var(--primary-strong); font-weight: 700; }
.inline-warning { margin: 12px 0; padding: 12px 14px; color: #784512; background: var(--warning-bg); border: 1px solid #e7bd87; border-radius: 9px; line-height: 1.6; }
.compact-table { margin: 14px 0; }
.compact-table th, .compact-table td { padding: 10px 12px; }
.prescription-details { display: grid; grid-template-columns: minmax(110px, .7fr) 3fr; gap: 0 18px; }
.prescription-details dt, .prescription-details dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--patient-border); }
.exam-results { margin: 20px 0; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.exam-results-head { align-items: center; margin-bottom: 14px; }
.exam-results-head h3 { margin: 0; }
.exam-result-row { margin-top: 12px; padding: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; background: #fff; border: 1px solid var(--border); border-radius: 9px; }
.exam-result-row > div { min-width: 0; }
.exam-result-row label { display: block; margin-bottom: 5px; font-size: 10px; font-weight: 600; }
.exam-result-row input { width: 100%; height: 40px; padding: 0 9px; border: 1px solid #dedde7; border-radius: 8px; }
.button-link { padding: 8px; border: 0; color: var(--primary); background: transparent; }
.button-link.danger { color: var(--danger); }
.medical-catalog h2, .prescription-row h2 { margin: 0; font-size: 16px; }
.medical-form input[type="checkbox"] { width: auto; height: auto; margin-right: 8px; }

@media (max-width: 760px) {
  .section-heading, .medical-entry-head, .prescription-row { flex-direction: column; }
  .exam-result-row { grid-template-columns: 1fr 1fr; }
  .exam-result-row .button-link { grid-column: 1 / -1; justify-self: start; }
  .prescription-details { display: block; }
  .prescription-details dt { border: 0; padding-bottom: 0; }
}

.reference-filters { padding: 0; }
.favorite-filter { min-height: 40px; display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.reference-card { padding: 22px; display: flex; flex-direction: column; align-items: flex-start; }
.reference-card h2 { margin: 16px 0 4px; font-size: 18px; }
.reference-card h2 a { color: var(--ink); text-decoration: none; }
.reference-card p { color: var(--muted); line-height: 1.6; }
.reference-card .button { margin-top: auto; }
.favorite-star { display: inline-flex; vertical-align: middle; margin-left: 8px; color: #bf7a14; }
.favorite-star .icon, .favorite-button .icon { width: 17px; height: 17px; }
.reference-detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 18px; align-items: start; }
.reference-detail-grid h2 { margin-top: 28px; }
.reference-detail-grid h2:first-child { margin-top: 0; }
.protocol-steps { padding-left: 28px; }
.protocol-steps li { padding: 4px 0 16px 8px; }
.protocol-steps h3 { margin-bottom: 6px; }
.dynamic-collection { margin: 14px 0 24px; }
.collection-row { margin-bottom: 12px; padding: 16px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 12px; align-items: end; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.collection-row > div { min-width: 0; }
.collection-row label { display: block; margin-bottom: 5px; font-size: 10px; font-weight: 600; }
.collection-row input, .collection-row textarea { width: 100%; min-height: 40px; padding: 9px; border: 1px solid #dedde7; border-radius: 8px; }
.reference-form select[multiple] { min-height: 130px; padding: 8px; }

@media (max-width: 1050px) { .reference-grid { grid-template-columns: 1fr 1fr; } .collection-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .reference-grid, .reference-detail-grid { grid-template-columns: 1fr; } .collection-row { grid-template-columns: 1fr; } }

/* Statistiques */
.statistics-page { max-width: 1480px; }
.statistics-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.statistics-filters { padding: 14px; display: grid; grid-template-columns: 210px 170px 170px auto 1fr; align-items: end; gap: 10px; overflow: visible; }
.statistics-filters > p { margin: 0; align-self: center; color: var(--muted); font-size: 10px; text-align: right; }
.statistics-summary { margin: 16px 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.statistic-kpi { padding: 17px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.statistic-kpi > span { width: 40px; height: 40px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 10px; }
.statistic-kpi > span .icon { width: 20px; height: 20px; }
.statistic-kpi strong, .statistic-kpi small { display: block; }
.statistic-kpi strong { font-size: 20px; letter-spacing: -.4px; }
.statistic-kpi small { color: var(--muted); font-size: 9.5px; }
.statistic-kpi p { grid-column: 1 / -1; margin: 2px 0 0; color: var(--muted); font-size: 9px; }
.statistics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.statistics-chart { min-height: 275px; }
.bar-chart { padding: 7px 17px 18px; display: grid; align-content: start; gap: 13px; }
.bar-row { display: grid; gap: 6px; }
.bar-copy { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 10px; }
.bar-copy span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-copy strong { color: var(--primary-strong); font-size: 10.5px; }
.bar-track { height: 9px; overflow: hidden; border-radius: 99px; background: #eeecf3; }
.bar-track span { min-width: 3px; height: 100%; display: block; border-radius: inherit; background: repeating-linear-gradient(135deg, var(--primary), var(--primary) 6px, #8b75c4 6px, #8b75c4 10px); }
.statistics-empty { padding: 34px 10px; color: var(--muted); font-size: 10px; text-align: center; }
.statistics-note { margin: 14px 0 0; color: var(--muted); font-size: 9.5px; }

@media (max-width: 1050px) {
  .statistics-filters { grid-template-columns: 1fr 1fr; }
  .statistics-filters > p { text-align: left; }
  .statistics-summary { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .statistics-page .page-heading { align-items: flex-start; flex-direction: column; }
  .statistics-actions, .statistics-actions .button { width: 100%; }
  .statistics-actions .button { justify-content: center; }
  .statistics-filters, .statistics-summary, .statistics-grid { grid-template-columns: 1fr; }
}

/* Consultation and reference enhancements */
a.stat-card { display: block; color: inherit; text-decoration: none; }
a.stat-card:hover, a.stat-card:focus-visible { border-color: var(--primary, #426b57); box-shadow: 0 4px 16px #16382818; }
.mastery-mastered { background: #edf8ef; border: 1px solid #82b68d; border-left: 5px solid #328247; }
.mastery-review { background: #fff5e5; border: 1px solid #d5ad6f; border-left: 5px solid #b16b0c; }
.mastery-unmastered { background: #fff0ef; border: 1px solid #dca09c; border-left: 5px solid #b63c35; }
.mastery-label { font-weight: 650; }
.source-list { padding-left: 1.2rem; overflow-wrap: anywhere; }
.source-list li { margin: .75rem 0; }

.stat-top { flex-wrap: wrap; }
.stat-top > div { min-width: 0; max-width: 100%; }

/* iPhone and other narrow touch screens */
@media (max-width: 1024px) {
  html { scroll-padding-top: calc(80px + env(safe-area-inset-top, 0px)); }
  .sidebar { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .main-nav { overscroll-behavior: contain; }
  .topbar { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .page-content { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }
  .auth-page, .error-page { padding-top: max(22px, env(safe-area-inset-top, 0px)); padding-right: max(13px, env(safe-area-inset-right, 0px)); padding-bottom: max(22px, env(safe-area-inset-bottom, 0px)); padding-left: max(13px, env(safe-area-inset-left, 0px)); }
  .toast-region { bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
  .sidebar-scrim { padding: 0; }
  .icon-button { width: 44px; height: 44px; flex: 0 0 44px; }
  .button, .nav-item, .segmented button, .row-menu, .button-link, .profile-popover a, .profile-popover button, .popover-head button { min-height: 44px; }
  .row-menu, .favorite-button { min-width: 44px; min-height: 44px; }
  .button { font-size: 14px; }
  .nav-item, .card-link { font-size: 14px; }
  .quick-action { font-size: 13px; }
  .segmented button { font-size: 13px; }
  .notification-item { min-height: 48px; }
  .notification-item strong { font-size: 13px; }
  .notification-item small { font-size: 12px; line-height: 1.4; }
  .profile-popover { bottom: 60px; }
}

@media (max-width: 1024px) and (pointer: coarse) {
  input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="range"]),
  select, textarea { font-size: 16px !important; }
  .modal-backdrop { top: var(--visual-top, 0px); bottom: auto; height: var(--visual-height, 100dvh); padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px)); display: block; overflow-y: auto; overscroll-behavior: contain; }
  .modal { max-height: none; margin: 0 auto; }
}

@media (max-width: 640px) {
  .app-shell, .main, .auth-page, .error-page { min-height: 100svh; }
  .topbar { height: calc(64px + env(safe-area-inset-top, 0px)); padding-top: env(safe-area-inset-top, 0px); }
  .search { min-width: 0; height: 44px; padding: 0 4px 0 11px; }
  .search input { font-size: 16px; }
  .search button { flex: 0 0 44px; width: 44px; height: 44px; }
  .search button:active { background: var(--primary-soft); }
  .notification-popover { top: calc(60px + env(safe-area-inset-top, 0px)); right: max(10px, env(safe-area-inset-right, 0px)); width: min(360px, calc(100vw - 20px)); max-height: min(70dvh, 560px); overflow-y: auto; }
  .page-heading { align-items: flex-start; flex-wrap: wrap; }
  .page-heading > div { min-width: 0; }
  .page-heading h1 { overflow-wrap: anywhere; }
  .page-heading p:not(.eyebrow) { font-size: 14px; line-height: 1.45; }
  .field > span, .field > label, .password-group label, .collection-row label, .exam-result-row label { font-size: 13px; line-height: 1.35; }
  .field input, .field select, .password-group input, .collection-row input, .exam-result-row input { min-height: 44px; }
  .field textarea, .collection-row textarea { line-height: 1.5; }
  .field ul, .password-group ul, .auth-form ul, .settings-form ul, .field-error { font-size: 12px; line-height: 1.4; }
  .auth-heading p, .auth-switch, .auth-foot { font-size: 13px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .button { flex: 1 1 130px; }
  .toast { font-size: 14px; }
  #toastMessage { font-size: 13px; }

  .mobile-card-scroll { overflow-x: visible; }
  .mobile-card-table { display: block; width: 100%; min-width: 0; border-collapse: separate; }
  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody { display: grid; gap: 10px; padding: 12px; }
  .mobile-card-table tr { display: block; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: var(--shadow-sm); }
  .mobile-card-table td { min-width: 0; width: 100%; padding: 5px 0; display: block; border: 0; color: var(--ink); font-size: 14px; line-height: 1.45; white-space: normal; overflow-wrap: anywhere; }
  .mobile-card-table td a { min-height: 44px; display: inline-flex; align-items: center; }
  .mobile-card-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-size: 12px; font-weight: 600; }
  .mobile-card-table td:first-child { padding-bottom: 9px; border-bottom: 1px solid var(--border); }
  .mobile-card-table td:first-child::before { display: none; }
  .mobile-card-table td:first-child a { font-size: 16px; }
  .mobile-card-table td[colspan] { padding: 12px 0; text-align: center; }
  .mobile-card-table td[colspan]::before { display: none; }
  .mobile-card-table .patient { min-height: 44px; }
  .mobile-card-table .row-menu { min-width: 44px; }
  .patient-pagination { flex-wrap: wrap; gap: 10px; font-size: 13px; }
  .patient-pagination .button { flex: 1 1 auto; }
  .table-tools { font-size: 13px; }
  .segmented { overflow-x: auto; }
}
