/* ==========================================================================
   Karser — injected theme
   --------------------------------------------------------------------------
   Two surfaces share this one stylesheet, so every rule is scoped:
     • login      →  body:not(:has(aside.sidebar))
     • dashboard  →  body:has(aside.sidebar)
   The dashboard shell is only present once the SPA mounts, so :has() flips
   automatically. Nothing here needs the app rebuilt.
   ========================================================================== */

/* ==========================================================================
   1. LOGIN
   ========================================================================== */

:root {
  --k-ink: #0f172a;
  --k-ink-soft: #334155;
  --k-muted: #64748b;
  --k-faint: #94a3b8;
  --k-line: rgba(15, 23, 42, 0.1);
  --k-card: rgba(246, 246, 244, 0.93);
  --k-blue: #2f7df6;
  --k-blue-deep: #1d63d8;
}

body:not(:has(aside.sidebar)) {
  min-height: 100vh;
  margin: 0;
  padding: 0;
  background: #5eb3e8 url("/login-peppa.jpg?v=1") center center / cover fixed no-repeat !important;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body:not(:has(aside.sidebar)) #app,
body:not(:has(aside.sidebar)) #app > * {
  background: transparent !important;
}

/* Strip AuthLayout's decorative layers: gradient wash, blurred blobs, grid. */
body:not(:has(aside.sidebar)) #app div.relative.flex.min-h-screen > div[class*="absolute"] {
  display: none !important;
}

body:not(:has(aside.sidebar)) #app div.relative.flex.min-h-screen {
  padding: 24px 16px !important;
  background: transparent !important;
  background-image: none !important;
}

/* The column that directly wraps .card-glass becomes the single glass card,
   which folds the brand + heading + form + register link + copyright inside. */
body:not(:has(aside.sidebar)) #app div:has(> .card-glass) {
  position: relative;
  /* Nudged left of centre to clear the artwork, which sits on the right half
     of the background. Scales with the viewport and clamps so narrow screens
     are unaffected. */
  left: clamp(-210px, -13vw, 0px);
  z-index: 10;
  width: min(462px, 100%);
  max-width: 462px;
  margin: 0 auto;
  padding: 38px 38px 30px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 26px;
  color: var(--k-ink);
  background: var(--k-card);
  box-shadow:
    0 26px 64px rgba(15, 23, 42, 0.2),
    0 2px 8px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(28px) saturate(175%);
  backdrop-filter: blur(28px) saturate(175%);
  animation: k-card-in 620ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
  margin-bottom: 26px;
  text-align: left !important;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > div:first-child > div {
  flex: 0 0 auto;
  width: 42px !important;
  height: 42px !important;
  margin: 0 !important;
  border-radius: 11px !important;
  box-shadow: none !important;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > div:first-child img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > div:first-child h1 {
  flex: 0 1 auto;
  margin: 0 !important;
  color: var(--k-ink) !important;
  background: none !important;
  background-image: none !important;
  font-size: 22px !important;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  -webkit-text-fill-color: var(--k-ink) !important;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > div:first-child p {
  flex-basis: 100%;
  margin: 5px 0 0 !important;
  color: var(--k-muted) !important;
  font-size: 13px;
  line-height: 1.35;
}

body:not(:has(aside.sidebar)) #app .card-glass {
  width: 100%;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

body:not(:has(aside.sidebar)) #app .card-glass .space-y-6 > .text-center {
  margin-bottom: 26px !important;
  text-align: left !important;
}

body:not(:has(aside.sidebar)) #app .card-glass h1,
body:not(:has(aside.sidebar)) #app .card-glass h2,
body:not(:has(aside.sidebar)) #app .card-glass .text-2xl {
  margin: 0 0 6px !important;
  color: var(--k-ink) !important;
  font-size: 29px !important;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.022em;
}

body:not(:has(aside.sidebar)) #app .card-glass .text-center > .mt-2,
body:not(:has(aside.sidebar)) #app .card-glass .space-y-6 > .text-center p {
  margin: 0 !important;
  color: var(--k-muted) !important;
  font-size: 14px;
}

body:not(:has(aside.sidebar)) #app .input-label {
  display: block;
  margin-bottom: 7px !important;
  color: var(--k-ink-soft) !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  text-align: left;
}

body:not(:has(aside.sidebar)) #app .input,
body:not(:has(aside.sidebar)) #app input:not([type="checkbox"]):not([type="radio"]),
body:not(:has(aside.sidebar)) #app textarea,
body:not(:has(aside.sidebar)) #app select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px 12px 44px !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 11px !important;
  color: var(--k-ink) !important;
  background: #ffffff !important;
  background-image: none !important;
  font-size: 14.5px !important;
  line-height: 1.4;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

body:not(:has(aside.sidebar)) #app input::placeholder,
body:not(:has(aside.sidebar)) #app textarea::placeholder,
body:not(:has(aside.sidebar)) #app .input::placeholder {
  color: var(--k-faint) !important;
}

body:not(:has(aside.sidebar)) #app .input:hover,
body:not(:has(aside.sidebar)) #app input:hover {
  border-color: #cbd5e1 !important;
}

body:not(:has(aside.sidebar)) #app .input:focus,
body:not(:has(aside.sidebar)) #app input:focus,
body:not(:has(aside.sidebar)) #app textarea:focus {
  border-color: var(--k-blue) !important;
  box-shadow: 0 0 0 3px rgba(47, 125, 246, 0.15) !important;
  outline: none !important;
}

