:root {
  color-scheme: light;
  --bg: #f4f8f5;
  --panel: #ffffff;
  --panel-soft: #f8fbf9;
  --ink: #13251d;
  --muted: #687b71;
  --line: #dbe6df;
  --line-strong: #c5d5cb;
  --brand: #087f5b;
  --brand-dark: #056345;
  --brand-soft: #e8f6ef;
  --brand-pale: #f1faf5;
  --amber: #b7680c;
  --amber-soft: #fff5e6;
  --red: #bd2f3b;
  --red-soft: #fff0f1;
  --blue: #2d68a3;
  --blue-soft: #edf5fc;
  --shadow: 0 18px 45px rgba(28, 60, 43, 0.09);
  --shadow-soft: 0 8px 24px rgba(28, 60, 43, 0.07);
  --radius: 18px;
  --rail-width: 270px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -15%, rgba(8, 127, 91, 0.12), transparent 34rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

.is-hidden {
  display: none !important;
}

.app-layout {
  min-height: 100vh;
}

.side-rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--rail-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  padding: 22px 16px;
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 10px 20px;
}

.brand img {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(8, 127, 91, 0.12);
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
  padding: 3px;
  box-shadow: var(--shadow-soft);
}

.brand span {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand small {
  color: var(--brand);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.side-nav {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.nav-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-height: 48px;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  padding: 10px 12px;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: 160ms ease;
}

.nav-item:hover {
  background: var(--panel-soft);
  color: var(--ink);
}

.nav-item.is-active {
  border-color: rgba(8, 127, 91, 0.14);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 700;
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.nav-count,
.count-badge {
  display: inline-flex;
  min-width: 28px;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  padding: 3px 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.rail-security-note {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  margin: auto 6px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  padding: 13px;
}

.security-pulse {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: #17a773;
  box-shadow: 0 0 0 5px rgba(23, 167, 115, 0.12);
}

.rail-security-note div {
  display: grid;
  gap: 4px;
}

.rail-security-note strong {
  font-size: 11px;
}

.rail-security-note small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 11px;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.back-link:hover {
  background: var(--panel-soft);
  color: var(--brand-dark);
}

.back-link svg {
  width: 17px;
  height: 17px;
}

.main-stage {
  min-height: 100vh;
  margin-left: var(--rail-width);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 84px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(219, 230, 223, 0.86);
  background: rgba(244, 248, 245, 0.88);
  padding: 14px clamp(18px, 3vw, 42px);
  backdrop-filter: blur(18px);
}

.page-heading {
  min-width: 0;
}

.eyebrow,
.section-kicker {
  display: block;
  color: var(--brand);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.17em;
}

.page-heading h1 {
  margin: 4px 0 2px;
  font-size: 19px;
  letter-spacing: -0.025em;
}

.page-heading p {
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.connection-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d19436;
  box-shadow: 0 0 0 4px rgba(209, 148, 54, 0.12);
}

.connection-state.is-live i {
  background: #17a773;
  box-shadow: 0 0 0 4px rgba(23, 167, 115, 0.12);
}

.connection-state.is-offline i {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(189, 47, 59, 0.12);
}

.profile-button {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.8);
  padding: 6px 10px 6px 7px;
  cursor: default;
}

.profile-avatar {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #0e966d, #056344);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.profile-copy {
  display: grid;
  max-width: 150px;
  text-align: left;
}

.profile-copy strong,
.profile-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy strong {
  font-size: 11px;
}

.profile-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
  cursor: pointer;
  transition: 150ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.mobile-menu {
  display: none;
}

.workspace,
.loading-screen,
.denied-screen {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 42px);
}

.loading-screen,
.denied-screen {
  display: flex;
  min-height: calc(100vh - 84px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.loading-screen strong {
  margin-top: 22px;
  font-size: 16px;
}

.loading-screen small {
  margin-top: 7px;
  color: var(--muted);
}

.loading-mark {
  display: flex;
  height: 42px;
  align-items: end;
  gap: 5px;
}

.loading-mark span {
  width: 8px;
  border-radius: 5px;
  background: var(--brand);
  animation: loading-bars 900ms ease-in-out infinite alternate;
}

.loading-mark span:nth-child(1) {
  height: 20px;
}

.loading-mark span:nth-child(2) {
  height: 38px;
  animation-delay: 160ms;
}

.loading-mark span:nth-child(3) {
  height: 28px;
  animation-delay: 320ms;
}

@keyframes loading-bars {
  to {
    opacity: 0.35;
    transform: scaleY(0.65);
  }
}

.denied-screen {
  max-width: 620px;
}

.denied-icon {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  margin-bottom: 22px;
  border: 1px solid #f0c9cd;
  border-radius: 24px;
  background: var(--red-soft);
  color: var(--red);
}

.denied-icon svg {
  width: 38px;
  height: 38px;
}

.denied-screen h2 {
  margin: 10px 0 8px;
  font-size: clamp(24px, 4vw, 34px);
  letter-spacing: -0.035em;
}

.denied-screen p {
  max-width: 500px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.denied-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.hero-card {
  position: relative;
  display: flex;
  min-height: 210px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  overflow: hidden;
  border: 1px solid rgba(8, 127, 91, 0.15);
  border-radius: 24px;
  background:
    radial-gradient(circle at 86% 10%, rgba(132, 230, 188, 0.34), transparent 18rem),
    linear-gradient(135deg, #f8fcf9, #eaf7f0);
  padding: clamp(24px, 4vw, 42px);
  box-shadow: var(--shadow-soft);
}

.hero-card::after {
  position: absolute;
  top: -95px;
  right: -65px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(8, 127, 91, 0.11);
  border-radius: 50%;
  box-shadow:
    0 0 0 36px rgba(8, 127, 91, 0.035),
    0 0 0 72px rgba(8, 127, 91, 0.025);
  content: "";
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 760px;
}

.hero-copy h2,
.view-intro h2 {
  margin: 12px 0 12px;
  font-size: clamp(25px, 3.4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.hero-copy p,
.view-intro p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 11px;
  padding: 9px 15px;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: 150ms ease;
}

.primary-button {
  position: relative;
  z-index: 1;
  border: 1px solid var(--brand);
  background: linear-gradient(145deg, #0c9168, #066a4a);
  color: #fff;
  box-shadow: 0 9px 20px rgba(8, 127, 91, 0.17);
}

.primary-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #aabfb1;
  background: var(--panel-soft);
}

.danger-button {
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
}

.danger-button:hover {
  background: #a9232f;
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: wait;
  filter: grayscale(0.3);
  opacity: 0.62;
  transform: none;
}

.primary-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
}

.wide {
  width: 100%;
}

.compact {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 11px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.metric-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.metric-card::after {
  position: absolute;
  right: -20px;
  bottom: -25px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(8, 127, 91, 0.06);
  content: "";
}

.metric-card > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 9px 0 5px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.metric-card small {
  color: var(--muted);
  font-size: 10px;
}

.metric-active strong {
  color: var(--brand);
}

.metric-warning strong {
  color: var(--amber);
}

.metric-sessions strong {
  color: var(--blue);
}

.content-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: clamp(18px, 2.5vw, 28px);
  box-shadow: var(--shadow-soft);
}

.card-header,
.view-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.card-header h3 {
  margin: 7px 0 5px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.card-header p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(150px, 190px) minmax(150px, 190px);
  gap: 10px;
  margin: 22px 0 14px;
}

.search-field {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel-soft);
  padding: 0 12px;
}

.search-field:focus-within,
.select-field:focus-within,
.form-field:focus-within {
  border-color: rgba(8, 127, 91, 0.55);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.09);
}

.search-field svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.select-field {
  display: grid;
  grid-template-columns: auto 1fr;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: var(--panel-soft);
  padding: 0 10px;
}

.select-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.select-field select {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
}

.table-shell {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.responsive-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.responsive-table th,
.responsive-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.responsive-table th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.responsive-table tbody tr:last-child td {
  border-bottom: 0;
}

.responsive-table tbody tr:hover {
  background: #fbfdfc;
}

.actions-column {
  text-align: right !important;
}

.user-identity {
  display: flex;
  min-width: 170px;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(8, 127, 91, 0.16);
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 850;
}

.user-identity div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.user-identity strong,
.user-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-identity strong {
  font-size: 11px;
}

.user-identity small {
  color: var(--muted);
  font-size: 9px;
}

.chip-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.role-chip,
.status-chip,
.permission-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 4px 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  white-space: nowrap;
}

.role-chip.is-superadmin {
  border-color: #dcc48e;
  background: #fff7df;
  color: #8a5b04;
}

.status-chip.is-active {
  border-color: #b6dfcb;
  background: var(--brand-pale);
  color: var(--brand-dark);
}

.status-chip.is-disabled {
  border-color: #edc4c8;
  background: var(--red-soft);
  color: var(--red);
}

.status-chip.is-locked {
  border-color: #edcf9b;
  background: var(--amber-soft);
  color: var(--amber);
}

.muted-cell {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
}

.row-action {
  min-height: 31px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 5px 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
  cursor: pointer;
}

.row-action:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
  color: var(--ink);
}

.row-action.is-danger {
  border-color: #edc4c8;
  color: var(--red);
}

.row-action.is-danger:hover {
  background: var(--red-soft);
}

.row-action.is-activate {
  border-color: #b6dfcb;
  color: var(--brand-dark);
}

.protected-label {
  color: var(--amber);
  font-size: 9px;
  font-weight: 750;
}

.empty-state {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 13px;
}

.empty-state span {
  font-size: 11px;
}

.inline-error,
.form-error {
  border: 1px solid #edc4c8;
  border-radius: 10px;
  background: var(--red-soft);
  padding: 10px 12px;
  color: var(--red);
  font-size: 11px;
  line-height: 1.55;
}

.view-intro {
  min-height: 150px;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  padding: 12px 4px 26px;
}

.view-intro h2 {
  margin-bottom: 9px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.role-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 21px;
  box-shadow: var(--shadow-soft);
}

.role-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--brand);
  content: "";
}

.role-card.is-protected::before {
  background: #c48a22;
}

.role-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.role-card h3 {
  margin: 0;
  font-size: 15px;
}

.role-code {
  display: inline-block;
  margin-top: 5px;
  color: var(--muted);
  font: 9px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.role-card p {
  min-height: 42px;
  margin: 15px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.role-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
  color: var(--muted);
  font-size: 9px;
}

.permission-card {
  margin-top: 18px;
}

.permission-matrix-wrap {
  overflow: auto;
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.permission-matrix {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 10px;
}

.permission-matrix th,
.permission-matrix td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: center;
}

.permission-matrix th:first-child,
.permission-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 240px;
  background: var(--panel);
  text-align: left;
}

.permission-matrix thead th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 9px;
}

