/* Study Consultants staff portal · v0.7
   One stylesheet for every screen. No inline styles are used anywhere, so the strict Content-Security-Policy holds. */
:root {
    --ink: #10283a; --muted: #4d616c; --nav: #0e2a3c; --nav-soft: #1f4d63; --accent: #0a6f6b; --accent-dark: #085955;
    --bg: #f2f5f7; --line: #dde6ea; --line-strong: #b9c9cf; --white: #fff; --soft: #ddf1ee;
    --good-bg: #dcf2e6; --good: #155840; --warn-bg: #fff0d2; --warn: #774b06; --bad-bg: #fbe5e5; --bad: #942a2a;
    --info-bg: #e2edfb; --info: #17497a; --violet-bg: #ece8fb; --violet: #49398d; --side: 256px; --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-width: thin; scrollbar-color: #b4c3ca transparent; scroll-padding-top: 80px; }
body { margin: 0; color: var(--ink); background: var(--bg); font: 14.5px/1.5 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', sans-serif; overflow-x: hidden; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #b4c3ca; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: clamp(22px, 2.2vw, 27px); }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button, summary, select, label[for] { cursor: pointer; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #2ba39b; outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--white); padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.skip:focus { left: 8px; }

/* ---------- Shell: the sidebar never scrolls with the page ---------- */
.side { position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--side); background: var(--nav); color: #dce8ee; padding: 18px 14px; display: flex; flex-direction: column; overflow-y: auto; scrollbar-width: none; }
.side::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 6px; font-size: 13.5px; font-weight: 800; letter-spacing: .01em; color: var(--white); }
.brand img { width: 40px; height: 40px; object-fit: contain; flex: none; }
.brand small { display: block; color: #a9c2ce; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.nav { margin-top: 10px; display: grid; gap: 3px; }
.nav-group { padding: 14px 12px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #9ab5c2; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; color: #c9dae2; font-weight: 500; }
.nav a:hover { background: #17394e; color: var(--white); }
.nav a.active { background: var(--nav-soft); color: var(--white); font-weight: 600; }
.nav svg { flex: none; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 20px; background: var(--warn-bg); color: var(--warn); font-size: 12px; font-weight: 700; text-align: center; }
.side .nav-close, .top .mobile-menu, .nav-backdrop, .bottom-bar { display: none; }
.main { margin-left: var(--side); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px clamp(14px, 2.6vw, 32px); background: var(--white); border-bottom: 1px solid var(--line); }
.top-search { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 440px; min-height: 44px; padding: 0 12px; border: 1px solid #d3dee2; border-radius: 10px; background: #f6f9fa; color: var(--muted); }
.top-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px #bfe6e0; }
.top-search input:not([type=checkbox]):not([type=radio]) { flex: 1; min-width: 0; min-height: 40px; border: 0; border-radius: 0; background: none; outline: 0; padding: 0; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; position: relative; }
.bell { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; color: var(--ink); }
.bell:hover, .account-button:hover { background: #eef4f5; }
.count { position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--bad); color: var(--white); font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--soft); color: #0a5b56; font-weight: 700; font-size: 13.5px; flex: none; }
.avatar.large { width: 52px; height: 52px; font-size: 17px; }
.account-button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 3px 8px; border: 0; background: none; border-radius: 10px; text-align: left; }
.account-name { display: grid; line-height: 1.25; max-width: 24vw; }
.account-name strong, .account-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-name small { color: var(--muted); font-size: 12.5px; }
.account-menu { position: absolute; right: 0; top: 52px; z-index: 50; min-width: 220px; display: grid; padding: 6px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 40, 58, .16); }
.account-menu a, .account-menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 12px; border: 0; border-radius: 8px; background: none; text-align: left; font-weight: 500; }
.account-menu a:hover, .account-menu button:hover { background: #eef4f5; }
.account-menu form { margin: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.account-menu .danger-text { color: var(--bad); }
.content { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: clamp(16px, 2.6vw, 32px); min-width: 0; }

/* ---------- Building blocks ---------- */
.heading, .card-head, .row, .actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.heading, .card-head, .between { justify-content: space-between; }
.heading { margin-bottom: 20px; }
.card-head { margin-bottom: 12px; }
.sub, .muted, .empty { color: var(--muted); }
.sub { margin-top: 3px; font-size: 13.5px; }
.small { font-size: 13px; }
.auth-link { color: var(--accent); font-weight: 600; }
.auth-link:hover { text-decoration: underline; }
.grid, .stack, .form-grid { display: grid; gap: 18px; align-content: start; }
.stack.tight { gap: 10px; }
.two, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid { gap: 14px; }
.top-align { align-items: start; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 1.8vw, 22px); min-width: 0; }
.card.flat { background: #f4f7f8; border-color: transparent; }
.card.notice { background: #fff6e3; border-color: #ebd49b; }
.narrow { max-width: 860px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--white); font-size: 14px; font-weight: 600; white-space: nowrap; transition: background .15s; }
.btn:hover { background: var(--accent-dark); }
.btn.secondary { background: var(--white); color: var(--ink); border-color: #c9d5da; }
.btn.secondary:hover { background: #eef4f5; }
.btn.danger { background: var(--white); color: #a12a2a; border-color: #e2b3b3; }
.btn.danger:hover { background: #fceeee; }
.btn.wa { background: #e6f5eb; color: #125c2d; border-color: #bce1c8; }
.btn.wa:hover { background: #d5eedd; }
.btn.big { min-height: 54px; padding: 0 28px; font-size: 16px; }
.btn.light { background: var(--white); color: var(--nav); border-color: var(--white); }
.btn.light:hover { background: #e6eef2; }
.btn svg { flex: none; }
.is-submitting { opacity: .75; pointer-events: none; }
.is-submitting::after { content: ''; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-action { width: 44px; height: 44px; display: inline-grid; place-items: center; padding: 0; flex: none; border: 1px solid #d3dee2; border-radius: 10px; background: var(--white); color: var(--ink); }
.icon-action:hover { background: #eef4f5; }
.icon-action.wa { background: #e6f5eb; border-color: #bce1c8; color: #125c2d; }
.icon-action.done { background: var(--soft); border-color: #b5ddd7; color: #0a5b56; }
.danger-action { color: #a12a2a; border-color: #e9c9c9; }
.danger-action:hover { background: #fceeee; }
.row-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-tools form { margin: 0; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; font-size: 13px; font-weight: 600; }
.field.full, .full { grid-column: 1 / -1; }
.field small, .hint { color: var(--muted); font-weight: 400; font-size: 12.5px; }
label { font-size: 13px; font-weight: 600; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--white); color: var(--ink); font-weight: 400; font-size: 14.5px; }
input[readonly] { background: #f4f7f8; color: var(--muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; }
textarea { min-height: 92px; resize: vertical; }
.phone-row { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 8px; }
.checkboxes { display: flex; gap: 8px 16px; flex-wrap: wrap; }
.checkboxes label { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-weight: 500; font-size: 14px; }
.badge { display: inline-block; white-space: nowrap; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #e8eef0; color: #42545d; }
.badge.good, .badge.leave-approved, [data-crm-status="Completed"] { background: var(--good-bg); color: var(--good); }
.badge.warn, .badge.leave-pending, [data-crm-status="In process"] { background: var(--warn-bg); color: var(--warn); }
.badge.bad, .badge.leave-rejected, [data-crm-status="Lost"] { background: var(--bad-bg); color: var(--bad); }
.badge.info, [data-crm-status="New"] { background: var(--info-bg); color: var(--info); }
.badge.teal { background: var(--soft); color: #0a5b56; }
[data-crm-status="Interested"] { background: var(--violet-bg); color: var(--violet); }
[data-crm-status="On hold"] { background: #e8eef0; color: #42545d; }
select[data-crm-status] { background: var(--white); color: var(--ink); }
.badge.large { padding: 6px 12px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 15px; border-radius: 999px; border: 1px solid #c9d5da; background: var(--white); font-weight: 600; font-size: 13px; white-space: nowrap; }
.chip:hover { background: #eef4f5; }
.chip[aria-current] { background: var(--nav); border-color: var(--nav); color: var(--white); }
.empty { padding: 22px 0 6px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 2px; }
.alert { margin: 0 0 16px; border-radius: 10px; background: var(--soft); color: #185849; padding: 12px 16px; }
.alert.error { background: #fff0ef; color: #8a2929; }
.alert ul { margin: 0; padding-left: 18px; }
#notification-alert:not(:empty) { padding: 10px 16px; margin-bottom: 12px; background: var(--info-bg); color: var(--info); border-radius: 10px; }
.toast-stack { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: min(560px, calc(100vw - 24px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; border-radius: 12px; background: var(--ink); color: var(--white); font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.toast.leaving { opacity: 0; transition: opacity .3s; }
.toast-close { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: #c9dae2; font-size: 20px; line-height: 1; flex: none; }
.toast-close:hover { background: #24465a; color: var(--white); }
details { border: 1px solid var(--line); padding: 14px; border-radius: 10px; background: var(--white); }
summary { font-weight: 600; }
details[open] > summary { margin-bottom: 14px; }
.spacer { height: 14px; }
.page-nav { padding-top: 14px; }
.pagination { margin-top: 14px; }
.section-tabs, .tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid #d3dee2; scrollbar-width: none; }
.section-tabs::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.section-tabs a, .tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; white-space: nowrap; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.section-tabs a[aria-current], .tabs a[aria-current] { border-color: var(--accent); color: var(--accent); }
.filters, .crm-filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.filters .field, .crm-filters .field { flex: 1 1 150px; max-width: 240px; }
.crm-filters .crm-search { flex: 2 1 240px; max-width: none; }

/* ---------- Tables: real tables on desktop, stacked cards on phones ---------- */
.table-wrap { overflow-x: auto; scrollbar-width: thin; }
table { border-collapse: collapse; text-align: left; width: 100%; }
th, td { padding: 12px 10px; border-top: 1px solid #e6edf0; vertical-align: middle; }
th { color: var(--muted); font-size: 12.5px; font-weight: 600; border-top: 0; padding-top: 4px; white-space: nowrap; }
td { font-size: 14px; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
.cell-sub { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.nowrap { white-space: nowrap; }
.item { padding: 14px 0; border-top: 1px solid #e6edf0; overflow-wrap: anywhere; }
.item:first-of-type { border-top: 0; }
.list-row { display: grid; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid #e6edf0; grid-template-columns: minmax(0, 1fr) auto; }
.list-row.followup { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) auto auto; }
.list-row.three-col { grid-template-columns: minmax(0, 1.4fr) auto auto; }
.list-row > * { min-width: 0; }
.list-row > .badge { justify-self: start; }
.directory-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #e6edf0; flex-wrap: wrap; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.details-list { margin: 14px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.details-list dt { color: var(--muted); font-size: 13px; }
.details-list dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.details-list.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 0; }
.history-event { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.timeline .item { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; border: 0; border-top: 1px solid #e6edf0; border-radius: 0; background: none; }
.record-title { font: inherit; font-weight: 600; text-align: start; color: var(--ink); background: transparent; border: 0; padding: 0; min-height: 32px; }
.record-title:hover { text-decoration: underline; color: var(--accent); }
.record-details { white-space: pre-wrap; overflow-wrap: anywhere; }
.announcement-title { margin: 12px 0 6px; }
.announcement-body { white-space: pre-line; overflow-wrap: anywhere; }
.notice-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.banner { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; min-height: 56px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.banner:hover { border-color: var(--accent); background: #f3faf9; }
.banner > span { flex: 1; min-width: 0; }
.banner.attention { background: #fff6e3; border-color: #ebd49b; }

/* ---------- Dashboard ---------- */
.checkin { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; background: var(--nav); border-color: var(--nav); color: var(--white); }
.checkin h2 { font-size: 21px; margin: 2px 0; }
.checkin p { color: #b5cdd8; }
.checkin form { margin: 0; }
.metrics { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { display: grid; gap: 3px; align-content: start; }
a.metric:hover { border-color: var(--accent); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.metric-value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; overflow-wrap: anywhere; }
.metric-hint { color: var(--muted); font-size: 13px; }
.metric-hint.bad { color: #a12a2a; font-weight: 600; }
.bar-row { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr) 34px; gap: 10px; align-items: center; padding: 6px 0; }
.bar-row.wide { grid-template-columns: minmax(120px, 1.2fr) minmax(0, 1fr) 30px auto; }
.bar-row strong:last-child, .bar-value { text-align: right; font-weight: 700; }
progress.bar { appearance: none; -webkit-appearance: none; width: 100%; height: 10px; border: 0; border-radius: 5px; background: #e8eef1; overflow: hidden; }
progress.bar::-webkit-progress-bar { background: #e8eef1; border-radius: 5px; }
progress.bar::-webkit-progress-value { background: #2f7f9e; border-radius: 5px; }
progress.bar::-moz-progress-bar { background: #2f7f9e; border-radius: 5px; }
.trend { width: 100%; height: auto; max-height: 220px; display: block; margin-top: 10px; }
.trend rect { fill: #a9cbd8; }
.trend a:hover rect, .trend a:focus rect { fill: #5fa3bb; }
.trend .current rect { fill: var(--accent); }
.trend text { fill: var(--muted); font-size: 13px; }
.trend .value { fill: var(--ink); font-weight: 700; }
.month-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.month-form select, .month-form input:not([type=checkbox]):not([type=radio]) { width: auto; }

/* ---------- Student page ---------- */
.student-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.student-head .person h1 { display: inline; margin-right: 8px; }
.app-card { display: grid; gap: 10px; align-content: start; }
.next-step { background: #f4f7f8; border-radius: 10px; padding: 10px 12px; }
.add-card { display: grid; place-content: center; justify-items: center; gap: 6px; min-height: 170px; width: 100%; text-align: center; border: 1px dashed #9db3bc; border-radius: var(--radius); background: var(--white); color: var(--accent); padding: 16px; }
.add-card:hover { background: #f3faf9; }
.add-card span { color: var(--muted); font-size: 13px; font-weight: 400; max-width: 34ch; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-weight: 400; font-size: 14px; }
.choice:has(input:checked) { border-color: var(--accent); background: #f3faf9; }
.choice strong { display: block; }

/* ---------- Dialogs ---------- */
.action-dialog { width: min(560px, calc(100% - 24px)); max-height: 88dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; padding: 22px; color: var(--ink); box-shadow: 0 24px 80px rgba(16, 46, 66, .25); }
.action-dialog.wide { width: min(720px, calc(100% - 24px)); }
.action-dialog::backdrop { background: rgba(9, 28, 41, .55); }
.action-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.action-dialog footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.action-dialog form { margin: 0; }
.note { background: #f4f7f8; border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
[data-directory-editor] [hidden] { display: none; }
.preference-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 18px; }
.preference-copy { display: flex; align-items: center; gap: 12px; }
.preference-copy label { font-size: 15px; }
#sound-feedback:not(:empty) { grid-column: 1 / -1; margin-top: 6px; font-size: 13px; color: var(--muted); }
.preference-switch { appearance: none; -webkit-appearance: none; width: 46px !important; min-height: 26px !important; height: 26px; margin: 0; padding: 0 !important; background: #8fa3ac !important; border-radius: 30px !important; border: 0 !important; position: relative; }
.preference-switch::after { content: ''; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; background: var(--white); border-radius: 50%; transition: transform .15s; }
.preference-switch:checked { background: var(--accent) !important; }
.preference-switch:checked::after { transform: translateX(20px); }

/* ---------- Sign-in and invitation pages ---------- */
.signin-shell { display: grid; grid-template-columns: .9fr 1.1fr; min-height: 100vh; }
.signin-brand { position: relative; display: grid; place-items: center; padding: 48px 24px; background: var(--nav); color: var(--white); }
.portal-identity { position: absolute; top: 28px; left: clamp(20px, 4vw, 56px); display: flex; gap: 10px; align-items: center; font-weight: 600; color: #dcecf0; }
.portal-identity span { width: 24px; height: 3px; background: #5fd0bd; border-radius: 4px; }
.brand-lockup { text-align: center; }
.brand-lockup img { display: block; width: 132px; height: 132px; object-fit: contain; margin: 0 auto 20px; }
.brand-lockup strong { display: block; font-size: clamp(22px, 2.6vw, 34px); letter-spacing: -.03em; }
.brand-lockup p { margin-top: 6px; color: #c3d6df; }
.signin-panel { display: grid; align-content: center; justify-items: center; padding: clamp(24px, 5vw, 72px); background: var(--white); }
.signin-form { width: min(100%, 440px); }
.signin-form h1 { margin-bottom: 18px; }
.signin-form form { margin-top: 16px; }

/* ---------- Tablet and phone ---------- */
@media (max-width: 1100px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .list-row.followup { grid-template-columns: minmax(0, 1fr) auto; }
    .list-row.followup > :nth-child(2) { grid-column: 1; grid-row: 2; }
    .list-row.followup > :nth-child(4) { grid-column: 1 / -1; }
    .three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .main { margin-left: 0; }
    .side { transform: translateX(-102%); transition: transform .2s ease; width: min(300px, 86vw); box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    body.nav-open { overflow: hidden; }
    body.nav-open .side { transform: none; }
    body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 35; width: 100%; height: 100%; border: 0; background: rgba(9, 28, 41, .5); }
    .top .mobile-menu { display: inline-grid; }
    .side .nav-close { display: inline-grid; position: absolute; top: 16px; right: 12px; background: transparent; border-color: #3a5b6e; color: var(--white); }
    .account-name, .account-button > svg { display: none; }
    .two, .form-grid, .three { grid-template-columns: minmax(0, 1fr); }
    .bottom-bar { display: flex; gap: 4px; position: sticky; bottom: 0; z-index: 25; background: var(--white); border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
    .bottom-bar a, .bottom-bar button { flex: 1; display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 6px 0; border: 0; border-radius: 10px; background: none; font-size: 11.5px; font-weight: 600; color: var(--muted); }
    .bottom-bar .active { color: var(--accent); }
    .bottom-bar .add { background: var(--accent); color: var(--white); }
    .toast-stack { bottom: 76px; }
    .hide-phone { display: none !important; }
    .timeline .item { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
@media (max-width: 700px) {
    table.stack thead { position: absolute; left: -9999px; }
    table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
    table.stack tr { padding: 12px 0; border-top: 1px solid #e6edf0; }
    table.stack tr:first-child { border-top: 0; }
    table.stack td { border: 0; padding: 3px 0; }
    table.stack td[data-label]::before { content: attr(data-label) ' · '; color: var(--muted); font-size: 12.5px; }
    table.stack td.primary::before, table.stack td.plain::before { content: none; }
    .list-row, .list-row.three-col, .list-row.followup { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .list-row.followup > :nth-child(2) { grid-row: auto; }
    .details-list.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bar-row.wide { grid-template-columns: minmax(0, 1fr) 30px; }
    .bar-row.wide progress { grid-column: 1 / -1; grid-row: 2; }
    .signin-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .signin-brand { padding: 18px 22px 24px; }
    .portal-identity { position: static; margin-bottom: 12px; justify-self: start; font-size: 14px; }
    .brand-lockup img { width: 72px; height: 72px; margin-bottom: 10px; }
    .signin-panel { align-content: start; padding-top: 30px; }
    .action-dialog { padding: 16px; }
    .filters .field, .crm-filters .field { max-width: none; flex-basis: 100%; }
    .btn.big { width: 100%; }
    .checkin form { width: 100%; }
}
@media (max-width: 420px) { .metrics { gap: 10px; } .metric-value { font-size: 26px; } .details-list { grid-template-columns: minmax(0, 1fr); } .phone-row { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { *, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; } }
@media print { .side, .top, .bottom-bar, .toast-stack, .btn, .icon-action { display: none !important; } .main { margin: 0; } }
