:root {
    --navy: #111c4e;
    --navy-2: #17265f;
    --ink: #171d2d;
    --muted: #77819a;
    --line: #e7e9f0;
    --surface: #ffffff;
    --background: #f1f2f7;
    --primary: #845adf;
    --primary-soft: #f0eafd;
    --success: #15996a;
    --success-soft: #e7f8f1;
    --warning: #c67a00;
    --warning-soft: #fff4dc;
    --danger: #d83a55;
    --danger-soft: #ffebef;
    --shadow: 0 2px 5px rgba(24, 33, 66, .035);
    --radius: 10px;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--background); font-size: 14px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 2vw, 2.2rem); line-height: 1.12; margin-bottom: 7px; letter-spacing: -.035em; }
h2 { font-size: 1.05rem; margin-bottom: 5px; letter-spacing: -.015em; }
h3 { font-size: .94rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app-loader { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.loader-mark, .brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: #fff; background: linear-gradient(145deg, #9b6cf0, #7445d3); font-size: 11px; font-weight: 900; letter-spacing: -.02em; box-shadow: 0 6px 15px rgba(132,90,223,.22); }
.loader-mark { width: 56px; height: 56px; border-radius: 16px; }
.brand-mark.large { width: 58px; height: 58px; border-radius: 17px; font-size: 16px; }

.app-frame { min-height: 100vh; }
.side-nav { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 236px; color: #52617e; background: #f8f9fc; border-right: 1px solid #e1e4ed; display: flex; flex-direction: column; transition: width .2s ease, transform .2s ease; }
.brand { height: 72px; padding: 0 16px 0 22px; display: flex; align-items: center; gap: 12px; background: #fff; border-bottom: 1px solid #e7e9f0; }
.brand-copy { min-width: 0; flex: 1; overflow: hidden; }
.brand strong, .brand small { display: block; }
.brand strong { color: #192440; font-size: 15px; }
.brand small { color: #8993a9; margin-top: 3px; font-size: 11px; }
.side-nav nav { padding: 17px 12px; display: flex; flex-direction: column; gap: 5px; }
.nav-section { color: #a0a8b9; padding: 14px 10px 7px; text-transform: uppercase; letter-spacing: .11em; font-size: 10px; font-weight: 750; }
.side-nav nav a { min-height: 44px; border-radius: 8px; display: flex; align-items: center; gap: 12px; padding: 0 12px; color: #53617d; text-decoration: none; font-weight: 600; position: relative; }
.side-nav nav a > span:first-child { width: 20px; flex: 0 0 20px; color: #77849d; font-size: 18px; text-align: center; }
.side-nav nav a .nav-label { width: auto; min-width: 0; flex: 1; color: inherit; font-size: inherit; text-align: left; white-space: nowrap; }
.side-nav nav a:hover { color: #26334f; background: #eff1f6; }
.side-nav nav a.active { color: #273451; background: #e9ebf1; box-shadow: none; }
.side-nav nav a.active > span:first-child { color: var(--primary); }
.side-nav nav a b { margin-left: auto; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 999px; background: #e33c5b; color: #fff; display: grid; place-items: center; font-size: 10px; }
.side-footer { margin-top: auto; padding: 20px 22px; color: #7f899f; background: #fff; font-size: 11px; border-top: 1px solid #e7e9f0; }
.side-footer span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #3bd29a; }
.side-nav.is-collapsed { width: 78px; }
.side-nav.is-collapsed .brand { padding: 0 12px; justify-content: center; gap: 0; }
.side-nav.is-collapsed .brand-copy, .side-nav.is-collapsed .nav-label, .side-nav.is-collapsed .nav-section, .side-nav.is-collapsed .side-footer span { display: none; }
.side-nav.is-collapsed .brand-mark { width: 36px; height: 36px; }
.side-nav.is-collapsed nav { padding: 17px 10px 16px; }
.side-nav.is-collapsed nav a { padding: 0; justify-content: center; }
.side-nav.is-collapsed nav a > span:first-child { width: 44px; font-size: 20px; }
.side-nav.is-collapsed nav a b { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; font-size: 8px; }
.side-nav.is-collapsed .side-footer { min-height: 58px; padding: 0; border-top-color: #e7e9f0; }

.portal-main { min-height: 100vh; margin-left: 236px; min-width: 0; transition: margin-left .2s ease; }
.portal-main.drawer-collapsed { margin-left: 78px; }
.topbar { position: sticky; top: 0; z-index: 20; height: 72px; padding: 0 clamp(18px, 2.2vw, 38px); color: #fff; background: var(--navy); border-bottom: 0; display: flex; align-items: center; gap: 16px; }
.global-search { height: 42px; width: clamp(250px, 30vw, 450px); display: flex; align-items: center; gap: 9px; padding: 0 14px; background: rgba(255,255,255,.075); border: 1px solid rgba(255,255,255,.11); border-radius: 8px; color: #aeb9d6; }
.global-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: #fff; }
.global-search input::placeholder { color: #aeb9d0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; position: relative; }
.health-pill { min-height: 40px; padding: 0 13px; border: 1px solid transparent; border-radius: 11px; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 750; cursor: pointer; white-space: nowrap; }
.health-ok { color: #61dfb1; background: rgba(29,181,126,.13); border-color: rgba(84,213,164,.25); }
.health-warning { color: #ffd175; background: rgba(214,143,15,.13); border-color: rgba(255,209,117,.25); }
.health-danger { color: #ff93a7; background: rgba(216,58,85,.13); border-color: rgba(255,147,167,.25); }
.health-unknown { color: #c4cbe0; background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.13); }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent); }
.profile-button { min-height: 46px; padding: 4px 8px; border: 1px solid rgba(255,255,255,.11); border-radius: 8px; background: rgba(255,255,255,.055); display: flex; align-items: center; gap: 9px; color: #fff; cursor: pointer; }
.avatar { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; background: #584ecb; color: #fff; font-weight: 800; font-size: 12px; }
.profile-copy { min-width: 104px; text-align: left; }
.profile-copy strong, .profile-copy small { display: block; white-space: nowrap; }
.profile-copy strong { font-size: 12px; }
.profile-copy small { color: #aeb8d2; font-size: 10px; margin-top: 2px; }
.profile-menu { position: absolute; top: 55px; right: 0; min-width: 230px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.profile-menu span { display: block; padding: 8px 10px; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.profile-menu button { width: 100%; min-height: 42px; border: 0; border-radius: 9px; color: var(--danger); background: var(--danger-soft); text-align: left; padding: 0 10px; font-weight: 700; cursor: pointer; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #5e6882; cursor: pointer; font-size: 20px; }
.topbar .icon-button { color: #c5cde2; background: transparent; border-color: rgba(255,255,255,.12); }
.desktop-drawer-button { display: grid; flex: 0 0 auto; border-color: transparent !important; font-size: 22px; }
.desktop-drawer-button:hover { color: #fff; background: rgba(255,255,255,.08); }
.menu-button { display: none; }
.page-content { width: 100%; padding: clamp(24px, 2.4vw, 42px); padding-bottom: 56px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 20px; }
.page-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; align-items: center; gap: 16px; }
.breadcrumb { display: flex; align-items: center; gap: 9px; color: #68748e; font-size: 11px; white-space: nowrap; }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb b { color: #adb4c3; font-size: 17px; }
.eyebrow { display: block; margin-bottom: 8px; color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: .09em; text-transform: uppercase; }
.refresh-button { flex: 0 0 auto; }
.refresh-button.is-loading { animation: spin 1s linear infinite; }

.panel { background: var(--surface); border: 1px solid #eceef3; border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-heading { min-height: 66px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-heading p { color: var(--muted); margin-bottom: 0; font-size: 11px; }
.attention-panel { margin-bottom: 18px; border-color: #f0cf91; box-shadow: 0 8px 24px rgba(188,117,0,.06); }
.attention-grid { padding: 0 10px 10px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.attention-grid .consultation-card { border: 1px solid var(--line); border-radius: 11px; }
.button-link, .primary-button, .secondary-button { min-height: 44px; padding: 0 17px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; text-decoration: none; font-weight: 750; white-space: nowrap; cursor: pointer; }
.primary-button { color: #fff; background: var(--primary); box-shadow: 0 5px 12px rgba(91,80,214,.2); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.secondary-button { color: #39415a; background: #fff; border-color: #dce1eb; }
.secondary-button.compact { min-height: 38px; padding: 0 13px; }
.danger-soft { color: var(--danger); background: var(--danger-soft); }
.text-link, .row-action, .back-link { color: var(--primary); font-weight: 750; text-decoration: none; }
.back-link { min-height: 44px; border: 0; background: transparent; padding: 0; cursor: pointer; margin-bottom: 8px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { min-width: 0; min-height: 132px; padding: 18px 20px; display: flex; flex-direction: column; align-items: stretch; justify-content: space-between; gap: 12px; text-align: left; border: 1px solid #eceef3; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); cursor: pointer; color: var(--ink); transition: transform .15s ease, box-shadow .15s ease; }
.metric-card:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(26,34,65,.11); }
.metric-main { display: flex; align-items: center; gap: 13px; }
.metric-copy { min-width: 0; }
.metric-copy > * { display: block; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-copy strong { font-size: 21px; margin: 5px 0 3px; line-height: 1; }
.metric-copy small { color: var(--muted); font-size: 10px; white-space: normal; }
.metric-icon { width: 44px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: #fff !important; font-size: 18px; font-weight: 800; }
.metric-primary .metric-icon { background: #845adf; }
.metric-success .metric-icon { background: #22b889; }
.metric-warning .metric-icon { background: #f0ad36; }
.metric-danger .metric-icon { background: #df5b72; }
.metric-trend { width: 112px; height: 30px; overflow: visible; }
.metric-trend polyline { fill: none; stroke: var(--primary); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.metric-success .metric-trend polyline { stroke: var(--success); }
.metric-warning .metric-trend polyline { stroke: #d5982d; }
.metric-danger .metric-trend polyline { stroke: var(--danger); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(390px, .85fr); gap: 18px; align-items: start; }
.chart-panel, .activity-panel { min-width: 0; }
.chart-shell { width: 100%; height: 280px; padding: 16px 14px 12px 2px; }
.chart-shell svg { width: 100%; height: calc(100% - 22px); overflow: visible; }
.chart-grid { stroke: #e8eaf1; stroke-width: 1; }
.chart-bar { fill: #6b5ee5; transition: opacity .15s; }
.chart-bar:hover { opacity: .72; }
.chart-axis { margin-left: 42px; display: grid; grid-template-columns: repeat(8,1fr); color: #7f879e; font-size: 9px; text-align: center; }
.live-caption { display: flex; align-items: center; gap: 7px; color: var(--success); font-size: 10px; font-weight: 750; white-space: nowrap; }
.activity-list, .alert-list { padding: 0 16px 8px; }
.consultation-card { min-height: 66px; display: flex; align-items: center; gap: 11px; padding: 10px 2px; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.consultation-card:last-child { border-bottom: 0; }
.consultation-card:focus-visible { outline: 3px solid rgba(91,80,214,.25); outline-offset: 2px; }
.consultation-icon { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; font-weight: 850; }
.consultation-icon.success { color: #267bd3; background: #eaf3ff; }
.consultation-icon.warning { color: var(--warning); background: var(--warning-soft); }
.consultation-icon.danger { color: var(--danger); background: var(--danger-soft); }
.consultation-content { min-width: 0; flex: 1; }
.consultation-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.consultation-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.consultation-content > span, .consultation-content small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.row-arrow { color: #8b94ad; font-size: 22px; }
.status-badge { width: max-content; min-height: 24px; padding: 0 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.status-success { color: #08754f; background: var(--success-soft); }
.status-warning { color: #8e5900; background: var(--warning-soft); }
.status-danger { color: #ae2941; background: var(--danger-soft); }
.status-neutral { color: #5b647d; background: #eef0f5; }

.system-alert { min-height: 58px; margin-bottom: 16px; padding: 12px 16px; border-radius: 11px; display: flex; align-items: center; gap: 12px; border: 1px solid; }
.system-alert strong { white-space: nowrap; }
.system-alert span { font-size: 12px; }
.system-alert.warning { color: #794f09; background: #fff8e9; border-color: #f0d49d; }
.system-alert.danger { color: #a6253c; background: var(--danger-soft); border-color: #f3c4cd; }
.system-alert.info { color: #375a84; background: #edf5ff; border-color: #cfe2f7; }
.system-alert.success { color: #08754f; background: var(--success-soft); border-color: #bce8d8; }
.loading-panel { min-height: 250px; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.spinner { width: 24px; height: 24px; display: inline-block; border: 3px solid #dfe2eb; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-row { min-height: 150px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.empty-state { min-height: 170px; display: grid; place-content: center; justify-items: center; gap: 7px; padding: 24px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 15px; }
.empty-state.error strong { color: var(--danger); }
.empty-state.success strong { color: var(--success); }

.filter-panel { margin-bottom: 18px; padding: 17px; }
.filter-grid { display: grid; grid-template-columns: minmax(230px, 1.6fr) repeat(3,minmax(140px,.8fr)) auto; align-items: end; gap: 12px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: #47506b; font-size: 11px; font-weight: 700; }
.field input, .field select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid #dce1eb; border-radius: 9px; background: #fff; color: var(--ink); outline: 0; }
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,80,214,.12); }
.field > small { color: var(--muted); font-size: 9px; font-weight: 400; line-height: 1.4; }
.filter-actions { display: flex; gap: 8px; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 13px; }
.quick-filters button { min-height: 36px; padding: 0 13px; border: 0; border-radius: 999px; background: #f0effd; color: #554bc0; font-size: 11px; font-weight: 750; cursor: pointer; }
.results-panel { overflow: hidden; }
.desktop-table { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 17px; border-bottom: 1px solid var(--line); text-align: left; font-size: 12px; }
th { color: var(--muted); background: #fafbfc; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #fafaff; }
.mobile-cards { display: none; }

.detail-heading { align-items: center; }
.detail-meta { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 1px; overflow: hidden; margin-bottom: 18px; background: var(--line); }
.detail-meta > div { min-width: 0; padding: 16px; background: #fff; }
.detail-meta span, .portal-facts small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.detail-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.portal-results { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.portal-result { overflow: hidden; }
.portal-summary { padding: 16px 18px 8px; margin: 0; color: #424b65; min-height: 55px; }
.portal-facts { padding: 7px 18px 15px; display: flex; gap: 28px; }
.portal-facts strong { display: block; }
.evidence-list { margin: 0 18px 14px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.evidence-list a { min-height: 60px; padding: 9px 12px; display: flex; align-items: center; gap: 10px; text-decoration: none; border-bottom: 1px solid var(--line); }
.evidence-list a:last-child { border: 0; }
.evidence-list a > span:nth-child(2) { min-width: 0; flex: 1; }
.evidence-list strong, .evidence-list small { display: block; }
.evidence-list strong { font-size: 11px; }
.evidence-list small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.evidence-list b { color: var(--primary); font-size: 10px; }
.evidence-icon { width: 34px; height: 34px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); border-radius: 9px; }
.retry-box { padding: 14px 18px; border-top: 1px solid #f0d8a6; background: #fffaf0; display: flex; align-items: end; gap: 10px; }
.retry-box .field { flex: 1; }
.technical-details { border-top: 1px solid var(--line); padding: 0 18px; }
.technical-details summary { min-height: 46px; display: flex; align-items: center; color: #505a74; font-size: 11px; font-weight: 750; cursor: pointer; }
.technical-details dl { margin: 0 0 14px; }
.technical-details dl > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--line); font-size: 10px; }
.technical-details dt { color: var(--muted); }
.technical-details dd { margin: 0; word-break: break-word; }
.toast-message { position: fixed; right: 24px; bottom: 24px; z-index: 70; max-width: min(390px, calc(100vw - 32px)); padding: 13px 16px; border-radius: 10px; background: #282e51; color: #fff; box-shadow: var(--shadow); }
.users-table td { vertical-align: middle; }
.users-table th:last-child, .users-table td:last-child { width: 1%; text-align: right; }
.user-identity { min-width: 180px; display: flex; align-items: center; gap: 10px; }
.user-identity strong, .user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.role-badges span { min-height: 24px; padding: 0 8px; display: inline-flex; align-items: center; border-radius: 999px; color: #554bc0; background: var(--primary-soft); font-size: 9px; font-weight: 750; }
.table-action { white-space: nowrap; }
.user-mobile-list { padding-top: 8px; }
.user-mobile-card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.user-mobile-card:last-child { border-bottom: 0; }
.user-mobile-card header { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; }
.user-mobile-card header > div { min-width: 0; }
.user-mobile-card header strong, .user-mobile-card header span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-mobile-card header > div span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.user-mobile-card dl { margin: 13px 0; display: grid; gap: 7px; }
.user-mobile-card dl > div { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 10px; }
.user-mobile-card dt { color: var(--muted); font-size: 10px; }
.user-mobile-card dd { margin: 0; text-align: right; font-size: 10px; font-weight: 650; }
.user-mobile-actions { display: flex; }
.user-mobile-actions > * { width: 100%; }
.permission-panel { margin-top: 18px; overflow: hidden; }
.permission-summary { min-height: 66px; padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; cursor: pointer; list-style: none; }
.permission-summary::-webkit-details-marker { display: none; }
.permission-summary p { margin: 0; color: var(--muted); font-size: 11px; }
.permission-toggle { min-height: 38px; padding: 0 13px; display: inline-flex; align-items: center; border: 1px solid #dce1eb; border-radius: 9px; color: #39415a; background: #fff; font-size: 10px; font-weight: 750; white-space: nowrap; }
.permission-toggle span:last-child, .permission-panel[open] .permission-toggle span:first-child { display: none; }
.permission-panel[open] .permission-toggle span:last-child { display: inline; }
.permission-panel[open] .permission-summary { border-bottom: 1px solid var(--line); }
.permission-description { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: normal; }
.permission-cards { padding-top: 10px; }
.permission-card { padding: 14px 0; border-bottom: 1px solid var(--line); }
.permission-card:last-child { border-bottom: 0; }
.permission-card > span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.permission-card dl { margin: 12px 0 0; display: grid; gap: 7px; }
.permission-card dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.permission-card dt { color: var(--muted); font-size: 10px; }
.permission-card dd { margin: 0; font-size: 11px; font-weight: 750; }

.modal-scrim { position: fixed; inset: 0; z-index: 80; padding: 0; border: 0; background: rgba(13,18,40,.46); }
.user-editor-modal { position: fixed; inset: 0 0 0 auto; z-index: 81; width: min(500px,100vw); display: flex; flex-direction: column; background: #fff; box-shadow: -14px 0 40px rgba(20,26,54,.2); animation: slideIn .2s ease-out; }
.user-editor-modal .drawer-header { flex: 0 0 auto; margin: 0; padding: 22px; border-bottom: 1px solid var(--line); }
.user-editor-modal .drawer-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.user-editor-body { min-height: 0; flex: 1; padding: 20px 22px; display: grid; align-content: start; gap: 16px; overflow-y: auto; }
.role-fieldset { min-width: 0; margin: 0; padding: 0; display: grid; gap: 8px; border: 0; }
.role-fieldset legend { margin-bottom: 8px; color: #47506b; font-size: 11px; font-weight: 750; }
.role-option, .active-option { min-height: 60px; padding: 11px 13px; display: flex; align-items: flex-start; gap: 11px; border: 1px solid #dce1eb; border-radius: 10px; background: #fff; cursor: pointer; }
.role-option:hover, .active-option:hover { border-color: #b8b1f2; background: #fbfaff; }
.role-option input, .active-option input { width: 18px; height: 18px; flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--primary); }
.role-option input:disabled, .active-option input:disabled { cursor: not-allowed; }
.role-option > span, .active-option > span { min-width: 0; }
.role-option strong, .role-option small, .active-option strong, .active-option small { display: block; }
.role-option small, .active-option small { margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 400; line-height: 1.4; }
.protected-note { margin: 0; padding: 11px 13px; border-radius: 9px; color: #794f09; background: #fff8e9; font-size: 10px; line-height: 1.5; }
.user-editor-actions { flex: 0 0 auto; padding: 14px 22px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); background: #fff; }

.health-drawer { position: fixed; inset: 0 0 0 auto; z-index: 61; width: min(420px, 100vw); padding: 22px; background: #fff; box-shadow: -14px 0 40px rgba(20,26,54,.16); overflow-y: auto; animation: slideIn .2s ease-out; }
.drawer-scrim, .scrim { position: fixed; inset: 0; z-index: 60; padding: 0; border: 0; background: rgba(13,18,40,.42); }
.scrim { z-index: 29; display: none; }
.drawer-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.health-list { margin: 20px 0; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.health-list > div { min-height: 48px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.health-list > div:last-child { border: 0; }
.health-list dt { color: var(--muted); font-size: 11px; }
.health-list dd { margin: 0; font-weight: 750; font-size: 11px; text-align: right; }
.portal-health { margin-bottom: 20px; }
.portal-health > div { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); font-size: 11px; }
.mobile-nav { display: none; }

.empty-layout { min-height: 100vh; }
.login-page { min-height: 100vh; padding: 24px; display: grid; place-content: center; background: radial-gradient(circle at 75% 10%, #dedafd 0, transparent 32%), #f3f5fa; }
.login-card { width: min(430px, calc(100vw - 32px)); padding: 36px; border: 1px solid #e0e3ec; border-radius: 20px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(26,34,65,.13); text-align: center; }
.login-card .brand-mark { margin: 0 auto 19px; }
.login-card p { color: var(--muted); line-height: 1.55; }
.login-button { width: 100%; margin: 14px 0 12px; }
.google-signin { min-height: 44px; margin: 18px auto 4px; display: flex; justify-content: center; }
.login-card > small { color: var(--muted); font-size: 10px; }
.form-message { padding: 11px; border-radius: 9px; font-size: 11px; }
.form-message.error { color: var(--danger); background: var(--danger-soft); }

#blazor-error-ui { display: none; position: fixed; z-index: 1000; inset: auto 12px 12px 12px; padding: 12px 16px; border-radius: 10px; color: #fff; background: #9e263c; box-shadow: var(--shadow); }
#blazor-error-ui .reload { color: #fff; margin-left: 8px; }
#blazor-error-ui .dismiss { float: right; border: 0; color: #fff; background: transparent; }


.consultation-notice { justify-content: space-between; }
.consultation-notice > div { min-width: 0; display: grid; gap: 3px; }
.consultation-notice .text-link { flex: 0 0 auto; }
.ynex-pagination { min-height: 72px; padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); background: #fff; }
.ynex-pagination p { margin: 0; color: var(--muted); font-size: 11px; }
.ynex-pagination p strong { color: var(--ink); }
.pagination-controls { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.pagination-button { width: 40px; min-width: 40px; height: 40px; padding: 0; display: grid; place-items: center; border: 1px solid #e0e4ec; border-radius: 8px; color: #48516b; background: #fff; font: inherit; font-size: 12px; font-weight: 750; cursor: pointer; }
.pagination-button:hover:not(:disabled) { color: var(--primary); border-color: #bcb5f3; background: #f7f5ff; }
.pagination-button.active { color: #fff; border-color: var(--primary); background: var(--primary); box-shadow: 0 4px 10px rgba(91,80,214,.2); }
.pagination-button:disabled { color: #b9bfcd; background: #f7f8fa; cursor: not-allowed; }
.pagination-gap { width: 24px; display: grid; place-items: center; color: #969eb1; }
.consultation-editor-modal { position: fixed; inset: 0 0 0 auto; z-index: 81; width: min(460px,100vw); display: flex; flex-direction: column; background: #fff; box-shadow: -14px 0 40px rgba(20,26,54,.2); animation: slideIn .2s ease-out; }
.consultation-editor-modal .drawer-header { flex: 0 0 auto; margin: 0; padding: 22px; border-bottom: 1px solid var(--line); }
.consultation-editor-modal .drawer-header p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.consultation-editor-body { min-height: 0; flex: 1; padding: 22px; display: grid; align-content: start; gap: 16px; overflow-y: auto; }
.manual-consultation-info { padding: 13px; display: grid; gap: 4px; border: 1px solid #ddd9fb; border-radius: 10px; color: #49418e; background: #f8f7ff; }
.manual-consultation-info strong { font-size: 11px; }
.manual-consultation-info span { color: #696483; font-size: 10px; line-height: 1.5; }
.consultation-editor-actions { flex: 0 0 auto; padding: 14px 22px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); background: #fff; }
@media (max-width: 1280px) {
    .dashboard-grid { grid-template-columns: minmax(0,1fr); }
    .activity-panel .activity-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); column-gap: 20px; }
    .filter-grid { grid-template-columns: minmax(220px,1.4fr) repeat(2,minmax(130px,.8fr)); }
    .filter-actions { grid-column: 2 / 4; justify-content: end; }
}

@media (max-width: 1024px) {
    .side-nav, .side-nav.is-collapsed { width: 236px; transform: translateX(-100%); box-shadow: 16px 0 36px rgba(13,18,40,.24); }
    .side-nav.is-open { transform: translateX(0); }
    .side-nav.is-collapsed .brand { padding: 0 16px 0 22px; justify-content: flex-start; gap: 12px; }
    .side-nav.is-collapsed .brand-copy, .side-nav.is-collapsed .nav-label, .side-nav.is-collapsed .nav-section, .side-nav.is-collapsed .side-footer span { display: block; }
    .side-nav.is-collapsed nav { padding: 17px 12px; }
    .side-nav.is-collapsed nav a { padding: 0 12px; justify-content: flex-start; }
    .side-nav.is-collapsed nav a > span:first-child { width: 20px; font-size: 18px; }
    .side-nav.is-collapsed nav a b { position: static; min-width: 21px; height: 21px; margin-left: auto; font-size: 10px; }
    .scrim { display: block; }
    .portal-main, .portal-main.drawer-collapsed { margin-left: 0; }
    .menu-button { display: grid; }
    .desktop-drawer-button { display: none; }
    .page-content { padding: 28px 24px 48px; }
    .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .portal-results { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 768px) {
    body { font-size: 13px; }
    .topbar { height: 64px; padding: 0 12px; gap: 8px; }
    .global-search { flex: 1; width: auto; min-width: 0; }
    .health-pill { width: 40px; padding: 0; justify-content: center; }
    .health-pill > span:last-child { display: none; }
    .profile-button { border: 0; padding: 3px; }
    .profile-copy, .profile-button > span:last-child { display: none; }
    .page-content { padding: 20px 14px calc(88px + env(safe-area-inset-bottom)); }
    .page-heading { margin-bottom: 16px; flex-direction: column; gap: 12px; }
    .attention-grid { grid-template-columns: minmax(0,1fr); }
    .metrics-grid { gap: 10px; margin-bottom: 14px; }
    .metric-card { min-height: 102px; padding: 13px; }
    .metric-copy strong { font-size: 23px; }
    .metric-icon { width: 36px; height: 36px; border-radius: 50%; }
    .metric-copy small { display: none; }
    .dashboard-grid { gap: 14px; }
    .chart-shell { height: 230px; padding-left: 0; }
    .activity-panel .activity-list { display: block; }
    .panel-heading { padding: 14px; }
    .system-alert { align-items: flex-start; flex-direction: column; gap: 3px; }
    .system-alert strong { white-space: normal; }
    .filter-panel { padding: 14px; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-actions { grid-column: auto; }
    .filter-actions > * { flex: 1; }
    .desktop-table { display: none; }
    .mobile-cards { display: block; padding: 0 14px 8px; }
    .ynex-pagination { align-items: flex-start; flex-direction: column; gap: 10px; }
    .pagination-controls { width: 100%; justify-content: center; }
    .pagination-button { width: 44px; min-width: 44px; height: 44px; }
    .detail-meta { grid-template-columns: 1fr; }
    .detail-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
    .retry-box { align-items: stretch; flex-direction: column; }
    .evidence-list b { display: none; }
    .page-heading .heading-actions { width: 100%; flex-wrap: wrap; }
    .page-heading .heading-actions > * { width: auto; }
    .page-heading .heading-actions > .primary-button { width: 100%; }
    .page-heading .heading-actions .breadcrumb { min-width: 0; flex: 1; }
    .page-heading .heading-actions .refresh-button { width: 44px; flex: 0 0 44px; }
    .mobile-nav { position: fixed; inset: auto 0 0 0; z-index: 24; min-height: calc(64px + env(safe-area-inset-bottom)); padding: 7px 10px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(12px); box-shadow: 0 -5px 22px rgba(26,34,65,.08); }
    .mobile-nav a, .mobile-nav button { min-height: 50px; padding: 4px; border: 0; border-radius: 9px; background: transparent; color: #757e97; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 9px; text-decoration: none; font-weight: 700; }
    .mobile-nav a > span, .mobile-nav button > span { font-size: 19px; line-height: 1; }
    .mobile-nav a.active { color: var(--primary); background: var(--primary-soft); }
    .mobile-alert { position: relative; }
    .mobile-alert b { position: absolute; top: -7px; right: -12px; min-width: 17px; height: 17px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--danger); font-size: 8px; }
    .toast-message { bottom: calc(78px + env(safe-area-inset-bottom)); right: 16px; }
}

@media (max-width: 430px) {
    h1 { font-size: 1.65rem; }
    .topbar .menu-button { width: 40px; height: 40px; }
    .global-search { height: 40px; padding: 0 10px; }
    .global-search input::placeholder { font-size: 11px; }
    .profile-button { display: none; }
    .page-heading p { font-size: 11px; }
    .metrics-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .metric-card { min-height: 92px; }
    .metric-label { font-size: 10px; }
    .metric-copy strong { font-size: 21px; }
    .metric-icon { width: 31px; height: 31px; font-size: 16px; }
    .attention-panel .panel-heading, .results-panel .panel-heading { align-items: flex-start; }
    .panel-heading .button-link { min-height: 38px; padding: 0 10px; font-size: 10px; }
    .consultation-title { align-items: flex-start; flex-direction: column; gap: 4px; }
    .chart-panel .panel-heading { align-items: flex-start; }
    .technical-details dl > div { grid-template-columns: 86px 1fr; }
    .login-card { padding: 28px 20px; }
    .permission-summary { padding: 14px; align-items: flex-start; }
    .user-editor-modal, .consultation-editor-modal { width: 100%; }
    .user-editor-modal .drawer-header, .consultation-editor-modal .drawer-header { padding: 18px 16px; }
    .user-editor-body, .consultation-editor-body { padding: 16px; }
    .user-editor-actions, .consultation-editor-actions { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
    .user-editor-actions > *, .consultation-editor-actions > * { flex: 1; padding-left: 10px; padding-right: 10px; }
    .ynex-pagination { padding: 13px 14px; }
    .pagination-controls { gap: 4px; }
    .pagination-gap { display: none; }
    .pagination-button.page-edge { display: none; }
    .consultation-notice { align-items: stretch; }
    .consultation-notice .text-link { min-height: 40px; display: inline-flex; align-items: center; }
}

@media (max-width: 360px) {
    .page-content { padding-left: 10px; padding-right: 10px; }
    .metrics-grid { gap: 7px; }
    .metric-card { padding: 11px 9px; }
    .metric-icon { display: none; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
