/* ==========================================================================
   Okami-ID Admin Console

   Chỉ dùng cho các trang /admin/* render tĩnh (AdminShell.razor).

   File này KHÔNG định nghĩa lại color token — nó dùng lại các biến `:root` của
   `_content/Okami.Shared.Pwa/css/auth.css`, vốn đã được App.razor nạp trước.
   Nhờ vậy admin console giống hệt màn đăng nhập về màu/typography, nhưng có
   layout riêng: sidebar + vùng nội dung trải rộng, không cột thương hiệu,
   không thẻ 3D.

   Lý do tách khỏi auth.css: auth.css thuộc `Okami.Shared.Pwa` và được cả PWA
   dùng chung; màn quản trị chỉ tồn tại trong host Identity.Api.

   Token riêng của console được khai báo trên `.admin-shell` chứ không phải
   `:root`: đây là thang đo dày (dashboard density) chỉ đúng cho màn quản trị,
   đưa lên `:root` sẽ làm co cả màn đăng nhập vốn dùng chung body.
   ========================================================================== */

/* ==========================================================================
   Admin Top Loading Progress Bar
   ========================================================================== */
.admin-top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3.5px;
  width: 0%;
  background: linear-gradient(90deg, #0082FF 0%, #7B61FF 50%, #FF4B72 100%);
  background-size: 200% 100%;
  animation: admin-progress-shimmer 2s infinite linear;
  box-shadow: 0 0 16px rgba(123, 97, 255, 0.9), 0 0 6px rgba(255, 75, 114, 0.7);
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  border-radius: 0 3px 3px 0;
}

.admin-top-progress::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -3px;
  width: 7.5px;
  height: 7.5px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff, 0 0 16px #7B61FF;
}

.admin-top-progress.is-done {
  box-shadow: 0 0 20px rgba(0, 130, 255, 0.95);
}

@keyframes admin-progress-shimmer {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes admin-fade-in-up {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.admin-shell {
  /* Thang khoảng cách dày hơn màn đăng nhập: console hiển thị bảng và nhiều
     cặp nhãn/giá trị, không phải một form 6 dòng. */
  --admin-space-1: 4px;
  --admin-space-2: 8px;
  --admin-space-3: 12px;
  --admin-space-4: 16px;
  --admin-space-5: 20px;
  --admin-space-6: 24px;
  --admin-space-8: 32px;

  --admin-radius-sm: 9px;
  --admin-radius-md: 13px;
  --admin-radius-lg: 18px;

  /* Đường viền/nền lấy sắc tím của brand thay vì xám trung tính, để console
     không rơi về giao diện bootstrap mặc định. */
  --admin-line: rgba(18, 19, 25, 0.08);
  --admin-line-soft: rgba(18, 19, 25, 0.045);
  --admin-surface: rgba(255, 255, 255, 0.68);
  --admin-surface-solid: rgba(255, 255, 255, 0.92);
  --admin-hover: rgba(123, 97, 255, 0.06);
  --admin-focus-ring: 0 0 0 3px rgba(123, 97, 255, 0.28);

  /* Id, ví, hash: dùng mono để so sánh từng ký tự được. Không nạp webfont mới —
     app chạy trong Docker và màn quản trị không đáng một request font nữa. */
  --admin-mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* auth.css canh giữa body cho khung đăng nhập 1120x720 cố định. Console không
   sửa `body` (App.razor dùng chung cho mọi trang) mà tự trải rộng bên trong:
   một tấm panel bo góc lấp đầy viewport trừ padding của body. */
.admin-shell {
  display: flex;
  width: 100%;
  align-self: stretch;
  min-height: calc(100vh - 48px);
  background: var(--color-panel-bg);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--color-panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  position: relative;
  z-index: 1;
  animation: admin-shell-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

@keyframes admin-shell-in {
  from {
    opacity: 0;
    transform: scale(0.992) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Bàn phím: đường tắt nhảy thẳng vào nội dung, không phải tab qua cả sidebar. */
.admin-skip-link {
  position: absolute;
  left: var(--admin-space-4);
  top: var(--admin-space-4);
  z-index: 20;
  padding: 10px 16px;
  border-radius: var(--admin-radius-sm);
  background: #ffffff;
  color: var(--color-purple);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-panel);
  transform: translateY(-160%);
  transition: transform 0.15s ease;
}

.admin-skip-link:focus-visible {
  transform: translateY(0);
}

/* Mọi phần tử tương tác trong console phải có vòng focus nhìn thấy được —
   console điều khiển được hoàn toàn bằng bàn phím vì nó không có JavaScript. */
.admin-shell a:focus-visible,
.admin-shell button:focus-visible,
.admin-shell input:focus-visible,
.admin-shell select:focus-visible {
  outline: none;
  box-shadow: var(--admin-focus-ring);
  border-radius: var(--admin-radius-sm);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.admin-sidebar {
  width: 244px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: var(--admin-space-5) var(--admin-space-3) var(--admin-space-4);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 255, 255, 0.34) 100%);
  border-right: 1px solid var(--admin-line);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--color-text-main);
  padding: var(--admin-space-1) var(--admin-space-3) var(--admin-space-6);
  transition: opacity 0.2s ease;
}

/* Logo đặt trong một ô có quầng gradient của brand: 32px hình vuông trần trên
   nền kính trông như icon bị bỏ quên, không như dấu hiệu nhận diện. */
.admin-brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(123, 97, 255, 0.16);
  box-shadow: 0 4px 14px rgba(123, 97, 255, 0.16);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.admin-brand:hover .admin-brand-mark {
  transform: scale(1.08) rotate(-4deg);
  box-shadow: 0 6px 20px rgba(123, 97, 255, 0.32);
  border-color: rgba(123, 97, 255, 0.35);
}

.admin-brand-logo {
  width: 22px;
  height: 22px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.admin-brand:hover .admin-brand-logo {
  transform: scale(1.12);
}

.admin-brand-text {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.15;
  transition: color 0.2s ease;
}

.admin-brand-text small {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-top: 3px;
}

/* Brand làm ô chọn khu admin (okami-project#48): <select> trong suốt phủ lên cả brand, vẫn là select thật để
   danh sách mở được ở mọi bề rộng; vòng focus vẽ lên brand vì select không nhìn thấy. */
.admin-brand-switch {
  position: relative;
  cursor: pointer;
  border-radius: var(--admin-radius-md);
}

.admin-brand-switch:focus-within {
  box-shadow: var(--admin-focus-ring);
}

/* Mũi tên đứng sau "Okami ID", không sau "ADMINISTRATION": dòng dưới đã đầy ở tiếng Anh và đẩy nó xuống hàng. */
.admin-brand-name {
  white-space: nowrap;
}

.admin-brand-chevron {
  width: 14px;
  height: 14px;
  margin-left: 3px;
  vertical-align: -1px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--color-text-muted);
}

.admin-brand-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.admin-nav-heading {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding: var(--admin-space-2) var(--admin-space-3) var(--admin-space-1);
}

.admin-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--admin-radius-md);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-nav-link:hover {
  background: rgba(123, 97, 255, 0.08);
  color: var(--color-purple);
  transform: translateX(4px);
}

.admin-nav-link.active {
  background: rgba(123, 97, 255, 0.14);
  color: var(--color-purple);
  font-weight: 800;
}

/* Thanh dọc bên trái: khi nhiều mục nav xuất hiện (G7–G9), riêng nền tím nhạt
   không đủ để mắt bắt được mục đang mở trong một lượt quét. */
.admin-nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3.5px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--color-primary-gradient);
  box-shadow: 0 0 10px rgba(123, 97, 255, 0.8), 0 0 4px rgba(255, 75, 114, 0.5);
}

.admin-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.admin-nav-link:hover .admin-nav-icon {
  transform: scale(1.16) rotate(3deg);
  color: var(--color-purple);
}

/* Chân sidebar: đang đăng nhập là ai, và đường thoát. */
/* Hàng tài khoản ở góc trên bên phải cột nội dung: ngôn ngữ, ai đang đăng nhập,
   và lối ra. Một đường kẻ dưới tách nó khỏi tiêu đề và nút của chính trang, vốn
   nằm ở hàng kế tiếp. */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--admin-space-4);
  padding-bottom: var(--admin-space-3);
  margin-bottom: var(--admin-space-5);
  border-bottom: 1px solid var(--admin-line);
}

/* Chữ cái đầu thay cho ảnh đại diện: tài khoản quản trị không có avatar, và một
   ô trống ở đây còn tệ hơn không có gì. */
.admin-identity-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--color-primary-gradient);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(123, 97, 255, 0.3);
}

.admin-identity-email {
  display: block;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  /* Email dài không được đẩy thanh trên cùng rộng ra; cắt ở đuôi và giữ nguyên
     phần định danh phía trước. */
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-signout-form {
  margin: 0;
}

/* Menu tài khoản (AdminAccountMenu.razor): một chip ở thanh trên cùng mở ra tên, ngôn ngữ,
   theme, trang tài khoản và đăng xuất. Dưới 560px chip chỉ còn chữ cái đầu (quy tắc của drawer ở cuối file).
   Wallet và Mall có cùng menu này. */
.admin-account-menu {
  position: relative;
}

.admin-account-menu > summary {
  list-style: none;
  cursor: pointer;
}

.admin-account-menu > summary::-webkit-details-marker {
  display: none;
}

.admin-account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--admin-line);
  border-radius: 12px;
  background: var(--admin-surface-solid);
  transition: var(--transition-fast);
}

.admin-account-chip:hover,
.admin-account-menu[open] > .admin-account-chip {
  border-color: rgba(123, 97, 255, 0.3);
  background: var(--admin-hover);
}

.admin-account-chip:focus-visible {
  outline: none;
  box-shadow: var(--admin-focus-ring);
}

.admin-account-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--color-text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s ease;
}

.admin-account-menu[open] .admin-account-chevron {
  transform: rotate(180deg);
}

.admin-account-popover {
  position: absolute;
  right: 0;
  top: calc(100% + var(--admin-space-2));
  z-index: 40;
  width: min(300px, calc(100vw - 24px));
  padding: var(--admin-space-2);
  display: grid;
  gap: 2px;
  background: #ffffff;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-md);
  box-shadow: 0 18px 40px -12px rgba(18, 19, 25, 0.25);
}

.admin-account-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 8px 12px;
}

.admin-account-who {
  display: grid;
  min-width: 0;
}

.admin-account-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-main);
  overflow-wrap: anywhere;
}

.admin-account-email {
  font-size: 12.5px;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.admin-account-section {
  display: grid;
  gap: 6px;
  padding: 10px 8px;
  border-top: 1px solid var(--admin-line);
}

.admin-account-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

/* Nút phân đoạn: thấy ngay lựa chọn hiện tại, đổi chỉ bằng một lần bấm. Mục đang chọn là aria-current (link ngôn
   ngữ) hoặc aria-pressed="true" (nút theme, admin-shell.js đặt). */
.admin-segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(18, 19, 25, 0.05);
}

.admin-segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-fast);
}

.admin-segment:hover {
  color: var(--color-purple);
}

.admin-segment:focus-visible {
  outline: none;
  box-shadow: var(--admin-focus-ring);
}

.admin-segment[aria-current="true"],
.admin-segment[aria-pressed="true"] {
  background: #ffffff;
  color: var(--color-purple);
  box-shadow: 0 1px 3px rgba(18, 19, 25, 0.12);
}

.admin-segment-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.admin-account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-main);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

.admin-account-section + .admin-account-item {
  margin-top: 2px;
  border-top: 1px solid var(--admin-line);
  border-radius: 0;
  padding-top: 4px;
  min-height: 44px;
}

.admin-account-item:hover {
  background: var(--admin-hover);
  color: var(--color-purple);
}

.admin-account-item.danger:hover {
  background: var(--color-error-bg);
  color: var(--color-error-text);
}

.admin-account-item:focus-visible {
  outline: none;
  box-shadow: var(--admin-focus-ring);
}

/* --------------------------------------------------------------------------
   Vùng nội dung
   -------------------------------------------------------------------------- */
.admin-main {
  flex: 1;
  min-width: 0;
  padding: var(--admin-space-6) var(--admin-space-8) var(--admin-space-8);
  overflow-y: auto;
  animation: admin-fade-in-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-page-header {
  display: flex;
  align-items: flex-end;
  gap: var(--admin-space-4);
  flex-wrap: wrap;
  margin-bottom: var(--admin-space-5);
}

.admin-page-heading {
  min-width: 0;
  flex: 1;
}

/* Breadcrumb nằm TRÊN tiêu đề, không phải một link "quay lại" ở cuối trang:
   đường thoát phải nhìn thấy được ngay khi mở trang, không phải sau khi cuộn. */
.admin-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.admin-breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: var(--transition-fast);
}

/* Mục đầu ("ユーザー") không bao giờ bị ép xuống hai dòng. Các mục sau có thể là email của bản
   ghi — dài, không khoảng trắng — nên được tự ngắt thay vì đẩy mục cuối ra ngoài màn hình. */
.admin-breadcrumb > :first-child {
  white-space: nowrap;
}

.admin-breadcrumb > :not(:first-child) {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-breadcrumb a:hover {
  color: var(--color-purple);
}

.admin-breadcrumb-separator {
  opacity: 0.45;
}

/* The title is a user's display name, or their email when they have none — an address of a wallet
   account holds no space at all, so it is given a break opportunity like the subtitle below (#128). */
.admin-page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.2;
  color: var(--color-text-main);
  overflow-wrap: anywhere;
}

.admin-page-subtitle {
  font-size: 14.5px;
  color: var(--color-text-muted);
  margin-top: 5px;
  word-break: break-word;
}

.admin-page-actions {
  display: flex;
  align-items: center;
  gap: var(--admin-space-2);
  flex-shrink: 0;
}

.admin-panel {
  background: var(--admin-surface);
  border: 1px solid var(--color-panel-border);
  border-radius: var(--admin-radius-lg);
  padding: var(--admin-space-5) var(--admin-space-6);
  box-shadow: 0 10px 30px -5px rgba(18, 19, 25, 0.03);
}

/* Panel không viền, dùng khi nội dung đã tự chia thành các card. Bọc thêm một
   lớp khung quanh nhiều khung con chỉ tạo ra hai đường viền song song. */
.admin-panel.bare {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  animation: none;
}

/* --------------------------------------------------------------------------
   Card — nhóm thông tin có tiêu đề
   -------------------------------------------------------------------------- */
.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: var(--admin-space-4);
  align-items: start;
}

.admin-card {
  background: var(--admin-surface-solid);
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-lg);
  padding: var(--admin-space-5);
  min-width: 0;
  box-shadow: 0 4px 20px rgba(18, 19, 25, 0.03);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.25s ease;
}

.admin-card:hover {
  transform: translateY(-3.5px);
  border-color: rgba(123, 97, 255, 0.25);
  box-shadow: 0 14px 32px -4px rgba(123, 97, 255, 0.12), 0 4px 14px rgba(18, 19, 25, 0.04);
}

.admin-card.wide {
  grid-column: 1 / -1;
}

.admin-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding-bottom: var(--admin-space-3);
  margin-bottom: var(--admin-space-4);
  border-bottom: 1px solid var(--admin-line-soft);
}

/* Ô icon của tiêu đề card: nền tím rất nhạt + nét icon theo màu brand. Một hàng
   chữ hoa nhỏ màu xám tự nó không phân biệt được năm thẻ với nhau khi lướt mắt. */
.admin-card-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  background: rgba(123, 97, 255, 0.1);
  color: var(--color-purple);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, box-shadow 0.2s ease;
}

.admin-card:hover .admin-card-icon {
  transform: scale(1.15) rotate(-6deg);
  background: rgba(123, 97, 255, 0.18);
  box-shadow: 0 4px 12px rgba(123, 97, 255, 0.25);
}

.admin-card-icon svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------------------------------------------------
   Cặp nhãn / giá trị
   -------------------------------------------------------------------------- */
.admin-fields {
  display: grid;
  gap: var(--admin-space-4);
}

/* A radio with its label on one line (the 表示設定 tab of /admin/account); a fieldset lists them vertically. */
.admin-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 14px;
}

.admin-radio input[type="radio"] {
    accent-color: var(--okami-primary, #2563eb);
    width: 16px;
    height: 16px;
    margin: 0;
}

fieldset.input-group {
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

/* The group heading sits above 14px radio labels, so it must not be the 11px uppercase .input-label of a text box. */
fieldset.input-group > legend {
    padding: 0;
    margin-bottom: 4px;
    font-size: 14px;
    letter-spacing: normal;
    text-transform: none;
}

.admin-fields.two-up {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.admin-field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.admin-field-value {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--color-text-main);
  word-break: break-word;
}

/* Giá trị rỗng phải trông như "không có dữ liệu", không như chữ bị mất. */
.admin-field-value.empty {
  color: var(--color-text-muted);
  font-weight: 500;
}

.admin-field-value.mono {
  font-family: var(--admin-mono);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.2px;
  overflow-wrap: anywhere;
}

.admin-card-text {
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--color-text-main);
}

/* Đoạn văn phải giữ độ dài dòng đọc được; trong console rộng 1400px một cảnh báo
   trải hết bề ngang là 200 ký tự một dòng. */
.admin-narrow {
  max-width: 720px;
}

.admin-field-note {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-top: 3px;
}

/* --------------------------------------------------------------------------
   Nút
   -------------------------------------------------------------------------- */
/* auth.css chỉ có `.btn-primary` (nút submit full-width của form đăng nhập) và
   `.signup-link`. Console cần một bộ nút thật: các thao tác ở đây khác nhau về
   hệ quả — xuất dữ liệu cá nhân và khoá tài khoản không thể cùng là link xanh. */
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--admin-radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-btn:active {
  transform: scale(0.96) translateY(1px);
}

.admin-btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.admin-btn:hover .admin-btn-icon {
  transform: scale(1.15);
}

/* Icon-only row actions (the passkey tab's pencil and bin): square, the label in title/aria-label. */
.admin-btn.icon {
  padding: 8px;
}

.admin-btn.icon .admin-btn-icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.6;
}