body:not(:has(aside.sidebar)) #app .pointer-events-none.absolute.inset-y-0.left-0 {
  color: var(--k-faint) !important;
}

body:not(:has(aside.sidebar)) #app .pointer-events-none.absolute.inset-y-0.left-0 svg {
  width: 17px;
  height: 17px;
}

body:not(:has(aside.sidebar)) #app button.absolute.inset-y-0.right-0 {
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--k-faint) !important;
  background: transparent !important;
  box-shadow: none !important;
}

body:not(:has(aside.sidebar)) #app button.absolute.inset-y-0.right-0:hover {
  color: var(--k-ink-soft) !important;
}

body:not(:has(aside.sidebar)) #app .btn {
  min-height: 48px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.005em;
}

body:not(:has(aside.sidebar)) #app .btn-primary {
  border: 0 !important;
  color: #ffffff !important;
  background-image: linear-gradient(135deg, #4f8ff7 0%, var(--k-blue-deep) 100%) !important;
  box-shadow: 0 8px 20px rgba(47, 125, 246, 0.3) !important;
  transition: box-shadow 200ms ease, transform 200ms ease, filter 200ms ease;
}

body:not(:has(aside.sidebar)) #app .btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 11px 26px rgba(47, 125, 246, 0.38) !important;
  transform: translateY(-1px);
}

body:not(:has(aside.sidebar)) #app .btn-primary:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

body:not(:has(aside.sidebar)) #app .btn-secondary {
  border: 1px solid #e2e8f0 !important;
  color: var(--k-ink) !important;
  background: #ffffff !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
}

body:not(:has(aside.sidebar)) #app .btn-secondary:hover {
  border-color: #cbd5e1 !important;
  background: #f8fafc !important;
}

body:not(:has(aside.sidebar)) #app .card-glass div:has(> .h-px) {
  color: var(--k-muted) !important;
  font-size: 13px !important;
}

body:not(:has(aside.sidebar)) #app .card-glass div:has(> .h-px) > .h-px {
  background-color: rgba(15, 23, 42, 0.1) !important;
}

body:not(:has(aside.sidebar)) #app .card-glass .mt-1.text-sm,
body:not(:has(aside.sidebar)) #app .card-glass .mt-2.text-sm,
body:not(:has(aside.sidebar)) #app .card-glass .mt-3.text-sm {
  color: var(--k-muted) !important;
}

body:not(:has(aside.sidebar)) #app .card-glass a {
  color: var(--k-blue) !important;
  font-weight: 500;
  text-decoration: none;
}

body:not(:has(aside.sidebar)) #app .card-glass a:hover {
  color: var(--k-blue-deep) !important;
  text-decoration: underline;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > .mt-6 {
  margin-top: 20px !important;
  padding-top: 0;
  border-top: 0;
  color: var(--k-muted) !important;
  font-size: 13.5px !important;
  text-align: left !important;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > .mt-6 a {
  color: var(--k-blue) !important;
  font-weight: 600;
}

body:not(:has(aside.sidebar)) #app div:has(> .card-glass) > .mt-8 {
  margin-top: 16px !important;
  color: var(--k-faint) !important;
  font-size: 12px !important;
  text-align: left !important;
}

body:not(:has(aside.sidebar)) #app .card-glass input[type="checkbox"] {
  min-height: 0;
  width: 16px;
  height: 16px;
  padding: 0 !important;
  border-radius: 4px !important;
  accent-color: var(--k-blue);
}

@media (max-width: 640px) {
  body:not(:has(aside.sidebar)) {
    background-attachment: scroll;
  }

  body:not(:has(aside.sidebar)) #app div:has(> .card-glass) {
    left: 0;
    width: 100%;
    max-width: 100%;
    padding: 30px 24px 24px;
    border-radius: 22px;
  }

  body:not(:has(aside.sidebar)) #app .card-glass h1,
  body:not(:has(aside.sidebar)) #app .card-glass .text-2xl {
    font-size: 25px !important;
  }
}

/* ==========================================================================
   2. DASHBOARD — centred island, hover-stretch
   --------------------------------------------------------------------------
   The island hugs its content and sits dead centre. Nav items are icon-only;
   hovering one stretches its label open, and because the island stays centred,
   that growth is symmetric about the middle of the screen.
   ========================================================================== */

