:root {
  --shell-z-topbar: 70;
  --shell-z-backdrop: 55;
  --shell-z-sidebar: 60;
  --shell-z-sidebar-overlay: 45;
  --shell-sidebar-collapsed: 64px;
  --shell-sidebar-expanded: 248px;
}

.layout-shell {
  min-height: 100dvh;
  height: 100dvh;
}

.layout {
  grid-template-columns: var(--shell-sidebar-collapsed) minmax(0, 1fr);
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns 200ms ease;
}

.layout.sidebar-expanded:not(.sidebar-pinned) {
  grid-template-columns: var(--shell-sidebar-expanded) minmax(0, 1fr);
}

.sidebar {
  width: var(--shell-sidebar-collapsed);
  padding: 10px 8px;
  background: #f6f8fc;
  color: #1f2937;
  border-right: 1px solid #dbe3ee;
  overflow: hidden auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-padding-block: 8px;
  scrollbar-gutter: stable;
  transition: padding 200ms ease, width 200ms ease, margin-right 200ms ease, box-shadow 200ms ease;
}

.layout > .sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  max-height: 100dvh;
}

.content {
  min-width: 0;
  min-height: 0;
  height: 100dvh;
  padding: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.content .card {
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}

.content table th,
.content table td {
  padding: 8px 9px;
}

.content .ops-summary-strip {
  margin-bottom: 10px;
}

.content .ops-summary-pill {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.content .ops-summary-pill strong {
  font-size: 13px;
}

.content .admin-primary-card {
  position: relative;
}

@media (min-width: 961px) {
  .content .admin-page-title-source,
  .content .admin-page-head-compact .ops-page-copy,
  .content .admin-page-head-compact > h2,
  .content .admin-page-head-compact > h3,
  .content .admin-page-head-compact > h4 {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .content .admin-page-head-compact {
    min-height: 0;
    margin-bottom: 8px;
    align-items: center;
    justify-content: flex-end;
  }

  .content .admin-page-head-compact .ops-page-actions,
  .content .admin-page-head-compact > .inline-help-wrap {
    margin-left: auto;
  }

  .content .admin-page-head-compact .ops-page-actions:empty {
    display: none;
  }
}

.layout:not(.sidebar-pinned) .sidebar {
  z-index: var(--shell-z-sidebar-overlay);
}

.layout.sidebar-expanded:not(.sidebar-pinned) .sidebar {
  width: var(--shell-sidebar-expanded);
  margin-right: 0;
  box-shadow: none;
}

.layout.sidebar-pinned {
  grid-template-columns: var(--shell-sidebar-expanded) minmax(0, 1fr);
}

.layout.sidebar-pinned .sidebar {
  width: var(--shell-sidebar-expanded);
  margin-right: 0;
  box-shadow: none;
  z-index: var(--shell-z-sidebar);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 100%;
  padding-bottom: 8px;
}

.sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 2px 0 6px;
}

.sidebar-brand-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  gap: 0;
}

.sidebar-logo {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  flex: 0 0 auto;
}

.sidebar-mobile-menu-btn {
  display: none;
  flex: 0 0 auto;
}

.sidebar-brand-text {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
}

.sidebar-pin-btn {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  background: #ffffff;
  color: #334155;
  min-width: 48px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.sidebar-pin-btn:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}

.sidebar-pin-btn.is-active {
  border-color: #1d4ed8;
  color: #1d4ed8;
  background: #dbeafe;
}

.nav-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-block-bottom {
  margin-top: auto;
}

.sidebar .nav-label {
  margin: 8px 8px 3px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar .nav-link,
.sidebar .nav-section-head {
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-section-head:hover {
  background: #e9eef8;
  color: #0f172a;
}

.sidebar .nav-link.active,
.layout.sidebar-expanded .sidebar .nav-link.active {
  background: #dbe7ff;
  color: #0f172a;
  box-shadow: inset 0 0 0 1px #bfd3ff;
  font-weight: 700;
}

.sidebar .nav-section {
  margin: 0;
  border-radius: 10px;
}

.sidebar .nav-head-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.sidebar .nav-ico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.sidebar .nav-ico svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar .nav-text {
  white-space: nowrap;
}

.sidebar .chev {
  margin-left: auto;
  color: #64748b;
  font-size: 11px;
  transition: transform 160ms ease, opacity 160ms ease;
}

.sidebar .nav-section-body {
  display: none;
  padding: 1px 0 4px;
}

.sidebar .nav-section.open .nav-section-body {
  display: none;
}

.layout.sidebar-expanded .sidebar .nav-section.open .nav-section-body {
  display: block;
}

.sidebar .nav-link.child {
  font-size: 14px;
  min-height: 30px;
  color: #475569;
}

.layout.sidebar-expanded .sidebar .nav-link.child {
  padding-left: 30px;
}

.sidebar .nav-child-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #94a3b8;
  flex: 0 0 auto;
}

.sidebar .nav-label,
.sidebar .nav-text,
.sidebar .chev,
.sidebar .sidebar-brand-text {
  opacity: 0;
  visibility: hidden;
  width: 0;
  pointer-events: none;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.sidebar .sidebar-pin-btn {
  opacity: 0;
  visibility: hidden;
  width: 0;
  min-width: 0;
  padding: 0;
  border-width: 0;
  pointer-events: none;
}

.sidebar .nav-link,
.sidebar .nav-section-head {
  justify-content: center;
  gap: 0;
  padding: 7px;
}

.sidebar .nav-head-main {
  justify-content: center;
  gap: 0;
}

.sidebar .nav-section.open .chev {
  transform: rotate(180deg);
}

.layout.sidebar-expanded .sidebar {
  padding: 10px 8px;
}

.layout.sidebar-expanded .sidebar .nav-label,
.layout.sidebar-expanded .sidebar .nav-text,
.layout.sidebar-expanded .sidebar .chev,
.layout.sidebar-expanded .sidebar .sidebar-brand-text {
  opacity: 1;
  visibility: visible;
  width: auto;
  pointer-events: auto;
}

.layout.sidebar-expanded .sidebar .nav-link,
.layout.sidebar-expanded .sidebar .nav-section-head {
  justify-content: flex-start;
  gap: 8px;
  padding: 7px 9px;
}

.layout.sidebar-expanded .sidebar .nav-head-main {
  justify-content: flex-start;
  gap: 8px;
}

.layout.sidebar-expanded .sidebar .sidebar-brand-row {
  justify-content: space-between;
  padding: 2px 4px 6px;
}

.layout.sidebar-expanded .sidebar .sidebar-brand-main {
  justify-content: flex-start;
  width: auto;
  gap: 10px;
}

.layout.sidebar-expanded .sidebar .sidebar-pin-btn {
  opacity: 1;
  visibility: visible;
  width: auto;
  min-width: 48px;
  padding: 6px 8px;
  border-width: 1px;
  pointer-events: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--shell-z-topbar);
  background: linear-gradient(180deg, #f8fafd 0%, #f4f6fb 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 8px;
  margin-bottom: 10px;
}

.topbar-left {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.topbar-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.topbar-brand-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-brand-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
}

.topbar-inline-help-slot {
  display: none;
  flex: 0 0 auto;
  align-items: center;
}

.topbar-inline-help-slot:empty {
  display: none;
}

.topbar-panel-name {
  font-size: 12px;
  line-height: 1.1;
  max-width: min(52vw, 280px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-live-wrap {
  position: relative;
}

.admin-live-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 999px;
  height: 34px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.admin-live-btn .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #10b981;
}

.admin-live-btn .label {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.admin-live-btn .count {
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: #eef2ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  padding: 0 6px;
}

.admin-live-wrap.has-new .admin-live-btn {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.admin-live-wrap.has-new .admin-live-btn .dot {
  background: #ef4444;
}

.admin-live-dropdown {
  position: absolute;
  right: 0;
  top: 40px;
  width: min(480px, 92vw);
  max-width: calc(100vw - 16px);
  max-height: min(70vh, 560px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 26px rgba(2, 6, 23, 0.16);
  padding: 8px;
  z-index: 70;
  display: none;
}

.admin-live-dropdown.show {
  display: block;
}

.avatar-btn {
  width: 34px;
  height: 34px;
}

.avatar-menu {
  top: 40px;
}

.admin-live-dropdown-head {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-live-dropdown-head .title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  font-weight: 700;
}

.admin-live-dropdown-head .summary {
  font-size: 12px;
  color: #475569;
}

.admin-live-dropdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-live-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.admin-live-item .title {
  font-weight: 700;
  color: #0f172a;
}

.admin-live-item .meta {
  margin-top: 2px;
  color: #64748b;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-live-item .sub {
  margin-top: 2px;
  color: #334155;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.admin-toast-root,
.admin-live-toast-root {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.admin-toast,
.admin-live-toast {
  pointer-events: auto;
  min-width: min(420px, calc(100vw - 28px));
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  box-shadow: 0 8px 18px rgba(30, 58, 138, 0.14);
  transition: transform 180ms ease, opacity 180ms ease;
}

.admin-toast.is-ok,
.admin-live-toast.is-ok {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  box-shadow: 0 8px 18px rgba(30, 58, 138, 0.14);
}

.admin-toast.is-live,
.admin-live-toast.is-live {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  box-shadow: 0 8px 18px rgba(30, 58, 138, 0.14);
}

.admin-toast.is-warn,
.admin-live-toast.is-warn {
  border-color: #fcd34d;
  background: #fffbeb;
  color: #92400e;
  box-shadow: 0 8px 18px rgba(146, 64, 14, 0.14);
}

.admin-toast.is-bad,
.admin-live-toast.is-bad {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
  box-shadow: 0 8px 18px rgba(153, 27, 27, 0.14);
}

.admin-toast.is-leaving,
.admin-live-toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}

.admin-toast .title,
.admin-live-toast .title {
  font-weight: 700;
}

.admin-toast .meta,
.admin-live-toast .meta {
  margin-top: 3px;
  color: #334155;
  font-size: 12px;
}

.topbar-menu-btn {
  display: none;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  width: 42px;
  height: 42px;
  padding: 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.topbar-menu-btn:hover {
  background: #eef2ff;
  border-color: #94a3b8;
}

.topbar-menu-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.24);
}

.topbar-menu-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 14px;
}

.topbar-menu-icon > span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 999px;
  background: #0f172a;
  transition: transform 180ms ease, opacity 160ms ease, top 180ms ease, background 180ms ease;
}

.topbar-menu-icon > span:nth-child(1) {
  top: 0;
}

.topbar-menu-icon > span:nth-child(2) {
  top: 6px;
}

.topbar-menu-icon > span:nth-child(3) {
  top: 12px;
}

.topbar-menu-btn[aria-expanded="true"] {
  background: #0f172a;
  border-color: #0f172a;
}

.topbar-menu-btn[aria-expanded="true"] .topbar-menu-icon > span {
  background: #ffffff;
}

.topbar-menu-btn[aria-expanded="true"] .topbar-menu-icon > span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

.topbar-menu-btn[aria-expanded="true"] .topbar-menu-icon > span:nth-child(2) {
  opacity: 0;
}

.topbar-menu-btn[aria-expanded="true"] .topbar-menu-icon > span:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

.mobile-nav-backdrop {
  display: none;
}

@media (max-width: 960px) {
  :root {
    --shell-mobile-safe-top: max(8px, env(safe-area-inset-top, 0px));
    --shell-mobile-safe-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

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

  .layout.sidebar-expanded,
  .layout.sidebar-pinned {
    grid-template-columns: 1fr;
  }

  .content {
    height: 100dvh;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
  }

  .topbar-right {
    min-width: 0;
    gap: 8px;
  }

  .topbar {
    padding: 8px;
    margin-bottom: 10px;
  }

  .topbar-brand-block {
    gap: 0;
  }

  .topbar-title-row {
    gap: 10px;
  }

  .topbar-brand-title {
    font-size: clamp(1.6rem, 5vw, 2rem);
    line-height: 1;
  }

  .topbar-inline-help-slot:not(:empty) {
    display: inline-flex;
  }

  .topbar-inline-help-slot .inline-help-btn {
    width: 32px;
    height: 32px;
    font-size: 17px;
  }

  .topbar-panel-name {
    display: none;
  }

  .topbar-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar-panel-picker {
    display: none !important;
  }

  .admin-live-wrap {
    position: static;
  }

  .admin-live-dropdown {
    position: fixed;
    top: 68px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
  }

  .admin-toast-root,
  .admin-live-toast-root {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .admin-toast,
  .admin-live-toast {
    min-width: 0;
    width: auto;
  }

  .layout > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 312px);
    height: 100dvh;
    max-height: 100dvh;
    border-right: 1px solid #dbe3ee;
    border-bottom: 0;
    transform: translateX(-104%);
    transition: transform 220ms ease;
    z-index: calc(var(--shell-z-topbar) + 12);
    box-shadow: 8px 0 28px rgba(2, 6, 23, 0.35);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: calc(var(--shell-mobile-safe-top) + 12px) 10px var(--shell-mobile-safe-bottom);
    margin-right: 0;
  }

  .layout:not(.sidebar-pinned) > .sidebar,
  .layout.sidebar-expanded:not(.sidebar-pinned) > .sidebar,
  .layout.sidebar-pinned > .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    align-self: auto;
    height: 100dvh;
    max-height: 100dvh;
    z-index: calc(var(--shell-z-topbar) + 12);
    margin-right: 0;
  }
  .sidebar-inner {
    min-height: auto;
    gap: 8px;
    padding-bottom: 8px;
  }

  .sidebar .sidebar-brand-row {
    justify-content: flex-start;
    padding: 4px 6px 12px;
  }

  .sidebar .sidebar-brand-main {
    justify-content: flex-start;
    gap: 12px;
    width: auto;
  }

  .sidebar .sidebar-mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar .sidebar-logo {
    display: none;
  }

  .sidebar .nav-label {
    margin: 8px 8px 4px;
    font-size: 10px;
  }

  .sidebar .nav-label,
  .sidebar .nav-text,
  .sidebar .chev,
  .sidebar .sidebar-brand-text {
    opacity: 1;
    visibility: visible;
    width: auto;
    pointer-events: auto;
  }

  .sidebar .nav-link,
  .sidebar .nav-section-head {
    justify-content: flex-start;
    min-height: 38px;
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 14px;
  }

  .sidebar .nav-head-main {
    justify-content: flex-start;
  }

  .sidebar .nav-section.open .nav-section-body {
    display: block;
  }

  .sidebar .nav-link.child {
    min-height: 34px;
    padding-left: 30px;
    font-size: 13px;
  }

  .sidebar .sidebar-pin-btn {
    display: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0%);
  }

  .mobile-nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: calc(var(--shell-z-topbar) + 6);
  }

  .mobile-nav-backdrop.show {
    display: block;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  body.mobile-nav-open .topbar {
    pointer-events: none;
  }

  .admin-live-btn .label {
    display: none;
  }

  .admin-live-btn {
    padding: 0 8px;
  }
}