.admin-passkey-actions form {
  display: inline-block;
}

/* The pencil sits right after the label it renames; the bin stays in the actions column. */
.admin-passkey-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-passkey-name form {
  display: inline-flex;
}

.admin-passkey-name .admin-btn.icon {
  padding: 5px;
}

.admin-passkey-name .admin-btn.icon .admin-btn-icon {
  width: 15px;
  height: 15px;
}

.admin-btn.primary {
  color: #ffffff;
  background: var(--color-primary-gradient);
  box-shadow: 0 4px 14px rgba(123, 97, 255, 0.28);
}

.admin-btn.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(123, 97, 255, 0.42);
}

.admin-btn.secondary {
  color: var(--color-text-main);
  background: var(--color-btn-secondary-bg);
  border-color: var(--color-btn-secondary-border);
  box-shadow: 0 2px 6px rgba(18, 19, 25, 0.03);
}

.admin-btn.secondary:hover {
  background: var(--color-btn-secondary-hover-bg);
  border-color: rgba(123, 97, 255, 0.3);
  color: var(--color-purple);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 16px rgba(123, 97, 255, 0.1);
}

.admin-btn.ghost {
  color: var(--color-text-muted);
  background: transparent;
}

.admin-btn.ghost:hover {
  background: rgba(123, 97, 255, 0.08);
  color: var(--color-purple);
  transform: translateX(2px);
}

/* Khoá tài khoản là hành động phá vỡ — nó không được trông giống "Xuất CSV". */
.admin-btn.danger {
  color: var(--color-error-text);
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
}

.admin-btn.danger:hover {
  background: var(--color-error-text);
  color: #ffffff;
  border-color: var(--color-error-text);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.25);
}

.admin-btn.solid-danger {
  color: #ffffff;
  background: var(--color-error-text);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.24);
}

.admin-btn.solid-danger:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(239, 68, 68, 0.42);
}

/* --------------------------------------------------------------------------
   Thanh công cụ & form tìm kiếm
   -------------------------------------------------------------------------- */
.admin-toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--admin-space-3);
  flex-wrap: wrap;
}

/* Đẩy nhóm hành động sang phải: ô tìm kiếm bên trái, thao tác trên kết quả bên
   phải — hai vai trò khác nhau thì không xếp cạnh nhau như một danh sách link. */
.admin-toolbar-spacer {
  flex: 1;
  min-width: var(--admin-space-4);
}

/* Form trong màn quản trị không kéo dài hết bề ngang panel — một ô input rộng
   1100px không dễ đọc hơn ô rộng 420px. */
.admin-search {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex: 0 1 540px;
  min-width: 280px;
}

.admin-search .input-group {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.admin-search .input-label {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  display: block;
}

.admin-search .input-wrapper.has-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.admin-search .input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  stroke: var(--color-purple);
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.65;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), stroke 0.2s ease;
}

.admin-search .input-wrapper.has-icon:focus-within .input-icon {
  opacity: 1;
  transform: scale(1.18) rotate(-4deg);
  stroke: var(--color-purple);
}

.admin-search .form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid rgba(123, 97, 255, 0.2);
  box-shadow: 0 2px 8px rgba(18, 19, 25, 0.03);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-search .input-wrapper.has-icon .form-input {
  padding-left: 42px;
}

.admin-search .form-input:focus {
  border-color: var(--color-purple);
  box-shadow: 0 0 0 4px rgba(123, 97, 255, 0.18), 0 8px 24px rgba(123, 97, 255, 0.12);
  transform: translateY(-1px);
  outline: none;
}

/* Xếp dọc các khối của một trang khi trang tự dựng bố cục (`Bare`), thay cho
   một loạt margin rời rạc trên từng khối. */
.admin-stack {
  display: grid;
  gap: var(--admin-space-4);
}

/* --------------------------------------------------------------------------
   Bảng
   -------------------------------------------------------------------------- */
.admin-table-wrapper {
  /* Bảng rộng cuộn trong khung của chính nó, không đẩy cả trang cuộn ngang. */
  overflow-x: auto;
  /* overflow-x: auto kéo trục dọc thành auto: hàng bảng đang lướt lên (admin-fade, translateY) lòi khỏi khung vài px
     và hiện thanh cuộn dọc trong lúc animation. Khung nào cần cuộn dọc thì tự đặt lại (vd .sales-import-changes). */
  overflow-y: hidden;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-lg);
  background: var(--admin-surface-solid);
  box-shadow: 0 10px 30px -5px rgba(18, 19, 25, 0.04);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.admin-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 13px var(--admin-space-4);
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--color-text-muted);
  background: rgba(246, 248, 251, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--admin-line);
  white-space: nowrap;
}

.admin-table td {
  padding: 13px var(--admin-space-4);
  border-bottom: 1px solid var(--admin-line-soft);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr {
  transition: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.admin-table tbody tr:hover {
  background: rgba(123, 97, 255, 0.055);
}

/* Cột trạng thái là câu trả lời, không phải phần đuôi thừa: ghim nó vào chiều
   rộng của chính nó thay vì để bảng kéo nó ra tận rìa phải màn hình. */
.admin-table .col-status {
  width: 1%;
  white-space: nowrap;
}

/* Ngày và badge không được ngắt dòng — cột co lại tới mức đó thì nên cuộn ngang,
   chứ không phải bẻ "2026-04-22" thành hai dòng. */
.admin-table td.nowrap {
  white-space: nowrap;
}

.admin-table .col-name {
  width: 30%;
}

.admin-table a {
  color: var(--color-text-main);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.18s ease;
}

.admin-table a:hover {
  color: var(--color-purple);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Chữ cái đầu trên nền màu suy ra từ chính id của tài khoản: cùng một hàng luôn
   ra cùng một màu, nên mắt nhận lại được một dòng đã xem mà không phải đọc email.
   Màu chỉ để nhận dạng — mọi thông tin trạng thái vẫn nằm ở cột Status. */
.admin-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 11px;
  font-size: 13.5px;
  font-weight: 800;
  text-transform: uppercase;
  color: hsl(var(--admin-avatar-hue, 250) 62% 34%);
  background: hsl(var(--admin-avatar-hue, 250) 78% 94%);
  border: 1px solid hsl(var(--admin-avatar-hue, 250) 70% 86%);
  box-shadow: 0 2px 6px rgba(123, 97, 255, 0.08);
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease;
}

.admin-avatar .sign-up-method-icon {
  width: 18px;
  height: 18px;
}

.admin-method-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.admin-method-label .sign-up-method-icon {
  width: 15px;
  height: 15px;
  color: var(--color-purple);
}

.admin-page-title.with-icon {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.admin-page-title.with-icon > span {
  min-width: 0;
}

.admin-page-title-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-top: -1px;
  border-radius: 10px;
  color: var(--color-purple);
  background: rgba(123, 97, 255, 0.1);
}

.admin-page-title-icon .sign-up-method-icon {
  width: 20px;
  height: 20px;
}

.admin-table tbody tr:hover .admin-avatar {
  transform: scale(1.1) rotate(3deg);
  box-shadow: 0 4px 14px rgba(123, 97, 255, 0.25);
}

.admin-row-identity {
  display: flex;
  align-items: center;
  gap: var(--admin-space-3);
  min-width: 0;
}

/* Ô định danh chính của hàng: email, và ngay dưới là id rút gọn. Hàng không có
   email (tài khoản ví) vẫn phải nhận ra được — dòng dưới là thứ duy nhất còn lại. */
.admin-cell-primary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  /* Email và địa chỉ ví không có khoảng trắng: không cho ngắt thì chúng quyết định độ rộng tối
     thiểu của cả bảng, và ở 768px cột trạng thái bị đẩy ra ngoài mép phải (#92). */
  overflow-wrap: anywhere;
}

/* Ô định danh là một link cả khối, nhưng gạch chân cả id 36 ký tự thì mắt không
   còn bắt được đâu là dòng chính — chỉ dòng trên được gạch. */
.admin-table a.admin-row-identity:hover {
  text-decoration: none;
}

.admin-table a.admin-row-identity:hover .admin-cell-primary > span:first-child {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.admin-cell-secondary {
  font-family: var(--admin-mono);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: -0.2px;
}

.admin-cell-muted {
  color: var(--color-text-muted);
}

/* Trạng thái tài khoản — câu hỏi hay gặp nhất khi support mở danh sách.
   Có chấm màu VÀ chữ: WCAG cấm truyền thông tin chỉ bằng màu. */
.admin-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.admin-status:hover {
  transform: translateY(-1px) scale(1.03);
}

.admin-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.admin-status.ok {
  background: var(--color-success-bg);
  color: #15803d;
  border-color: var(--color-success-border);
}

.admin-status.ok::before {
  animation: admin-pulse-ok 2.4s ease-out infinite;
}

.admin-status.warn {
  background: #fff7ed;
  color: #c2610a;
  border-color: rgba(217, 119, 6, 0.22);
}

.admin-status.warn::before {
  animation: admin-pulse-warn 2.2s ease-out infinite;
}

.admin-status.bad {
  background: var(--color-error-bg);
  color: #dc2626;
  border-color: var(--color-error-border);
}

.admin-status.bad::before {
  animation: admin-pulse-bad 1.8s ease-out infinite;
}

.admin-pagination {
  margin-top: var(--admin-space-4);
  display: flex;
  gap: var(--admin-space-3);
  align-items: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.admin-pagination-count {
  flex: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Dòng thời gian (nhật ký thao tác quản trị)
   -------------------------------------------------------------------------- */
.admin-timeline {
  display: grid;
  gap: var(--admin-space-3);
}

.admin-timeline-item {
  position: relative;
  padding-left: var(--admin-space-4);
  font-size: 13px;
  line-height: 1.5;
}

.admin-timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-purple);
  opacity: 0.5;
}

.admin-timeline-item.failed::before {
  background: var(--color-error-text);
  opacity: 1;
}

.admin-timeline-time {
  font-family: var(--admin-mono);
  font-size: 11.5px;
  color: var(--color-text-muted);
  letter-spacing: -0.2px;
}

.admin-timeline-body {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Trạng thái rỗng
   -------------------------------------------------------------------------- */
.admin-empty {
  display: grid;
  justify-items: center;
  gap: var(--admin-space-2);
  padding: 56px var(--admin-space-5);
  text-align: center;
  border: 1px dashed var(--admin-line);
  border-radius: var(--admin-radius-lg);
  background: rgba(255, 255, 255, 0.4);
}

.admin-empty-icon {
  width: 30px;
  height: 30px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.55;
}

.admin-empty-title {
  font-size: 14.5px;
  font-weight: 700;
}

.admin-empty-hint {
  font-size: 12.5px;
  color: var(--color-text-muted);
  max-width: 380px;
}

/* Alert của auth.css mặc định ẩn (`display: none`) và được form bật lên; trong
   console nó luôn hiện khi được render, nên khỏi cần style inline ở từng trang. */
.admin-alert {
  display: flex;
  margin-bottom: var(--admin-space-5);
}

/* --------------------------------------------------------------------------
   Chuyển động

   Các trang này render tĩnh và tải lại toàn trang cho mỗi lần tìm kiếm hay đổi
   trang — không có JavaScript nào cập nhật tại chỗ. Một lượt vào ngắn khi trang
   dựng lên là thứ nói cho người dùng biết trang đã đổi; thiếu nó, mỗi lần bấm là
   một cú nháy trắng.

   Chỉ animate `opacity` và `transform`: hai thuộc tính này chạy trên compositor,
   không gây reflow và không đẩy layout (CLS).
   -------------------------------------------------------------------------- */
@keyframes admin-rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.988);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes admin-slide-in {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes admin-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes admin-bar-grow {
  0% {
    transform: translateY(-50%) scaleY(0.1);
    opacity: 0;
  }
  60% {
    transform: translateY(-50%) scaleY(1.15);
    opacity: 1;
  }
  100% {
    transform: translateY(-50%) scaleY(1);
    opacity: 1;
  }
}

/* Nhịp thở pulsing mềm mại cho các trạng thái chấm tròn */
@keyframes admin-pulse-ok {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
  }
  50% {
    box-shadow: 0 0 0 4.5px rgba(22, 163, 74, 0);
  }
}

@keyframes admin-pulse-warn {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.55);
  }
  50% {
    box-shadow: 0 0 0 4.5px rgba(217, 119, 6, 0);
  }
}

@keyframes admin-pulse-bad {
  0%, 70%, 100% {
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
  }
  35% {
    box-shadow: 0 0 0 5.5px rgba(220, 38, 38, 0);
  }
}