.permission-matrix thead th:first-child {
  z-index: 2;
  background: var(--panel-soft);
}

.permission-matrix tr:last-child td {
  border-bottom: 0;
}

.permission-matrix th:last-child,
.permission-matrix td:last-child {
  border-right: 0;
}

.permission-name {
  display: grid;
  gap: 3px;
}

.permission-name code {
  color: var(--ink);
  font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.permission-name span {
  color: var(--muted);
  font-size: 9px;
}

.permission-check {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}

.permission-dash {
  color: #b2beb7;
}

.audit-filters {
  grid-template-columns: minmax(240px, 1fr) minmax(170px, 220px);
  margin-top: 0;
}

.audit-list {
  display: grid;
  gap: 0;
}

.audit-event {
  display: grid;
  grid-template-columns: 160px minmax(130px, 0.65fr) minmax(160px, 1fr) minmax(180px, 1.35fr) 90px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px 3px;
  font-size: 10px;
}

.audit-event:last-child {
  border-bottom: 0;
}

.audit-time,
.audit-target {
  color: var(--muted);
}

.audit-actor {
  font-weight: 750;
}

.audit-action {
  font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.audit-result {
  justify-self: end;
}

.modal {
  width: min(680px, calc(100vw - 28px));
  max-height: min(90vh, 860px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
  padding: 0;
  color: var(--ink);
  box-shadow: 0 32px 90px rgba(18, 46, 31, 0.25);
}

.modal::backdrop {
  background: rgba(12, 29, 20, 0.58);
  backdrop-filter: blur(5px);
}

.modal form {
  padding: clamp(21px, 4vw, 32px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.modal-header h2,
.login-modal h2,
.confirm-modal h2 {
  margin: 7px 0 7px;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.modal-header p,
.login-modal p,
.confirm-modal p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.modal-close {
  width: 35px;
  height: 35px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-field {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.form-field > span,
.role-picker legend {
  color: var(--ink);
  font-size: 10px;
  font-weight: 750;
}

.form-field input {
  width: 100%;
  height: 43px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  background: var(--panel-soft);
  padding: 0 12px;
  color: var(--ink);
  font-size: 12px;
}

.form-field input:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.75;
}

.form-field small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.role-picker {
  margin: 5px 0 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px;
}

.role-picker p {
  margin: 5px 0 12px;
  color: var(--muted);
  font-size: 9px;
}

.role-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.role-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  padding: 10px;
  cursor: pointer;
}

.role-option:has(input:checked) {
  border-color: rgba(8, 127, 91, 0.42);
  background: var(--brand-pale);
}

.role-option input {
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}

.role-option div {
  display: grid;
  gap: 3px;
}

.role-option strong {
  font-size: 10px;
}

.role-option small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.toggle-row.single {
  grid-template-columns: 1fr;
}

.toggle-control {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px;
  cursor: pointer;
}

.toggle-control > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-control > span {
  position: relative;
  width: 32px;
  height: 18px;
  margin-top: 1px;
  border-radius: 999px;
  background: #c8d3cc;
  transition: 150ms ease;
}

.toggle-control > span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: 150ms ease;
}

.toggle-control > input:checked + span {
  background: var(--brand);
}

.toggle-control > input:checked + span::after {
  transform: translateX(14px);
}

.toggle-control div {
  display: grid;
  gap: 3px;
}

.toggle-control strong {
  font-size: 10px;
}

.toggle-control small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.protected-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  border: 1px solid #ead8ae;
  border-radius: 10px;
  background: #fff9eb;
  padding: 10px;
  color: #825b0e;
  font-size: 9px;
  font-weight: 650;
}

.protected-note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.login-modal {
  width: min(440px, calc(100vw - 28px));
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 18px;
}

.login-brand img {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  object-fit: contain;
  padding: 3px;
}

.login-modal code {
  border-radius: 5px;
  background: var(--panel-soft);
  padding: 2px 4px;
  font-size: 10px;
}

.login-modal .form-field:first-of-type {
  margin-top: 22px;
}

.confirm-modal {
  width: min(480px, calc(100vw - 28px));
  text-align: center;
}

.confirm-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  margin: 0 auto 17px;
  border: 1px solid #edc4c8;
  border-radius: 17px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 22px;
  font-weight: 850;
}

.confirm-modal .modal-actions {
  justify-content: center;
}

.toast-region {
  position: fixed;
  top: 96px;
  right: 18px;
  z-index: 100;
  display: grid;
  width: min(380px, calc(100vw - 36px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 7px 1fr auto;
  gap: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.97);
  padding: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 180ms ease-out;
  pointer-events: auto;
}

.toast-bar {
  border-radius: 999px;
  background: var(--brand);
}

.toast.is-error .toast-bar {
  background: var(--red);
}

.toast div {
  display: grid;
  gap: 3px;
}

.toast strong {
  font-size: 11px;
}

.toast small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.toast button {
  align-self: start;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.rail-backdrop {
  display: none;
}

@media (max-width: 1150px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .responsive-table th:nth-child(4),
  .responsive-table td:nth-child(4) {
    display: none;
  }

  .audit-event {
    grid-template-columns: 140px minmax(120px, 0.7fr) minmax(160px, 1fr) 80px;
  }

  .audit-target {
    display: none;
  }
}

@media (max-width: 850px) {
  :root {
    --rail-width: 270px;
  }

  .side-rail {
    transform: translateX(-105%);
    box-shadow: 24px 0 55px rgba(18, 46, 31, 0.18);
    transition: transform 180ms ease;
  }

  .side-rail.is-open {
    transform: translateX(0);
  }

  .main-stage {
    margin-left: 0;
  }

  .mobile-menu {
    display: inline-grid;
  }

  .rail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(12, 29, 20, 0.45);
  }

  .rail-backdrop.is-open {
    display: block;
  }

  .connection-state {
    display: none;
  }

  .filter-row,
  .audit-filters {
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
  }

  .responsive-table th:nth-child(5),
  .responsive-table td:nth-child(5),
  .responsive-table th:nth-child(6),
  .responsive-table td:nth-child(6) {
    display: none;
  }

  .hero-card {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  .top-bar {
    min-height: 70px;
    padding: 10px 13px;
  }

  .page-heading p,
  .page-heading .eyebrow,
  .profile-copy {
    display: none;
  }

  .page-heading h1 {
    margin: 0;
    font-size: 16px;
  }

  .profile-button {
    border: 0;
    background: transparent;
    padding: 0;
  }

  .profile-avatar {
    width: 36px;
    height: 36px;
  }

  #logoutButton {
    display: none;
  }

  .workspace {
    padding: 14px;
  }

  .hero-card {
    min-height: 0;
    border-radius: 18px;
    padding: 22px;
  }

  .hero-copy h2,
  .view-intro h2 {
    font-size: 26px;
  }

  .hero-card .primary-button {
    width: 100%;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 10px 0;
  }

  .metric-card {
    padding: 15px;
  }

  .metric-card strong {
    font-size: 23px;
  }

  .metric-card small {
    display: none;
  }

  .content-card {
    border-radius: 16px;
    padding: 15px;
  }

  .card-header {
    align-items: center;
  }

  .card-header p {
    display: none;
  }

  .filter-row,
  .audit-filters {
    grid-template-columns: 1fr;
    margin-top: 16px;
  }

  .search-field {
    grid-column: auto;
  }

  .table-shell {
    border: 0;
    overflow: visible;
  }

  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    display: grid;
    gap: 10px;
  }

  .responsive-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--panel);
    padding: 13px;
  }

  .responsive-table td {
    border: 0;
    padding: 0;
  }

  .responsive-table td:first-child,
  .responsive-table td:last-child {
    grid-column: 1 / -1;
  }

  .responsive-table td:nth-child(4),
  .responsive-table td:nth-child(5),
  .responsive-table td:nth-child(6) {
    display: block;
  }

  .responsive-table td::before {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 8px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .responsive-table td:first-child::before,
  .responsive-table td:last-child::before {
    display: none;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 4px;
  }

  .row-action {
    min-height: 36px;
  }

  .view-intro {
    min-height: 130px;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 3px 22px;
  }

  .role-grid {
    grid-template-columns: 1fr;
  }

  .audit-event {
    grid-template-columns: 1fr auto;
    gap: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    margin-bottom: 9px;
    padding: 13px;
  }

  .audit-time,
  .audit-actor,
  .audit-action {
    grid-column: 1;
  }

  .audit-target {
    display: block;
    grid-column: 1;
  }

  .audit-result {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .form-grid,
  .role-options,
  .toggle-row {
    grid-template-columns: 1fr;
  }

  .modal {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
    border-radius: 16px;
  }

  .modal form {
    padding: 20px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

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