/* Xiaomai console theme: visual-only, scoped to authenticated routes. */
html[data-xiaomai-page="console"] {
  --xm-ink: #202a25;
  --xm-muted: #6e7872;
  --xm-paper: #f5f3ee;
  --xm-surface: #fffefa;
  --xm-sidebar: #faf9f5;
  --xm-line: #dedfd8;
  --xm-line-strong: #cfd3ca;
  --xm-accent: #173e31;
  --xm-accent-soft: #e6eee9;
  --xm-focus: rgba(23, 62, 49, .18);
}

html[data-xiaomai-page="console"] body {
  background: var(--xm-paper) !important;
  color: var(--xm-ink) !important;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Microsoft YaHei", sans-serif !important;
}

html[data-xiaomai-page="console"] body * {
  border-color: var(--xm-line);
}

html[data-xiaomai-page="console"] header {
  background: rgba(255, 254, 250, .92) !important;
  border-bottom: 1px solid var(--xm-line) !important;
  box-shadow: 0 1px 0 rgba(32, 42, 37, .025) !important;
  backdrop-filter: blur(14px);
}

html[data-xiaomai-page="console"] [data-sidebar="sidebar"] {
  background: var(--xm-sidebar) !important;
  border-right: 1px solid var(--xm-line) !important;
}

html[data-xiaomai-page="console"] [data-sidebar="sidebar"] [data-sidebar="header"] {
  background: transparent !important;
  border-bottom: 0 !important;
  box-shadow: none !important;
}

html[data-xiaomai-page="console"] [data-sidebar="content"] {
  padding: 14px 10px !important;
  scrollbar-color: #c8cec7 transparent;
}

html[data-xiaomai-page="console"] [data-sidebar="group-label"] {
  color: #8a938d !important;
  font-size: 10px !important;
  font-weight: 650 !important;
  letter-spacing: .13em !important;
  text-transform: uppercase;
}

html[data-xiaomai-page="console"] [data-sidebar="menu-button"] {
  min-height: 36px !important;
  border: 1px solid transparent !important;
  border-radius: 8px !important;
  color: #5c6861 !important;
  font-size: 13px !important;
  transition: background .16s ease, border-color .16s ease, color .16s ease !important;
}

html[data-xiaomai-page="console"] [data-sidebar="menu-button"]:hover {
  background: #f0f2ed !important;
  border-color: #e4e7df !important;
  color: var(--xm-ink) !important;
}

html[data-xiaomai-page="console"] [data-sidebar="menu-button"][data-active="true"],
html[data-xiaomai-page="console"] [data-sidebar="menu-button"][aria-current="page"] {
  background: var(--xm-accent-soft) !important;
  border-color: #d3e1d8 !important;
  color: var(--xm-accent) !important;
  font-weight: 650 !important;
}

html[data-xiaomai-page="console"] [data-sidebar="menu-button"] svg {
  color: currentColor !important;
  opacity: .82;
}

html[data-xiaomai-page="console"] main[data-slot="sidebar-inset"] {
  background: var(--xm-paper) !important;
}

html[data-xiaomai-page="console"] main[data-slot="sidebar-inset"] > * {
  scrollbar-color: #c8cec7 transparent;
}

html[data-xiaomai-page="console"] [data-slot="card"],
html[data-xiaomai-page="console"] [data-card-hover] {
  border: 1px solid var(--xm-line) !important;
  border-radius: 12px !important;
  background: var(--xm-surface) !important;
  box-shadow: 0 8px 24px rgba(42, 53, 46, .045) !important;
}

html[data-xiaomai-page="console"] [data-slot="card-header"] {
  border-bottom: 1px solid #ebece6 !important;
  background: #fffefa !important;
}

html[data-xiaomai-page="console"] [data-slot="card-title"],
html[data-xiaomai-page="console"] h1,
html[data-xiaomai-page="console"] h2,
html[data-xiaomai-page="console"] h3 {
  color: var(--xm-ink) !important;
  letter-spacing: -.018em;
}

html[data-xiaomai-page="console"] [data-slot="button"],
html[data-xiaomai-page="console"] button {
  border-radius: 8px !important;
  transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease !important;
}

html[data-xiaomai-page="console"] [data-slot="button"]:focus-visible,
html[data-xiaomai-page="console"] button:focus-visible,
html[data-xiaomai-page="console"] input:focus-visible,
html[data-xiaomai-page="console"] textarea:focus-visible,
html[data-xiaomai-page="console"] select:focus-visible {
  outline: 2px solid var(--xm-accent) !important;
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--xm-focus) !important;
}

html[data-xiaomai-page="console"] [data-slot="input"],
html[data-xiaomai-page="console"] input,
html[data-xiaomai-page="console"] textarea,
html[data-xiaomai-page="console"] select {
  border-color: var(--xm-line-strong) !important;
  border-radius: 8px !important;
  background: #fffefa !important;
  color: var(--xm-ink) !important;
  box-shadow: none !important;
}

html[data-xiaomai-page="console"] [data-slot="input"]:focus,
html[data-xiaomai-page="console"] input:focus,
html[data-xiaomai-page="console"] textarea:focus,
html[data-xiaomai-page="console"] select:focus {
  border-color: #8aa596 !important;
  box-shadow: 0 0 0 3px var(--xm-focus) !important;
}

html[data-xiaomai-page="console"] table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
  overflow: hidden;
  border: 1px solid var(--xm-line) !important;
  border-radius: 10px !important;
  background: var(--xm-surface) !important;
}

html[data-xiaomai-page="console"] th {
  background: #f3f4ef !important;
  color: #66736b !important;
  font-size: 11px !important;
  font-weight: 650 !important;
  letter-spacing: .035em;
  text-transform: uppercase;
}