.admin-sidebar {
  animation: admin-slide-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.admin-page-header {
  animation: admin-rise 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.admin-panel {
  animation: admin-rise 0.42s cubic-bezier(0.16, 1, 0.3, 1) 0.04s both;
}

.admin-alert {
  animation: admin-rise 0.36s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.admin-nav-link.active::before {
  animation: admin-bar-grow 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

@keyframes admin-card-pop {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.965);
  }
  65% {
    opacity: 1;
    transform: translateY(-3.5px) scale(1.006);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Thẻ vào lệch nhau theo nhịp nảy (spring bounce) rõ ràng */
.admin-card {
  animation: admin-card-pop 0.48s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.admin-card:nth-child(1) { animation-delay: 0.10s; }
.admin-card:nth-child(2) { animation-delay: 0.20s; }
.admin-card:nth-child(3) { animation-delay: 0.30s; }
.admin-card:nth-child(4) { animation-delay: 0.38s; }
.admin-card:nth-child(5) { animation-delay: 0.46s; }
.admin-card:nth-child(n + 6) { animation-delay: 0.52s; }

.admin-table-wrapper {
  animation: admin-rise 0.42s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both;
}

/* Các hàng bảng lướt lên và hiện ra mượt mà theo nhịp cascade */
.admin-table tbody tr {
  animation: admin-fade 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.admin-table tbody tr:nth-child(1) { animation-delay: 0.04s; }
.admin-table tbody tr:nth-child(2) { animation-delay: 0.07s; }
.admin-table tbody tr:nth-child(3) { animation-delay: 0.10s; }
.admin-table tbody tr:nth-child(4) { animation-delay: 0.13s; }
.admin-table tbody tr:nth-child(5) { animation-delay: 0.16s; }
.admin-table tbody tr:nth-child(6) { animation-delay: 0.19s; }
.admin-table tbody tr:nth-child(7) { animation-delay: 0.22s; }
.admin-table tbody tr:nth-child(8) { animation-delay: 0.25s; }
.admin-table tbody tr:nth-child(n + 9) { animation-delay: 0.28s; }

.admin-empty {
  animation: admin-rise 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both;
}

/* Vệt sáng chạy qua theo con trỏ ở hàng đang trỏ tới */
.admin-table tbody tr:hover td:first-child {
  box-shadow: inset 3.5px 0 0 var(--color-purple);
  transition: box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   Responsive — sidebar xếp thành hàng ngang trên màn hẹp
   -------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------
   Bộ chuyển ngữ (日本語 / English)

   Nằm ở thanh trên cùng của cột nội dung trên các màn console, và ghim ở góc
   trên bên phải trên hai màn dùng AccountShell (đăng nhập, đổi mật khẩu) —
   hai màn đó không có thanh trên cùng để đặt vào.
   -------------------------------------------------------------------------- */
.admin-lang {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}

.admin-lang.floating {
  position: absolute;
  top: 16px;
  right: 24px;
  z-index: 10;
}

/* The globe-and-menu control itself is auth.css's .lang-selector, loaded on every page. Only its dark colours live
   here: auth.css knows nothing about the console's theme. */
html.admin-dark .lang-selector-toggle:hover,
html.admin-dark .lang-selector[open] > .lang-selector-toggle,
html.admin-dark .lang-selector-option:hover {
  background: rgba(255, 255, 255, 0.07);
}

html.admin-dark .lang-selector-menu {
  background: var(--color-input-bg);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

/* A dialog opened from a table row sits inside that row's cell, so it inherits td.nowrap and its text never wraps —
   the passkey removal message scrolled sideways. The dialog wraps like any other text. */
.admin-table .code-dialog {
  white-space: normal;
}

/* The confirmation dialogs the passkey tab borrows from account.css (.code-dialog) are drawn on white there. */
html.admin-dark .code-dialog {
  background: #1a1d28;
  color: var(--color-text-main);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

html.admin-dark .code-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

html.admin-dark .code-dialog-close:hover,
html.admin-dark .code-dialog-cancel:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-main);
}

html.admin-dark .code-dialog-icon {
  background: rgba(123, 97, 255, 0.16);
}

/* The brand column of the two AccountShell screens (/admin/login, /admin/password) is drawn light by auth.css;
   in the console's dark mode it follows the form column. The cards and the gradient title carry their own colours. */
html.admin-dark .brand-column {
  background: linear-gradient(135deg, rgba(24, 27, 38, 0.92) 0%, rgba(14, 16, 23, 0.95) 100%);
  border-right-color: rgba(255, 255, 255, 0.06);
}

/* The form column lays a white wash over the panel in auth.css; in the dark it reads as grey. */
html.admin-dark .form-column {
  background: rgba(255, 255, 255, 0.025);
}

html.admin-dark .confirm-dialog .code-dialog-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-main);
}

html.admin-dark .confirm-dialog .code-dialog-cancel:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Vùng bấm 44px cho ngón tay. Ngưỡng 900px chứ không phải 860px: bộ chuyển ngữ cũng nằm trên
   hai màn dùng AccountShell (đăng nhập, đổi mật khẩu), vốn đổi bố cục ở 900px. */
@media (max-width: 900px) {
  .admin-lang .lang-selector-toggle,
  .admin-lang .lang-selector-option {
    min-height: 44px;
  }
}

@media (max-width: 1024px) {
  .admin-main {
    padding: var(--admin-space-5) var(--admin-space-6) var(--admin-space-6);
  }
}

@media (max-width: 860px) {
  .admin-shell {
    flex-direction: column;
    border-radius: 20px;
  }

  /* Thanh trên cùng hẹp lại thì nhãn "言語" là thứ bỏ được đầu tiên: hai lựa
     chọn ngôn ngữ tự nó đã nói lên đang chọn cái nào. */
  .admin-topbar {
    flex-wrap: wrap;
    gap: var(--admin-space-2);
  }

  .admin-identity-email {
    max-width: 140px;
  }

  .admin-page-header {
    align-items: flex-start;
  }

  /* Ba nút của màn chi tiết user không vừa một hàng 375px; không cho xuống dòng thì nút thứ
     ba bị cắt ở mép phải (#92). */
  .admin-page-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Vùng bấm 44px cho ngón tay. */
  .admin-brand,
  .admin-nav-link,
  .admin-btn,
  .admin-row-identity {
    min-height: 44px;
  }

  /* Link breadcrumb chỉ cao bằng dòng chữ: phần đệm nới vùng bấm ra 44px, margin âm trả lại
     đúng chỗ đó để tiêu đề bên dưới không bị đẩy xuống. */
  .admin-breadcrumb a {
    padding: 14px 0;
    margin: -14px 0;
  }

  /* Dưới 16px, iOS Safari tự zoom trang khi ô nhập được focus. */
  .admin-search .form-input {
    font-size: 16px;
  }

  /* Không chữ nào trên điện thoại nhỏ hơn 12px. */
  .admin-search .input-label,
  .admin-field-label,
  .admin-table th,
  .admin-timeline-time {
    font-size: 12px;
  }

  .admin-main {
    padding: var(--admin-space-5) var(--admin-space-4) var(--admin-space-6);
  }

  .admin-panel {
    padding: var(--admin-space-4) var(--admin-space-4);
  }

  .admin-card-grid {
    grid-template-columns: 1fr;
  }

  .admin-search {
    flex: 1 1 100%;
    min-width: 0;
  }
}

@media (max-width: 560px) {
  /* Console trải hết màn hình thay vì là một tấm card nổi giữa lề 16px của body: ở bề ngang
     này, 32px lề là gần một phần mười màn hình. Chỉ áp cho body có chứa console, giống
     `body:has(.account-page)` của account.css. */
  /* `clip`, không phải `hidden` như auth.css: `overflow-x: hidden` biến body thành vùng cuộn, và
     phần tử sticky bên trong khi đó bám vào body (không cuộn) thay vì màn hình. */
  body:has(.admin-shell) {
    padding: 0;
    overflow-x: clip;
  }

  /* Hai màn đăng nhập/đổi mật khẩu admin dùng AccountShell, trên điện thoại không còn card:
     bộ chuyển ngữ nằm vào thanh 60px trên cùng (auth.css). */
  .admin-lang.floating {
    top: 8px;
    right: 12px;
  }

  /* Cả hai đều phải hết là vùng cuộn/cắt, nếu không thanh trên cùng và ô tìm kiếm không bám được
     theo màn hình khi cuộn. */
  .admin-shell {
    min-height: 100vh;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  .admin-main {
    overflow: visible;
  }

  /* Nút chỉ còn icon (xuất CSV, tìm kiếm). Nhãn vẫn nằm trong DOM làm tên truy cập được. */
  .admin-btn-icon-phone {
    width: 44px;
    padding: 0;
  }

  .admin-btn-icon-phone .admin-btn-label,
  .admin-search-form .input-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* Nút xuất CSV đứng cạnh tiêu đề thay vì chiếm một hàng riêng. */
  .admin-page-actions:has(> .admin-btn-icon-phone:only-child) {
    width: auto;
  }

  /* Ô tìm kiếm bám ngay dưới thanh trên cùng khi cuộn danh sách. */
  .admin-search-form {
    position: sticky;
    top: 64px;
    z-index: 20;
    margin-inline: calc(-1 * var(--admin-space-4));
    padding: var(--admin-space-2) var(--admin-space-4);
    background: linear-gradient(180deg, var(--color-bg-base) 80%, rgba(246, 248, 251, 0));
  }

  .admin-search {
    gap: var(--admin-space-2);
  }

  /* Mỗi user một hàng thấp (#92, phương án C): avatar + email ở dòng trên, tên và ngày tạo ở dòng
     dưới, trạng thái bên phải — gấp đôi số user trên một màn so với dạng thẻ. Bảng cuộn ngang từng
     giấu mất cột trạng thái, đúng thứ support mở danh sách để xem. Tiêu đề cột ẩn khỏi mắt nhưng
     vẫn còn cho trình đọc màn hình. */
  .admin-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .admin-table,
  .admin-table tbody {
    display: block;
  }

  /* Cột 1 = avatar + khoảng cách (34 + 12), cột 2 = tên, cột 3 = ngày, cột 4 = trạng thái. */
  .admin-table tr {
    position: relative;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto auto;
    align-items: center;
    padding: 10px var(--admin-space-3);
    border-bottom: 1px solid var(--admin-line-soft);
  }

  .admin-table tbody tr:last-child {
    border-bottom: none;
  }

  .admin-table td {
    display: block;
    padding: 0;
    border-bottom: none;
  }

  .admin-table td:nth-child(1) {
    grid-column: 1 / 4;
    grid-row: 1;
    min-width: 0;
  }

  /* Dòng thứ hai kéo lên cạnh avatar thay vì nằm dưới nó, để hàng chỉ cao hơn avatar một chút. */
  .admin-table td:nth-child(2),
  .admin-table td:nth-child(3) {
    grid-row: 2;
    margin-top: -14px;
    min-width: 0;
    font-size: 12.5px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .admin-table td:nth-child(2) {
    grid-column: 2;
  }

  .admin-table td:nth-child(3) {
    grid-column: 3;
    padding-left: var(--admin-space-2);
  }

  .admin-table td:nth-child(4) {
    grid-column: 4;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    padding-left: var(--admin-space-2);
  }

  /* Id / địa chỉ ví rời khỏi danh sách (vẫn tìm được, và có trên màn chi tiết); email cắt bằng "…". */
  .admin-row-identity {
    align-items: flex-start;
  }

  .admin-row-identity .admin-cell-secondary {
    display: none;
  }

  .admin-row-identity .admin-cell-primary > span:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Cả hàng là một vùng bấm mở bản ghi, không chỉ dòng email. */
  .admin-table a.admin-row-identity::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  /* Vệt tím bên trái chỉ hợp với ô đầu của một hàng bảng; trên thẻ nó chỉ tô nửa trên. */
  .admin-table tbody tr:hover td:first-child {
    box-shadow: none;
  }
}

@media (max-width: 420px) {
  .admin-page-title {
    font-size: 21px;
  }

  /* Email đầy đủ không còn chỗ; chỉ giữ chữ cái đầu, phần còn lại vẫn đọc được
     bằng title. */
  .admin-identity-email {
    display: none;
  }
}

/* Chuyển động ở đây chỉ là trang trí (nhấc nút, đổi nền hàng); người đã tắt
   hiệu ứng không mất thông tin nào khi bỏ chúng đi. */
@media (prefers-reduced-motion: reduce) {
  .admin-shell *,
  .admin-shell *::before,
  .admin-shell *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    /* Không bỏ delay thì phần tử vẫn nằm ở khung hình `from` (opacity 0) suốt
       thời gian chờ — tắt hiệu ứng lại thành trang chớp nháy. */
    animation-delay: 0ms !important;
  }

  .admin-btn:hover {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Nhật ký audit (#35 G9) — /admin/audit và khung hoạt động ở trang chi tiết user
   -------------------------------------------------------------------------- */
.audit-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--admin-space-3) 14px;
  padding: 18px;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-lg);
  background: var(--admin-surface-solid);
  box-shadow: 0 10px 30px -5px rgba(18, 19, 25, 0.04);
}

.audit-filters .input-label {
  display: block;
  margin-bottom: 7px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.audit-filters .form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 12px;
  background: #ffffff;
  border: 1.5px solid rgba(123, 97, 255, 0.2);
}

.audit-filters .form-input:focus {
  outline: none;
  border-color: var(--color-purple);
  box-shadow: var(--admin-focus-ring);
}

.audit-filter-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.audit-spacer {
  flex: 1;
}

.audit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--admin-space-2);
}

.audit-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--admin-line);
}

.audit-chip:hover,
.audit-chip.on {
  color: var(--color-purple);
  border-color: rgba(123, 97, 255, 0.35);
  background: rgba(123, 97, 255, 0.08);
}

.audit-note {
  margin: 0;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  border-radius: 12px;
  background: rgba(123, 97, 255, 0.05);
  border: 1px dashed rgba(123, 97, 255, 0.25);
}

.audit-location-note {
  display: block;
  margin-top: 4px;
}

.audit-time,
.audit-mono {
  font-family: var(--admin-mono);
  font-size: 12px;
  white-space: nowrap;
}

/* Location under the address in the audit IP cell: the database's estimate, so quieter than the address itself. */
.audit-location {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.audit-actor {
  display: flex;
  align-items: center;
  gap: var(--admin-space-2);
  min-width: 180px;
}

.audit-kind {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 4px;
  border-radius: 7px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: nowrap;
  color: #64748b;
  background: #eef1f5;
}

.audit-kind.admin { color: #6d28d9; background: #f3efff; }
.audit-kind.user { color: #0369a1; background: #e8f4ff; }
.audit-kind.system { color: #b45309; background: #fff4e0; }

.audit-action {
  font-weight: 700;
}

.audit-action code {
  display: block;
  font-family: var(--admin-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--color-text-muted);
}

.audit-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 280px;
}

.audit-kv {
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--admin-mono);
  font-size: 11px;
  /* A value can be a list of ids (userIdTo=<id>,<id>,…): wrap inside the chip instead of widening the table or card. */
  max-width: 100%;
  overflow-wrap: anywhere;
  background: rgba(18, 19, 25, 0.045);
}

/* Một hàng thất bại có vệt đỏ bên trái, để một chuỗi lần bị từ chối nhìn thấy mà không phải đọc từng dòng. */
.audit-table tbody tr.failed td:first-child {
  box-shadow: inset 3px 0 0 #ef4444;
}

/* Nhật ký audit trên điện thoại: bố cục thẻ của danh sách user (4 cột) không hợp với 7 cột ở đây — các ô chồng lên nhau.
   Mỗi bản ghi thành một thẻ đọc từ trên xuống: thời điểm + kết quả, hành động, người thực hiện, đối tượng, chi tiết, IP. */
@media (max-width: 560px) {
  .admin-table.audit-table tr {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px var(--admin-space-2);
    align-items: start;
    padding: var(--admin-space-3);
  }

  .admin-table.audit-table td {
    display: block;
    grid-column: 1 / -1;
    grid-row: auto;
    margin-top: 0;
    padding-left: 0;
    min-width: 0;
    font-size: 13px;
    color: inherit;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
  }

  .admin-table.audit-table td:nth-child(1) { grid-column: 1; grid-row: 1; color: var(--color-text-muted); }
  .admin-table.audit-table td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .admin-table.audit-table td:nth-child(3) { grid-row: 2; }
  .admin-table.audit-table td:nth-child(2) { grid-row: 3; }
  .admin-table.audit-table td:nth-child(4) { grid-row: 4; }
  .admin-table.audit-table td:nth-child(7) { grid-row: 5; }
  .admin-table.audit-table td:nth-child(6) { grid-row: 6; color: var(--color-text-muted); }

  .audit-actor {
    min-width: 0;
    flex-wrap: wrap;
  }

  .audit-details {
    max-width: none;
  }

  .audit-lines {
    max-width: none;
  }

  /* Vệt đỏ cho cả thẻ, không chỉ ô đầu. */
  .audit-table tbody tr.failed td:first-child {
    box-shadow: none;
  }

  .audit-table tbody tr.failed {
    box-shadow: inset 3px 0 0 #ef4444;
  }
}

/* Nhật ký /admin/audit: mỗi ngày một dải, mỗi bản ghi một dòng (kết quả · giờ · người thực hiện · hành động · đối tượng · IP),
   bấm vào dòng để mở phần còn lại. Bảng .audit-table ở trên vẫn dùng cho dashboard. */
.audit-journal {
  --audit-session: #0b74c4;
  --audit-security: #b26a00;
  --audit-admin: #6d28d9;
  --audit-sales: #0f8577;
  --audit-wallet: #c2410c;
  --audit-danger: #d03434;
  --audit-ok: #15924b;
  --audit-failed-bg: rgba(239, 68, 68, 0.07);

  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-md);
  background: var(--admin-surface-solid);
  font-size: 14px;
  overflow: hidden;
}

/* Như link trong .admin-table: màu chữ thường, gạch chân khi rê chuột. */
.audit-target a {
  color: var(--color-text-main);
  font-weight: 700;
  text-decoration: none;
}

.audit-target a.audit-target-self,
a.audit-target-self {
  color: var(--color-text-muted);
  font-weight: 500;
}

.audit-target a:hover {
  color: var(--color-purple);
  text-decoration: underline;
  text-underline-offset: 3px;
}

html.admin-dark .audit-journal {
  --audit-session: #6cc0ff;
  --audit-security: #f5bd4f;
  --audit-admin: #c4b5fd;
  --audit-sales: #5fd6c6;
  --audit-wallet: #fb9a62;
  --audit-danger: #f87171;
  --audit-ok: #4ade80;
  --audit-failed-bg: rgba(239, 68, 68, 0.11);
}

.audit-cols,
.audit-entry > summary {
  display: grid;
  grid-template-columns: 20px 92px minmax(0, 1.25fr) minmax(0, 1.7fr) minmax(0, 1.1fr) 150px 14px;
  gap: var(--admin-space-3);
  align-items: center;
  padding: 9px var(--admin-space-4);
}

.audit-cols {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--admin-line);
}

.audit-day {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--admin-space-3);
  padding: 8px var(--admin-space-4);
  font-weight: 700;
  background: var(--admin-line-soft);
  border-bottom: 1px solid var(--admin-line);
}

.audit-day-count {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.audit-day-failed {
  font-weight: 700;
  color: var(--audit-danger);
}

.audit-entry {
  border-bottom: 1px solid var(--admin-line-soft);
}

.audit-entry:last-child {
  border-bottom: 0;
}

.audit-entry > summary {
  list-style: none;
  cursor: pointer;
}

.audit-entry > summary::-webkit-details-marker {
  display: none;
}

.audit-entry > summary:hover,
.audit-entry[open] > summary {
  background: var(--admin-hover);
}

.audit-entry > summary:focus-visible {
  outline: 2px solid var(--color-purple);
  outline-offset: -2px;
}

/* Vệt đỏ bên trái như bảng cũ: một chuỗi lần bị từ chối nhìn thấy mà không phải đọc từng dòng. */
.audit-entry.failed {
  background: var(--audit-failed-bg);
  box-shadow: inset 3px 0 0 #ef4444;
}

.audit-state {
  display: grid;
}

.audit-state svg,
.audit-ico svg,
.audit-chevron {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audit-state svg {
  width: 18px;
  height: 18px;
}

.audit-state.ok { color: var(--audit-ok); }
.audit-state.bad { color: var(--audit-danger); }

.audit-journal .audit-actor {
  min-width: 0;
}

.audit-actor-name,
.audit-target {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-act {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px var(--admin-space-2);
  min-width: 0;
}

.audit-act-name {
  font-weight: 700;
}

.audit-ico {
  --audit-family: var(--color-text-muted);
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--audit-family);
  background: color-mix(in srgb, var(--audit-family) 14%, transparent);
}

.audit-ico svg {
  width: 15px;
  height: 15px;
}

.audit-ico.session { --audit-family: var(--audit-session); }
.audit-ico.security { --audit-family: var(--audit-security); }
.audit-ico.admin { --audit-family: var(--audit-admin); }
.audit-ico.sales { --audit-family: var(--audit-sales); }
.audit-ico.wallet { --audit-family: var(--audit-wallet); }
.audit-ico.danger { --audit-family: var(--audit-danger); }

.audit-chip-kv {
  max-width: 180px;
  padding: 1px 7px;
  border: 1px solid var(--admin-line);
  border-radius: 999px;
  font-family: var(--admin-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--admin-line-soft);
}

.audit-chip-kv.bad {
  color: var(--audit-danger);
  border-color: color-mix(in srgb, var(--audit-danger) 40%, transparent);
  background: transparent;
}

.audit-ip {
  min-width: 0;
}

.audit-chevron {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: transform 0.15s;
}

.audit-entry[open] .audit-chevron {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
  .audit-chevron { transition: none; }
}

/* Phần mở ra thẳng hàng với cột người thực hiện. */
.audit-more {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 5px var(--admin-space-3);
  align-items: baseline;
  margin: 0;
  padding: 4px var(--admin-space-4) var(--admin-space-3) calc(var(--admin-space-4) + 20px + 92px + 2 * var(--admin-space-3));
  font-size: 12.5px;
}

.audit-more dt {
  color: var(--color-text-muted);
}

.audit-more dd {
  margin: 0;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.audit-more .audit-details,
.audit-more .audit-lines {
  max-width: none;
  margin: 0;
}

/* Hẹp: mỗi bản ghi thành một thẻ — hành động và giờ ở hàng đầu, rồi người thực hiện, đối tượng, IP. */
@media (max-width: 860px) {
  .audit-cols {
    display: none;
  }

  .audit-entry > summary {
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 4px var(--admin-space-2);
    align-items: start;
    padding: var(--admin-space-3);
  }

  .audit-state { grid-row: 1; margin-top: 4px; }
  .audit-act { grid-column: 2; grid-row: 1; }
  .audit-journal .audit-time { grid-column: 3; grid-row: 1; padding-top: 5px; color: var(--color-text-muted); }

  .audit-journal .audit-actor,
  .audit-target,
  .audit-ip {
    grid-column: 2 / -1;
  }

  .audit-journal .audit-actor {
    flex-wrap: nowrap;
  }

  .audit-target:has(> .admin-cell-muted),
  .audit-chevron {
    display: none;
  }

  .audit-ip {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--admin-space-2);
    color: var(--color-text-muted);
  }

  .audit-ip .audit-location {
    margin-top: 0;
  }

  .audit-day {
    padding-inline: var(--admin-space-3);
  }

  .audit-more {
    grid-template-columns: 96px minmax(0, 1fr);
    padding: 0 var(--admin-space-3) var(--admin-space-3) calc(var(--admin-space-3) + 20px + var(--admin-space-2));
  }
}

/* ==========================================================================
   Dashboard (/admin, add-admin-dashboard)

   Thẻ số liệu, biểu đồ cột SVG vẽ phía server và thanh theo provider. Dùng lại token của console
   (--admin-*), cùng màu với .admin-status cho trạng thái cảnh báo, không thêm font hay thư viện.
   ========================================================================== */
.admin-dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--admin-space-4);
}

/* A card title is an h2 for the outline but keeps the console's small uppercase label. */
.admin-dashboard h2.admin-card-title {
  margin-top: 0;
}

.admin-dashboard .admin-card-title h2 {
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
}

.admin-dashboard .admin-card-title {
  justify-content: space-between;
}

.admin-card-link {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: none;
  color: var(--color-purple);
  text-decoration: none;
}

.admin-card-link:hover,
.admin-card-link:focus-visible {
  text-decoration: underline;
}

.admin-dashboard-stamp {
  font-family: var(--admin-mono);
  font-size: 12.5px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.admin-dashboard-split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--admin-space-4);
  align-items: start;
}