:root {
  --island-h: 48px;
  --island-top: 10px;
  --island-total: 70px;
  --k-surface: #ffffff;
  --k-canvas: #f6f8fb;
  --k-hairline: rgba(15, 23, 42, 0.08);
  /* Same glass recipe as the login card: translucent fill, a bright hairline
     border, a soft layered shadow and an inset top highlight. */
  --k-island-bg: rgba(255, 255, 255, 0.38);
  --k-island-border: rgba(255, 255, 255, 0.78);
  --k-island-shadow:
    0 14px 40px rgba(15, 23, 42, 0.13),
    0 2px 6px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  /* A soft aurora across the top of the canvas. This is what the island's
     backdrop-filter actually blurs — without it, glass over a flat fill is
     indistinguishable from a solid bar. */
  --k-aurora:
    radial-gradient(ellipse 600px 230px at 26% -120px, rgba(45, 212, 191, 0.42), transparent 64%),
    radial-gradient(ellipse 540px 210px at 66% -110px, rgba(129, 140, 248, 0.34), transparent 64%),
    radial-gradient(ellipse 420px 185px at 93% -90px, rgba(244, 114, 182, 0.22), transparent 66%),
    radial-gradient(ellipse 390px 175px at 5% -80px, rgba(56, 189, 248, 0.3), transparent 66%);
  --k-stretch: 300ms;
  --k-stretch-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html.dark {
  /* Neutral graphite rather than slate: no blue cast. */
  --k-surface: #1a1a1c;
  --k-canvas: #0e0e10;
  --k-hairline: rgba(255, 255, 255, 0.09);
  --k-island-bg: rgba(38, 38, 41, 0.5);
  --k-island-border: rgba(255, 255, 255, 0.14);
  --k-island-shadow:
    0 14px 40px rgba(0, 0, 0, 0.5),
    0 2px 6px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --k-aurora:
    radial-gradient(ellipse 560px 210px at 26% -110px, rgba(20, 184, 166, 0.1), transparent 62%),
    radial-gradient(ellipse 500px 190px at 66% -100px, rgba(94, 234, 212, 0.06), transparent 62%),
    radial-gradient(ellipse 380px 170px at 93% -80px, rgba(148, 163, 184, 0.05), transparent 64%),
    radial-gradient(ellipse 360px 160px at 5% -70px, rgba(20, 184, 166, 0.07), transparent 64%);
}

/* ---- Canvas: kill the mesh wash and the login backdrop ------------------ */
body:has(aside.sidebar) {
  margin: 0;
  background: var(--k-canvas) !important;
  background-image: none !important;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body:has(aside.sidebar) #app > *,
body:has(aside.sidebar) .bg-mesh-gradient {
  background-image: none !important;
}

/* The aurora the island diffuses. Pinned to the viewport so it stays under the
   fixed island as the page scrolls; it fades out before the content begins. */
body:has(aside.sidebar) #app {
  background-color: transparent !important;
  background-image: none !important;
}

body:has(aside.sidebar) {
  background-image: var(--k-aurora) !important;
  background-repeat: no-repeat !important;
  background-attachment: fixed !important;
}

body:has(aside.sidebar) #app > .navigation-progress {
  z-index: 70 !important;
}

/* ---- The island: content-hugging and horizontally centred ---------------- */
body:has(aside.sidebar) aside.sidebar {
  position: fixed !important;
  top: var(--island-top) !important;
  bottom: auto !important;
  left: 50% !important;
  right: auto !important;
  width: auto !important;
  max-width: calc(100% - 24px) !important;
  height: var(--island-h) !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  padding: 0 9px !important;
  border: 1px solid var(--k-island-border) !important;
  border-right-width: 1px !important;
  border-radius: 9999px !important;
  background: var(--k-island-bg) !important;
  box-shadow: var(--k-island-shadow) !important;
  -webkit-backdrop-filter: blur(28px) saturate(175%) !important;
  backdrop-filter: blur(28px) saturate(175%) !important;
  /* translateX(-50%) both centres it and neutralises -translate-x-full */
  transform: translateX(-50%) !important;
  transition: none !important;
  z-index: 60 !important;
}


body:has(aside.sidebar) div.fixed.inset-0.z-30.bg-black\/50 {
  display: none !important;
}

/* ---- Island: brand ------------------------------------------------------ */
body:has(aside.sidebar) .sidebar-header {
  flex: 0 0 auto !important;
  height: auto !important;
  gap: 8px !important;
  padding: 0 6px 0 4px !important;
  border-bottom: 0 !important;
}

