: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) 1fr 52px 212px; 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; }
.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 { 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 { overflow: hidden; }
.administration-welcome { align-items: center; }
.directory-summary { min-width: 120px; padding: 14px 18px; 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-filters { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(190px, 1fr) minmax(170px, .8fr) 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, .access-matrix 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, .access-matrix 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; }
.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 { color: var(--danger); background: var(--danger-soft); border-color: #d8a19c; }
.matrix-wrap { max-width: 100%; }
.access-matrix th, .access-matrix td { min-width: 180px; }
.access-matrix th:first-child, .access-matrix td:first-child { position: sticky; left: 0; z-index: 2; min-width: 220px; background: var(--surface); box-shadow: 1px 0 var(--border); }
.access-matrix th:first-child { z-index: 3; background: #fafbf9; }
.access-matrix select { width: 100%; min-width: 150px; }
.matrix-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 16px 22px; background: var(--surface-muted); border-top: 1px solid var(--border); }
.matrix-actions p { color: var(--muted); font-size: 12px; }
.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) 24px 52px 190px; }
  .app-shell { grid-template-columns: 220px minmax(0, 1fr); }
  .brand { padding-inline: 16px; }
  .directory-filters { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
}

@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; }
}

@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; }
  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; }
}