.admin-dashboard-column {
  display: flex;
  flex-direction: column;
  gap: var(--admin-space-4);
  min-width: 0;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--admin-space-3);
}

.admin-stat-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: var(--admin-space-3);
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: var(--admin-space-3) var(--admin-space-4);
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-md);
  background: var(--admin-surface-solid);
}

.admin-stat-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.admin-stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--color-text-main);
  font-variant-numeric: tabular-nums;
}

.admin-stat-grid.compact .admin-stat-value {
  font-size: 22px;
}

.admin-stat-note {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.admin-stat-note.up {
  color: #15803d;
  font-weight: 700;
}

.admin-stat.warn {
  background: #fff7ed;
  border-color: rgba(217, 119, 6, 0.22);
}

.admin-stat.warn .admin-stat-value {
  color: #c2610a;
}

.admin-stat.alert {
  background: var(--color-error-bg);
  border-color: var(--color-error-border);
}

.admin-stat.alert .admin-stat-value {
  color: #dc2626;
}

.admin-chart-legend {
  display: flex;
  gap: var(--admin-space-4);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.admin-chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
}

.admin-chart-legend i.succeeded,
.admin-chart rect.succeeded {
  background: var(--color-purple);
  fill: var(--color-purple);
}

.admin-chart-legend i.failed,
.admin-chart rect.failed {
  background: var(--color-pink);
  fill: var(--color-pink);
}

.admin-chart {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}

.admin-chart line.grid {
  stroke: var(--admin-line);
  stroke-width: 1;
}

.admin-chart text.axis {
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  fill: var(--color-text-muted);
}

.admin-bars {
  display: grid;
  gap: var(--admin-space-2);
  margin-bottom: var(--admin-space-3);
}

.admin-bar {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 64px;
  align-items: center;
  gap: var(--admin-space-3);
  font-size: 13px;
  font-weight: 600;
}

.admin-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--admin-line-soft);
  overflow: hidden;
}

.admin-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--color-primary-gradient);
}

.admin-bar-value {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.admin-health {
  margin: 0;
  display: grid;
}

.admin-health > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--admin-space-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--admin-line-soft);
}

.admin-health > div:last-child {
  border-bottom: none;
}

.admin-health dt {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-main);
}

.admin-health dd {
  margin: 0;
}

.admin-health-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  text-align: right;
}

@media (max-width: 860px) {
  .admin-dashboard-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .admin-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-stat-value {
    font-size: 24px;
  }

  .admin-bar {
    grid-template-columns: 80px minmax(0, 1fr) 52px;
  }

  .admin-dashboard-stamp {
    white-space: normal;
  }

  /* The chart is drawn 560 units wide and shrinks with the screen, so its labels shrink too: about half size at
     390px. Doubling them in chart units brings them back to roughly the 10px they are on a desktop. */
  .admin-chart text.axis {
    font-size: 16px;
  }
}

/* Role choices on the create-admin form (#236, #269): one checkbox per role, its code and scope underneath. */
.admin-checks {
  border: 0;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.admin-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.admin-check input {
  margin-top: 3px;
}

.admin-check > span {
  display: grid;
  gap: 2px;
}

/* The signed-in identity in the top bar is a link to the admin's own account screen (#236, #269). */
/* The three tabs of the admin account screen (#236, #269): profile, password, two-factor. Plain links rendered on
   the server (?tab=), since these pages carry no circuit. Same purple as the active sidebar entry. */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin: 4px 0 16px;
  border-bottom: 1px solid var(--admin-line);
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-tab {
  position: relative;
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-radius: var(--admin-radius-md) var(--admin-radius-md) 0 0;
  transition: color 0.2s ease, background 0.2s ease;
}

.admin-tab:hover {
  color: var(--color-purple);
  background: rgba(123, 97, 255, 0.06);
}

.admin-tab.active {
  color: var(--color-purple);
  font-weight: 800;
}

.admin-tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--color-primary-gradient);
}

/* On a phone five tabs do not fit on one line, and the strip scrolled sideways with its scrollbar hidden, so 2FA's
   neighbours (passkey, display settings) were off screen with nothing to say they were there. The tabs wrap instead,
   as pills: an underline on two lines reads as two tab rows. */
@media (max-width: 560px) {
  .admin-tabs {
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 12px;
    overflow-x: visible;
  }

  .admin-tab {
    padding: 7px 12px;
    font-size: 13.5px;
    border-radius: 999px;
    background: rgba(123, 97, 255, 0.04);
  }

  .admin-tab.active {
    background: rgba(123, 97, 255, 0.14);
  }

  .admin-tab.active::after {
    content: none;
  }
}

/* One tab's content at a time: a single card, kept to a readable width on a wide screen. */
.admin-tab-panel {
  max-width: 640px;
}

/* The rename / delete controls of one catalog row (#236, #270), folded so the table keeps one line per row.
   <details> opens it without JavaScript, which these pages do not carry. */
.admin-row-edit > summary {
  list-style: none;
  cursor: pointer;
}

.admin-row-edit > summary::-webkit-details-marker {
  display: none;
}

.admin-row-edit-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  min-width: 240px;
}

/* The roles an admin holds, on the admin detail screen (#236, #270): one ruled row per role — name, code and scope on
   the left, its Remove button on the right — and the assign form set apart below. */
.admin-role-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-md);
  background: var(--admin-surface-solid);
  overflow: hidden;
}

.admin-role-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
}

.admin-role-row + .admin-role-row {
  border-top: 1px solid var(--admin-line-soft);
}

.admin-role-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.admin-role-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.admin-role-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.admin-role-code {
  font-family: var(--admin-mono);
  font-size: 12px;
  color: var(--color-text-muted);
}

.admin-role-scope {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(123, 97, 255, 0.1);
  color: var(--color-purple);
  font-size: 11.5px;
  font-weight: 700;
}

.admin-btn.compact {
  padding: 6px 12px;
  font-size: 12.5px;
}

.admin-role-assign {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--admin-line);
}

/* ==========================================================================
   Dark mode và sidebar thu gọn (js/admin-shell.js)

   Cả hai là class trên <html>: `admin-dark` và `admin-sidebar-collapsed`. Script đặt
   chúng trước lần vẽ đầu, và chỉ trên /admin/*. Không có JS → không có class →
   console sáng, sidebar mở, đúng như trước.
   ========================================================================== */

/* Nút icon dùng cho hai công tắc; cùng cỡ với avatar 32px của hàng tài khoản. */
.admin-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--admin-line);
  background: var(--admin-surface-solid);
  color: var(--color-text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  transition: var(--transition-fast);
}

.admin-icon-btn:hover {
  color: var(--color-purple);
  border-color: rgba(123, 97, 255, 0.3);
  background: var(--admin-hover);
}

.admin-icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--admin-focus-ring);
}

.admin-icon-btn .admin-nav-icon {
  width: 17px;
  height: 17px;
}

/* Mặt trăng khi đang sáng, mặt trời khi đang tối: icon nói về trạng thái sẽ chuyển sang. */
.admin-theme-icon-sun {
  display: none;
}

html.admin-dark .admin-theme-icon-sun {
  display: block;
}

html.admin-dark .admin-theme-icon-moon {
  display: none;
}

/* Hàng đầu sidebar: logo bên trái, nút thu gọn bên phải. Thu gọn rồi thì xếp dọc:
   logo trên, nút dưới, cả hai canh giữa cột 76px. */
.admin-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--admin-space-2);
}

.admin-sidebar-head .admin-brand {
  min-width: 0;
  flex: 1;
}

.admin-sidebar-toggle {
  flex-shrink: 0;
  margin-top: 2px;
  border-color: transparent;
  background: transparent;
}

.admin-sidebar-toggle:hover {
  background: rgba(123, 97, 255, 0.08);
}

.admin-sidebar {
  transition: width 0.28s cubic-bezier(0.16, 1, 0.3, 1), padding 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Trên cột nội dung: tooltip bên dưới thò ra ngoài sidebar, mà sidebar là một stacking context
   (animation transform) đứng trước `.admin-main` trong DOM, nên không nâng lên thì tiêu đề và ô tìm
   kiếm của trang vẽ đè lên tooltip. */
html.admin-sidebar-collapsed .admin-sidebar {
  position: relative;
  z-index: 30;
  width: 76px;
  padding-inline: var(--admin-space-2);
}

html.admin-sidebar-collapsed .admin-sidebar-head {
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding-bottom: var(--admin-space-5);
}

html.admin-sidebar-collapsed .admin-brand {
  justify-content: center;
  padding: var(--admin-space-1) 0 var(--admin-space-2);
}

html.admin-sidebar-collapsed .admin-sidebar-toggle {
  margin-top: 0;
}

html.admin-sidebar-collapsed .admin-brand-text,
html.admin-sidebar-collapsed .admin-nav-heading,
html.admin-sidebar-collapsed .admin-nav-text {
  display: none;
}

html.admin-sidebar-collapsed .admin-nav-link {
  justify-content: center;
  padding-inline: 0;
}

html.admin-sidebar-collapsed .admin-nav-link:hover {
  transform: none;
}

/* Thu gọn rồi thì chỉ còn icon; tên mục hiện ra bên phải khi rê chuột hoặc focus. */
html.admin-sidebar-collapsed .admin-nav-link:hover::after,
html.admin-sidebar-collapsed .admin-nav-link:focus-visible::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 50;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  color: var(--color-text-main);
  background: var(--admin-surface-solid);
  border: 1px solid var(--admin-line);
  box-shadow: 0 8px 24px -8px rgba(18, 19, 25, 0.25);
  pointer-events: none;
}

html.admin-sidebar-collapsed .admin-sidebar-toggle-chevron {
  transform: scaleX(-1);
  transform-origin: 15.5px 12px;
}

/* Dưới 860px sidebar là drawer (cuối file), luôn mở rộng đủ nhãn: không có gì để thu gọn, và trạng thái thu gọn
   đã lưu của máy tính không được áp vào drawer. */
@media (max-width: 860px) {
  .admin-sidebar-toggle {
    display: none;
  }

  html.admin-sidebar-collapsed .admin-sidebar {
    position: fixed;
    z-index: 60;
    width: var(--admin-drawer-width);
    padding-inline: var(--admin-space-3);
  }

  html.admin-sidebar-collapsed .admin-sidebar-head {
    flex-direction: row;
    align-items: center;
    padding-bottom: 0;
  }

  html.admin-sidebar-collapsed .admin-brand {
    justify-content: flex-start;
  }

  html.admin-sidebar-collapsed .admin-brand-text,
  html.admin-sidebar-collapsed .admin-nav-text {
    display: initial;
  }

  html.admin-sidebar-collapsed .admin-nav-heading {
    display: block;
  }

  html.admin-sidebar-collapsed .admin-nav-link {
    justify-content: flex-start;
    padding: 10px 14px;
  }

  html.admin-sidebar-collapsed .admin-nav-link:hover::after {
    content: none;
  }
}

/* --------------------------------------------------------------------------
   Dark mode

   Ghi đè token `:root` của auth.css ngay trên <html>, nên body (nền) và các
   class dùng chung (form-input, alert-banner, admin-btn) đổi theo mà không cần
   viết lại. Phần dưới chỉ xử lý những chỗ admin.css đã viết màu cứng.
   -------------------------------------------------------------------------- */
html.admin-dark {
  color-scheme: dark;

  --color-bg-base: #0e1017;
  --color-bg-gradient: linear-gradient(180deg, #13151e 0%, #0b0d13 100%);

  --color-panel-bg: rgba(23, 25, 35, 0.82);
  --color-panel-border: rgba(255, 255, 255, 0.07);
  --shadow-panel: 0 30px 60px rgba(0, 0, 0, 0.45), 0 10px 20px rgba(0, 0, 0, 0.3);

  --color-input-bg: #1a1d28;
  --color-input-border: rgba(123, 97, 255, 0.32);

  --color-btn-secondary-bg: #222634;
  --color-btn-secondary-hover-bg: #2b3042;
  --color-btn-secondary-border: rgba(255, 255, 255, 0.08);

  --color-text-main: #e9ebf3;
  --color-text-muted: #9ba4b9;

  --color-error-bg: rgba(239, 68, 68, 0.14);
  --color-error-border: rgba(239, 68, 68, 0.38);
  --color-success-bg: rgba(34, 197, 94, 0.14);
  --color-success-border: rgba(34, 197, 94, 0.38);
}

html.admin-dark .admin-shell {
  --admin-line: rgba(255, 255, 255, 0.09);
  --admin-line-soft: rgba(255, 255, 255, 0.05);
  --admin-surface: rgba(255, 255, 255, 0.04);
  --admin-surface-solid: rgba(31, 34, 46, 0.94);
  --admin-hover: rgba(123, 97, 255, 0.16);
}

html.admin-dark .admin-skip-link,
html.admin-dark .admin-account-popover,
html.admin-dark .admin-search .form-input,
html.admin-dark .audit-filters .form-input {
  background: var(--color-input-bg);
}

html.admin-dark .admin-account-popover {
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
}

html.admin-dark .admin-segmented {
  background: rgba(255, 255, 255, 0.06);
}

html.admin-dark .admin-segment[aria-current="true"],
html.admin-dark .admin-segment[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: none;
}

html.admin-dark .admin-sidebar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.015) 100%);
}

html.admin-dark .admin-brand-mark {
  background: rgba(255, 255, 255, 0.08);
}

html.admin-dark .admin-table th {
  background: rgba(23, 25, 35, 0.94);
}

html.admin-dark .admin-empty {
  background: rgba(255, 255, 255, 0.03);
}

html.admin-dark .audit-kv {
  background: rgba(255, 255, 255, 0.07);
}

html.admin-dark .audit-chip {
  background: rgba(255, 255, 255, 0.05);
}

html.admin-dark .audit-kind {
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.08);
}

