:root {
  --primary: #287457;
  --primary-dark: #205e47;
  --ink: #17211b;
  --muted: #637067;
  --background: #f6f7f4;
  --surface: #ffffff;
  --surface-muted: #f1f3f0;
  --border: #b9c3bb;
  --border-soft: #dbe1dc;
  --sidebar: #18261f;
  --sidebar-surface: #2a4034;
  --sidebar-text: #f4f6f2;
  --success: #247650;
  --success-soft: #dceee3;
  --warning: #825100;
  --warning-soft: #f8e8c8;
  --danger: #ac382f;
  --danger-soft: #f5dad6;
  --critical: #7b2025;
  --critical-soft: #ecd2d5;
  --shadow: 0 8px 24px rgba(23, 33, 27, 0.07);
  --focus: 0 0 0 3px rgba(40, 116, 87, 0.3);
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--background); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { letter-spacing: -0.015em; }
button, a, input { border-radius: 4px; }
:focus-visible { outline: 0; box-shadow: var(--focus); }
[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; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; line-height: 1.2; text-transform: uppercase; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); grid-template-rows: 68px minmax(0, 1fr); }
.topbar { grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; display: grid; grid-template-columns: 252px minmax(260px, 620px) minmax(16px, 1fr) 52px clamp(360px, 28vw, 420px); align-items: center; min-height: 68px; color: var(--sidebar-text); background: var(--sidebar); border-bottom: 1px solid rgba(255,255,255,.13); }
.brand { height: 68px; display: flex; align-items: center; gap: 12px; padding: 0 20px; border-right: 1px solid rgba(255,255,255,.13); font-size: 16px; font-weight: 700; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; color: #fff; background: var(--primary); border: 1px solid rgba(255,255,255,.22); font-size: 12px; font-weight: 800; letter-spacing: .04em; }
.global-search { position: relative; display: block; margin-left: 22px; }
.global-search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: rgba(255,255,255,.7); pointer-events: none; }
.global-search input { width: 100%; height: 42px; padding: 0 14px 0 43px; color: #fff; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.22); }
.global-search input::placeholder { color: rgba(255,255,255,.62); }
.global-search input:focus { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.7); box-shadow: 0 0 0 3px rgba(255,255,255,.14); }
.topbar-spacer { min-width: 16px; }
.icon-button { position: relative; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; color: inherit; background: transparent; border: 0; cursor: pointer; }
.icon-button:hover { background: rgba(255,255,255,.1); }
.notice-dot { position: absolute; top: 3px; right: 1px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 4px; color: var(--ink); background: #f0b24a; border: 2px solid var(--sidebar); border-radius: 999px; font-size: 10px; font-weight: 800; }
.profile-button { height: 68px; display: flex; align-items: center; gap: 11px; min-width: 0; padding: 0 18px; color: inherit; text-align: left; background: transparent; border: 0; border-left: 1px solid rgba(255,255,255,.13); cursor: pointer; }
.profile-logout { min-width: 0; height: 68px; margin: 0; }
.profile-logout .profile-button { width: 100%; }
.profile-button:hover { background: rgba(255,255,255,.07); }
.avatar { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; color: var(--sidebar); background: #fff; border-radius: 50%; font-size: 12px; font-weight: 800; }
.profile-copy { min-width: 0; display: block; }
.profile-name, .profile-role { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-name { font-size: 14px; font-weight: 700; }
.profile-role { margin-top: 1px; color: rgba(255,255,255,.62); font-size: 12px; }

.sidebar { grid-column: 1; position: sticky; top: 68px; align-self: start; height: calc(100vh - 68px); display: flex; flex-direction: column; color: var(--sidebar-text); background: var(--sidebar); border-right: 1px solid rgba(0,0,0,.2); }
.nav-list { padding: 18px 12px; overflow-y: auto; }
.nav-item { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin-bottom: 3px; color: rgba(244,246,242,.78); font-size: 14px; font-weight: 600; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav-item.is-active { color: #fff; background: var(--primary); }
.nav-item svg { width: 19px; height: 19px; }
.nav-bullet { width: 7px; height: 7px; margin-left: 6px; margin-right: 6px; flex: 0 0 auto; background: #81ad97; border-radius: 50%; }
.nav-heading { margin: 26px 12px 8px; color: rgba(244,246,242,.42); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.nav-empty { display: block; padding: 10px 12px; color: rgba(244,246,242,.52); font-size: 13px; }
.sidebar-footer { margin-top: auto; min-height: 74px; display: flex; align-items: center; gap: 11px; padding: 15px 20px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer span:last-child { min-width: 0; }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer strong { font-size: 12px; }
.sidebar-footer small { margin-top: 2px; color: rgba(244,246,242,.54); font-size: 11px; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; background: #65c890; border-radius: 50%; box-shadow: 0 0 0 4px rgba(101,200,144,.12); }

.main-content { grid-column: 2; min-width: 0; padding: 36px clamp(24px, 3vw, 48px) 56px; }
.service-messages { max-width: 1500px; margin: 0 auto 14px; }
.service-message { padding: 11px 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); }
.service-message-success { color: var(--success); background: var(--success-soft); }
.service-message-error { color: var(--danger); background: var(--danger-soft); }
.welcome { max-width: 1440px; display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin: 0 auto 30px; padding-bottom: 30px; border-bottom: 1px solid var(--border); }
.welcome h1 { margin-top: 8px; font-size: clamp(32px, 3vw, 40px); line-height: 1.16; }
.welcome-copy { max-width: 680px; margin-top: 10px; color: var(--muted); font-size: 16px; }
.attention-summary { min-width: 280px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; padding: 14px 16px; background: var(--warning-soft); border: 1px solid #deb66d; border-left: 4px solid var(--warning); }
.attention-summary:hover { border-color: var(--warning); }
.attention-summary strong, .attention-summary small { display: block; }
.attention-summary strong { font-size: 14px; }
.attention-summary small { margin-top: 2px; color: #71531d; font-size: 12px; }
.attention-number { font-size: 28px; font-weight: 750; line-height: 1; }
.attention-summary.is-clear { background: var(--success-soft); border-color: #9bc8ad; border-left-color: var(--success); }
.attention-check { width: 32px; height: 32px; display: grid; place-items: center; color: #fff; background: var(--success); border-radius: 50%; font-weight: 800; }

.section-block { width: 100%; min-width: 0; max-width: 1440px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.section-heading { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.section-heading h2 { margin-top: 5px; font-size: 22px; line-height: 1.25; }
.section-count { padding: 6px 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 700; }
.section-heading-compact { min-height: 74px; }
.service-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.service-card { position: relative; min-height: 258px; display: flex; flex-direction: column; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--success); }
.service-card.state-attention { border-left-color: var(--warning); }
.service-card.state-development { border-left-color: #6d7f9e; }
.service-card.state-unavailable { border-left-color: var(--danger); }
.service-card:hover { border-top-color: var(--primary); border-right-color: var(--primary); border-bottom-color: var(--primary); box-shadow: 0 5px 16px rgba(23,33,27,.08); }
.service-topline { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.service-state { color: var(--success); }
.state-attention .service-state { color: var(--warning); }
.state-development .service-state { color: #53698e; }
.state-unavailable .service-state { color: var(--danger); }
.service-icon { width: 42px; height: 42px; display: grid; place-items: center; margin-top: 22px; color: var(--primary); background: var(--success-soft); border: 1px solid #a8cdb7; }
.service-icon svg { width: 22px; height: 22px; }
.service-card h3 { margin-top: 15px; font-size: 18px; line-height: 1.25; }
.service-card > p { margin-top: 7px; color: var(--muted); font-size: 14px; }
.service-meta { margin-top: 13px; padding-top: 10px; color: var(--muted); border-top: 1px solid var(--border-soft); font-size: 12px; font-weight: 600; }
.service-link { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 13px; color: var(--primary); font-size: 14px; font-weight: 750; }
.service-link:hover { color: var(--primary-dark); }
.service-link.is-disabled { color: var(--muted); }
.empty-state { grid-column: 1 / -1; min-height: 160px; display: grid; place-items: center; align-content: center; gap: 4px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font-size: 17px; }
.search-empty { margin: 0 18px 18px; padding: 24px; color: var(--muted); background: var(--surface-muted); border: 1px dashed var(--border); text-align: center; }

.work-layout { max-width: 1440px; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr); gap: 22px; margin: 22px auto 0; align-items: start; }
.queue-section, .events-section { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { height: 42px; padding: 0 16px; color: var(--muted); background: #fafbf9; border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { min-height: 60px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcf9; }
td strong, td span { display: block; }
td strong { font-size: 14px; }
td strong + span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.priority { width: max-content; padding: 4px 7px; border: 1px solid var(--border); font-size: 11px; font-weight: 750; }
.priority-attention { color: var(--warning); background: var(--warning-soft); border-color: #dfbd7d; }
.priority-critical { color: var(--critical); background: var(--critical-soft); border-color: #c99599; }
.priority-normal { color: var(--success); background: var(--success-soft); border-color: #a6cbb4; }
.row-action { width: 34px; height: 34px; display: grid; place-items: center; color: var(--primary); border: 1px solid var(--border); font-size: 18px; font-weight: 700; }
.row-action:hover { color: #fff; background: var(--primary); border-color: var(--primary); }
.table-empty { height: 112px; color: var(--muted); text-align: center; }
.event-list { padding: 4px 20px; }
.event-item { display: grid; grid-template-columns: 10px 1fr; gap: 12px; padding: 17px 0; border-bottom: 1px solid var(--border-soft); }
.event-item:last-child { border-bottom: 0; }
.event-marker { width: 8px; height: 8px; margin-top: 7px; background: var(--primary); border-radius: 50%; }
.event-item strong { display: block; font-size: 14px; }
.event-item p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.event-item small { display: block; margin-top: 7px; color: #7b857e; font-size: 11px; }
.event-empty { padding: 34px 0; color: var(--muted); text-align: center; }

.notification-popover { position: fixed; z-index: 50; top: 62px; right: 190px; width: min(350px, calc(100vw - 24px)); display: none; color: var(--ink); background: var(--surface); border: 1px solid var(--border); box-shadow: 0 12px 34px rgba(23,33,27,.18); }
.notification-popover.is-open { display: block; }
.notification-popover header { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.notification-popover header button { width: 32px; height: 32px; background: transparent; border: 0; font-size: 22px; cursor: pointer; }
.notification-popover > p { padding: 17px 14px; color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(115deg, var(--sidebar) 0 38%, var(--background) 38% 100%); }
.login-panel { width: min(460px, 100%); padding: 38px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 20px 60px rgba(8,20,14,.2); }
.login-brand { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 28px; color: #fff; background: var(--primary); font-size: 13px; font-weight: 800; }
.login-panel h1 { margin-top: 8px; font-size: 36px; line-height: 1.16; }
.login-lead { margin-top: 12px; color: var(--muted); font-size: 16px; }
.login-form { display: grid; gap: 9px; margin-top: 28px; }
.login-form label { margin-top: 7px; font-size: 13px; font-weight: 750; }
.login-form input { height: 44px; padding: 0 12px; color: var(--ink); background: #fff; border: 1px solid var(--border); }
.login-form input:focus { border-color: var(--primary); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 18px; border: 1px solid transparent; font-weight: 750; cursor: pointer; }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--border); }
.button-secondary:hover { color: var(--primary-dark); border-color: var(--primary); }
.button-wide { width: 100%; margin-top: 20px; }
.login-note { margin-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }
.form-error { padding: 10px 12px; color: var(--danger); background: var(--danger-soft); border: 1px solid #d8a19c; }
.form-error ul { margin: 0; padding-left: 18px; }

.administration-context { margin-left: 22px; color: rgba(255,255,255,.7); font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.profile-static { cursor: default; }
.administration-content { min-width: 0; max-width: 100%; overflow: hidden; }
.administration-welcome { align-items: center; }
.directory-summaries { display: flex; align-items: stretch; gap: 8px; }
.directory-summary { min-width: 112px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); text-align: center; }
.directory-summary strong, .directory-summary span { display: block; }
.directory-summary strong { font-size: 28px; line-height: 1; }
.directory-summary span { margin-top: 5px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.directory-summary-success { background: var(--success-soft); border-color: #a6cbb4; }
.directory-summary-success strong { color: var(--success); }
.directory-summary-warning { background: var(--warning-soft); border-color: #dfbd7d; }
.directory-summary-warning strong { color: var(--warning); }
.directory-filters { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(160px, .8fr) minmax(170px, .9fr) auto auto; align-items: end; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.directory-filters label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.directory-filters input, .directory-filters select { height: 42px; padding: 0 11px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.directory-filters input:focus, .directory-filters select:focus { border-color: var(--primary); outline: 0; box-shadow: var(--focus); }
.directory-table td { min-width: 150px; }
.directory-table td:first-child { min-width: 220px; }
.authentication-cell time, .authentication-cell small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; padding: 3px 7px; color: var(--primary-dark); background: var(--success-soft); border: 1px solid #a6cbb4; font-size: 11px; font-weight: 700; }
.muted { color: var(--muted); }
.status-badge { display: inline-flex; width: max-content; padding: 4px 7px; border: 1px solid var(--border); font-size: 11px; font-weight: 750; }
.status-active, .status-success { color: var(--success); background: var(--success-soft); border-color: #a6cbb4; }
.status-suspended, .status-warning { color: var(--warning); background: var(--warning-soft); border-color: #dfbd7d; }
.status-terminated, .status-deny { color: var(--danger); background: var(--danger-soft); border-color: #d8a19c; }
.status-view { color: #355c7d; background: #e1edf6; border-color: #a9c3d6; }
.status-edit { color: var(--warning); background: var(--warning-soft); border-color: #dfbd7d; }
.status-manage { color: var(--success); background: var(--success-soft); border-color: #a6cbb4; }
.matrix-welcome { max-width: 1260px; margin-bottom: 20px; padding-bottom: 22px; }
.matrix-welcome .welcome-copy { max-width: 760px; }
.matrix-mode-tabs { width: 100%; max-width: 1260px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 0 auto 12px; }
.matrix-mode-tab { min-width: 0; min-height: 60px; display: flex; align-items: center; gap: 11px; padding: 9px 14px; color: var(--muted); text-align: left; background: var(--surface); border: 1px solid var(--border); }
.matrix-mode-tab:hover { color: var(--ink); border-color: var(--primary); }
.matrix-mode-tab.is-active { color: var(--ink); background: var(--success-soft); border-color: var(--primary); box-shadow: inset 0 -3px var(--primary); }
.matrix-mode-icon { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; color: var(--primary); background: var(--surface); border: 1px solid #a6cbb4; font-size: 16px; font-weight: 800; }
.matrix-mode-tab > span:last-child { min-width: 0; }
.matrix-mode-tab strong, .matrix-mode-tab small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-mode-tab strong { font-size: 13px; }
.matrix-mode-tab small { margin-top: 1px; font-size: 12px; }

.matrix-workspace { width: 100%; max-width: 1260px; min-width: 0; display: grid; grid-template-columns: 280px minmax(0, 1fr); margin: 0 auto; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: clip; }
.matrix-subject-pane { min-width: 0; display: flex; flex-direction: column; background: #fafbf9; border-right: 1px solid var(--border); }
.matrix-pane-head, .matrix-detail-head { min-width: 0; min-height: 74px; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.matrix-pane-head { justify-content: space-between; }
.matrix-pane-head h2, .matrix-detail-head h2 { margin-top: 3px; font-size: 20px; line-height: 1.2; }
.matrix-icon-action, .matrix-dialog-close { width: 40px; height: 40px; flex: 0 0 auto; padding: 0; color: var(--primary); background: var(--surface); border: 1px solid var(--border); font-size: 22px; cursor: pointer; }
.matrix-icon-action:hover, .matrix-dialog-close:hover { border-color: var(--primary); }
.matrix-search { position: relative; display: block; margin: 12px; }
.matrix-search > span:first-child { position: absolute; left: 12px; top: 8px; color: var(--muted); font-size: 20px; line-height: 1; pointer-events: none; }
.matrix-search input { width: 100%; height: 42px; padding: 0 10px 0 36px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); }
.matrix-search input:focus { border-color: var(--primary); outline: 0; box-shadow: var(--focus); }
.matrix-subject-list { min-height: 350px; max-height: 540px; overflow-y: auto; overflow-x: clip; padding: 0 8px 8px; scrollbar-width: thin; }
.matrix-subject { width: 100%; min-width: 0; min-height: 64px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 9px; margin-bottom: 4px; padding: 9px 10px; color: var(--ink); text-align: left; background: transparent; border: 1px solid transparent; cursor: pointer; }
.matrix-subject:hover { background: var(--surface); border-color: var(--border-soft); }
.matrix-subject.is-active { background: var(--surface); border-color: var(--primary); box-shadow: inset 3px 0 var(--primary); }
.matrix-subject > span:first-child { min-width: 0; }
.matrix-subject strong, .matrix-subject small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-subject strong { font-size: 13px; }
.matrix-subject small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.matrix-subject-badge { min-width: 30px; min-height: 26px; display: grid; place-items: center; padding: 0 6px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--border-soft); font-size: 11px; font-weight: 750; }
.matrix-subject-badge.is-system { color: var(--warning); background: var(--warning-soft); border-color: #dfbd7d; }
.matrix-subject-badge.is-disabled { color: var(--danger); background: var(--danger-soft); border-color: #d8a19c; }
.matrix-search-empty { padding: 16px 10px; color: var(--muted); font-size: 13px; }
.matrix-list-foot { min-height: 45px; margin-top: auto; padding: 13px 16px; color: var(--muted); background: var(--surface-muted); border-top: 1px solid var(--border); font-size: 12px; }

.matrix-detail-pane { min-width: 0; display: flex; flex-direction: column; }
.matrix-detail-panel { min-width: 0; }
.matrix-selected-mark { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--primary); font-size: 12px; font-weight: 800; }
.matrix-detail-title { min-width: 0; }
.matrix-detail-title h2, .matrix-detail-title > p:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-detail-title > p:last-child { margin-top: 3px; color: var(--muted); font-size: 12px; }
.matrix-detail-head > .status-badge { flex: 0 0 auto; margin-left: auto; }
.matrix-context-strip { min-width: 0; min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 16px; color: var(--muted); background: #f7faf8; border-bottom: 1px solid var(--border); font-size: 12px; }
.matrix-context-strip strong { color: var(--ink); }
.matrix-context-strip.is-warning { color: #71531d; background: var(--warning-soft); }
.matrix-context-strip.is-warning strong { color: var(--warning); }
.matrix-context-strip .tag-list { min-width: 0; justify-content: flex-end; }
.matrix-service-list, .matrix-member-list { min-width: 0; }
.matrix-service-row { min-width: 0; display: grid; grid-template-columns: minmax(190px, .8fr) minmax(390px, 1.35fr); align-items: center; gap: 16px; min-height: 82px; padding: 11px 16px; border-bottom: 1px solid var(--border-soft); }
.matrix-service-row:hover, .matrix-member-row:hover { background: #fafcf9; }
.matrix-service-info { min-width: 0; display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: center; gap: 10px; }
.matrix-service-mark { width: 36px; height: 36px; display: grid; place-items: center; color: var(--primary-dark); background: var(--success-soft); border: 1px solid #a6cbb4; font-size: 11px; font-weight: 800; }
.matrix-service-info > span:last-child { min-width: 0; }
.matrix-service-info strong, .matrix-service-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-service-info strong { font-size: 13px; }
.matrix-service-info small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.matrix-inline-status { display: inline-flex; margin-top: 5px; padding: 2px 5px; color: var(--primary-dark); background: var(--success-soft); border: 1px solid #a6cbb4; font-size: 11px; font-weight: 700; }
.matrix-control-stack { min-width: 0; }
.matrix-level-control { min-width: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: 2px; background: var(--surface-muted); border: 1px solid var(--border); border-radius: 5px; }
.matrix-level-control.is-personal { grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr)); }
.matrix-level-option { position: relative; min-width: 0; min-height: 42px; display: block; color: var(--muted); cursor: pointer; }
.matrix-level-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.matrix-level-option span { min-width: 0; min-height: 42px; display: grid; place-items: center; padding: 4px 5px; border-right: 1px solid var(--border-soft); border-radius: 3px; font-size: 11px; font-weight: 750; line-height: 1.2; text-align: center; }
.matrix-level-option:last-child span { border-right: 0; }
.matrix-level-option:hover span { color: var(--ink); background: var(--surface); }
.matrix-level-option input:focus-visible + span { position: relative; z-index: 1; box-shadow: var(--focus); }
.matrix-level-option input:checked + span { color: #fff; background: var(--primary); }
.matrix-level-option[data-level="deny"] input:checked + span { background: var(--danger); }
.matrix-level-option[data-level="none"] input:checked + span { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.matrix-level-option[data-level="inherit"] input:checked + span { color: var(--primary-dark); background: var(--success-soft); box-shadow: inset 0 0 0 1px #9bc8ad; }
.matrix-effective-line { min-width: 0; min-height: 25px; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.matrix-effective-line > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.matrix-effective-line strong { color: var(--ink); }
.matrix-effective-badge { flex: 0 0 auto; padding: 2px 6px; border: 1px solid var(--border); font-size: 11px; font-weight: 750; white-space: nowrap; }
.control-note { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.control-note-warning { color: var(--warning); }
.locked-access { min-height: 58px; padding: 10px; color: var(--success); background: var(--success-soft); border: 1px solid #a6cbb4; }
.locked-access strong, .locked-access span { display: block; }
.locked-access span { margin-top: 3px; font-size: 12px; }

.matrix-member-row { min-width: 0; min-height: 70px; display: grid; grid-template-columns: minmax(180px, 1fr) auto; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--border-soft); }
.matrix-member-copy { min-width: 0; }
.matrix-member-copy strong, .matrix-member-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-member-copy strong { font-size: 13px; }
.matrix-member-copy small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.matrix-membership-toggle { position: relative; min-width: 132px; min-height: 42px; display: flex; align-items: center; gap: 8px; padding: 5px 9px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--border); cursor: pointer; }
.matrix-membership-toggle:hover { color: var(--primary-dark); border-color: var(--primary); }
.matrix-membership-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.matrix-membership-toggle:has(input:focus-visible) { box-shadow: var(--focus); }
.matrix-switch { position: relative; width: 32px; height: 19px; flex: 0 0 auto; background: #89958c; border-radius: 999px; }
.matrix-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 13px; height: 13px; background: #fff; border-radius: 50%; transition: transform .16s ease; }
.matrix-membership-toggle:has(input:checked) { color: var(--primary-dark); background: var(--success-soft); border-color: #9bc8ad; }
.matrix-membership-toggle input:checked + .matrix-switch { background: var(--primary); }
.matrix-membership-toggle input:checked + .matrix-switch::after { transform: translateX(13px); }
.matrix-membership-toggle [data-membership-label] { font-size: 12px; font-weight: 750; white-space: nowrap; }
.matrix-capability-control { margin: 8px 0 0; padding: 9px 10px; background: #f7faf8; border: 1px solid var(--border-soft); }
.matrix-capability-control legend { padding: 0 4px; color: var(--ink); font-size: 11px; font-weight: 750; }
.matrix-capability-control > small { display: block; margin-top: 7px; color: var(--muted); font-size: 11px; }
.matrix-capability-list { display: flex; flex-wrap: wrap; gap: 7px; }
.matrix-capability-toggle { position: relative; min-height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 5px 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.matrix-capability-toggle:hover { color: var(--primary-dark); border-color: var(--primary); }
.matrix-capability-toggle > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.matrix-capability-toggle:has(input:focus-visible) { box-shadow: var(--focus); }
.matrix-capability-toggle:has(input:checked) { color: var(--primary-dark); background: var(--success-soft); border-color: #9bc8ad; }
.matrix-capability-toggle input:checked + .matrix-switch { background: var(--primary); }
.matrix-capability-toggle input:checked + .matrix-switch::after { transform: translateX(13px); }
.matrix-capability-toggle > span:last-child { font-size: 12px; font-weight: 750; }
.matrix-personal-capabilities { margin-top: 8px; padding: 9px 10px; background: #f7faf8; border: 1px solid var(--border-soft); }
.matrix-personal-capabilities > p { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.matrix-personal-capabilities > p strong, .matrix-personal-capabilities > p small { font-size: 11px; }
.matrix-personal-capabilities > p small { color: var(--muted); font-weight: 400; }
.matrix-capability-override { display: grid; grid-template-columns: minmax(150px, 1fr) repeat(3, minmax(86px, auto)) minmax(105px, auto); align-items: center; gap: 4px; margin: 0; padding: 6px 0; border: 0; border-top: 1px solid var(--border-soft); }
.matrix-capability-override legend { display: contents; }
.matrix-capability-override legend strong, .matrix-capability-override legend span { grid-column: 1; }
.matrix-capability-override legend strong { align-self: end; font-size: 12px; }
.matrix-capability-override legend span { align-self: start; color: var(--muted); font-size: 10px; }
.matrix-capability-override label { position: relative; min-height: 36px; display: grid; place-items: center; cursor: pointer; }
.matrix-capability-override label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.matrix-capability-override label span { width: 100%; min-height: 36px; display: grid; place-items: center; padding: 3px 6px; color: var(--muted); background: var(--surface); border: 1px solid var(--border-soft); font-size: 10px; font-weight: 750; text-align: center; }
.matrix-capability-override label:hover span { color: var(--ink); border-color: var(--primary); }
.matrix-capability-override label input:focus-visible + span { box-shadow: var(--focus); }
.matrix-capability-override label input:checked + span { color: #fff; background: var(--primary); border-color: var(--primary); }
.matrix-capability-override label:last-of-type input:checked + span { background: var(--danger); border-color: var(--danger); }
.matrix-capability-result { color: var(--muted); font-size: 11px; text-align: right; }

.matrix-save-bar { position: sticky; bottom: 0; z-index: 5; min-width: 0; min-height: 70px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; margin-top: auto; padding: 10px 16px; background: rgba(241, 243, 240, .97); border-top: 1px solid var(--border); backdrop-filter: blur(6px); }
.matrix-save-bar p { min-width: 0; }
.matrix-save-bar p strong, .matrix-save-bar p small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix-save-bar p strong { font-size: 12px; }
.matrix-save-bar p strong.is-dirty { color: var(--warning); }
.matrix-save-bar p small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.matrix-save-bar .button { min-height: 42px; }

.matrix-dialog { width: min(480px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 5px; box-shadow: 0 18px 60px rgba(8, 20, 14, .25); }
.matrix-dialog::backdrop { background: rgba(15, 28, 20, .55); }
.matrix-dialog form > header { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.matrix-dialog h2 { margin-top: 4px; font-size: 20px; }
.matrix-dialog label { display: grid; gap: 6px; margin: 20px 20px 10px; font-size: 12px; font-weight: 750; }
.matrix-dialog input { width: 100%; height: 42px; padding: 0 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--border); }
.matrix-dialog input:focus { border-color: var(--primary); outline: 0; box-shadow: var(--focus); }
.matrix-dialog form > p { margin: 0 20px 20px; color: var(--muted); font-size: 12px; }
.matrix-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--surface-muted); border-top: 1px solid var(--border); }
.message-stack { max-width: 1440px; margin: 0 auto 18px; }
.message { padding: 12px 14px; border: 1px solid var(--border); }
.message-success { color: var(--success); background: var(--success-soft); border-color: #a6cbb4; }
.message-error { color: var(--danger); background: var(--danger-soft); border-color: #d8a19c; }

@media (max-width: 1180px) {
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .work-layout { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: 220px minmax(240px, 1fr) minmax(16px, 24px) 52px minmax(350px, 36vw); }
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .brand { padding-inline: 16px; }
  .directory-filters { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
  .matrix-workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .matrix-service-row { display: block; min-height: 0; padding: 14px; }
  .matrix-control-stack { margin-top: 10px; }
  .matrix-service-info strong, .matrix-service-info small { white-space: normal; }
}

@media (max-width: 880px) and (min-width: 821px) {
  .topbar { grid-template-columns: 220px minmax(240px, 1fr) 16px 52px 240px; }
  .profile-role { display: none; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .topbar { position: sticky; display: grid; grid-template-columns: 1fr 48px 52px; min-height: 60px; }
  .brand { height: 60px; border: 0; }
  .global-search { grid-column: 1 / -1; grid-row: 2; margin: 0; padding: 9px 14px; background: var(--sidebar-surface); }
  .global-search svg { left: 28px; }
  .global-search input { height: 40px; padding-left: 43px; }
  .topbar-spacer, .profile-copy { display: none; }
  .profile-button { min-width: 52px; height: 60px; padding: 0 8px; border-left: 1px solid rgba(255,255,255,.13); }
  .avatar { width: 34px; height: 34px; }
  .sidebar { position: static; height: auto; display: block; overflow-x: auto; border: 0; border-top: 1px solid rgba(255,255,255,.1); }
  .nav-list { display: flex; gap: 4px; padding: 9px 12px; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; margin: 0; }
  .nav-heading, .nav-empty, .sidebar-footer { display: none; }
  .main-content { padding: 26px 16px 42px; }
  .welcome { display: block; margin-bottom: 20px; padding-bottom: 22px; }
  .attention-summary { min-width: 0; margin-top: 20px; }
  .notification-popover { top: 58px; right: 12px; }
  .administration-context { grid-column: 1 / -1; grid-row: 2; min-height: 38px; display: flex; align-items: center; margin: 0; padding: 0 16px; background: var(--sidebar-surface); }
  .directory-filters { grid-template-columns: 1fr; padding: 16px; }
  .directory-summaries { margin-top: 18px; overflow-x: auto; }
  .directory-summary { flex: 1 0 112px; }
  .matrix-welcome { margin-bottom: 16px; }
  .matrix-mode-tabs { gap: 4px; }
  .matrix-mode-tab { min-height: 54px; justify-content: center; padding: 7px 5px; text-align: center; }
  .matrix-mode-icon, .matrix-mode-tab small { display: none; }
  .matrix-mode-tab strong { font-size: 12px; white-space: normal; }
  .matrix-workspace { display: block; }
  .matrix-subject-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .matrix-pane-head { min-height: 64px; }
  .matrix-subject-list { min-height: 0; max-height: 220px; }
  .matrix-list-foot { min-height: 40px; padding-block: 10px; }
  .matrix-detail-head { min-height: 70px; padding-inline: 12px; }
  .matrix-detail-head h2 { font-size: 18px; }
  .matrix-context-strip { display: block; padding: 10px 12px; }
  .matrix-context-strip > span:last-child { display: block; margin-top: 6px; }
  .matrix-context-strip .tag-list { justify-content: flex-start; }
  .matrix-service-row, .matrix-member-row { padding-inline: 12px; }
  .matrix-save-bar { grid-template-columns: minmax(0, 1fr) auto; padding: 10px 12px; }
  .matrix-save-bar .button-secondary, .matrix-save-bar p small { display: none; }
}

@media (max-width: 580px) {
  .brand span:last-child { font-size: 14px; }
  .brand-mark { width: 30px; height: 30px; }
  .welcome h1 { font-size: 31px; }
  .welcome-copy { font-size: 15px; }
  .section-heading { min-height: 72px; padding: 15px 16px; }
  .section-heading h2 { font-size: 20px; }
  .service-grid { grid-template-columns: 1fr; padding: 12px; }
  .service-card { min-height: 232px; }
  .section-count { display: none; }
  .matrix-level-control, .matrix-level-control.is-personal { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; background: transparent; border: 0; padding: 0; }
  .matrix-level-option span { min-height: 42px; background: var(--surface-muted); border: 1px solid var(--border-soft); font-size: 12px; }
  .matrix-level-control.is-personal .matrix-level-option:first-of-type { grid-column: 1 / -1; }
  .matrix-capability-list { display: grid; grid-template-columns: 1fr 1fr; }
  .matrix-capability-toggle { width: 100%; }
  .matrix-personal-capabilities > p { display: block; }
  .matrix-personal-capabilities > p small { display: block; margin-top: 3px; }
  .matrix-capability-override { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 9px 0; }
  .matrix-capability-override legend { display: block; grid-column: 1 / -1; margin-bottom: 3px; }
  .matrix-capability-override legend strong, .matrix-capability-override legend span { display: block; }
  .matrix-capability-result { grid-column: 1 / -1; text-align: left; }
  .matrix-effective-line { align-items: flex-start; }
  .matrix-member-row { display: block; }
  .matrix-member-copy strong, .matrix-member-copy small { white-space: normal; }
  .matrix-membership-toggle { width: 100%; margin-top: 10px; justify-content: center; }
  .matrix-detail-head { flex-wrap: wrap; }
  .matrix-detail-head > .status-badge { margin-left: 52px; }
  th, td { padding-inline: 12px; }
  .queue-section th:nth-child(2), .queue-section td:nth-child(2),
  .queue-section th:nth-child(3), .queue-section td:nth-child(3),
  .directory-table th:nth-child(2), .directory-table td:nth-child(2),
  .directory-table th:nth-child(3), .directory-table td:nth-child(3) { display: none; }
  .login-page { background: var(--sidebar); }
  .login-panel { padding: 28px 22px; }
  .login-panel h1 { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