body:has(aside.sidebar) .sidebar-header .sidebar-logo {
  width: 28px !important;
  height: 28px !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

body:has(aside.sidebar) .sidebar-header .sidebar-brand {
  display: flex;
  align-items: center;
  max-width: 11rem !important;
  opacity: 1 !important;
  transform: none !important;
  pointer-events: auto !important;
}

body:has(aside.sidebar) .sidebar-brand > *:not(.sidebar-brand-title) {
  display: none !important;
}

body:has(aside.sidebar) .sidebar-brand-title {
  font-size: 14px !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

body:has(aside.sidebar) .sidebar-header::after {
  content: "";
  width: 1px;
  height: 18px;
  margin-left: 4px;
  background: var(--k-hairline);
}

/* ---- Island: nav row ---------------------------------------------------- */
body:has(aside.sidebar) .sidebar-nav {
  flex: 0 1 auto !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px !important;
  min-width: 0 !important;
  padding: 0 !important;
  /* An overflow context would clip the stretch, so never scroll here. */
  overflow: visible !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

body:has(aside.sidebar) .sidebar-nav::-webkit-scrollbar {
  display: none !important;
}

body:has(aside.sidebar) .sidebar-nav > .sidebar-section {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 2px !important;
  flex: 0 0 auto !important;
  margin-bottom: 0 !important;
}

body:has(aside.sidebar) .sidebar-nav > .sidebar-section + .sidebar-section {
  margin-left: 6px !important;
  padding-left: 7px !important;
  border-left: 1px solid var(--k-hairline) !important;
}

body:has(aside.sidebar) .sidebar-section-title {
  display: none !important;
}

body:has(aside.sidebar) .sidebar-nav > div:not(.sidebar-section) {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 2px !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  padding: 0 !important;
  border-left: 0 !important;
}

/* ---- Island: nav items stretch open on hover ---------------------------- */
body:has(aside.sidebar) .sidebar-link {
  position: relative !important;
  flex: 0 0 auto !important;
  width: auto !important;
  height: 34px !important;
  gap: 0 !important;
  margin: 0 !important;
  padding: 0 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 9999px !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  color: #4b5563 !important;
  background: transparent !important;
  overflow: hidden !important;
  transition:
    background-color 160ms ease,
    color 160ms ease,
    gap var(--k-stretch) var(--k-stretch-ease),
    padding var(--k-stretch) var(--k-stretch-ease) !important;
}

html.dark body:has(aside.sidebar) .sidebar-link {
  color: #cbd5e1 !important;
}

body:has(aside.sidebar) .sidebar-link:hover {
  gap: 7px !important;
  padding: 0 12px 0 8px !important;
  background: rgba(255, 255, 255, 0.62) !important;
  color: #0f172a !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
}

html.dark body:has(aside.sidebar) .sidebar-link:hover {
  background: rgba(148, 163, 184, 0.2) !important;
  color: #f1f5f9 !important;
  box-shadow: none !important;
}

body:has(aside.sidebar) .sidebar-link-active,
body:has(aside.sidebar) .sidebar-link-active:hover {
  color: #0d7a6f !important;
  background: rgba(20, 184, 166, 0.13) !important;
}

html.dark body:has(aside.sidebar) .sidebar-link-active,
html.dark body:has(aside.sidebar) .sidebar-link-active:hover {
  color: #5eead4 !important;
  background: rgba(20, 184, 166, 0.18) !important;
}

body:has(aside.sidebar) .sidebar-link svg {
  width: 18px !important;
  height: 18px !important;
  flex-shrink: 0 !important;
}

/* Labels rest fully collapsed (the app already marks every item collapsed)
   and stretch to their natural width on hover. */
body:has(aside.sidebar) .sidebar-label,
body:has(aside.sidebar) .sidebar-label-collapsed {
  display: inline-block !important;
  position: static !important;
  max-width: 0 !important;
  min-width: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  transform: none !important;
  pointer-events: none !important;
  white-space: nowrap !important;
  transition:
    max-width var(--k-stretch) var(--k-stretch-ease),
    opacity 200ms ease !important;
}

body:has(aside.sidebar) .sidebar-link:hover .sidebar-label,
body:has(aside.sidebar) .sidebar-link:focus-visible .sidebar-label {
  max-width: 12rem !important;
  opacity: 1 !important;
}

body:has(aside.sidebar) .sidebar-link-collapsed {
  gap: 0 !important;
  padding: 0 8px !important;
}

body:has(aside.sidebar) .sidebar-link-collapsed:hover {
  gap: 7px !important;
  padding: 0 12px 0 8px !important;
}

/* ---- Island: right-hand controls --------------------------------------- */
body:has(aside.sidebar) .sidebar-nav ~ div,
body:has(aside.sidebar) aside.sidebar > div.mt-auto {
  flex: 0 0 auto !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 2px !important;
  margin: 0 !important;
  padding: 0 0 0 6px !important;
  border-top: 0 !important;
  border-left: 1px solid var(--k-hairline) !important;
  overflow: visible !important;
}

body:has(aside.sidebar) aside.sidebar > div.mt-auto > .sidebar-link:last-child {
  display: none !important;
}

/* ---- Header: only the page title remains ------------------------------- */
body:has(aside.sidebar) header.glass {
  top: var(--island-total) !important;
  border-bottom: 1px solid var(--k-hairline) !important;
  background: color-mix(in srgb, var(--k-canvas) 84%, transparent) !important;
  -webkit-backdrop-filter: blur(16px) !important;
  backdrop-filter: blur(16px) !important;
}

body:has(aside.sidebar) header.glass > div {
  height: 54px !important;
}

body:has(aside.sidebar) header.glass button.btn-ghost.btn-icon.lg\:hidden {
  display: none !important;
}

/* ---- Shell -------------------------------------------------------------- */
body:has(aside.sidebar) div.relative.min-h-screen,
body:has(aside.sidebar) div.relative.min-h-screen.lg\:ml-64,
body:has(aside.sidebar) div.relative.min-h-screen.lg\:ml-\[72px\] {
  margin-left: 0 !important;
  padding-top: var(--island-total) !important;
}

body:has(aside.sidebar) main {
  padding: 20px 24px 28px !important;
}

body:has(aside.sidebar) main > * {
  max-width: 1600px;
}

body:has(aside.sidebar) .table-page-layout {
  height: calc(100vh - var(--island-total) - 64px - 48px) !important;
}

/* ---- Cards -------------------------------------------------------------- */
body:has(aside.sidebar) .card {
  border: 1px solid var(--k-hairline) !important;
  border-radius: 14px !important;
  background: var(--k-surface) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition: border-color 180ms ease, box-shadow 180ms ease !important;
}

html.dark body:has(aside.sidebar) .card {
  background: var(--k-surface) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
}

body:has(aside.sidebar) .card:hover {
  border-color: rgba(20, 184, 166, 0.35) !important;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06) !important;
}

body:has(aside.sidebar) .card-header {
  padding: 14px 18px !important;
  border-bottom: 1px solid var(--k-hairline) !important;
}

body:has(aside.sidebar) .card-body {
  padding: 18px !important;
}

body:has(aside.sidebar) .card-glass {
  border: 1px solid var(--k-hairline) !important;
  border-radius: 14px !important;
  background: var(--k-surface) !important;
}

/* ---- Dark mode: graphite instead of slate ------------------------------- */
/* The app hardcodes Tailwind slate in dark mode (dark-950 #020617 for the
   canvas, dark-800 #1e293b for panels), which reads distinctly blue. Re-point
   those specific utilities to neutral greys. Scoped to html.dark so light mode
   is untouched, and only covers surfaces/text, not the accent colours. */

html.dark body:has(aside.sidebar) .dark\:bg-dark-950,
html.dark body:has(aside.sidebar) [class*="dark:bg-dark-950"] {
  background-color: #0e0e10 !important;
}

html.dark body:has(aside.sidebar) [class*="dark:bg-dark-900"] {
  background-color: #141416 !important;
}

html.dark body:has(aside.sidebar) [class*="dark:bg-dark-800"] {
  background-color: #1a1a1c !important;
}

html.dark body:has(aside.sidebar) [class*="dark:bg-dark-700"] {
  background-color: #242427 !important;
}

html.dark body:has(aside.sidebar) [class*="dark:bg-dark-600"] {
  background-color: #2e2e32 !important;
}

/* Muted text: swap the blue-grey ramp for a neutral one. */
html.dark body:has(aside.sidebar) [class*="dark:text-dark-400"],
html.dark body:has(aside.sidebar) [class*="dark:text-dark-500"] {
  color: #8a8a90 !important;
}

html.dark body:has(aside.sidebar) [class*="dark:text-dark-300"] {
  color: #a8a8ae !important;
}

/* Borders pick up the same neutral cast. */
html.dark body:has(aside.sidebar) [class*="dark:border-dark-800"],
html.dark body:has(aside.sidebar) [class*="dark:border-dark-700"],
html.dark body:has(aside.sidebar) [class*="dark:border-dark-600"] {
  border-color: rgba(255, 255, 255, 0.09) !important;
}

/* Inputs and secondary buttons sit on dark-700; give them the graphite fill. */
html.dark body:has(aside.sidebar) input,
html.dark body:has(aside.sidebar) textarea,
html.dark body:has(aside.sidebar) select {
  background-color: #1a1a1c !important;
  border-color: rgba(255, 255, 255, 0.11) !important;
  color: #ededf0 !important;
}

html.dark body:has(aside.sidebar) .btn-secondary {
  background-color: #202023 !important;
  border-color: rgba(255, 255, 255, 0.1) !important;
  color: #e4e4e7 !important;
}

/* Table rows, hovers and striped surfaces. */
html.dark body:has(aside.sidebar) tr:hover,
html.dark body:has(aside.sidebar) [class*="dark:hover:bg-dark-800"]:hover,
html.dark body:has(aside.sidebar) [class*="dark:hover:bg-dark-700"]:hover {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

body:has(aside.sidebar) .card {
  background: var(--k-surface);
}

html.dark body:has(aside.sidebar) .card {
  background: var(--k-surface) !important;
  border-color: var(--k-hairline) !important;
}

/* ---- Island: header components relocated into the pill ------------------ */
/* The bell / locale switcher / balance pill are moved here by karser-island.js.
   They arrive wrapped in their original Tailwind markup, so they need a little
   normalising to sit flush with the nav icons. */
body:has(aside.sidebar) .k-island-cluster {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 2px !important;
  flex: 0 0 auto !important;
  overflow: visible !important;
}

body:has(aside.sidebar) .k-island-cluster > div {
  display: flex !important;
  align-items: center !important;
}

/* Buttons inside the cluster: 34px tall, icon-ish, matching the nav row. */
body:has(aside.sidebar) .k-island-cluster button {
  height: 34px !important;
  min-height: 0 !important;
  padding: 0 8px !important;
  border: 0 !important;
  border-radius: 9999px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #4b5563 !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  transition: background-color 160ms ease, color 160ms ease !important;
}

html.dark body:has(aside.sidebar) .k-island-cluster button {
  color: #cbd5e1 !important;
}

body:has(aside.sidebar) .k-island-cluster button:hover {
  background: rgba(255, 255, 255, 0.62) !important;
  color: #0f172a !important;
}

html.dark body:has(aside.sidebar) .k-island-cluster button:hover {
  background: rgba(148, 163, 184, 0.2) !important;
  color: #f1f5f9 !important;
}

body:has(aside.sidebar) .k-island-cluster button svg {
  width: 18px !important;
  height: 18px !important;
}

/* The locale switcher reveals its country code only on wider screens; in the
   island there is room for it, so keep it visible. */
body:has(aside.sidebar) .k-island-cluster .hidden.sm\:inline {
  display: inline !important;
}

/* The balance pill keeps its teal emphasis but shrinks to island scale. */
body:has(aside.sidebar) .k-island-cluster .bg-primary-50 {
  height: 30px !important;
  padding: 0 10px !important;
  border-radius: 9999px !important;
  gap: 5px !important;
}

body:has(aside.sidebar) .k-island-cluster .bg-primary-50 span {
  font-size: 12.5px !important;
}

body:has(aside.sidebar) .k-island-cluster .bg-primary-50 svg {
  width: 15px !important;
  height: 15px !important;
}

/* Balance tooltip must not be clipped by the bar it hangs from. */
body:has(aside.sidebar) .k-island-cluster .group.relative {
  overflow: visible !important;
}

/* ---- Logout card injected at the foot of /profile ---------------------- */
body:has(aside.sidebar) .k-logout-card {
  margin-top: 18px;
  border: 1px solid rgba(220, 38, 38, 0.22);
  border-radius: 14px;
  background: var(--k-surface);
  overflow: hidden;
}

body:has(aside.sidebar) .k-logout-card .k-logout-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
}

body:has(aside.sidebar) .k-logout-text strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

body:has(aside.sidebar) .k-logout-text span {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: #64748b;
}

html.dark body:has(aside.sidebar) .k-logout-text strong { color: #e2e8f0; }
html.dark body:has(aside.sidebar) .k-logout-text span { color: #94a3b8; }

body:has(aside.sidebar) .k-logout-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.06);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

body:has(aside.sidebar) .k-logout-btn:hover {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.45);
}

body:has(aside.sidebar) .k-logout-btn:active {
  transform: translateY(1px);
}

html.dark body:has(aside.sidebar) .k-logout-btn {
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(248, 113, 113, 0.35);
}

body:has(aside.sidebar) .k-logout-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- Motion + a11y ------------------------------------------------------ */
@keyframes k-card-in {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

body:has(aside.sidebar) :focus-visible,
body:not(:has(aside.sidebar)) :focus-visible {
  outline: 2px solid var(--k-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  #app *,
  #app *::before,
  #app *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Narrow screens ----------------------------------------------------- */
@media (max-width: 1400px) {
  body:has(aside.sidebar) .sidebar-header .sidebar-brand,
  body:has(aside.sidebar) .sidebar-header::after {
    display: none !important;
  }
}

@media (max-width: 1024px) {
  /* Touch devices have no hover; scroll the row instead of overflowing. */
  body:has(aside.sidebar) .sidebar-nav {
    overflow-x: auto !important;
    overflow-y: hidden !important;
  }
}

@media (max-width: 768px) {
  :root {
    --island-h: 44px;
    --island-total: 64px;
  }
  body:has(aside.sidebar) aside.sidebar {
    max-width: calc(100% - 12px) !important;
    padding: 0 6px !important;
  }
  body:has(aside.sidebar) main {
    padding: 16px 14px 24px !important;
  }
  body:has(aside.sidebar) header.glass > div {
    height: 50px !important;
  }
  body:has(aside.sidebar) .table-page-layout {
    height: calc(100vh - var(--island-total) - 58px - 40px) !important;
  }
}

/* ==========================================================================
   Nav items hidden per request: 渠道管理 (group), 渠道状态, 我的订阅.
   Matched by route href rather than the Chinese label, so a locale switch or
   a copy tweak can't silently un-hide them. /admin/channels never appears as
   an href in the nav, so no route collision to worry about.
   ========================================================================== */
body:has(aside.sidebar) aside.sidebar .sidebar-link[href="/monitor"],
body:has(aside.sidebar) aside.sidebar .sidebar-link[href="/subscriptions"] {
  display: none !important;
}

/* 渠道管理 is a <button> group (no href). It is the only expandable group left
   in the sidebar, so hiding the group + its nested submenu container by class
   is unambiguous. The submenu can't render while its toggle is gone, but hide
   the container too so an already-open menu doesn't linger mid-transition. */
body:has(aside.sidebar) aside.sidebar button.sidebar-link:has(> .sidebar-label-flex),
body:has(aside.sidebar) aside.sidebar .sidebar-nav .mb-1.ml-4.border-l {
  display: none !important;
}

/* ==========================================================================
   Customer dashboard: eight metric tiles fold into one hero panel.
   --------------------------------------------------------------------------
   The app renders two 4-up grids of .card tiles. The reference layout leads
   with the balance and inlines everything else, so the two rows are joined
   into a single surface: row 1 keeps the balance oversized, every remaining
   metric becomes a compact inline stat. Tile chrome and the coloured icon
   chips are dropped — they were most of the visual noise.
   ========================================================================== */

/* Both metric rows become one continuous surface. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 0 !important;
  padding: 0 22px !important;
  border: 1px solid var(--k-hairline) !important;
  background: var(--k-surface) !important;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) {
  border-radius: 16px 16px 0 0 !important;
  border-bottom: 1px solid var(--k-hairline) !important;
  padding-top: 18px !important;
  padding-bottom: 16px !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(2) {
  /* Defeat space-y-6 so the two rows read as one card. */
  margin-top: 0 !important;
  border-radius: 0 0 16px 16px !important;
  border-top: 0 !important;
  padding-top: 15px !important;
  padding-bottom: 17px !important;
}

/* Tiles drop their own card chrome. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card {
  min-width: 0 !important;
  overflow: hidden !important;
  padding: 5px 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: none !important;
  box-shadow: none !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card:hover {
  border-color: transparent !important;
  box-shadow: none !important;
}

/* The coloured icon chips carried most of the noise; the reference has none. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card > div > div.rounded-lg {
  display: none !important;
}

/* Inline stats sit on one baseline and align left within their slot. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card > div {
  display: block !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card p {
  line-height: 1.35 !important;
}

/* ---- The balance leads: full width, oversized figure ------------------- */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) > .card:first-child {
  grid-column: 1 / -1 !important;
  margin-bottom: 15px;
  padding-bottom: 15px !important;
  border-bottom: 1px solid var(--k-hairline) !important;
}

/* The other three lead metrics share the remaining columns evenly. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) > .card:not(:first-child) {
  grid-column: span 1 !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) > .card:first-child p:first-child {
  font-size: 12.5px !important;
  font-weight: 500 !important;
  letter-spacing: 0.01em;
  color: var(--k-muted, #64748b) !important;
  text-transform: none;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) > .card:first-child p.text-xl {
  margin: 5px 0 3px !important;
  font-size: 40px !important;
  font-weight: 700 !important;
  line-height: 1.02 !important;
  letter-spacing: -0.03em !important;
  color: #0f172a !important;
}

html.dark body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) > .card:first-child p.text-xl {
  color: #f4f4f5 !important;
}

/* ---- Secondary metrics: quiet, compact, evenly spaced ------------------ */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card:not(:first-child) p:first-child,
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(2) > .card p:first-child {
  font-size: 11.5px !important;
  font-weight: 500 !important;
  color: var(--k-faint, #94a3b8) !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card:not(:first-child) p.text-xl,
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(2) > .card p.text-xl {
  margin: 3px 0 0 !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em !important;
}

/* Trend sub-lines ("0 启用", "总计: 0") stay small and muted. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card:not(:first-child) p.text-xs:last-child,
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(2) > .card p.text-xs:last-child {
  margin-top: 2px !important;
  font-size: 10.5px !important;
  line-height: 1.3 !important;
}

/* The in-row colour highlights on 今日消费 read as noise at this size. */
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card span.text-purple-600,
body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) > .card span.text-purple-400 {
  color: inherit !important;
}

/* ---- The charts row keeps its cards, but calmer ----------------------- */
body:has(aside.sidebar) main > div.space-y-6 > div.space-y-6 > .card {
  border-radius: 16px !important;
}

body:has(aside.sidebar) main > div.space-y-6 > div.space-y-6 > .card .card-body,
body:has(aside.sidebar) main > div.space-y-6 > div.space-y-6 > .card > div {
  padding: 16px 18px !important;
}

/* Phones: four columns squeeze each metric to ~74px, so drop to two.
   The balance keeps spanning the full width above them. */
@media (max-width: 768px) {
  body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    row-gap: 4px !important;
    padding: 0 16px !important;
  }

  body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(1) > .card:first-child p.text-xl {
    font-size: 32px !important;
  }
}

@media (max-width: 768px) {
  body:has(aside.sidebar) .k-page-head h1 {
    font-size: 21px;
  }
  body:has(aside.sidebar) .k-page-head p {
    font-size: 13px;
  }
}

/* ---- Create-key modal: collapsible 高级设置 ----------------------------- */
/* karser-island.js inserts .k-key-adv-toggle right after the 自定义密钥 row.
   Everything below it is optional, and leaving it open overflows the dialog's
   own max-height and clips the last row. Hide those siblings unless the form
   carries .k-key-adv-open. */
body:has(aside.sidebar) [role="dialog"] form:not(.k-key-adv-open) > .k-key-adv-toggle ~ * {
  display: none !important;
}

body:has(aside.sidebar) [role="dialog"] .k-key-adv-toggle > button {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 2px 0 2px;
  padding: 9px 0;
  border: 0;
  border-top: 1px solid var(--k-hairline);
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--k-muted, #64748b);
  cursor: pointer;
  transition: color 160ms ease;
}

body:has(aside.sidebar) [role="dialog"] .k-key-adv-toggle > button:hover {
  color: var(--k-ink, #0f172a);
}

body:has(aside.sidebar) [role="dialog"] .k-key-adv-toggle svg {
  width: 15px;
  height: 15px;
  margin-left: auto;
  transition: transform 200ms ease;
}

body:has(aside.sidebar) [role="dialog"] form.k-key-adv-open .k-key-adv-toggle svg {
  transform: rotate(180deg);
}

html.dark body:has(aside.sidebar) [role="dialog"] .k-key-adv-toggle > button:hover {
  color: #ededf0;
}

/* Collapsing shrinks the form, so let the body scroll cleanly when expanded. */
body:has(aside.sidebar) [role="dialog"] .modal-body {
  overflow-y: auto !important;
}

/* Keep the dialog vertically centred instead of letting the expanded form push
   it against the top of the viewport. The body scrolls; the shell stays put. */
body:has(aside.sidebar) [role="dialog"] .modal-overlay {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 24px 16px !important;
}

body:has(aside.sidebar) [role="dialog"] .modal-content {
  margin: 0 !important;
  max-height: min(760px, calc(100vh - 48px)) !important;
  overflow: hidden !important;
}

/* ---- /usage: 实时用量 / 图形统计 tabs ------------------------------------ */
/* karser-island.js tags each block and stamps the active tab on <html>. */
body:has(aside.sidebar) .k-usage-tabs {
  display: inline-flex;
  gap: 2px;
  margin: 0 0 18px;
  padding: 3px;
  border: 1px solid var(--k-hairline);
  border-radius: 11px;
  background: var(--k-surface);
}

body:has(aside.sidebar) .k-usage-tab {
  padding: 7px 16px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 550;
  color: #64748b;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

body:has(aside.sidebar) .k-usage-tab:hover {
  color: #0f172a;
  background: rgba(15, 23, 42, 0.05);
}

body:has(aside.sidebar) .k-usage-tab[aria-selected="true"] {
  color: #0d7a6f;
  background: transparent;
}

html.dark body:has(aside.sidebar) .k-usage-tab {
  color: #94a3b8;
}

html.dark body:has(aside.sidebar) .k-usage-tab:hover {
  color: #e2e8f0;
  background: rgba(148, 163, 184, 0.1);
}

html.dark body:has(aside.sidebar) .k-usage-tab[aria-selected="true"] {
  color: #5eead4;
  background: transparent;
}

/* Sliding pill behind the selected tab. Positioned by karser-island.js. */
body:has(aside.sidebar) .k-usage-tabs {
  position: relative;
}

body:has(aside.sidebar) .k-usage-tab {
  position: relative;
  z-index: 1;
}

body:has(aside.sidebar) .k-usage-indicator {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  width: 0;
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.14);
  transition:
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    width 320ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

html.dark body:has(aside.sidebar) .k-usage-indicator {
  background: rgba(20, 184, 166, 0.18);
}

body:has(aside.sidebar) .k-usage-tabs.k-no-anim .k-usage-indicator {
  transition: none;
}

/* Panel slide. Blocks come back from display:none on every switch, which
   restarts their animation, so each switch slides in from the side of the tab
   that was clicked: 图形统计 (right tab) enters from the right, 实时用量 (left
   tab) from the left. No direction attribute on first load -> no animation. */
@keyframes k-usage-in-next {
  from { opacity: 0; transform: translateX(36px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes k-usage-in-prev {
  from { opacity: 0; transform: translateX(-36px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* The summary stat row (.grid-cols-2) stays visible on both tabs, so it is
   left out: sliding something that didn't change just reads as a jolt. */
html[data-k-usage-dir="next"] body:has(aside.sidebar) main .k-usage-charts,
html[data-k-usage-dir="next"] body:has(aside.sidebar) main .k-usage-live:not(.grid-cols-2) {
  animation: k-usage-in-next 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

html[data-k-usage-dir="prev"] body:has(aside.sidebar) main .k-usage-charts,
html[data-k-usage-dir="prev"] body:has(aside.sidebar) main .k-usage-live:not(.grid-cols-2) {
  animation: k-usage-in-prev 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Slight stagger so the stacked blocks don't move as one slab. */
html[data-k-usage-dir] body:has(aside.sidebar) main .k-usage-live:nth-child(2),
html[data-k-usage-dir] body:has(aside.sidebar) main .k-usage-charts:nth-child(2) {
  animation-delay: 40ms;
}

html[data-k-usage-dir] body:has(aside.sidebar) main .k-usage-live:nth-child(3),
html[data-k-usage-dir] body:has(aside.sidebar) main .k-usage-live:nth-child(4) {
  animation-delay: 80ms;
}

/* Tab switching: the tagged blocks are the only ones that respond. */
html[data-k-usage-tab="live"] body:has(aside.sidebar) main .k-usage-charts,
html[data-k-usage-tab="charts"] body:has(aside.sidebar) main .k-usage-live {
  display: none !important;
}

/* ==========================================================================
   Customer dashboard: keep only the balance + metrics panel.
   --------------------------------------------------------------------------
   Everything below the metric grids is dropped — the date-range filter row,
   both chart cards, and the "最近使用 / 快捷操作" pair. That leaves the single
   hero panel as the whole page.

   Scoped by the route marker karser-island.js stamps on <html>, because the
   admin dashboard renders the same metric-grid markup and must keep its
   charts.

   Indexing note: <main> holds [.k-page-head, div.space-y-6]. Inside that
   space-y-6 the children are 1) metric row, 2) metric row, 3) filter+charts,
   4) recent/quick-actions — so n+3 removes the last two blocks.
   ========================================================================== */
html[data-k-route="/dashboard"] body:has(aside.sidebar) main > div.space-y-6 > div:nth-child(n + 3) {
  display: none !important;
}

/* The panel is the page now, so give it room instead of a stacked gap. */
html[data-k-route="/dashboard"] body:has(aside.sidebar) main > div.space-y-6 {
  margin-top: 0 !important;
}

html[data-k-route="/dashboard"] body:has(aside.sidebar) main > div.space-y-6 > div.grid.grid-cols-2:has(> .card):nth-child(2) {
  border-radius: 0 0 16px 16px !important;
}

/* ==========================================================================
   Page header folded into the content area.
   karser-island.js hides header.glass and mirrors its title/subtitle here, so
   the title still tracks the route without the extra sticky strip.
   ========================================================================== */
body:has(aside.sidebar) header.glass {
  display: none !important;
}

body:has(aside.sidebar) main {
  /* The header used to sit under the island; now main sits directly below it. */
  padding: 22px 24px 28px !important;
}

body:has(aside.sidebar) .k-page-head {
  margin: 0 0 18px;
}

body:has(aside.sidebar) .k-page-head h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #0f172a;
}

body:has(aside.sidebar) .k-page-head p {
  margin: 5px 0 0;
  font-size: 14px;
  line-height: 1.45;
  color: #64748b;
}

html.dark body:has(aside.sidebar) .k-page-head h1 {
  color: #ededf0;
}

html.dark body:has(aside.sidebar) .k-page-head p {
  color: #8a8a90;
}