html.admin-dark .audit-kind.admin { color: #c4b5fd; background: rgba(109, 40, 217, 0.28); }
html.admin-dark .audit-kind.user { color: #7dd3fc; background: rgba(3, 105, 161, 0.3); }
html.admin-dark .audit-kind.system { color: #fcd34d; background: rgba(180, 83, 9, 0.3); }

/* Màu trạng thái: cùng sắc, nhưng sáng hơn để đọc được trên nền tối. */
html.admin-dark .admin-status.ok,
html.admin-dark .admin-stat-note.up {
  color: #4ade80;
}

html.admin-dark .admin-status.warn,
html.admin-dark .admin-stat.warn {
  background: rgba(217, 119, 6, 0.14);
  border-color: rgba(217, 119, 6, 0.4);
}

html.admin-dark .admin-status.warn,
html.admin-dark .admin-stat.warn .admin-stat-value {
  color: #fbbf24;
}

html.admin-dark .admin-status.bad,
html.admin-dark .admin-stat.alert .admin-stat-value {
  color: #f87171;
}

@media (max-width: 860px) {
  html.admin-dark .admin-sidebar {
    background: #151721;
  }
}

@media (max-width: 560px) {
  html.admin-dark .admin-topbar {
    background: rgba(17, 19, 28, 0.96);
  }

  html.admin-dark .admin-search-form {
    background: linear-gradient(180deg, var(--color-bg-base) 80%, rgba(14, 16, 23, 0));
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar {
    transition: none;
  }
}

/* The permission matrix of a role (spec identity/admin-permission-matrix): one checkbox per grantable cell, a muted
   dash where the catalog has no cell. Columns are narrow and centred so nine of them fit beside the resource name. */
.admin-matrix th.admin-matrix-col,
.admin-matrix td.admin-matrix-cell {
  text-align: center;
  white-space: nowrap;
  width: 1%;
}

.admin-matrix th[scope="row"] {
  text-align: left;
  font-weight: inherit;
}

.admin-matrix input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-purple);
}

.admin-matrix-off {
  color: var(--color-text-muted);
  opacity: 0.6;
}

.admin-matrix-notes {
  margin: 16px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}

.admin-role-matrix-link {
  color: var(--color-purple);
  font-weight: 700;
  text-decoration: none;
}

.admin-role-matrix-link:hover,
.admin-role-matrix-link:focus-visible {
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   Màn chép ví từ Wallet (#189 ID-5): bốn bước thành bốn thẻ, mô tả nằm ngay cạnh
   nút của nó — một đoạn văn dài + danh sách tách rời khỏi nút thì phải đọc hai lần.
   -------------------------------------------------------------------------- */
.wi-lead {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--admin-space-5);
}

.wi-running {
  max-width: 720px;
  padding: var(--admin-space-3) var(--admin-space-4);
  border-radius: var(--admin-radius-md);
  background: rgba(123, 97, 255, 0.08);
  border: 1px solid rgba(123, 97, 255, 0.2);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-purple);
}

.wi-skip {
  margin-bottom: var(--admin-space-5);
}

.wi-skip textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--admin-radius-sm);
  border: 1px solid var(--admin-line);
  background: var(--admin-surface-solid);
  font-family: var(--admin-mono);
  font-size: 12.5px;
  resize: vertical;
}

.wi-skip textarea:focus {
  outline: none;
  border-color: rgba(123, 97, 255, 0.5);
  box-shadow: var(--admin-focus-ring);
}

.wi-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--admin-space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.wi-step {
  display: flex;
  flex-direction: column;
  gap: var(--admin-space-3);
  min-width: 0;
  padding: var(--admin-space-4);
  background: var(--admin-surface-solid);
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-lg);
  box-shadow: 0 4px 20px rgba(18, 19, 25, 0.03);
}

.wi-step.final {
  border-color: rgba(217, 119, 6, 0.3);
}

.wi-step-head {
  display: flex;
  align-items: center;
  gap: var(--admin-space-2);
  font-size: 18px;
}

.wi-step-no {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(123, 97, 255, 0.12);
  color: var(--color-purple);
  font-size: 12px;
  font-weight: 800;
}

.wi-tag {
  margin-left: auto;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.wi-tag.safe {
  background: var(--color-success-bg);
  color: #15803d;
}

.wi-tag.write {
  background: rgba(123, 97, 255, 0.1);
  color: var(--color-purple);
}

.wi-tag.last {
  background: #fff7ed;
  color: #c2610a;
}

/* flex: 1 đẩy nút xuống đáy, để bốn nút thẳng một hàng dù mô tả dài ngắn khác nhau. */
.wi-step-text {
  flex: 1;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--color-text-main);
}

.wi-confirm {
  display: flex;
  align-items: flex-start;
  gap: var(--admin-space-2);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.45;
  color: #c2610a;
  cursor: pointer;
}

.wi-confirm input {
  margin-top: 2px;
  accent-color: #d97706;
}

.wi-step .admin-btn {
  width: 100%;
}