html[data-xiaomai-page="console"] td,
html[data-xiaomai-page="console"] th {
  border-bottom: 1px solid #eceee8 !important;
}

html[data-xiaomai-page="console"] tr:last-child td {
  border-bottom: 0 !important;
}

html[data-xiaomai-page="console"] [role="dialog"],
html[data-xiaomai-page="console"] [data-slot="dialog-content"] {
  border: 1px solid var(--xm-line-strong) !important;
  border-radius: 12px !important;
  background: #fffefa !important;
  box-shadow: 0 24px 70px rgba(24, 35, 29, .18) !important;
}

html[data-xiaomai-page="console"] [data-slot="popover-content"],
html[data-xiaomai-page="console"] [data-slot="dropdown-menu-content"] {
  border: 1px solid var(--xm-line) !important;
  border-radius: 10px !important;
  background: #fffefa !important;
  box-shadow: 0 16px 40px rgba(24, 35, 29, .12) !important;
}

html[data-xiaomai-page="console"] [data-slot="badge"] {
  border-radius: 999px !important;
  font-weight: 600 !important;
}

html[data-xiaomai-page="console"] ::selection {
  background: #cfe0d5;
  color: #143c2e;
}

html.dark[data-xiaomai-page="console"] {
  --xm-ink: #e7eee9;
  --xm-muted: #a6b4aa;
  --xm-paper: #121914;
  --xm-surface: #18231d;
  --xm-sidebar: #151e19;
  --xm-line: #2d3a31;
  --xm-line-strong: #3b4a3f;
  --xm-accent: #c4e0ce;
  --xm-accent-soft: #21382b;
  --xm-focus: rgba(167, 214, 181, .2);
}

html.dark[data-xiaomai-page="console"] body,
html.dark[data-xiaomai-page="console"] main[data-slot="sidebar-inset"] {
  background: var(--xm-paper) !important;
  color: var(--xm-ink) !important;
}

html.dark[data-xiaomai-page="console"] header,
html.dark[data-xiaomai-page="console"] [data-sidebar="sidebar"],
html.dark[data-xiaomai-page="console"] [data-slot="card"],
html.dark[data-xiaomai-page="console"] [data-card-hover],
html.dark[data-xiaomai-page="console"] [role="dialog"],
html.dark[data-xiaomai-page="console"] [data-slot="dialog-content"],
html.dark[data-xiaomai-page="console"] [data-slot="popover-content"],
html.dark[data-xiaomai-page="console"] [data-slot="dropdown-menu-content"] {
  background: var(--xm-surface) !important;
  border-color: var(--xm-line) !important;
}

html.dark[data-xiaomai-page="console"] [data-slot="card-header"],
html.dark[data-xiaomai-page="console"] th {
  background: #1c2a22 !important;
  border-color: var(--xm-line) !important;
}

html.dark[data-xiaomai-page="console"] [data-slot="input"],
html.dark[data-xiaomai-page="console"] input,
html.dark[data-xiaomai-page="console"] textarea,
html.dark[data-xiaomai-page="console"] select {
  background: #121a15 !important;
  color: var(--xm-ink) !important;
  border-color: var(--xm-line-strong) !important;
}

@media (max-width: 768px) {
  html[data-xiaomai-page="console"] [data-sidebar="content"] { padding: 10px 8px !important; }
  html[data-xiaomai-page="console"] [data-slot="card-header"],
  html[data-xiaomai-page="console"] [data-slot="card-content"] { padding: 17px !important; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-xiaomai-page="console"] * { transition-duration: .01ms !important; }
}

/* Sticky cells must use the outer scrolling viewport, not a clipped table. */
html[data-xiaomai-page="console"] [data-slot="table"]:has([data-column-id="actions"]) {
  overflow: visible !important;
  isolation: isolate;
}

/* Keep the header above pinned body cells during vertical scrolling. */
html[data-xiaomai-page="console"] [data-slot="table"]:has([data-column-id="actions"]) > thead {
  z-index: 31 !important;
}

/* Keep the API key actions available while the table scrolls horizontally. */
html[data-xiaomai-page="console"] [data-slot="table"] [data-column-id="actions"] {
  position: sticky !important;
  right: 0 !important;
  z-index: 20 !important;
  min-width: 104px;
  background: var(--xm-surface, #fffefa) !important;
  box-shadow:
    -10px 0 16px -14px rgba(24, 35, 29, .68),
    inset 1px 0 var(--xm-line, #dedfd8) !important;
}

html[data-xiaomai-page="console"] [data-slot="table"] thead [data-column-id="actions"] {
  z-index: 30 !important;
  background: #f3f4ef !important;
}

html[data-xiaomai-page="console"] [data-slot="table"] tbody [data-column-id="actions"] {
  background: var(--xm-surface, #fffefa) !important;
}

html[data-xiaomai-page="console"] [data-slot="table"] tbody tr:hover [data-column-id="actions"] {
  background: #f8faf6 !important;
}

html.dark[data-xiaomai-page="console"] [data-slot="table"] [data-column-id="actions"] {
  background: var(--xm-surface, #18231d) !important;
  box-shadow:
    -10px 0 16px -14px rgba(0, 0, 0, .75),
    inset 1px 0 var(--xm-line, #2d3a31) !important;
}

html.dark[data-xiaomai-page="console"] [data-slot="table"] thead [data-column-id="actions"] {
  background: #1c2a22 !important;
}

html.dark[data-xiaomai-page="console"] [data-slot="table"] tbody tr:hover [data-column-id="actions"] {
  background: #203027 !important;
}
