html {
  font-size: 14px;
}

:root {
  --admin-bg: #f4f6f8;
  --admin-surface: #fff;
  --admin-surface-muted: #f8fafc;
  --admin-surface-alt: #f1f5f9;
  --admin-border: #d8dee8;
  --admin-border-soft: #edf1f6;
  --admin-text: #172033;
  --admin-muted: #667085;
  --admin-primary: #1d4ed8;
  --admin-primary-soft: #dbeafe;
  --admin-success: #166534;
  --admin-success-soft: #dcfce7;
  --admin-warning: #92400e;
  --admin-warning-soft: #fef3c7;
  --admin-danger: #991b1b;
  --admin-danger-soft: #fee2e2;
  --admin-neutral-soft: #e5e7eb;
  --admin-shadow: 0 8px 22px rgba(15, 23, 42, .06);
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background: var(--admin-bg);
  color: var(--admin-text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  padding: 24px;
}

.app-sidebar {
  background: #111827;
  border-right: 1px solid rgba(255, 255, 255, .08);
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  height: 100vh;
  left: 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  transition: width .18s ease;
  width: 272px;
  z-index: 1020;
}

.sidebar-brand {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  gap: 12px;
  min-height: 72px;
  padding: 18px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-copy strong {
  color: #f9fafb;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.1;
}

.brand-copy span {
  color: #9ca3af;
  font-size: .8rem;
  margin-top: 3px;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
}

.nav-section {
  margin-bottom: 18px;
}

.nav-section-title {
  color: #6b7280;
  display: block;
  font-size: .72rem;
  font-weight: 650;
  letter-spacing: .08em;
  margin: 0 10px 7px;
  text-transform: uppercase;
}

.nav-item {
  align-items: center;
  border-radius: 8px;
  color: #cbd5e1;
  display: flex;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  text-decoration: none;
  transition: background .14s ease, color .14s ease;
}

.nav-item:hover,
.nav-item:focus {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.nav-item-active {
  background: rgba(37, 99, 235, .22);
  color: #fff;
}

.nav-icon {
  align-items: center;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 7px;
  color: #e5e7eb;
  display: inline-flex;
  flex: 0 0 26px;
  font-size: .72rem;
  font-weight: 650;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.nav-svg {
  display: block;
  height: 16px;
  width: 16px;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding: 14px 18px 18px;
}

.environment-label {
  background: rgba(219, 234, 254, .12);
  border: 1px solid rgba(219, 234, 254, .22);
  border-radius: 999px;
  color: #dbeafe;
  display: inline-flex;
  font-size: .72rem;
  font-weight: 650;
  line-height: 1;
  padding: 6px 8px;
  text-transform: uppercase;
}

.sidebar-footer-text {
  color: #9ca3af;
  display: block;
  font-size: .78rem;
  margin-top: 8px;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  align-items: center;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 1010;
}

.topbar-left,
.topbar-right {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.topbar-right {
  flex-shrink: 0;
}

.topbar-title {
  color: #111827;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.1;
}

.topbar-subtitle {
  color: var(--admin-muted);
  font-size: .82rem;
  margin-top: 2px;
}

.sidebar-toggle {
  align-items: center;
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.sidebar-toggle span {
  background: #475467;
  border-radius: 999px;
  display: block;
  height: 2px;
  width: 16px;
}

.app-content {
  padding: 28px;
}

body.app-sidebar-collapsed .app-shell {
  grid-template-columns: 84px minmax(0, 1fr);
}

body.app-sidebar-collapsed .app-sidebar {
  width: 84px;
}

body.app-sidebar-collapsed .brand-copy,
body.app-sidebar-collapsed .nav-label,
body.app-sidebar-collapsed .nav-section-title,
body.app-sidebar-collapsed .sidebar-footer-text {
  display: none;
}

body.app-sidebar-collapsed .sidebar-brand,
body.app-sidebar-collapsed .nav-item,
body.app-sidebar-collapsed .sidebar-footer {
  justify-content: center;
}

body.app-sidebar-collapsed .nav-item {
  padding-left: 8px;
  padding-right: 8px;
}

.admin-navbar {
  background: #111827;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .16);
  min-height: 56px;
}

.admin-brand {
  align-items: center;
  color: #fff !important;
  display: inline-flex;
  font-weight: 650;
  gap: 10px;
  letter-spacing: 0;
}

.admin-brand:hover,
.admin-brand:focus {
  color: #fff !important;
}

.brand-mark {
  align-items: center;
  background: #dbeafe;
  border-radius: 8px;
  color: #1e3a8a;
  display: inline-flex;
  font-size: .82rem;
  font-weight: 650;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.admin-navbar .nav-link {
  border-radius: 7px;
  color: rgba(255, 255, 255, .76);
  font-size: .92rem;
  font-weight: 400;
  margin: 0 2px;
  padding-left: 10px;
  padding-right: 10px;
}

.admin-navbar .nav-link:hover,
.admin-navbar .nav-link:focus,
.admin-navbar .nav-link.active {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.admin-navbar .dropdown-menu {
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
}

.admin-navbar .dropdown-item {
  font-size: .92rem;
}

.admin-navbar .dropdown-item.active,
.admin-navbar .dropdown-item:active {
  background: var(--admin-primary);
}

.nav-mode {
  background: rgba(219, 234, 254, .14);
  border: 1px solid rgba(219, 234, 254, .24);
  border-radius: 999px;
  color: #dbeafe;
  font-size: .75rem;
  font-weight: 650;
  line-height: 1;
  padding: 6px 9px;
  text-transform: uppercase;
}

.admin-user {
  color: rgba(255, 255, 255, .78) !important;
  font-weight: 600;
}

.topbar-right .admin-user {
  color: #344054 !important;
}

.admin-shell {
  padding: 28px;
}

.page-header {
  margin-bottom: 22px;
}

.page-header--split {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.page-header h1 {
  color: #0f172a;
  font-size: 1.85rem;
  font-weight: 650;
  margin: 0;
}

.page-title {
  color: #0f172a;
  font-size: 1.85rem;
  font-weight: 650;
  margin: 0;
}

.page-subtitle,
.muted-text {
  color: var(--admin-muted);
}

.page-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.page-header p {
  color: var(--admin-muted);
  margin: 6px 0 0;
}

.page-kicker {
  color: var(--admin-primary) !important;
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .04em;
  margin: 0 0 4px !important;
  text-transform: uppercase;
}

.page-status {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: max-content;
}

.status-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  min-height: 150px;
  min-width: 0;
  padding: 18px;
}

.content-card,
.form-section,
.detail-panel {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
}

.content-card,
.form-section {
  padding: 18px;
}

.detail-panel {
  overflow: hidden;
}

.section-title {
  color: #0f172a;
  font-size: 1rem;
  font-weight: 650;
  margin: 0 0 12px;
}

.status-card h2 {
  font-size: 1rem;
  font-weight: 650;
  margin: 0;
}

.status-card p {
  color: #172033;
  font-size: .96rem;
  margin: 18px 0 0;
}

.status-card .d-flex > div:first-child {
  min-width: 0;
}

.status-card .status-badge {
  flex: 0 0 auto;
  margin-left: 8px;
}

.service-detail {
  color: var(--admin-muted);
  display: block;
  font-size: .9rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  border-radius: 999px;
  display: inline-block;
  font-size: .75rem;
  font-weight: 650;
  line-height: 1;
  padding: 6px 9px;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-ok {
  background: var(--admin-success-soft);
  color: var(--admin-success);
}

.status-warn {
  background: var(--admin-warning-soft);
  color: var(--admin-warning);
}

.status-error {
  background: var(--admin-danger-soft);
  color: var(--admin-danger);
}

.table {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  margin-bottom: 0;
}

.table thead th {
  background: #f1f5f9;
  border-bottom: 1px solid var(--admin-border);
  color: #344054;
  font-size: .85rem;
  letter-spacing: .02em;
  font-weight: 650;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody td {
  border-color: var(--admin-border-soft);
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #fafcff;
}

.data-table td,
.data-table th {
  padding: 12px 14px;
}

.table-wrap {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  overflow: auto;
}

.empty-state {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  color: var(--admin-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 28px;
}

.empty-state strong {
  color: var(--admin-text);
}

.empty-title {
  color: var(--admin-text);
  font-size: 1rem;
  font-weight: 650;
}

.empty-hint {
  color: var(--admin-muted);
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.metric-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  min-height: 92px;
  padding: 16px;
}

.metric-card span {
  color: var(--admin-muted);
  display: block;
  font-size: .82rem;
  font-weight: 650;
  text-transform: uppercase;
}

.metric-card strong {
  color: #0f172a;
  display: block;
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 8px;
}

.risk-strip {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.risk-badge,
.state-pill,
.soft-badge,
.flag,
.auth-badge,
.result-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: .76rem;
  font-weight: 650;
  line-height: 1;
  padding: 6px 9px;
  white-space: nowrap;
}

.technical-code,
code.technical-code {
  color: #0f172a;
  font-family: Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.risk-badge strong {
  margin-left: 6px;
}

.risk-r0,
.risk-r1 {
  background: #dcfce7;
  color: #166534;
}

.risk-r2 {
  background: #e0f2fe;
  color: #075985;
}

.risk-r3 {
  background: #fef3c7;
  color: #92400e;
}

.risk-r4,
.risk-r5 {
  background: #fee2e2;
  color: #991b1b;
}

.state-enabled {
  background: var(--admin-success-soft);
  color: var(--admin-success);
}

.state-disabled {
  background: var(--admin-neutral-soft);
  color: #374151;
}

.state-warning {
  background: var(--admin-warning-soft);
  color: var(--admin-warning);
}

.state-error {
  background: var(--admin-danger-soft);
  color: var(--admin-danger);
}

.soft-badge {
  background: #eef2ff;
  color: #3730a3;
  font-weight: 600;
}

.auth-badge {
  background: #ecfeff;
  color: #155e75;
  font-weight: 600;
}

.result-ok,
.result-allowed {
  background: var(--admin-success-soft);
  color: var(--admin-success);
}

.result-error,
.result-forbidden,
.result-unauthorized {
  background: var(--admin-danger-soft);
  color: var(--admin-danger);
}

.result-warn,
.result-auth_required,
.result-multiple_matches {
  background: var(--admin-warning-soft);
  color: var(--admin-warning);
}

.result-neutral,
.result-not_found,
.result-invalid_parameters {
  background: var(--admin-neutral-soft);
  color: #374151;
}

.flag {
  background: var(--admin-neutral-soft);
  color: #4b5563;
  font-weight: 600;
}

.flag-on {
  background: var(--admin-primary-soft);
  color: var(--admin-primary);
}

.flag-off {
  opacity: .58;
}

.filter-panel {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  padding: 16px;
}

.filter-bar {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  padding: 16px;
}

.filter-grid {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1.6fr) repeat(4, minmax(140px, 1fr)) auto;
}

.filter-panel .form-label,
.filter-bar .form-label,
.form-section .form-label,
.status-card .form-label {
  color: #475467;
  font-size: .8rem;
  font-weight: 650;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.filter-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.form-control,
.form-select {
  border-color: #cfd8e3;
  border-radius: 7px;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 .18rem rgba(29, 78, 216, .14);
}

.btn {
  border-radius: 7px;
  font-weight: 600;
}

.btn-primary {
  background: var(--admin-primary);
  border-color: var(--admin-primary);
}

.capability-table {
  min-width: 980px;
}

.capability-main {
  min-width: 280px;
  max-width: 460px;
}

.technical-name {
  color: #0f172a;
  font-family: Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .92rem;
  font-weight: 600;
  word-break: break-word;
}

.description-muted {
  color: var(--admin-muted);
  display: -webkit-box;
  font-size: .88rem;
  line-height: 1.35;
  margin-top: 4px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.capability-detail {
  margin-top: 8px;
}

.capability-detail summary {
  color: var(--admin-primary);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
}

.capability-detail dl {
  background: var(--admin-surface-muted);
  border: 1px solid var(--admin-border-soft);
  border-radius: 6px;
  display: grid;
  grid-template-columns: 130px 1fr;
  margin: 8px 0 0;
  overflow: hidden;
}

.capability-detail dt,
.capability-detail dd {
  border-bottom: 1px solid var(--admin-border-soft);
  margin: 0;
  padding: 8px 10px;
}

.capability-detail dt {
  color: #475467;
  font-weight: 650;
}

.badge-stack,
.flag-list,
.limit-stack,
.count-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.limit-stack {
  color: #475467;
  flex-direction: column;
  gap: 4px;
}

.limit-stack strong {
  color: var(--admin-text);
}

.count-chip {
  background: var(--admin-surface-alt);
  border: 1px solid var(--admin-border-soft);
  border-radius: 7px;
  color: #475467;
  display: inline-flex;
  font-size: .82rem;
  font-weight: 600;
  gap: 6px;
  padding: 6px 8px;
}

.count-chip strong {
  color: var(--admin-text);
}

.text-truncate-soft {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.security-warning {
  background: #7f1d1d;
  color: #fff;
  font-weight: 650;
  padding: 10px 24px;
}

.login-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

.login-panel {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-panel .brand-mark {
  margin-bottom: 14px;
}

.login-panel h1 {
  font-size: 1.4rem;
  font-weight: 650;
  margin: 0;
}

.login-panel p {
  color: var(--admin-muted);
  margin: 6px 0 22px;
}

.config-list {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  margin: 0;
  overflow: hidden;
}

.config-list dt,
.config-list dd {
  border-bottom: 1px solid var(--admin-border-soft);
  margin: 0;
  padding: 12px 16px;
}

.config-list dt {
  background: var(--admin-surface-muted);
  color: #475467;
  font-weight: 650;
  word-break: break-word;
}

.config-list dd {
  color: var(--admin-text);
  word-break: break-word;
}

.admin-json {
  background: #111827;
  border-radius: 6px;
  color: #f9fafb;
  max-height: 360px;
  max-width: 520px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-sidebar {
    width: 72px;
  }

  .brand-copy,
  .nav-label,
  .nav-section-title,
  .sidebar-footer-text {
    display: none;
  }

  .sidebar-brand,
  .nav-item,
  .sidebar-footer {
    justify-content: center;
  }

  .app-topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .topbar-right {
    flex-wrap: wrap;
  }

  .app-content {
    padding: 16px;
  }

  .admin-shell {
    padding: 16px;
  }

  .page-header--split,
  .page-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .filter-actions {
    justify-content: stretch;
  }

  .filter-actions .btn {
    flex: 1;
  }

  .data-table td,
  .data-table th {
    padding: 10px 12px;
  }

  .config-list {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 721px) and (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(140px, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}