/* Địa chỉ trong bảng hot wallet: mono để so từng ký tự, được xuống dòng thay vì đẩy bảng tràn ngang. */
.wi-mono {
  font-family: var(--admin-mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

/* Tiêu đề mục của màn chép ví: badge trạng thái nằm trong tiêu đề chữ hoa nhưng tự giữ chữ thường. */
.wi-section {
  margin-top: var(--admin-space-8);
}

.wi-section .admin-status {
  text-transform: none;
  letter-spacing: 0;
}

.wi-keys {
  max-width: 900px;
}

.wi-keys .wi-good {
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
}

.wi-keys .wi-warn {
  border-color: rgba(217, 119, 6, 0.3);
  background: #fff7ed;
}

/* Báo cáo giữ nguyên văn bản (copy ra được), chỉ tô màu theo dấu hiệu runner ghi: [ok] / [FAILED] / tiêu đề mục. */
.wi-report {
  margin: 0;
  padding: var(--admin-space-4);
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius-md);
  background: rgba(18, 19, 25, 0.025);
  font-family: var(--admin-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--color-text-main);
}

.wi-report .head {
  font-weight: 700;
}

.wi-report .ok {
  color: #15803d;
}

.wi-report .bad {
  color: #dc2626;
}

/* Màn chép ví trong dark mode: các màu viết cứng ở trên, sáng hơn để đọc được trên nền tối. */
html.admin-dark .wi-tag.safe,
html.admin-dark .wi-report .ok {
  color: #4ade80;
}

html.admin-dark .wi-tag.last,
html.admin-dark .wi-keys .wi-warn {
  background: rgba(217, 119, 6, 0.14);
}

html.admin-dark .wi-tag.last,
html.admin-dark .wi-confirm {
  color: #fbbf24;
}

html.admin-dark .wi-report {
  background: rgba(255, 255, 255, 0.03);
}

html.admin-dark .wi-report .bad {
  color: #f87171;
}

/* --------------------------------------------------------------------------
   営業ダッシュボード (okami-project#2, #239)
   -------------------------------------------------------------------------- */

/* List — summary strip */
.sales-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--admin-space-3);
  padding: var(--admin-space-3) var(--admin-space-5);
  border-radius: var(--admin-radius-md);
  background: rgba(14, 165, 233, 0.08);
  color: #0b4f6c;
  font-size: 14px;
}
.sales-summary-item { display: inline-flex; align-items: center; gap: 6px; color: inherit; text-decoration: none; }
.sales-summary-item strong { font-size: 15px; font-weight: 800; color: #0b3d55; }
.sales-summary-item:hover { text-decoration: underline; }
.sales-summary-icon { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.sales-summary-divider { color: rgba(11, 79, 108, 0.35); }

/* List — search, filter dropdowns, quick filters */
.sales-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--admin-space-3); }
/* Wide enough for a whole OKM address (0x + 40 digits), which is searched for (PO, 2026-10-28). */
.sales-search { position: relative; flex: 1 1 100%; max-width: 440px; min-width: 220px; }
.sales-search .form-input { width: 100%; padding-right: 40px; border-radius: 999px; }
.sales-search-button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border: 0; background: none; color: var(--color-text-muted); cursor: pointer;
}
.sales-search-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.sales-tabs {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  border: 1px solid var(--admin-line); border-radius: var(--admin-radius-md); background: var(--admin-surface-solid);
}
.sales-tabs a {
  padding: 6px 12px; border-radius: var(--admin-radius-sm); font-size: 13.5px; font-weight: 600;
  color: var(--color-text-main); text-decoration: none; white-space: nowrap;
}
.sales-tabs a span { margin-left: 4px; color: var(--color-text-muted); font-weight: 500; }
.sales-tabs a.active { background: rgba(18, 19, 25, 0.06); font-weight: 800; }
.sales-filters { display: flex; flex-wrap: wrap; gap: var(--admin-space-2) var(--admin-space-3); width: 100%; }
.sales-filter { display: flex; flex-direction: column; gap: 4px; flex: 0 1 180px; min-width: 140px; }
.sales-filter > span { font-size: 11.5px; font-weight: 800; color: var(--color-text-muted); }
.sales-filter .form-input { width: 100%; padding: 7px 10px; font-size: 13.5px; }
.sales-filter-reset { align-self: flex-end; }
.sales-chips { display: flex; flex-wrap: wrap; gap: var(--admin-space-2); }
.sales-chip {
  padding: 6px 14px; border: 1px solid var(--admin-line); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--color-text-main); text-decoration: none; background: var(--admin-surface-solid);
}
.sales-chip.active { background: #1f2430; border-color: #1f2430; color: #fff; }

/* List — table */
.sales-table td { vertical-align: middle; }
.sales-table th, .sales-table td { padding-left: 12px; padding-right: 12px; }
.sales-customer-name { display: block; font-weight: 700; }
.sales-customer-meta { display: block; margin-top: 2px; font-size: 12px; color: var(--color-text-muted); }
.sales-customer-meta .mono { font-size: 11px; word-break: break-all; }
.sales-table td:first-child { min-width: 200px; max-width: 240px; }
.sales-rank { display: flex; align-items: center; gap: 10px; }
/* The card art of each rank (wwwroot/images/zef, square with transparent margins), none.png included. */
.sales-rank-img { flex: none; width: 38px; height: 38px; object-fit: contain; margin: -4px; }
.sales-rank-img.large { width: 64px; height: 64px; margin: -8px -6px; }
.sales-rank-name { font-weight: 800; color: #8a6a1c; }
.sales-rank-name.rank-none { color: var(--color-text-muted); }
.sales-rank-name.rank-platinum, .sales-rank-name.rank-platinum_plus { color: #2f7d76; }
.sales-rank-name.rank-black, .sales-rank-name.rank-black_plus { color: #b23a46; }
.sales-rank-lots { margin-left: 6px; font-size: 12px; color: var(--color-text-muted); }
.sales-rank-next { display: block; margin-top: 2px; font-size: 12.5px; color: var(--color-text-muted); }
.sales-rank-next strong { color: #d93025; font-weight: 800; }
.sales-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.sales-tag { padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.sales-tag.dividend { background: rgba(37, 99, 235, 0.1); color: #1d4ed8; }
.sales-tag.today { background: rgba(217, 48, 37, 0.1); color: #c5221f; }
.sales-tag.zwo { background: rgba(124, 58, 237, 0.1); color: #6d28d9; }
.sales-tag.linked { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.sales-tag-none { color: var(--color-text-muted); }
.sales-status { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.sales-status.status-NotContacted { background: rgba(18, 19, 25, 0.06); color: var(--color-text-main); }
.sales-status.status-Contacted { background: rgba(37, 99, 235, 0.1); color: #1d4ed8; }
.sales-status.status-Considering { background: rgba(234, 88, 12, 0.12); color: #c2410c; }
.sales-status.status-Closed { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.sales-status.status-Declined { background: rgba(217, 48, 37, 0.1); color: #c5221f; }
.sales-due { color: #d93025; font-weight: 700; }
.sales-note { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); }
.sales-table .sales-detail-link { font-weight: 700; color: #1d4ed8; text-decoration: none; }
.sales-table .sales-detail-link:hover, .sales-table .sales-detail-link:focus-visible { text-decoration: underline; }
.sales-email { max-width: 200px; font-size: 12.5px; word-break: break-all; }
.sales-account { display: block; font-size: 12.5px; }
.sales-account + .sales-account { margin-top: 2px; }
.sales-account .mono { font-size: 11px; color: var(--color-text-muted); }
/* Only 連携済み or nothing: as narrow as its heading. */
.sales-table .sales-wallet-cell { width: 1%; white-space: nowrap; }

/* Customer page — layout */
.sales-detail { display: flex; flex-direction: column; gap: var(--admin-space-4); }
.sales-back { font-size: 13px; font-weight: 700; color: #1d4ed8; text-decoration: none; }
.sales-detail-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--admin-space-3); margin-top: 6px; }
.sales-detail-meta { font-size: 12.5px; color: var(--color-text-muted); }
.sales-detail-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: var(--admin-space-5); align-items: start; }
.sales-detail-main, .sales-detail-side { display: flex; flex-direction: column; gap: var(--admin-space-4); min-width: 0; }
@media (max-width: 960px) { .sales-detail-grid { grid-template-columns: minmax(0, 1fr); } }

/* Rank hero and progress */
.sales-rank-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--admin-space-3); }
@media (max-width: 640px) { .sales-rank-row { grid-template-columns: minmax(0, 1fr); } }
/* Rank card and simulation: light surfaces in light mode, the dark look of the customer's wallet in dark mode. Every
   colour of the two goes through these tokens; html.admin-dark below sets the dark ones. */
.sales-rank-hero, .sales-sim {
  --sales-ink: var(--color-text-main);
  --sales-ink-soft: rgba(18, 19, 25, 0.72);
  --sales-ink-muted: rgba(18, 19, 25, 0.55);
  --sales-ink-faint: rgba(18, 19, 25, 0.45);
  --sales-fill: rgba(18, 19, 25, 0.04);
  --sales-fill-strong: rgba(18, 19, 25, 0.08);
  --sales-rule: rgba(18, 19, 25, 0.08);
  --sales-gold: #a16207;
  --sales-gold-line: #ca8a04;
  --sales-gold-fill: rgba(234, 179, 8, 0.1);
  --sales-gold-border: rgba(202, 138, 4, 0.4);
  --sales-gold-area: rgba(234, 179, 8, 0.16);
  --sales-gain: #15803d;
  --sales-current-line: rgba(18, 19, 25, 0.4);
  background: var(--admin-surface-solid);
  border: 1px solid var(--admin-line);
  box-shadow: 0 8px 24px -16px rgba(18, 19, 25, 0.18);
  color: var(--sales-ink);
}
.sales-rank-hero { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border-radius: var(--admin-radius-md); }
/* Light mode: the rank card stands out in the console's violet — not the progress card's yellow next to it. The dark
   rule below (html.admin-dark) replaces all three. */
.sales-rank-hero {
  background:
    radial-gradient(circle at 100% 0%, rgba(123, 97, 255, 0.2), transparent 60%),
    linear-gradient(135deg, #f5f2ff 0%, #ebe6ff 100%);
  border-color: rgba(123, 97, 255, 0.3);
  box-shadow: 0 12px 28px -18px rgba(123, 97, 255, 0.6);
  --sales-ink-muted: rgba(60, 45, 140, 0.7);
  --sales-ink-soft: rgba(30, 27, 75, 0.75);
}
.sales-rank-hero-label { display: block; font-size: 11.5px; letter-spacing: 0.08em; color: var(--sales-ink-muted); }
.sales-rank-hero-name { font-size: 22px; font-weight: 800; margin-right: 8px; }
.sales-rank-hero-rate { font-size: 13px; color: var(--sales-ink-soft); }
.sales-progress-card { padding: 16px 18px; border-radius: var(--admin-radius-md); background: #fff8e1; border: 1px solid #f4d77a; color: #2a2412; }
/* The card keeps its light fill in dark mode, so its text keeps dark colours too. */
.sales-progress-card .sales-progress-meta { color: #6b6250; }
.sales-progress-card .sales-progress-bar { background: rgba(42, 36, 18, 0.1); }
.sales-progress-title { margin: 0 0 6px; font-size: 15px; }
.sales-progress-title strong { color: #d93025; font-size: 18px; }
.sales-progress-meta { margin: 0 0 8px; font-size: 12px; color: var(--color-text-muted); }
.sales-progress-bar { height: 8px; border-radius: 999px; background: rgba(18, 19, 25, 0.08); overflow: hidden; }
.sales-progress-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #0ea5e9, #f97366); }

/* Talking points */
.sales-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.sales-point-icon { display: inline-block; width: 20px; margin-right: 6px; text-align: center; color: #1d4ed8; }
.sales-section-caption { margin: 4px 0 -6px; font-size: 12.5px; font-weight: 700; color: var(--color-text-muted); }

/* Simulation (dark in dark mode, as on the customer's screen; light in light mode) */
.sales-sim { padding: 22px; border-radius: var(--admin-radius-lg); }
.sales-sim-title { margin: 0; font-size: 20px; font-weight: 800; }
.sales-sim-subtitle { margin: 4px 0 12px; font-size: 12.5px; color: var(--sales-ink-muted); }
.sales-sim-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--sales-fill-strong); }
.sales-sim-tabs a { padding: 4px 12px; border-radius: 999px; font-size: 12.5px; color: var(--sales-ink-soft); text-decoration: none; }
.sales-sim-tabs a.active { background: var(--sales-tab-active, #fff); color: var(--sales-ink); font-weight: 800; box-shadow: var(--sales-tab-shadow, 0 1px 3px rgba(18, 19, 25, 0.12)); }
.sales-sim-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.sales-sim-total { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--admin-radius-md); background: var(--sales-fill); border: 1px solid var(--sales-rule); }
.sales-sim-total.next { background: var(--sales-gold-fill); border: 1px solid var(--sales-gold-border); }
.sales-sim-total-label { font-size: 12px; color: var(--sales-ink-soft); }
.sales-sim-total-value { font-size: 26px; font-weight: 800; }
.sales-sim-total.next .sales-sim-total-value { color: var(--sales-gold); }
.sales-sim-total-foot { font-size: 12px; color: var(--sales-ink-muted); }
.sales-sim-diff { margin-left: 6px; color: var(--sales-gain); font-weight: 700; }
.sales-sim-chart { width: 100%; height: auto; }
.sales-sim-chart .grid { stroke: var(--sales-rule); }
.sales-sim-chart .axis { fill: var(--sales-ink-muted); font-size: 11px; }
.sales-sim-chart .axis.y { text-anchor: end; dominant-baseline: middle; }
.sales-sim-chart .axis.x { text-anchor: middle; }
.sales-sim-chart .line { stroke-width: 3; fill: none; stroke-linejoin: round; }
.sales-sim-chart .line.next { stroke: var(--sales-gold-line); }
.sales-sim-chart .line.current { stroke: var(--sales-current-line); stroke-dasharray: 6 5; }
.sales-sim-chart .gain { fill: var(--sales-gold-area); }
.sales-sim-table { width: 100%; margin-top: 10px; border-collapse: collapse; font-size: 13px; }
.sales-sim-table th, .sales-sim-table td { padding: 10px 6px; border-top: 1px solid var(--sales-rule); text-align: right; }
.sales-sim-table thead th { font-size: 11.5px; font-weight: 600; color: var(--sales-ink-muted); }
.sales-sim-table th[scope="row"], .sales-sim-table thead th:first-child { text-align: left; font-weight: 600; }
.sales-sim-table td.next { color: var(--sales-gold); font-weight: 700; }
.sales-sim-table td.diff { color: var(--sales-gain); font-weight: 700; }
.sales-sim-note { margin: 12px 0 0; font-size: 11px; line-height: 1.6; color: var(--sales-ink-faint); }
/* 「シミュレーション」 popup (es-777/Okami-ID#493): the button beside the block's title, and the popup — wider than a confirm dialog,
   left-aligned, the simulation inside it drawn as the same card as the block. */
.sales-sim-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
/* Two classes: account.css loads after this file and sizes every .code-dialog at 420px, centred. */
.code-dialog.sales-try-dialog { width: calc(100vw - 32px); max-width: 780px; overflow: auto; text-align: left; }
/* From 768px, the open popup is a column as tall as the screen allows: the title, the form, the totals, the chart and the
   note stay in view and only the table of rounds scrolls (PO, 2026-11-12). On a phone everything is shown and the popup
   scrolls as a whole: the screen is too short to leave the table any room. [open] only: display would show a closed <dialog>. */
@media (min-width: 768px) {
  .code-dialog.sales-try-dialog[open] { display: flex; flex-direction: column; overflow: hidden; }
  .sales-try-region { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .sales-try-result { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .sales-try-result .sales-sim-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
  .sales-try-result .sales-sim-table-wrap { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .code-dialog.sales-try-dialog[open] > :not(.sales-try-region),
  .sales-try-region > :not(.sales-try-result),
  .sales-try-result > :not(.sales-sim-body),
  .sales-try-result .sales-sim-body > :not(.sales-sim-table-wrap) { flex-shrink: 0; }
  .sales-try-result .sales-sim-body > .sales-sim-tabs { align-self: flex-start; }
  /* One row on a PC: ランク, 合計Z2 with the current Z2, 試算. */
  .code-dialog.sales-try-dialog .sales-try-form { flex-wrap: nowrap; }
  .code-dialog.sales-try-dialog .sales-try-field { flex: 0 0 auto; }
  .code-dialog.sales-try-dialog .sales-try-field select { width: 220px; }
  .code-dialog.sales-try-dialog .sales-try-field input { width: 200px; }
  .code-dialog.sales-try-dialog .sales-try-form > button { flex: 0 0 auto; }
}
/* On a phone the four columns of the simulation's table — on the page and in the popup — get a smaller type and tighter
   cells, each on one line; a very large amount scrolls the table sideways rather than breaking out of the card
   (PO, 2026-11-12). */
@media (max-width: 767px) {
  .code-dialog.sales-try-dialog { padding-left: 14px; padding-right: 14px; }
  .sales-sim { padding: 14px 12px; }
  .sales-sim-table-wrap { overflow-x: auto; }
  .sales-sim-table { font-size: 11px; }
  .sales-sim-table thead th { font-size: 10px; }
  .sales-sim-table th,
  .sales-sim-table td { padding: 8px 3px; white-space: nowrap; }
  .sales-sim-total-value { font-size: 22px; }
}
.sales-try-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin: 16px 0; }
.sales-try-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.sales-try-field input, .sales-try-field select { min-width: 180px; padding: 8px 10px; border: 1px solid var(--admin-line); border-radius: var(--admin-radius-md); background: transparent; color: inherit; font-size: 15px; }
.sales-try-current { padding-bottom: 10px; font-size: 12px; opacity: 0.7; }
.sales-try-error { margin: 8px 0 0; color: var(--color-error-text); font-weight: 600; }

/* Forms */
.sales-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--color-text-muted); }
.sales-field.narrow { width: 120px; }
.sales-field.grow { flex: 1 1 200px; }
.sales-check { display: flex; align-items: center; gap: 6px; padding-bottom: 10px; font-size: 13px; }
.sales-notes { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.sales-notes li { padding: 10px 0; border-top: 1px solid var(--admin-line-soft); }
.sales-note-meta { font-size: 11.5px; color: var(--color-text-muted); }
.sales-note-body { margin-top: 2px; font-size: 13.5px; white-space: pre-wrap; }
.sales-note-body.status-change { color: #1d4ed8; }
.sales-wallet-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; word-break: break-all; }
.sales-wallet-note { margin-top: var(--admin-space-2); }
.sales-linked { margin-left: auto; padding: 2px 10px 2px 8px; letter-spacing: 0; text-transform: none; }
/* One compact line of a linked account's facts — its OKM addresses (the replaced ones in grey), its card totals; wraps when long. */
/* Baseline: the label, a mono address and a plain value have different font metrics, so centring them leaves them uneven. */
.sales-fact-row { margin: 0 0 var(--admin-space-2); display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--admin-space-3); row-gap: 2px; font-size: 12.5px; line-height: 22px; }
.sales-fact-label { color: var(--color-text-muted); margin-right: 4px; }
.sales-fact-row .retired { color: var(--color-text-muted); }
.sales-okm-retired-tag { font-size: 11px; }
.sales-copy-row { display: inline-flex; align-items: baseline; gap: 4px; }
.sales-copy-row .sales-copy { align-self: center; }
.sales-copy { display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--color-text-muted); cursor: pointer; }
.sales-copy:hover { background: var(--admin-line-soft); color: var(--color-text-main); }
.sales-copy.is-done { color: #15803d; }
.sales-copy svg { width: 15px; height: 15px; }

/* カード card (okami-project#39) */
/* The side column is ~340px on a laptop: the console's table padding and type pushed 残高 out of the frame. Tighter
   cells keep all four columns in view; the card type wraps, the short columns do not. */
.sales-cards-table { font-size: 13px; }
.sales-cards-table th, .sales-cards-table td { padding: 8px 6px; }
.sales-cards-table th { letter-spacing: 0.4px; }
.sales-cards-table th:first-child, .sales-cards-table td:first-child { padding-left: 12px; }
.sales-cards-table th:last-child, .sales-cards-table td:last-child { padding-right: 12px; }
.sales-cards-table th.num, .sales-cards-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#sales-delete .sales-asset-note { margin-bottom: var(--admin-space-3); }

/* When the side column is too narrow for four columns (laptops between the one-column breakpoint and ~1300px, and
   phones), each card reads as two lines instead: type and balance, then status and owned-since, muted. Keyed to the
   column's own width, not the viewport's. On a phone this also replaces the user list's row layout (avatar in cell 1,
   cell 2 pulled up beside it), which laid 状態 over the card type. */
.sales-detail-side { container: sales-side / inline-size; }

@container sales-side (max-width: 380px) {
  .admin-table.sales-cards-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .admin-table.sales-cards-table,
  .admin-table.sales-cards-table tbody { display: block; }

  .admin-table.sales-cards-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 2px var(--admin-space-3);
    padding: 10px var(--admin-space-3);
    border-bottom: 1px solid var(--admin-line-soft);
  }

  .admin-table.sales-cards-table tbody tr:last-child { border-bottom: none; }
  .admin-table.sales-cards-table tbody tr:hover td:first-child { box-shadow: none; }

  .admin-table.sales-cards-table td {
    display: block;
    grid-row: auto;
    margin-top: 0;
    padding: 0;
    border-bottom: none;
    min-width: 0;
    font-size: 13px;
  }

  .admin-table.sales-cards-table td:nth-child(1) { grid-column: 1; grid-row: 1; font-weight: 700; overflow-wrap: anywhere; }
  .admin-table.sales-cards-table td:nth-child(4) { grid-column: 2; grid-row: 1; display: block; padding-left: 0; }
  .admin-table.sales-cards-table td:nth-child(2) { grid-column: 1; grid-row: 2; color: var(--color-text-muted); }
  .admin-table.sales-cards-table td:nth-child(3) { grid-column: 2; grid-row: 2; padding-left: 0; text-align: right; color: var(--color-text-muted); }
}

/* Customer import (change import-sales-customers) */
.sales-import .admin-card { display: flex; flex-direction: column; gap: var(--admin-space-3); }
.sales-import > .sales-tabs { justify-self: start; }
.sales-import-meta { margin: 0; font-size: 13px; color: var(--color-text-muted); }
.sales-import-form { display: flex; flex-direction: column; align-items: flex-start; gap: var(--admin-space-3); }
.sales-import-modes { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; }
.sales-import-modes legend { margin-bottom: 6px; font-size: 13px; font-weight: 700; }
.sales-import-modes label { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; font-size: 14px; font-weight: 600; cursor: pointer; }
.sales-import-modes small { grid-column: 2; font-size: 12px; font-weight: 400; color: var(--color-text-muted); }
.sales-import-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.sales-import-counts div { min-width: 96px; padding: 8px 12px; border: 1px solid var(--admin-line); border-radius: var(--admin-radius-md); }
.sales-import-counts dt { font-size: 12px; color: var(--color-text-muted); }
.sales-import-counts dd { margin: 2px 0 0; font-size: 20px; font-weight: 800; }

/* Add customer — the customers a new one repeats (change add-sales-customer) */
.sales-dup { margin-bottom: var(--admin-space-3); padding: 12px 14px; border: 1px solid var(--admin-line); border-left: 4px solid #d97706; border-radius: var(--admin-radius-md); font-size: 13px; }
.sales-dup p { margin: 4px 0 0; }
.sales-dup-list { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.sales-dup-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.sales-dup-list a { font-weight: 700; color: #1d4ed8; }
.sales-dup-email { color: var(--color-text-muted); word-break: break-all; }
.sales-dup-reason { font-size: 12px; font-weight: 700; color: #b45309; }
.sales-dup-more { color: var(--color-text-muted); }
/* The Okami ID account of the customer forms (Components/SalesCustomerFields.razor, js/sales-customer-form.js). */
.sales-account-card { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--admin-space-3); padding: 10px 12px; border: 1px solid var(--admin-line); border-radius: var(--admin-radius-md); font-size: 13px; }
.sales-account-facts { display: flex; flex-direction: column; gap: 2px; min-width: 0; word-break: break-all; }
.sales-account-zef { margin-top: 6px; font-size: 13px; word-break: normal; }
.sales-account-found { font-size: 12px; color: var(--color-text-muted); }
/* A search result's actions: the link button, or 連携済み with 連携を解除 once the account is on the list. */
.sales-account-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.sales-account-actions .sales-linked { margin-left: 0; }
.sales-account-warning { margin: 6px 0 0; padding-left: 8px; border-left: 3px solid #d97706; font-size: 12.5px; font-weight: 700; color: #b45309; }
.sales-account-none { margin: 0; font-size: 13px; color: var(--color-text-muted); }
.sales-account-suggestion { margin-top: 8px; }
.sales-account-title { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 700; color: var(--color-text-muted); }
.sales-account-search { display: flex; gap: 8px; margin-top: 10px; }
/* Above the search results: the count on the left, 閉じる / クリア on the right. */
.sales-results-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sales-results-head .sales-account-title { margin-bottom: 0; }
.sales-results-actions { display: flex; gap: 4px; }
.sales-account-search .form-input { flex: 1; min-width: 0; }
.sales-checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
/* One linked account after another in the customer page's ウォレット card: its facts and its cards, a line between accounts. */
/* Baseline, not center: name (14.5px), email (13px) and the badge's text sit on one line whatever their sizes. */
.sales-account-head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--admin-space-2); margin-bottom: 6px; font-size: 14.5px; line-height: 22px; }
.sales-account-head .sales-zef-hidden { padding: 0 10px 0 8px; font-size: 11.5px; line-height: 20px; }
.sales-account-head strong { font-weight: 700; word-break: break-all; }
.sales-account-head .sales-copy-row { font-size: 13px; color: var(--color-text-muted); word-break: break-all; }
.sales-account-head .sales-copy-row.lead { font-size: 14.5px; font-weight: 700; color: var(--color-text-main); }
.sales-accounts { max-height: 560px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.sales-cards-account + .sales-cards-account { margin-top: var(--admin-space-3); padding-top: var(--admin-space-3); border-top: 1px solid var(--admin-line); }
.sales-import-changes { max-height: 480px; overflow-y: auto; }
.sales-import-id { font-size: 11px; word-break: break-all; }
.sales-import-action { padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.sales-import-action.action-Add { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.sales-import-action.action-Link { background: rgba(123, 97, 255, 0.14); color: #5b44e0; }
.sales-import-action.action-Update { background: rgba(234, 88, 12, 0.12); color: #c2410c; }
.sales-import-buttons { display: flex; flex-wrap: wrap; gap: var(--admin-space-2); }

/* Assets and Z2 history */
.sales-asset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sales-asset { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--admin-line); border-radius: var(--admin-radius-sm); }
.sales-asset span { font-size: 11.5px; color: var(--color-text-muted); }
.sales-asset strong { font-size: 15px; }
.sales-asset-note { margin: 8px 0 0; font-size: 12px; color: var(--color-text-muted); }
.sales-history-title { margin: 16px 0 6px; font-size: 13px; font-weight: 800; }
.sales-history { list-style: none; margin: 0; padding: 0; }
.sales-history li { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 12px; padding: 5px 0; border-top: 1px solid var(--admin-line-soft); font-size: 13px; }
.sales-history-date { color: var(--color-text-muted); }
.sales-history-kind { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.sales-history-kind.purchase { background: rgba(37, 99, 235, 0.1); color: #1d4ed8; }
.sales-history-kind.dividend { background: rgba(234, 179, 8, 0.18); color: #a16207; }
.sales-history-amount { text-align: right; }
.sales-history-amount small { color: var(--color-text-muted); }
/* Edit and delete on a history line (Okami-ID#359): two icons at the end of the line that each open a dialog, so
   the line stays as tall as it was. The fourth column is the icons; a line without them (view only) leaves it empty. */
.sales-history li:has(.sales-history-actions) { grid-template-columns: auto auto 1fr auto; }
.sales-history-actions { display: flex; align-items: center; gap: 2px; }
.sales-history-actions form { display: inline-flex; margin: 0; }
/* Rarely used, so quiet: no frame, small, muted until hovered. */
.sales-history-actions .admin-btn.icon { padding: 2px; min-height: 0; min-width: 0; width: auto; height: auto; line-height: 0; border: 0; background: transparent; box-shadow: none; color: var(--color-text-muted); }
.sales-history-actions .admin-btn.icon:hover { background: transparent; color: var(--color-text-main); }
.sales-history-actions .admin-btn.icon.danger:hover { color: #b91c1c; }
.sales-history-actions .admin-btn-icon { width: 13px; height: 13px; }
.sales-confirm .sales-field, .sales-history-actions .sales-field, .sales-membership .sales-field { display: block; margin: 8px 0; }
/* Z.E.F 管理: the rank, the lots held and ZWO as plain facts with a pencil, the form lives in a dialog. */
.sales-membership { display: block; margin: 0 0 6px; }
.sales-membership-facts { margin: 0; font-size: 13px; }
.sales-membership-facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid var(--admin-line-soft); }
.sales-membership-facts > div:first-child { border-top: 0; }
.sales-membership-facts dt { color: var(--color-text-muted); }
.sales-membership-facts dd { margin: 0; font-weight: 700; text-align: right; }
/* The pencil sits at the end of the card title, small and quiet. */
.sales-manage-title { display: flex; align-items: center; justify-content: space-between; }
.sales-manage-edit { padding: 2px; min-height: 0; min-width: 0; width: auto; height: auto; line-height: 0; border: 0; background: transparent; box-shadow: none; color: var(--color-text-muted); }
.sales-manage-edit:hover { background: transparent; color: var(--color-text-main); }
.sales-manage-edit .admin-btn-icon { width: 13px; height: 13px; }
/* The pencil beside the customer's name in the page title. */
.sales-title-edit { display: inline-flex; vertical-align: middle; margin-left: 8px; }
.sales-title-edit .admin-btn-icon { width: 16px; height: 16px; }
/* The delete dialog carries the text for both states of its "also update the holding" box; the box picks one. */
.sales-confirm:has(input[name="adjustHeld"]:checked) .when-off,
.sales-confirm:not(:has(input[name="adjustHeld"]:checked)) .when-on { display: none; }
.sales-history-total { margin: 10px 0 0; font-size: 13px; color: var(--color-text-muted); }
.sales-history-total strong { color: var(--color-text-main); }
/* One-line side cards (ZWO): label, value, pencil; the dialog behind the pencil takes no room. */
.sales-line-card { display: flex; align-items: center; gap: var(--admin-space-3); padding-top: var(--admin-space-3); padding-bottom: var(--admin-space-3); }
.sales-line-label { font-size: 12px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase; color: var(--color-text-muted); }
.sales-line-value { flex: 1; min-width: 0; text-align: right; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The ZWO member card as a thumbnail, the size of the rank card. */
.sales-zwo-thumb { flex: none; width: 46px; height: 27px; object-fit: cover; border-radius: 4px; }
.sales-zwo-thumb.none { filter: grayscale(1); opacity: 0.45; }
/* Two classes: account.css, loaded after this file, resets .code-dialog-title to margin: 0. */
.code-dialog-title.sales-zwo-title { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.sales-zwo-title + .sales-check { gap: 8px; }
.sales-membership-facts .sales-status { display: inline-block; }
/* Memo history and Z2 history show five rows, then scroll inside the card (rows measured at ~60px and 40px). */
.sales-notes { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
/* The card is its own column: the details use its width rather than the audit table's 280px. */
.sales-audit .audit-details { max-width: none; }
.sales-audit .audit-lines { max-width: none; }
/* ウォレット and 操作履歴 are <details>, closed on load: the title is the toggle, with a chevron that turns when open. */
.admin-card-collapsible > summary { cursor: pointer; list-style: none; margin-bottom: 0; padding-bottom: 0; border-bottom: 0; }
.admin-card-collapsible > summary::-webkit-details-marker { display: none; }
.admin-card-collapsible > summary::after {
  content: ""; width: 7px; height: 7px; margin-left: auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform 0.15s ease;
}
.admin-card-collapsible[open] > summary {
  padding-bottom: var(--admin-space-3); margin-bottom: var(--admin-space-4); border-bottom: 1px solid var(--admin-line-soft);
}
.admin-card-collapsible[open] > summary::after { transform: rotate(-135deg); }
/* ウォレット's title: account and card counts after the badge, in the body's case and weight, not the title's capitals. */
.sales-wallet-counts { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.sales-wallet-count-value { color: var(--color-text-main); }

/* Details of a sales customer action as labelled lines (Components/AuditDetails.razor): label on the left, value after. */
.audit-lines { display: grid; gap: 2px; margin: 4px 0 0; max-width: 320px; font-size: 12px; }
.audit-line { display: flex; flex-wrap: wrap; gap: 0 8px; }
.audit-line dt { color: var(--color-text-muted); font-weight: 500; }
.audit-line dt::after { content: ":"; }
.audit-line dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.audit-account { display: inline-flex; align-items: baseline; gap: 4px; margin-right: 8px; }
.audit-account .audit-mono { font-size: 11.5px; }
.audit-account-note { color: var(--color-text-muted); }

/* List: a long name (a web3 address, a long email) wraps inside its cell instead of running into the rank column. */
.sales-customer-name { overflow-wrap: anywhere; }
/* The customer opened last, on the way back to the list: the hovered row's bar, kept (wwwroot/js/sales-list-search.js).
   A deeper tint than hover (0.055), so the row under the pointer and the opened row stay apart. */
.admin-table tbody tr.is-last-opened { background: rgba(123, 97, 255, 0.16); }
.admin-table tbody tr.is-last-opened:hover { background: rgba(123, 97, 255, 0.2); }
.admin-table tbody tr.is-last-opened td:first-child { box-shadow: inset 3.5px 0 0 var(--color-purple); }
@media (max-width: 560px) {
  /* A phone shows rows as cards, without the cell bar: the card itself carries it. */
  .admin-table tbody tr.is-last-opened td:first-child { box-shadow: none; }
  .admin-table tbody tr.is-last-opened { box-shadow: inset 3.5px 0 0 var(--color-purple); }
}
.sales-rank > div { min-width: 0; }
.sales-rank-name, .sales-rank-lots { white-space: nowrap; }

/* Customer list on a phone: the user list's 4-cell row layout laid these 8 cells over each other. Each customer reads
   top-down instead: name + email beside 連携済み, the rank, then status · ZWO · talking points, then next contact and
   memo. Headers are hidden, so the next-contact date carries its own label, and "—" placeholders are dropped. */
@media (max-width: 560px) {
  .admin-table.sales-list-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px var(--admin-space-2);
    padding: var(--admin-space-3);
  }

  .admin-table.sales-list-table td {
    display: block;
    flex: none;
    margin-top: 0;
    padding: 0;
    min-width: 0;
    max-width: none;
    font-size: 13px;
    color: inherit;
    white-space: normal;
    overflow: visible;
  }

  .admin-table.sales-list-table td:nth-child(1) { order: 1; flex: 1 1 0; }
  .admin-table.sales-list-table td:nth-child(4) { order: 2; width: auto; }
  .admin-table.sales-list-table td:nth-child(2) { order: 3; flex-basis: 100%; }
  .admin-table.sales-list-table td:nth-child(6) { order: 4; }
  .admin-table.sales-list-table td:nth-child(3) { order: 5; }
  .admin-table.sales-list-table td:nth-child(5) { order: 6; }
  .admin-table.sales-list-table td:nth-child(7) { order: 7; color: var(--color-text-muted); }
  .admin-table.sales-list-table td:nth-child(8) { order: 8; flex: 1 1 0; }

  .admin-table.sales-list-table .sales-email { max-width: none; }
  .admin-table.sales-list-table .sales-tag-none,
  .admin-table.sales-list-table td.is-empty,
  .admin-table.sales-list-table td:nth-child(4):empty { display: none; }
  .admin-table.sales-list-table .sales-next-cell::before { content: attr(data-label) " "; font-weight: 400; color: var(--color-text-muted); }
  .admin-table.sales-list-table .sales-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Dark theme: the dark cards get an edge so they do not melt into the page, and the light accents get lighter. */
html.admin-dark .sales-summary { background: rgba(14, 165, 233, 0.12); color: #9fd8f2; }
html.admin-dark .sales-summary-item strong { color: #e0f4fd; }
html.admin-dark .sales-summary-divider { color: rgba(159, 216, 242, 0.35); }
html.admin-dark .sales-tabs a.active { background: rgba(255, 255, 255, 0.1); }
html.admin-dark .sales-chip.active { background: #e9ebf3; border-color: #e9ebf3; color: #121319; }
html.admin-dark .sales-rank-name { color: #e5bd5c; }
html.admin-dark .sales-rank-name.rank-none { color: var(--color-text-muted); }
html.admin-dark .sales-rank-name.rank-platinum, html.admin-dark .sales-rank-name.rank-platinum_plus { color: #7fd3ca; }
html.admin-dark .sales-rank-name.rank-black, html.admin-dark .sales-rank-name.rank-black_plus { color: #f08a94; }
html.admin-dark .sales-rank-next strong, html.admin-dark .sales-due { color: #ff7a70; }
html.admin-dark .sales-tag.dividend, html.admin-dark .sales-status.status-Contacted,
html.admin-dark .sales-history-kind.purchase { background: rgba(96, 165, 250, 0.16); color: #93c5fd; }
html.admin-dark .sales-tag.today, html.admin-dark .sales-status.status-Declined { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }
html.admin-dark .sales-tag.zwo { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
html.admin-dark .sales-tag.linked { background: rgba(74, 222, 128, 0.16); color: #86efac; }
html.admin-dark .sales-status.status-NotContacted { background: rgba(255, 255, 255, 0.08); }
html.admin-dark .sales-status.status-Considering { background: rgba(251, 146, 60, 0.16); color: #fdba74; }
html.admin-dark .sales-status.status-Closed { background: rgba(74, 222, 128, 0.16); color: #86efac; }
html.admin-dark .sales-history-kind.dividend { background: rgba(250, 204, 21, 0.16); color: #fde68a; }
html.admin-dark .sales-back, html.admin-dark .sales-table .sales-detail-link,
html.admin-dark .sales-point-icon, html.admin-dark .sales-note-body.status-change { color: #93c5fd; }
html.admin-dark .sales-match.match-Matched { color: #86efac; }
html.admin-dark .sales-rank-hero, html.admin-dark .sales-sim {
  --sales-ink: #f5f5f7;
  --sales-ink-soft: rgba(255, 255, 255, 0.7);
  --sales-ink-muted: rgba(255, 255, 255, 0.6);
  --sales-ink-faint: rgba(255, 255, 255, 0.5);
  --sales-fill: rgba(255, 255, 255, 0.06);
  --sales-fill-strong: rgba(255, 255, 255, 0.08);
  --sales-rule: rgba(255, 255, 255, 0.08);
  --sales-gold: #f5c542;
  --sales-gold-line: #f5c542;
  --sales-gold-fill: rgba(245, 197, 66, 0.12);
  --sales-gold-border: rgba(245, 197, 66, 0.45);
  --sales-gold-area: rgba(245, 197, 66, 0.16);
  --sales-gain: #4ade80;
  --sales-current-line: rgba(255, 255, 255, 0.55);
  --sales-tab-active: rgba(255, 255, 255, 0.16);
  --sales-tab-shadow: none;
  background: #1d2030;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
html.admin-dark .sales-rank-hero-label { color: rgba(255, 255, 255, 0.65); }
html.admin-dark .sales-rank-hero-rate { color: rgba(255, 255, 255, 0.8); }
html.admin-dark .sales-sim-total:not(.next) { border: 0; }
html.admin-dark .sales-sim-tabs a.active { color: #fff; }
html.admin-dark .sales-import-action.action-Add { background: rgba(74, 222, 128, 0.16); color: #86efac; }
html.admin-dark .sales-import-action.action-Link { background: rgba(167, 139, 250, 0.16); color: #c4b5fd; }
html.admin-dark .sales-import-action.action-Update { background: rgba(251, 146, 60, 0.16); color: #fdba74; }
html.admin-dark .sales-progress-card { background: rgba(245, 197, 66, 0.1); border-color: rgba(245, 197, 66, 0.4); color: #f3e7c4; }
html.admin-dark .sales-progress-card .sales-progress-meta { color: #c9bb92; }
html.admin-dark .sales-progress-card .sales-progress-bar { background: rgba(255, 255, 255, 0.1); }
html.admin-dark .sales-progress-title strong { color: #ff7a70; }
.sales-history { max-height: 480px; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.sales-subsection-title {
  margin: var(--admin-space-6) 0 var(--admin-space-3);
  padding-top: var(--admin-space-5);
  border-top: 1px solid var(--admin-line);
  font-size: 13px;
  font-weight: 800;
  color: var(--color-text-main);
}

/* The answer of a save, as a toast (Okami-ID#365). sales-detail.js removes it after a few seconds (the warning stays longer and
   has a close button) and moves it out of the page into .sales-toast-root. Without the script it stays in the stack the server
   drew, at the top of the page. */
.sales-toast-stack { display: flex; flex-direction: column; gap: 8px; }
.sales-toast-stack:empty { display: none; }
/* Under <body>, not inside the admin shell: the shell's backdrop-filter would turn `fixed` into "bottom of the page". A popover,
   so it is in the top layer — in view whatever the scroll and above a dialog that is open. The UA style of [popover] (centred,
   framed, with a background) is cleared. */
.sales-toast-root {
  position: fixed;
  inset: 20px 20px auto auto;
  z-index: 2000;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 32px));
  height: auto;
  pointer-events: none;
}
.sales-toast-root:not(:popover-open):not(:has([data-toast])) { display: none; }
.sales-toast {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--admin-radius-md);
  border-left: 4px solid #15803d;
  background: #f0fdf4;
  color: #14532d;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: 0 6px 20px rgba(18, 19, 25, 0.18);
  pointer-events: auto;
}
.sales-toast.error { border-left-color: #c5221f; background: #fef2f2; color: #7f1d1d; }
.sales-toast.warning { border-left-color: #ca8a04; background: #fefce8; color: #854d0e; }
.sales-toast-close { flex: none; padding: 0 4px; border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
html.admin-dark .sales-toast { background: #12261a; color: #bbf7d0; border-left-color: #4ade80; }
html.admin-dark .sales-toast.error { background: #2a1415; color: #fecaca; border-left-color: #f87171; }
html.admin-dark .sales-toast.warning { background: #2a2210; color: #fde68a; border-left-color: #facc15; }

/* 営業履歴: the meta line of a note carries its edit and delete icons at the end. */
.sales-note-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sales-note-quote { white-space: pre-wrap; max-height: 8em; overflow-y: auto; overflow-wrap: anywhere; }
.sales-kind-radios { display: flex; gap: 18px; margin: 8px 0; }
.sales-kind-radios .sales-check { padding-bottom: 0; }

/* The 「設定」 popup of the overview (change zef-wallet-display-setting): one choice per line under its label. */
.sales-settings-radios { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 4px; }
.sales-settings-radios .sales-check { padding-bottom: 0; }
.sales-settings-label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); }
.sales-settings-links { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 4px; }
.sales-settings-links .form-input { width: 100%; }
/* One tab per membership link (okami-project#49): its URL, then its Japanese and English caption one under the other, full
   width, as a caption runs to 100 characters. The three tabs stay on one row, each as wide as its name; on a phone a name
   breaks only before its bracket (Z.E.F / （ランクあり）), never inside a word. */
.sales-settings-tabs { display: flex; flex-wrap: nowrap; }
.sales-settings-tabs > button { flex: 1 1 auto; word-break: keep-all; }
.sales-tabs button {
  padding: 6px 8px; border: 0; border-radius: var(--admin-radius-sm); background: none; font: inherit; font-size: 13px;
  font-weight: 600; color: var(--color-text-muted); cursor: pointer;
}
.sales-tabs button[aria-selected="true"] { background: rgba(18, 19, 25, 0.06); color: var(--color-text-main); font-weight: 800; }
html.admin-dark .sales-tabs button[aria-selected="true"] { background: rgba(255, 255, 255, 0.1); }
.sales-settings-panel { display: flex; flex-direction: column; gap: 8px; }
.sales-settings-panel[hidden] { display: none; }
/* A JA / EN tag inside the field, on its first line, stands in for a label row. The field grows with its text where the
   browser can (field-sizing), from two lines; elsewhere it stays two lines and the admin can drag it taller. */
.sales-caption { position: relative; display: block; }
.sales-caption > span { position: absolute; left: 10px; top: 15px; font-size: 11px; line-height: 14px; font-weight: 600; color: var(--color-text-muted); pointer-events: none; }
.sales-caption > .form-input { padding-left: 34px; line-height: 1.5; resize: vertical; field-sizing: content; min-height: calc(2lh + 26px); }
#sales-settings .code-dialog-desc { font-size: 12px; line-height: 1.6; }

/* --------------------------------------------------------------------------
   営業ダッシュボード — overview (/admin/sales) and the two view tabs
   Reuses .admin-card / .admin-stat / .admin-bar / .admin-chart of the console home; only the layout and the sales
   colours (gold for Z.E.F, red for due) are added here.
   -------------------------------------------------------------------------- */
.sales-views { display: flex; gap: 4px; border-bottom: 1px solid var(--admin-line); }
.sales-views a {
  padding: 8px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent;
  color: var(--color-text-muted); font-weight: 700; text-decoration: none;
}
.sales-views a.active { color: var(--color-purple); border-bottom-color: var(--color-purple); }
.sales-views a:hover { color: var(--color-text-main); }

.sales-ov-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--admin-space-4); }
.sales-ov-grid > .admin-card { min-width: 0; }
.sales-ov-wide { grid-column: span 6; }
.sales-ov-half { grid-column: span 3; }
.sales-ov-third { grid-column: span 2; }
/* Cards stretch to their row. The pipeline card shares a row with the much taller upcoming-contacts table: keep
   its bars compact at the top and pin the two monthly tiles to the bottom. */
.sales-ov-pipeline { display: flex; flex-direction: column; }
.sales-ov-pipeline .admin-bars { row-gap: var(--admin-space-3); }
.sales-ov-two-thirds { grid-column: span 4; }
.sales-overview .admin-card-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--admin-space-2); }
.sales-overview .admin-card-title h2 { margin: 0; font-size: inherit; }
.sales-ov-subtitle { margin-top: var(--admin-space-4); }
.sales-ov-meta { font-size: 12px; font-weight: 500; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.sales-ov-note { margin: var(--admin-space-2) 0 0; font-size: 12px; }

.sales-ov-scope { display: inline-flex; border: 1px solid var(--admin-line); border-radius: 8px; overflow: hidden; font-size: 12px; }
.sales-ov-scope a { padding: 4px 10px; color: var(--color-text-muted); text-decoration: none; font-weight: 600; }
.sales-ov-scope a.active { background: rgba(123, 97, 255, 0.12); color: var(--color-purple); }

.sales-ov-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--admin-space-3); }
.sales-ov-kpi { color: inherit; text-decoration: none; transition: border-color 0.15s, background 0.15s; }
.sales-ov-kpi:hover, .sales-ov-kpi:focus-visible { border-color: rgba(123, 97, 255, 0.4); }
.sales-ov-kpi .admin-stat-label { text-transform: none; letter-spacing: 0; }
.sales-ov-kpi.due { background: rgba(217, 48, 37, 0.06); border-color: rgba(217, 48, 37, 0.3); }
.sales-ov-kpi.due .admin-stat-value { color: #c5221f; }
.sales-ov-kpi.gold { background: rgba(234, 179, 8, 0.08); border-color: rgba(202, 138, 4, 0.35); }
.sales-ov-kpi.gold .admin-stat-value { color: #a16207; }

.sales-ov-bar { color: inherit; text-decoration: none; border-radius: 6px; }
.sales-ov-bar:hover .admin-bar-label { text-decoration: underline; }
.sales-ov-foot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--admin-space-3); margin-top: auto; }
.sales-ov-foot .admin-stat { background: var(--admin-surface); }
.sales-ov-foot .admin-stat-label { text-transform: none; letter-spacing: 0; }
.sales-ov-foot .admin-stat-value { font-size: 22px; }
.sales-ov-foot .admin-stat-value.sales-ov-good { color: #15803d; }

.sales-ov-table td { padding-top: 8px; padding-bottom: 8px; }
.sales-ov-table td:first-child { min-width: 140px; }

.sales-ov-ranks { gap: 6px; }
.sales-ov-rank { grid-template-columns: 30px 7.5em minmax(0, 1fr) 7.5em; gap: var(--admin-space-2); }
.sales-ov-rank .sales-rank-img { width: 30px; height: 30px; margin: -2px 0; }
.sales-ov-rank .admin-bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sales-ov-rank .admin-bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sales-ov-rank .admin-bar-value small { margin-left: 4px; font-weight: 500; color: var(--color-text-muted); }
.admin-bar-fill.gold { background: #b47a06; }

.sales-ov-chart rect { fill: var(--color-purple); }
.sales-ov-chart.z2 rect { fill: #b47a06; }
.sales-ov-chart rect.current { opacity: 0.5; }
.sales-ov-chart text.value { font-size: 10px; font-weight: 700; fill: var(--color-text-main); }

.sales-ov-feed { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--admin-space-3); }
.sales-ov-feed li { display: grid; gap: 2px; padding-left: 14px; position: relative; font-size: 13px; }
.sales-ov-feed li::before { content: ""; position: absolute; left: 0; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--color-purple); }
.sales-ov-feed-meta { font-size: 11.5px; color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.sales-ov-feed-body a { color: #1d4ed8; font-weight: 600; text-decoration: none; }
.sales-ov-feed-body a:hover { text-decoration: underline; }

.sales-ov-team th.num, .sales-ov-team td.num { text-align: right; font-variant-numeric: tabular-nums; }

.sales-ov-checks { display: grid; gap: var(--admin-space-2); }
.sales-ov-checks a {
  display: flex; justify-content: space-between; align-items: center; gap: var(--admin-space-2);
  padding: 8px 12px; border-radius: var(--admin-radius-sm); background: rgba(18, 19, 25, 0.04);
  color: inherit; text-decoration: none; font-size: 13px;
}
.sales-ov-checks a:hover { background: var(--admin-hover); }
.sales-ov-checks strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.sales-ov-checks a.warn strong { color: #c5221f; }

@media (max-width: 1100px) {
  .sales-ov-half, .sales-ov-third, .sales-ov-two-thirds { grid-column: span 6; }
}
@media (max-width: 760px) {
  .sales-ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-ov-kpis > :last-child { grid-column: span 2; }
}

html.admin-dark .sales-views a.active, html.admin-dark .sales-ov-scope a.active { color: #c4b5fd; border-bottom-color: #a78bfa; }
html.admin-dark .sales-ov-kpi.due { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.35); }
html.admin-dark .sales-ov-kpi.due .admin-stat-value, html.admin-dark .sales-ov-checks a.warn strong { color: #fca5a5; }
html.admin-dark .sales-ov-kpi.gold { background: rgba(245, 197, 66, 0.1); border-color: rgba(245, 197, 66, 0.4); }
html.admin-dark .sales-ov-kpi.gold .admin-stat-value { color: #f5c542; }
html.admin-dark .admin-bar-fill.gold, html.admin-dark .sales-ov-chart.z2 rect { fill: #b98b1f; background: #b98b1f; }
html.admin-dark .sales-ov-chart rect { fill: #8f7cf5; }
html.admin-dark .sales-ov-foot .admin-stat-value.sales-ov-good { color: #86efac; }
html.admin-dark .sales-ov-feed-body a { color: #93c5fd; }
html.admin-dark .sales-ov-checks a { background: rgba(255, 255, 255, 0.05); }

/* Nút bị khoá (vd Save khi form chưa đổi gì — form-dirty.js): mờ đi, không nhấc lên khi hover. Đặt cuối file để thắng
   `:hover` của từng biến thể cùng độ ưu tiên. */
.admin-btn:disabled,
.admin-btn:disabled:hover,
.admin-btn:disabled:active {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
  transform: none;
  box-shadow: none;
}

/* Fields take the console's font instead of the browser default (Arial), whose kerning eats the space after a capital A
   ("ETA Admin" read as "ETAAdmin"). :where keeps it below any rule that sets its own font (the mono fields). */
:where(.admin-shell) :is(input, textarea, select) { font-family: inherit; }

/* --------------------------------------------------------------------------
   Điện thoại và tablet (≤ 860px): sidebar thành drawer, thanh trên cùng là thanh duy nhất

   Trước đây sidebar bị ép thành một hàng icon ngang trên đầu trang: không có nhãn, mục Dashboard bị ẩn để vừa
   chỗ, còn ☰ là menu tài khoản nên trông như menu điều hướng. Thêm mục là tràn. Giờ:
   - Thanh trên cùng (`.admin-topbar`): ☰ mở drawer, logo + "Okami ID" là link về /admin (logo của sidebar là ô
     chọn khu admin với super_admin / developer nên không làm link được), chip tài khoản bên phải.
   - Drawer: chính là sidebar của máy tính, đủ nhãn, trượt vào từ trái. Mở bằng checkbox `#admin-drawer-toggle`
     nên chạy được không cần JavaScript; ☰, nút ✕ và lớp phủ là label của nó.
   -------------------------------------------------------------------------- */
.admin-shell {
  --admin-drawer-width: min(288px, 84vw);
}

.admin-drawer-toggle,
.admin-drawer-open,
.admin-drawer-close,
.admin-drawer-scrim,
.admin-topbar-brand {
  display: none;
}

@media (max-width: 860px) {
  /* `backdrop-filter` và `transform` còn lại sau animation biến shell thành khung chứa của mọi phần tử
     `position: fixed` bên trong: drawer khi đó dính vào đầu shell và trôi mất khi trang đã cuộn. */
  .admin-shell {
    animation: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /* Ẩn khỏi mắt nhưng vẫn focus được: đây là control thật cho bàn phím và trình đọc màn hình (aria-label), ☰ chỉ
     là phần nhìn thấy của nó. */
  .admin-drawer-toggle {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: var(--admin-drawer-width);
    padding: calc(var(--admin-space-3) + env(safe-area-inset-top, 0px)) var(--admin-space-3)
      calc(var(--admin-space-4) + env(safe-area-inset-bottom, 0px)) calc(var(--admin-space-3) + env(safe-area-inset-left, 0px));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #ffffff;
    border-right: 1px solid var(--admin-line);
    box-shadow: 0 24px 60px rgba(18, 19, 25, 0.28);
    animation: none;
    transform: translateX(-100%);
    /* Đóng thì ẩn hẳn, để Tab không đi vào các link nằm ngoài màn hình. */
    visibility: hidden;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.28s;
  }

  .admin-drawer-toggle:checked ~ .admin-sidebar {
    transform: none;
    visibility: visible;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
  }

  .admin-sidebar-head {
    align-items: center;
    padding-bottom: var(--admin-space-3);
  }

  .admin-sidebar-head .admin-brand {
    padding: var(--admin-space-1) var(--admin-space-2);
  }

  .admin-drawer-close,
  .admin-drawer-open {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    padding: 0;
    cursor: pointer;
    border-color: transparent;
    background: transparent;
  }

  .admin-drawer-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(10, 11, 16, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
  }

  .admin-drawer-toggle:checked ~ .admin-drawer-scrim {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.2s ease, visibility 0s;
  }

  /* Drawer mở thì trang phía sau không cuộn theo ngón tay. */
  body:has(.admin-drawer-toggle:checked) {
    overflow: hidden;
  }

  .admin-topbar {
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: var(--admin-space-2);
  }

  .admin-drawer-open {
    margin-left: -10px;
  }

  .admin-drawer-toggle:focus-visible ~ .admin-main .admin-drawer-open {
    box-shadow: var(--admin-focus-ring);
  }

  .admin-topbar-brand {
    display: flex;
    min-width: 0;
    margin-right: auto;
    padding: 0;
  }

  .admin-topbar-brand .admin-brand-mark {
    width: 32px;
    height: 32px;
  }

  .admin-topbar-brand .admin-brand-text {
    font-size: 16px;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  /* Một thanh bám trên cùng khi cuộn. Cao 64px: ô tìm kiếm sticky của các danh sách đứng ngay dưới nó (`top: 64px`). */
  .admin-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    box-sizing: border-box;
    min-height: 64px;
    margin: calc(-1 * var(--admin-space-5)) calc(-1 * var(--admin-space-4)) var(--admin-space-5);
    padding: 10px var(--admin-space-4);
    background: rgba(255, 255, 255, 0.96);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }

  /* Chip tài khoản chỉ còn chữ cái đầu: tên và email nằm trong menu nó mở ra. */
  .admin-account-chip {
    padding: 4px;
    border-color: transparent;
    background: transparent;
  }

  .admin-account-chip .admin-identity-email,
  .admin-account-chip .admin-account-chevron {
    display: none;
  }

  .admin-account-chip .admin-identity-avatar {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar,
  .admin-drawer-toggle:checked ~ .admin-sidebar,
  .admin-drawer-scrim,
  .admin-drawer-toggle:checked ~ .admin-drawer-scrim {
    transition: none;
  }
}

/* Admin list, roles and scopes on a phone: the user list's 4-cell row layout placed these cells over each other.
   Admin list keeps the user list's shape (avatar + name, status on the right) and adds roles, two-factor and last
   sign-in below. Roles and scopes read as one card per row: name and code, then each count with its column name (the
   headers are hidden), and 編集 pushed right, opening to the full width. */
@media (max-width: 560px) {
  .admin-table.admin-accounts-table tr {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    row-gap: 4px;
  }

  .admin-table.admin-accounts-table td {
    margin-top: 0;
    padding-left: 0;
    white-space: normal;
    overflow: visible;
  }

  .admin-table.admin-accounts-table td:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .admin-table.admin-accounts-table td:nth-child(5) { grid-column: 3; grid-row: 1; display: block; justify-self: end; }
  .admin-table.admin-accounts-table td:nth-child(2) { grid-column: 2; grid-row: 2; }
  .admin-table.admin-accounts-table td:nth-child(3) { grid-column: 3; grid-row: 2; justify-self: end; }
  .admin-table.admin-accounts-table td:nth-child(4) { grid-column: 2 / 4; grid-row: 3; display: block; }

  .admin-table.admin-catalog-table tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px var(--admin-space-4);
    padding: var(--admin-space-3);
  }

  .admin-table.admin-catalog-table td {
    display: block;
    flex: none;
    margin-top: 0;
    padding: 0;
    min-width: 0;
    font-size: 13px;
    color: inherit;
    white-space: normal;
    overflow: visible;
  }

  .admin-table.admin-catalog-table td:first-child { flex-basis: 100%; }
  .admin-table.admin-catalog-table td:first-child .admin-status { margin-left: 6px; vertical-align: middle; }
  .admin-table.admin-catalog-table td:not(:first-child) .admin-cell-primary { flex-direction: row; align-items: baseline; gap: 6px; }
  .admin-table.admin-catalog-table td:has(> .admin-row-edit) { margin-left: auto; }
  .admin-table.admin-catalog-table td:has(> .admin-row-edit[open]) { flex-basis: 100%; }
  .admin-table.admin-catalog-table .admin-row-edit-body { min-width: 0; }

  .admin-table.admin-accounts-table td[data-label]::before,
  .admin-table.admin-catalog-table td[data-label]::before {
    content: attr(data-label) " ";
    font-family: inherit;
    font-size: 12px;
    font-weight: 400;
    color: var(--color-text-muted);
  }
}

/* Passkeys of the signed-in admin on a phone: the user list's row layout pulled the added date up under the rename
   button. Name + rename on the left and remove on the right, then added / last used, each with its column name. */
@media (max-width: 560px) {
  .admin-table.admin-passkey-table tr {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px var(--admin-space-2);
  }

  .admin-table.admin-passkey-table td {
    display: block;
    margin-top: 0;
    padding-left: 0;
    min-width: 0;
    white-space: normal;
    overflow: visible;
  }

  .admin-table.admin-passkey-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .admin-table.admin-passkey-table td:nth-child(4) { grid-column: 2; grid-row: 1; }
  .admin-table.admin-passkey-table td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .admin-table.admin-passkey-table td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; }

  .admin-table.admin-passkey-table td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--color-text-muted);
  }
}

/* --------------------------------------------------------------------------
   開発者ツール — /admin/dev-tools (okami-project#51, AdminDevTools.razor)
   One bar (switch + 「実行先」) over four tabs; one panel on screen at a time, its output scrolling inside its frame.
   -------------------------------------------------------------------------- */
.dev-tools-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--admin-space-3) var(--admin-space-4);
  padding-top: var(--admin-space-3);
  padding-bottom: var(--admin-space-3);
}

.dev-tools-bar-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--admin-space-3);
  flex: 1 1 260px;
}

.dev-tools-bar[data-enabled="false"] .admin-status {
  color: var(--color-text-muted);
  background: transparent;
  border-color: var(--admin-line);
}

.dev-tools-bar[data-enabled="false"] .admin-status::before {
  box-shadow: none;
}

.dev-tools-hint {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.dev-tools-switch {
  display: flex;
  flex-wrap: wrap;
  gap: var(--admin-space-2);
}

/* Razor drops the whitespace before the @if that renders it, so the gap after the hint comes from here. */
.dev-tools-expiry {
  margin-inline-start: 0.35em;
}

.dev-tools-confirm-code {
  margin-top: var(--admin-space-3);
}

.dev-tools-target {
  display: flex;
  align-items: center;
  gap: var(--admin-space-2);
}

.dev-tools-target .input-label {
  margin: 0;
  white-space: nowrap;
}

/* As tall as the switch button beside it, not the 44px of a form field. */
.dev-tools-target .form-input {
  width: auto;
  min-width: 180px;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.2;
  border-radius: 10px;
}

/* The account screen's tabs, as buttons: no frame of their own. */
.dev-tools-tabs {
  margin: 0;
}

.dev-tools-tabs .admin-tab {
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

/* A panel that holds an output it has not cleared. */
.dev-tools-tabs .admin-tab.has-output::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  vertical-align: middle;
  border-radius: 50%;
  background: var(--color-purple);
}

.dev-tools-card {
  display: flex;
  flex-direction: column;
  gap: var(--admin-space-3);
}

/* display: flex above would otherwise win over the hidden attribute of the panels behind. */
.dev-tools-card[hidden] {
  display: none;
}

.dev-tools-input,
.dev-tools-pre,
.dev-tools-confirm-input,
.dev-tools-table {
  font-family: var(--admin-mono);
  font-size: 12.5px;
}

textarea.dev-tools-input {
  resize: vertical;
  min-height: 72px;
}

.dev-tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--admin-space-2);
  align-items: center;
}

.dev-tools-actions .dev-tools-filter {
  flex: 1 1 220px;
}

.dev-tools-shortcut {
  font-size: 12px;
  color: var(--color-text-muted);
}

.dev-tools-output:empty {
  display: none;
}

.dev-tools-output {
  border: 1px solid var(--admin-line);
  border-radius: 8px;
  overflow: hidden;
}

.dev-tools-output-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--admin-space-2) var(--admin-space-3);
  padding: 6px 10px;
  border-bottom: 1px solid var(--admin-line);
  background: rgba(127, 127, 127, 0.06);
  font-size: 12.5px;
}

.dev-tools-output-title {
  font-weight: 700;
}

.dev-tools-output-time,
.dev-tools-output-count {
  color: var(--color-text-muted);
}

.dev-tools-output-spacer {
  flex: 1;
}

.admin-btn.dev-tools-small {
  padding: 3px 10px;
  font-size: 12px;
}

/* Under half the window: with the bar, the tabs and the input above it, a full output still fits the window. */
.dev-tools-output-body {
  max-height: 45vh;
  overflow: auto;
  padding: var(--admin-space-3);
}

.dev-tools-meta {
  margin: 0 0 var(--admin-space-2);
  font-size: 13px;
  font-weight: 600;
}

.dev-tools-meta:last-child {
  margin-bottom: 0;
}

.dev-tools-meta.warn {
  color: #c2610a;
}

.dev-tools-meta.bad {
  color: var(--color-error-text);
}

.dev-tools-pre {
  margin: 0 0 var(--admin-space-2);
  white-space: pre;
}

.dev-tools-pre:last-child {
  margin-bottom: 0;
}

.dev-tools-pre.stderr {
  color: var(--color-error-text);
}

.dev-tools-confirm-input {
  margin: 0 0 var(--admin-space-2);
  padding: var(--admin-space-3);
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--admin-line);
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.06);
}

.dev-tools-table {
  width: 100%;
  border-collapse: collapse;
}

.dev-tools-table th,
.dev-tools-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--admin-line);
  text-align: left;
  vertical-align: top;
  word-break: break-all;
}

.dev-tools-table tr:last-child th,
.dev-tools-table tr:last-child td {
  border-bottom: none;
}

.dev-tools-table th {
  width: 40%;
  font-weight: 600;
}

.dev-tools-table thead tr:last-child th {
  width: auto;
  border-bottom: 1px solid var(--admin-line);
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Where the value comes from: appsettings.json, env, args… Kept narrow, never wrapped mid-name. */
.dev-tools-table td.dev-tools-source {
  width: 1%;
  white-space: nowrap;
  word-break: normal;
  color: var(--color-text-muted);
}

.dev-tools-table mark {
  color: inherit;
  background: rgba(123, 97, 255, 0.28);
  border-radius: 2px;
}

@media (max-width: 560px) {
  .dev-tools-target {
    flex: 1 1 100%;
  }

  .dev-tools-target .form-input {
    flex: 1 1 auto;
    min-width: 0;
  }

  .dev-tools-bar .dev-tools-switch,
  .dev-tools-bar .dev-tools-switch form,
  .dev-tools-bar .dev-tools-switch .admin-btn {
    width: 100%;
  }

  .dev-tools-shortcut {
    display: none;
  }

  /* Copy and Clear keep the 44px touch target, so the title takes a line of its own above them. */
  .dev-tools-output-title {
    flex: 1 1 100%;
  }

  /* No room for the time beside the count and the two buttons on a phone. */
  .dev-tools-output-time {
    display: none;
  }

  .dev-tools-table th,
  .dev-tools-table td {
    display: block;
    width: auto;
  }

  /* Stacked rows need no column titles. */
  .dev-tools-table thead {
    display: none;
  }

  .dev-tools-table th {
    border-bottom: none;
    padding-bottom: 0;
  }
}
