/* ---------- Admin console + My Account (.adm-) ---------- */
.adm-page .page-head { margin-bottom: 8px; }
.adm-head-sub { color: var(--text-2); font-weight: 600; }
.adm-tabs a { white-space: nowrap; }
.adm-loading { padding: 40px; color: var(--muted); text-align: center; }

.adm-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.adm-spacer { flex: 1; }
.adm-search { max-width: 340px; }
.adm-count { font-weight: 700; color: var(--navy); font-size: 18px; }
.adm-dirty { color: #b57a00; font-weight: 600; font-size: 13px; }
.adm-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
.adm-table { min-width: 640px; }
.adm-table th { white-space: nowrap; }
.adm-table tr.adm-inactive td { color: var(--muted); }
.adm-td-actions { text-align: right; width: 1%; white-space: nowrap; }
.adm-empty { text-align: center; color: var(--muted); padding: 30px !important; }
.adm-nowrap { white-space: nowrap; }
.adm-edit-table td { padding: 6px 8px; vertical-align: middle; }
.adm-edit-table td .input { min-width: 70px; }
.adm-idx { color: var(--muted); font-size: 12px; text-align: center; }
.adm-row-actions { white-space: nowrap; text-align: right; }
.adm-icon-btn { border: 1px solid var(--line-2); background: #fff; border-radius: 3px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin-left: 4px; color: var(--text-2); padding: 0; }
.adm-icon-btn:hover:not(:disabled) { background: var(--bg-soft); color: var(--navy); }
.adm-icon-btn:disabled { opacity: .35; cursor: default; }
.adm-icon-btn.adm-danger:hover { color: var(--red); border-color: var(--red); }
.adm-rot180 { transform: rotate(180deg); }
.adm-multi { width: 100%; min-height: 36px; border: 1px solid var(--line-2); border-radius: 3px; background: #fff; text-align: left; padding: 4px 6px; cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.adm-multi:hover { border-color: var(--blue); }
.adm-tag { background: #e3f2fb; color: #0a5f8c; border-radius: 10px; padding: 2px 8px; font-size: 12px; white-space: nowrap; }

.adm-role { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; text-transform: capitalize; background: #e8edf1; }
.adm-role-admin { background: #fde3e0; color: #a12b1e; }
.adm-role-supervisor { background: #e3f2fb; color: #0a5f8c; }
.adm-ok { color: var(--green-dark); font-weight: 600; }
.adm-off { color: var(--muted); font-weight: 600; }

/* forms */
.adm-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
@media (max-width: 760px) { .adm-form-grid { grid-template-columns: 1fr; } }
.adm-span2 { grid-column: 1 / -1; }
.adm-field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; font-weight: 600; }
.adm-hint { font-size: 12px; color: var(--text-2); margin-top: 5px; line-height: 1.4; }
.adm-inline { display: flex; gap: 8px; align-items: center; }
.adm-inline .input { flex: 1; min-width: 0; }
.adm-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.adm-num { width: 110px; }
.adm-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.adm-two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .adm-two-col { grid-template-columns: 1fr; } }
.adm-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.adm-narrow { max-width: 760px; }
.adm-panel .panel-head { gap: 12px; }
.adm-help { display: flex; gap: 12px; align-items: flex-start; background: #eef7fc; border-left: 4px solid var(--blue); padding: 12px 16px; margin-bottom: 16px; line-height: 1.5; font-size: 14px; }
.adm-help > .ico { color: var(--blue); margin-top: 2px; }
.adm-help-plain { background: var(--bg-soft); border-left-color: #b3bec7; margin: 16px 0 0; }
.adm-help-plain > .ico { color: var(--text-2); }

/* switch */
.adm-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-weight: 600; font-size: 14px; color: var(--text); }
.adm-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.adm-switch-track { display: inline-block; width: 46px; height: 26px; border-radius: 13px; background: #c4ccd3; position: relative; transition: background .15s; flex: none; }
.adm-switch-knob { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: left .15s; }
.adm-switch input:checked + .adm-switch-track { background: var(--green); }
.adm-switch input:checked + .adm-switch-track .adm-switch-knob { left: 23px; }
.adm-switch input:focus-visible + .adm-switch-track { box-shadow: 0 0 0 3px rgba(11, 152, 222, .3); }

/* locations map + matrix */
.adm-loc-extras { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin-top: 20px; align-items: start; }
@media (max-width: 1100px) { .adm-loc-extras { grid-template-columns: 1fr; } }
.adm-map { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 3px; }
.adm-map .adm-grid { stroke: #dfe4da; stroke-width: 1; }
.adm-map .adm-axis { stroke: #b8c2b0; stroke-width: 1.4; stroke-dasharray: 4 3; }
.adm-map text { font-size: 11px; fill: #2f3d4a; paint-order: stroke; stroke: #f3f5f1; stroke-width: 3px; font-family: var(--font); }
.adm-map .adm-map-note { fill: #8a968a; font-size: 10px; }
.adm-pt circle { stroke: #fff; stroke-width: 1.5; }
.adm-pt-station circle { fill: var(--blue); }
.adm-pt-hospital circle { fill: var(--red); }
.adm-pt-other circle { fill: #6b7884; }
.adm-pt-hospital text, .adm-pt-station text { font-weight: 700; }
.adm-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 400; color: var(--text-2); }
.adm-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 8px; }
.adm-dot-station { background: var(--blue); } .adm-dot-hospital { background: var(--red); } .adm-dot-other { background: #6b7884; }
.adm-matrix-note { margin-bottom: 8px; }
.adm-matrix { border-collapse: collapse; font-size: 12px; width: 100%; }
.adm-matrix th, .adm-matrix td { border: 1px solid var(--line); padding: 5px 7px; }
.adm-matrix thead th { background: var(--bg-soft); font-weight: 600; text-align: center; vertical-align: bottom; min-width: 70px; }
.adm-matrix tbody th { background: var(--bg-soft); text-align: left; font-weight: 600; white-space: nowrap; }
.adm-matrix td { text-align: right; font-variant-numeric: tabular-nums; }
.adm-matrix td.adm-self { text-align: center; color: var(--muted); background: #fafbfc; }

/* branding preview */
.adm-brand-preview { position: sticky; top: 16px; }
.adm-preview-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-2); font-weight: 700; margin-bottom: 8px; }
.adm-preview-frame { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; box-shadow: var(--shadow); }
.adm-preview-header { height: 72px; border-bottom: 0; overflow: hidden; }
.adm-preview-header .brand-agency { min-width: 0; }
.adm-preview-header .brand-agency span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-preview-header .header-greet { flex: none; white-space: nowrap; }
.adm-preview-header .header-greet > div { overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.adm-preview-header::after { content: ''; }
.adm-preview-frame::after { content: ''; display: block; height: 14px; background: var(--navy); }
.adm-preview-ann { margin-top: 14px; }
.adm-preview-login { margin-top: 14px; font-size: 13px; color: var(--text-2); }
.adm-preview-login code, .adm-action { background: var(--bg-soft); padding: 1px 6px; border-radius: 3px; font-size: 12px; }

/* sonoran */
.adm-status { display: flex; gap: 12px; align-items: flex-start; }
.adm-status-dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 4px; flex: none; background: #b3bec7; }
.adm-status-ok { background: var(--green); box-shadow: 0 0 0 4px rgba(46, 204, 113, .2); }
.adm-status-bad { background: var(--red); box-shadow: 0 0 0 4px rgba(231, 76, 60, .18); }
.adm-status-msg { font-weight: 600; }
.adm-result { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 3px; margin-top: 14px; font-weight: 600; word-break: break-word; }
.adm-result-ok { background: #e7f8ee; color: #17703c; }
.adm-result-bad { background: #fdecea; color: #a12b1e; }
.adm-sample { margin-top: 10px; min-width: 0; font-size: 13px; }
.adm-steps { margin: 0; padding-left: 20px; line-height: 1.55; font-size: 14px; }
.adm-steps li { margin-bottom: 8px; }
.adm-steps code { background: var(--bg-soft); padding: 1px 5px; border-radius: 3px; }
.adm-panel .panel-body > .adm-field + .adm-field { margin-top: 14px; }
.adm-examples { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.adm-code { border: 1px solid #1d2a36; border-radius: 4px; overflow: hidden; }
.adm-code-head { display: flex; justify-content: space-between; align-items: center; background: var(--navy); color: #fff; padding: 6px 8px 6px 12px; font-size: 13px; font-weight: 600; }
.adm-code pre { margin: 0; background: #1d2a36; color: #dfe8ef; padding: 12px 14px; font-size: 12px; line-height: 1.5; overflow-x: auto; max-height: 360px; tab-size: 4; }

/* audit */
.adm-target { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; max-width: 220px; word-break: break-all; }
.adm-detail { font-size: 13px; color: var(--text-2); max-width: 420px; word-break: break-word; }

/* account */
.adm-account .adm-two-col { max-width: 1100px; }
.adm-profile { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.adm-avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; flex: none; }
.adm-profile-name { font-size: 22px; font-weight: 700; color: var(--navy); }
.adm-kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.adm-kv-label { color: var(--text-2); }
.adm-kv-value { font-weight: 600; text-align: right; }
.adm-pw-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.adm-pw-form .adm-actions { margin-top: 4px; }
.adm-pw-msg { font-weight: 600; font-size: 14px; min-height: 1em; }
.adm-pw-bad { color: var(--red); }
.adm-pw-ok { color: var(--green-dark); }
.adm-field label.adm-switch, .panel-head label.adm-switch { display: inline-flex; margin: 0; font-size: 14px; color: var(--text); }
.adm-label { display: block; font-size: 13px; color: var(--text-2); margin: 12px 0 4px; }

/* ---------- Roles & Permissions matrix (.rp-) ---------- */
.rp-wrap { max-height: calc(100vh - 290px); overflow: auto; }
.rp-matrix { border-collapse: separate; border-spacing: 0; min-width: 100%; }
.rp-matrix th, .rp-matrix td { border-bottom: 1px solid var(--line); }
.rp-matrix thead th { position: sticky; top: 0; z-index: 2; background: var(--bg-nav); vertical-align: bottom; }
.rp-perm-col { position: sticky; left: 0; z-index: 1; background: #fff; text-align: left; min-width: 260px; max-width: 360px; }
.rp-matrix thead .rp-perm-col { z-index: 3; background: var(--bg-nav); }
.rp-role-col { min-width: 118px; max-width: 150px; text-align: center; padding: 10px 8px !important; white-space: normal !important; }
.rp-role-head { display: flex; flex-direction: column; align-items: center; gap: 5px; position: relative; }
.rp-role-name { border: 0; background: none; padding: 0; font-weight: 700; color: var(--navy); cursor: pointer; line-height: 1.2; font-size: 13px; }
.rp-role-name:hover { color: var(--blue); text-decoration: underline; }
.rp-role-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.rp-lock, .rp-custom, .rp-users { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 1px 7px; white-space: nowrap; }
.rp-lock { background: #fff4cc; color: #7a5b00; }
.rp-lock .ico { width: 11px; height: 11px; }
.rp-lock-inline { vertical-align: middle; }
.rp-custom { background: #e3f2fb; color: #0a5f8c; }
.rp-users { background: #e8edf1; color: var(--text-2); font-weight: 600; }
.rp-role-count { font-size: 11px; color: var(--muted); }
.rp-del { width: 26px; height: 26px; margin: 0; }
.rp-group th { background: var(--navy) !important; color: #fff; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 7px 12px !important; }
.rp-perm { font-weight: 400; padding: 8px 12px !important; }
.rp-perm-label { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.3; }
.rp-perm-id { font-size: 11px; color: var(--muted); }
.rp-cell { text-align: center; padding: 0 !important; }
.rp-cb-wrap { display: flex; align-items: center; justify-content: center; min-height: 44px; cursor: pointer; }
.rp-cb { width: 18px; height: 18px; accent-color: var(--green-dark); cursor: pointer; }
.rp-cb:disabled { cursor: not-allowed; }
.rp-row:hover td, .rp-row:hover .rp-perm-col { background: #f6f9fb; }
.rp-cell.rp-admin { background: #fafbfc; }
.rp-cell.rp-changed { background: #fff6d6 !important; box-shadow: inset 0 0 0 2px #f2c200; }
.adm-role-desc { min-height: 1em; }

/* ---------- Scope of Practice (.sop-) ---------- */
.sop-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .sop-layout { grid-template-columns: 1fr; } }
.sop-levels { border: 1px solid var(--line); border-radius: 4px; overflow: hidden; position: sticky; top: 10px; }
@media (max-width: 860px) { .sop-levels { position: static; display: flex; overflow-x: auto; } .sop-levels-title { display: none; } .sop-level { min-width: 140px; } }
.sop-levels-title { background: var(--bg-nav); padding: 9px 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-2); letter-spacing: .05em; }
.sop-level { display: flex; flex-direction: column; gap: 3px; width: 100%; border: 0; border-top: 1px solid var(--line); background: #fff; text-align: left; padding: 10px 12px; cursor: pointer; }
.sop-level:hover { background: var(--bg-soft); }
.sop-level.active { background: #e3f2fb; box-shadow: inset 4px 0 0 var(--blue); }
.sop-level-name { font-weight: 700; color: var(--navy); }
.sop-level-counts { display: flex; gap: 5px; flex-wrap: wrap; }
.sop-n { font-size: 11px; font-weight: 700; border-radius: 9px; padding: 1px 7px; background: #e8edf1; color: var(--text-2); white-space: nowrap; }
.sop-n-block { background: #fde3e0; color: #a12b1e; }
.sop-n-warn { background: #fff1cc; color: #8a5a00; }
.sop-main-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sop-title { margin: 0; font-size: 22px; color: var(--navy); }
.sop-filter .chip { font-family: inherit; }
.sop-cat { margin-bottom: 16px; }
.sop-cat-counts { font-weight: 400; font-size: 13px; color: var(--text-2); }
.sop-bulk { display: inline-flex; gap: 10px; align-items: center; margin-left: auto; font-size: 13px; }
.sop-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 24px; }
.sop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 4px; border-bottom: 1px solid #eef1f3; }
.sop-name { font-size: 14px; }
.sop-row-block .sop-name { color: #a12b1e; font-weight: 600; }
.sop-row-warn .sop-name { color: #8a5a00; font-weight: 600; }
.sop-seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; flex: none; }
.sop-seg-btn { border: 0; background: #fff; padding: 5px 10px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--text-2); }
.sop-seg-btn + .sop-seg-btn { border-left: 1px solid var(--line-2); }
.sop-seg-btn:hover { background: var(--bg-soft); }
.sop-seg-btn.sop-allow.on { background: var(--green-dark); color: #fff; }
.sop-seg-btn.sop-warn.on { background: #f0a500; color: #2b1d00; }
.sop-seg-btn.sop-block.on { background: var(--red); color: #fff; }

/* Admin → Users: Discord link column, filter and editor details */
.adm-discord { display: flex; align-items: center; gap: 8px; }
.adm-discord-badge { display: inline-block; background: #5865f2; color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 1px 8px; }
.adm-discord-name { font-size: 13px; }
.adm-discord-cell .adm-hint { margin: 0; font-size: 11px; }
.adm-discord-filter { gap: 6px; }
.adm-discord-filter .input { width: auto; }
.adm-discord-details { margin-top: 16px; border-top: 1px solid var(--line, #d8dde2); padding-top: 12px; }
.adm-discord-details .adm-discord { margin-bottom: 8px; }
.adm-discord-roles { display: flex; flex-wrap: wrap; gap: 4px; }
.user-avatar.user-avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.adm-discord-details h3 { font-size: 14px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
