/* ==========================================================================
   DESIGN SYSTEM VARIABLES & RESETS
   ========================================================================== */
:root {
  /* Admin Panel Themes (Sleek SaaS Light) */
  --bg-color: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  
  --primary: #4F46E5; /* Royal Tech Indigo */
  --primary-hover: #4338CA;
  --primary-light: #EEF2F6;
  
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  
  --text-title: #0F172A;
  --text-primary: #334155;
  --text-secondary: #64748B;
  
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -4px rgba(0,0,0,0.05);
  --admin-footer-rule-offset: -1px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Alerts & Notices (Floating Toast Style) */
.notice {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  min-width: 320px;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  word-wrap: break-word;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid transparent;
  animation: noticeSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes noticeSlideIn {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.notice.ok { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.notice.error { background: #FEF2F2; border-color: #FCA5A5; color: #991B1B; }
.notice.warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }

.admin-toast {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translate(-50%, -14px);
  z-index: 12000;
  min-width: 240px;
  max-width: min(520px, calc(100vw - 40px));
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid #BFDBFE;
  background: #EFF6FF;
  color: #1E3A8A;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.admin-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.admin-toast.ok {
  border-color: #A7F3D0;
  background: #ECFDF5;
  color: #065F46;
}

.admin-toast.warn {
  border-color: #FDE68A;
  background: #FFFBEB;
  color: #92400E;
}

.admin-toast.error {
  border-color: #FCA5A5;
  background: #FEF2F2;
  color: #991B1B;
}

.admin-toast.inventory-liveness-toast {
  max-width: min(680px, calc(100vw - 40px));
}

/* Status Pills */
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 10px; font-size: 12px; font-weight: 500; border-radius: 9999px; border: 1px solid transparent;
  white-space: nowrap;
}
.pill.green { background: #D1FAE5; color: #065F46; }
.pill.red { background: #FEE2E2; color: #991B1B; }
.pill.blue { background: #DBEAFE; color: #1E40AF; }
.pill.orange { background: #FEF3C7; color: #92400E; }
.pill.gray { background: #E2E8F0; color: #475569; }
.pill.blue.bound-liveness.alive { color: #047857; }
.pill.blue.bound-liveness.dead { color: #B91C1C; }
.pill.blue.bound-liveness.unknown { color: #B45309; }

/* Form Elements */
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-title);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  outline: none;
}
input, select { height: 36px; }
select {
  padding-right: 32px;
}
textarea { padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

label {
  display: block; font-size: 14px; color: var(--text-title); margin-bottom: 8px; font-weight: 500;
}
label .desc { font-weight: normal; font-size: 12px; color: var(--text-secondary); margin-left: 4px; }

.setting-group-title {
  margin-bottom: 8px;
  color: var(--text-title);
  font-size: 14px;
  font-weight: 700;
}

.setting-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.setting-segment-option {
  min-width: 0;
  margin: 0;
}

.setting-segment-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.setting-segment-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.setting-segment-option input:checked + span {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
  color: var(--primary);
}

.setting-inline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.setting-inline-head label {
  margin: 0;
}

.setting-inline-head button {
  flex: 0 0 auto;
  height: 30px;
}

.redeem-gate-panel {
  margin-top: 14px;
}

.redeem-gate-panel.hidden {
  display: none;
}

.redeem-gate-question-list {
  display: grid;
  gap: 8px;
}

.redeem-gate-question-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.redeem-gate-question-row input {
  min-width: 0;
}

.redeem-gate-question-row button {
  width: 40px;
  height: 36px;
  padding: 0;
}

.redeem-gate-upload-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

.redeem-gate-upload-row .setting-checkbox-row {
  flex: 1 1 auto;
}

.redeem-gate-image-limit {
  flex: 0 0 150px;
}

.redeem-gate-image-limit label {
  margin-bottom: 6px;
  font-size: 12px;
}

.redeem-gate-image-limit input {
  height: 34px;
}

.setting-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  cursor: pointer;
}

.setting-checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.setting-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  margin-top: 16px;
}

.setting-checkbox-grid .setting-checkbox-row {
  min-width: 0;
}

.product-rule-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

@media (max-width: 680px) {
  .setting-checkbox-grid {
    grid-template-columns: 1fr;
  }
}

.card-generate-options {
  margin-top: 16px;
}

.card-generate-options .setting-checkbox-row {
  flex-wrap: wrap;
  margin-bottom: 0;
}

/* Buttons */
button, .btn-primary, .btn-secondary {
  font-family: inherit; font-size: 14px; cursor: pointer; transition: all 0.2s;
  background: transparent; border: none; padding: 0; outline: none;
}

.btn-primary, #loginBtn, #searchCardBtn, .modal-footer button[type="submit"], #openCreateProductBtn, #searchInventoryBtn, #searchLogBtn {
  background: var(--primary); color: #fff;
  padding: 6px 16px; height: 36px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500;
}
.btn-primary:hover, #loginBtn:hover, #searchCardBtn:hover, .modal-footer button[type="submit"]:hover, #openCreateProductBtn:hover, #searchInventoryBtn:hover, #searchLogBtn:hover { background: var(--primary-hover); }

.btn-secondary, #clearBtn, #resetCardSearchBtn, #resetInventorySearchBtn, #resetLogSearchBtn, #copyCodesBtn, #openImportInventoryBtn, #openGenerateCardBtn, .table-actions button, #logoutBtn, .modal-footer button.btn-secondary, #cancelProductBtn, .btn-clear-history {
  background: #fff; border: 1px solid var(--border); color: var(--text-primary);
  padding: 6px 16px; height: 36px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500;
}
.btn-secondary:hover, #clearBtn:hover, #resetCardSearchBtn:hover, #resetInventorySearchBtn:hover, #resetLogSearchBtn:hover, #copyCodesBtn:hover, #openImportInventoryBtn:hover, #openGenerateCardBtn:hover, .table-actions button:hover, #logoutBtn:hover, .modal-footer button.btn-secondary:hover, #cancelProductBtn:hover, .btn-clear-history:hover {
  color: var(--primary); border-color: var(--primary); background: var(--primary-light);
}

.btn-danger, .table-actions button.danger {
  color: var(--error);
  border: 1px solid var(--error);
  background: #fff;
  padding: 6px 16px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}
.btn-danger:hover, .table-actions button.danger:hover {
  background: #FEF2F2;
  color: var(--error);
  border-color: var(--error);
}

/* Tables */
.table-container { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; min-height: 0; }
table { width: 100%; border-collapse: collapse; text-align: left; table-layout: fixed; }
th { background: #F8FAFC; color: var(--text-title); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 6px 16px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; word-break: break-all; }
tbody tr { height: calc((100vh - 231px) / 12); min-height: 48px; }
tbody tr:hover { background: #F8FAFC; }
#inventoryRows tr.is-selected,
#cardRows tr.is-selected {
  background: #F8FAFC;
}
tbody tr:last-child td { border-bottom: 1px solid var(--border); }
/* Force the table to occupy 100% height when there are exactly 12 rows, pulling the bottom border to the very bottom of the container to overlap with the pagination border */
.table-container:has(tbody tr:first-child:nth-last-child(12)) table {
  height: 100%;
}
.empty-cell { text-align: center; color: var(--text-secondary); padding: 48px !important; font-size: 14px; }

/* Grid Layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }


/* ==========================================================================
   BUYER CARD PORTAL (PREMIUM GLASSMORPHISM DARK-TECH THEME)
   ========================================================================== */
/* --- Default Theme: Sage Mint (鼠尾草绿) --- */
.buyer-body {
  --blob1: rgba(134, 188, 120, 0.35);
  --blob2: rgba(100, 200, 180, 0.25);
  --blob3: rgba(180, 220, 160, 0.30);
  --primary-buyer: #6B9E5E;
  --primary-hover: #5A8A4E;
  --accent-glow: rgba(107, 158, 94, 0.25);
  --text-main: #3D5438;
  --text-sub: #5A7054;
  --buyer-scroll-thumb: rgba(61, 84, 56, 0.38);
  --buyer-scroll-thumb-hover: rgba(61, 84, 56, 0.58);
  --buyer-scroll-track: transparent;

  background: #F0F2F0;
  color: var(--text-sub);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

html:has(.buyer-body),
.buyer-body,
.buyer-body * {
  scrollbar-width: thin;
  scrollbar-color: var(--buyer-scroll-thumb) var(--buyer-scroll-track);
}

html:has(.buyer-body)::-webkit-scrollbar,
.buyer-body::-webkit-scrollbar,
.buyer-body *::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

html:has(.buyer-body)::-webkit-scrollbar-button,
.buyer-body::-webkit-scrollbar-button,
.buyer-body *::-webkit-scrollbar-button {
  width: 0;
  height: 0;
  display: none;
}

html:has(.buyer-body)::-webkit-scrollbar-track,
.buyer-body::-webkit-scrollbar-track,
.buyer-body *::-webkit-scrollbar-track {
  background: var(--buyer-scroll-track);
}

html:has(.buyer-body)::-webkit-scrollbar-thumb,
.buyer-body::-webkit-scrollbar-thumb,
.buyer-body *::-webkit-scrollbar-thumb {
  background: var(--buyer-scroll-thumb);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

html:has(.buyer-body)::-webkit-scrollbar-thumb:hover,
.buyer-body::-webkit-scrollbar-thumb:hover,
.buyer-body *::-webkit-scrollbar-thumb:hover {
  background: var(--buyer-scroll-thumb-hover);
  background-clip: padding-box;
}

.buyer-layout textarea::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
  width: 6px;
}

.buyer-layout textarea::-webkit-scrollbar-track {
  margin: 8px 0;
}

.history-list::-webkit-scrollbar-track {
  margin: 6px 0;
}

/* --- Theme: Scandinavian Slate (石板灰蓝) --- */
.buyer-body.theme-slate {
  --blob1: rgba(100, 140, 190, 0.35);
  --blob2: rgba(130, 170, 210, 0.25);
  --blob3: rgba(80, 120, 180, 0.20);
  --primary-buyer: #4B6584;
  --primary-hover: #3B5575;
  --accent-glow: rgba(75, 101, 132, 0.25);
  --text-main: #2C3E50;
  --text-sub: #4F5D73;
  --buyer-scroll-thumb: rgba(44, 62, 80, 0.38);
  --buyer-scroll-thumb-hover: rgba(44, 62, 80, 0.58);
  background: #EDF0F3;
}

/* --- Theme: Sakura Powder (樱花粉砂) --- */
.buyer-body.theme-rose {
  --blob1: rgba(220, 160, 155, 0.35);
  --blob2: rgba(240, 180, 170, 0.25);
  --blob3: rgba(200, 140, 150, 0.22);
  --primary-buyer: #B0807A;
  --primary-hover: #9A6A64;
  --accent-glow: rgba(176, 128, 122, 0.25);
  --text-main: #5A3D3A;
  --text-sub: #7D5955;
  --buyer-scroll-thumb: rgba(90, 61, 58, 0.36);
  --buyer-scroll-thumb-hover: rgba(90, 61, 58, 0.56);
  background: #F4EFEE;
}

/* --- Theme: Chamomile Cream (燕麦麦香) --- */
.buyer-body.theme-cream {
  --blob1: rgba(200, 185, 130, 0.35);
  --blob2: rgba(220, 200, 140, 0.25);
  --blob3: rgba(180, 170, 120, 0.22);
  --primary-buyer: #918260;
  --primary-hover: #7D6F50;
  --accent-glow: rgba(145, 130, 96, 0.25);
  --text-main: #4A4230;
  --text-sub: #6B6248;
  --buyer-scroll-thumb: rgba(74, 66, 48, 0.36);
  --buyer-scroll-thumb-hover: rgba(74, 66, 48, 0.56);
  background: #F3F1EC;
}

/* --- Theme: Lavender Fog (薰衣草雾紫) --- */
.buyer-body.theme-lavender {
  --blob1: rgba(150, 140, 200, 0.35);
  --blob2: rgba(180, 170, 230, 0.25);
  --blob3: rgba(130, 120, 190, 0.22);
  --primary-buyer: #7B6FA8;
  --primary-hover: #675C96;
  --accent-glow: rgba(123, 111, 168, 0.25);
  --text-main: #3E3660;
  --text-sub: #5A5280;
  --buyer-scroll-thumb: rgba(62, 54, 96, 0.36);
  --buyer-scroll-thumb-hover: rgba(62, 54, 96, 0.56);
  background: #F0EEF5;
}

/* --- Layout --- */
.buyer-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
}

.buyer-main {
  width: 100%;
  max-width: 680px;
  transition: max-width 0.3s ease;
}

.buyer-card-wrapper {
  display: flex;
  flex-direction: column;
  gap: 24px;
  animation: fadeInDown 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Frosted Glass Card --- */
.redeem-card {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  width: 100%;
  position: relative;
  transition: background 0.4s ease;
}

.redeem-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.redeem-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
  transition: color 0.4s ease;
}

.badge {
  background: rgba(255, 255, 255, 0.6);
  color: var(--primary-buyer);
  border: 1px solid rgba(255, 255, 255, 0.8);
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 9999px;
  backdrop-filter: blur(8px);
  transition: all 0.4s ease;
}

.form-group label {
  color: var(--text-sub);
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 500;
  transition: color 0.4s ease;
}

.form-group label .tip {
  color: var(--text-sub);
  opacity: 0.6;
  font-size: 12px;
}

.textarea-wrapper {
  position: relative;
}

/* --- Glass Inputs --- */
.buyer-layout textarea {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  color: var(--text-main);
  padding: 16px;
  font-size: 15px;
  font-family: 'JetBrains Mono', monospace;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
  backdrop-filter: blur(6px);
  transition: all 0.3s ease;
  width: 100%;
  resize: none;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.buyer-layout textarea::placeholder {
  color: var(--text-sub);
  opacity: 0.45;
}

.buyer-layout textarea:focus {
  border-color: var(--primary-buyer);
  box-shadow: 0 0 0 4px var(--accent-glow), inset 0 1px 3px rgba(0, 0, 0, 0.03);
  background: rgba(255, 255, 255, 0.8);
  outline: none;
}

/* --- Glass Format Selectors --- */
.format-box {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.buyer-layout .format-option {
  flex: 1;
  min-width: 160px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
}

.buyer-layout .format-option input { display: none; }

.buyer-layout .format-option svg {
  color: var(--text-sub);
  opacity: 0.5;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.buyer-layout .option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.buyer-layout .format-option .title {
  color: var(--text-sub);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 0;
  transition: color 0.3s ease;
}

.buyer-layout .format-option .desc {
  color: var(--text-sub);
  opacity: 0.6;
  font-size: 11px;
  transition: color 0.3s ease;
}

/* Format Selected State */
.buyer-layout .format-option.selected {
  border-color: var(--primary-buyer);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 16px var(--accent-glow);
}
.buyer-layout .format-option.selected .title { color: var(--text-main); }
.buyer-layout .format-option.selected svg { color: var(--primary-buyer); opacity: 1; }
.buyer-layout .format-option.selected .desc { opacity: 0.8; }

/* --- Toast Floating Notice --- */
.toast-notice {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
  z-index: 100;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  min-width: 260px;
  line-height: 1.5;
  white-space: pre-line;
  animation: toastShow 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes toastShow {
  from { opacity: 0; transform: translate(-50%, -40%) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.toast-notice.ok { border-color: #10B981; color: #065F46; background: rgba(236, 253, 245, 0.95); }
.toast-notice.error { border-color: #EF4444; color: #991B1B; background: rgba(254, 242, 242, 0.95); }
.toast-notice.warn { border-color: #F59E0B; color: #92400E; background: rgba(255, 251, 235, 0.95); }

/* --- Action Buttons --- */
.buyer-layout .actions-row {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.buyer-body #clearBtn {
  display: none !important;
}

#redeemBtn {
  flex: 1;
  background: var(--primary-buyer);
  color: #fff;
  border-radius: var(--radius);
  height: 48px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#redeemBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px var(--accent-glow);
  background: var(--primary-hover);
}

#redeemBtn:active {
  transform: translateY(0);
}

#redeemBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.3);
}

.buyer-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: block;
  background: rgba(15, 23, 42, 0.18);
}

.buyer-gate-overlay.hidden {
  display: none;
}

.buyer-gate-modal {
  --gate-text: #17221c;
  --gate-muted: #647067;
  --gate-border: #DDE5DE;
  --gate-field: #F7FAF7;
  --gate-primary: #2F6B4F;
  --gate-primary-hover: #285C44;
  position: fixed;
  left: 50vw;
  top: 50vh;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px));
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  padding: 30px;
  color: var(--gate-text);
}

.buyer-gate-question {
  margin: 0 0 26px;
  color: var(--gate-text);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.28;
  text-align: center;
  word-break: break-word;
}

.buyer-gate-question.medium {
  font-size: 25px;
}

.buyer-gate-question.long {
  font-size: 20px;
  text-align: left;
}

.buyer-gate-modal.is-upload-step .buyer-gate-question {
  margin-bottom: 18px;
  font-size: 22px;
  text-align: center;
}

.buyer-gate-modal.is-upload-step .buyer-gate-question.medium {
  font-size: 20px;
}

.buyer-gate-modal.is-upload-step .buyer-gate-question.long {
  font-size: 18px;
}

.buyer-gate-modal.is-text-step .buyer-gate-question {
  margin-bottom: 18px;
  font-size: 22px;
  text-align: center;
}

.buyer-gate-modal.is-text-step .buyer-gate-question.medium {
  font-size: 20px;
}

.buyer-gate-modal.is-text-step .buyer-gate-question.long {
  font-size: 18px;
}

.buyer-gate-modal.is-text-step .buyer-gate-question.hidden {
  display: none;
}

.buyer-gate-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.buyer-gate-dropzone {
  position: relative;
  width: 100%;
  min-height: 150px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border: 1.5px dashed rgba(61, 84, 56, 0.34);
  border-radius: 14px;
  background: var(--gate-field);
  color: var(--gate-text);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.buyer-gate-dropzone:hover,
.buyer-gate-dropzone:focus-visible,
.buyer-gate-dropzone.is-dragover {
  border-color: var(--gate-primary);
  background: #fff;
  transform: translateY(-1px);
}

.buyer-gate-dropzone.has-preview {
  width: var(--gate-preview-width, 100%);
  height: var(--gate-preview-height, auto);
  min-height: 0;
  margin: 0 auto;
  padding: 0;
  border-style: solid;
  background: transparent;
}

.buyer-gate-preview {
  display: block;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.buyer-gate-preview.hidden {
  display: none;
}

.buyer-gate-preview-actions {
  position: absolute;
  inset: 0;
  display: none;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  justify-items: center;
  pointer-events: none;
}

.buyer-gate-dropzone.has-preview:hover .buyer-gate-preview-actions {
  display: grid;
}

.buyer-gate-preview-action {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.26);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.16s ease, background 0.16s ease;
}

.buyer-gate-preview-action:hover,
.buyer-gate-preview-action:focus-visible {
  background: rgba(47, 107, 79, 0.92);
  transform: translateY(-1px);
}

.buyer-gate-preview-action.danger:hover,
.buyer-gate-preview-action.danger:focus-visible {
  background: rgba(180, 35, 24, 0.92);
}

.buyer-gate-preview-action svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.buyer-gate-drop-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.buyer-gate-drop-prompt.hidden {
  display: none;
}

.buyer-gate-drop-prompt svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--gate-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.buyer-gate-drop-prompt strong {
  font-size: 15px;
  font-weight: 800;
}

.buyer-gate-drop-prompt span {
  color: var(--gate-muted);
  font-size: 13px;
  text-align: center;
}

.buyer-gate-file {
  margin-top: 8px;
  color: var(--gate-muted);
  font-size: 13px;
  word-break: break-all;
}

.buyer-gate-text.hidden {
  display: none;
}

.buyer-gate-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.buyer-gate-text-target {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border: 1px solid var(--gate-border);
  border-radius: 14px;
  background: var(--gate-field);
  color: var(--gate-text);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
  word-break: break-word;
}

.buyer-gate-text-input {
  height: 44px;
  border-color: var(--gate-border);
  border-radius: 12px;
  background: #fff;
  color: var(--gate-text);
  text-align: center;
  font-size: 16px;
}

.buyer-gate-text-input::placeholder {
  color: #7C877F;
  opacity: 1;
}

.buyer-gate-text-input:focus {
  border-color: var(--gate-primary);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.16);
}

.buyer-gate-message {
  margin-top: 12px;
  color: #B42318;
  font-size: 13px;
  text-align: center;
}

.buyer-gate-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.buyer-gate-actions button {
  min-width: 92px;
  height: 40px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.buyer-gate-cancel {
  border: 1px solid var(--gate-border);
  background: #fff;
  color: var(--gate-muted);
}

.buyer-gate-confirm {
  border: 0;
  background: var(--gate-primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(47, 107, 79, 0.24);
}

.buyer-gate-confirm:hover:not(:disabled) {
  background: var(--gate-primary-hover);
}

.buyer-gate-confirm:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.buyer-layout .btn-clear {
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.6);
  color: var(--text-sub);
  border-radius: var(--radius);
  padding: 0 20px;
  height: 48px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}
.buyer-layout .btn-clear:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--text-main);
}

/* --- Glass History Panel --- */
.history-panel {
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: background 0.4s ease;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.history-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  transition: color 0.4s ease;
}

.btn-clear-history {
  height: 24px !important;
  font-size: 11px !important;
  padding: 0 8px !important;
  border-radius: 4px !important;
  background: rgba(255, 255, 255, 0.5) !important;
  border: 1px solid rgba(255, 255, 255, 0.6) !important;
  color: var(--text-sub) !important;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-clear-history:hover {
  color: #EF4444 !important;
  border-color: rgba(239, 68, 68, 0.25) !important;
  background: rgba(254, 242, 242, 0.8) !important;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 280px;
  overflow-y: auto;
  min-height: 0;
}

@media (min-width: 1180px) {
  .buyer-main:has(.history-panel:not(.hidden)) {
    max-width: 1120px;
  }

  .buyer-card-wrapper:has(.history-panel:not(.hidden)) {
    display: grid;
    grid-template-columns: minmax(620px, 680px) minmax(320px, 392px);
    align-items: start;
    justify-content: center;
    gap: 24px;
  }

  .buyer-card-wrapper:has(.history-panel:not(.hidden)) .history-panel {
    height: var(--history-panel-height);
    max-height: var(--history-panel-height);
  }

  .buyer-card-wrapper:has(.history-panel:not(.hidden)) .history-list {
    flex: 1 1 auto;
    max-height: none;
    padding-right: 4px;
  }
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  backdrop-filter: blur(6px);
  transition: all 0.2s ease;
}
.history-item:hover {
  background: rgba(255, 255, 255, 0.55);
}

.history-item.expired {
  opacity: 1;
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 12px;
  transition: color 0.4s ease;
}

.item-sub {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: var(--text-sub);
  opacity: 0.7;
}

.history-status {
  font-size: 11px;
  font-weight: 500;
}

.history-status.active {
  color: var(--primary-buyer);
}

.history-status.expired {
  color: var(--text-sub);
  opacity: 0.86;
}

.btn-history-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-buyer);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-history-download:hover:not([disabled]) {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-history-download[disabled] {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.14);
  color: var(--text-sub);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.94;
}

/* ==========================================================================
   SKIN 2: CYBERPUNK NEON (赛博霓虹)
   ========================================================================== */
.buyer-body.skin-cyber {
  --buyer-scroll-thumb: rgba(0, 255, 255, 0.28);
  --buyer-scroll-thumb-hover: rgba(0, 255, 255, 0.46);
  background: #0a0e1a;
  color: #8899aa;
}
/* Cyber grid overlay */
.skin-cyber::before {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background:
    linear-gradient(rgba(0, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.skin-cyber .redeem-card {
  background: rgba(10, 14, 30, 0.85);
  border: 1px solid rgba(0, 255, 255, 0.2);
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.06), inset 0 1px 0 rgba(0, 255, 255, 0.1);
  backdrop-filter: blur(20px);
}

/* Scanline animation */
.skin-cyber .redeem-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(transparent 50%, rgba(0, 255, 255, 0.01) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  border-radius: inherit;
  animation: scanlines 8s linear infinite;
}
@keyframes scanlines {
  0% { background-position: 0 0; }
  100% { background-position: 0 100%; }
}

.skin-cyber .redeem-header h2 {
  color: #00ffff;
  text-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
  font-family: 'JetBrains Mono', monospace;
}

.skin-cyber .badge {
  background: rgba(0, 255, 255, 0.1);
  color: #00ffff;
  border-color: rgba(0, 255, 255, 0.3);
  backdrop-filter: none;
}

.skin-cyber .form-group label { color: #6688aa; }
.skin-cyber .form-group label .tip { color: #445566; opacity: 1; }

.skin-cyber .buyer-layout textarea {
  background: rgba(0, 10, 20, 0.6);
  border-color: rgba(0, 255, 255, 0.15);
  color: #c0f0ff;
  backdrop-filter: none;
  font-family: 'JetBrains Mono', monospace;
}
.skin-cyber .buyer-layout textarea::placeholder { color: #334455; opacity: 1; }
.skin-cyber .buyer-layout textarea:focus {
  border-color: #00ffff;
  box-shadow: 0 0 0 3px rgba(0, 255, 255, 0.15), 0 0 20px rgba(0, 255, 255, 0.1);
  background: rgba(0, 10, 20, 0.8);
}

.skin-cyber .format-option {
  background: rgba(0, 10, 20, 0.5) !important;
  border-color: rgba(0, 255, 255, 0.1) !important;
  backdrop-filter: none !important;
}
.skin-cyber .format-option .title { color: #6688aa !important; }
.skin-cyber .format-option .desc { color: #445566 !important; opacity: 1 !important; }
.skin-cyber .format-option svg { color: #335566 !important; }

.skin-cyber .format-option.selected {
  border-color: #00ffff !important;
  background: rgba(0, 255, 255, 0.05) !important;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.08) !important;
}
.skin-cyber .format-option.selected .title { color: #00ffff !important; }
.skin-cyber .format-option.selected svg { color: #00ffff !important; opacity: 1 !important; }

.skin-cyber #redeemBtn {
  background:
    linear-gradient(135deg, #00f0ff 0%, #1f8dff 58%, #5867ff 100%);
  color: #03111f;
  border: 1px solid rgba(128, 245, 255, 0.42);
  box-shadow:
    0 10px 28px rgba(0, 200, 255, 0.24),
    0 0 0 1px rgba(0, 255, 255, 0.08) inset;
  text-shadow: none;
}
.skin-cyber #redeemBtn:hover:not(:disabled) {
  background: linear-gradient(135deg, #33f5ff 0%, #2b9cff 56%, #6f78ff 100%);
  box-shadow:
    0 14px 34px rgba(0, 220, 255, 0.34),
    0 0 0 1px rgba(165, 250, 255, 0.14) inset;
}

.skin-cyber .btn-clear {
  background: rgba(0, 10, 20, 0.5) !important;
  border-color: rgba(0, 255, 255, 0.15) !important;
  color: #6688aa !important;
  backdrop-filter: none !important;
}
.skin-cyber .btn-clear:hover {
  border-color: rgba(0, 255, 255, 0.4) !important;
  color: #00ffff !important;
}

.skin-cyber .history-panel {
  background: rgba(10, 14, 30, 0.8);
  border-color: rgba(0, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.04);
}
.skin-cyber .history-header h3 { color: #00ffff; text-shadow: 0 0 12px rgba(0,255,255,0.2); }
.skin-cyber .history-item {
  background: rgba(0, 10, 20, 0.4) !important;
  border-color: rgba(0, 255, 255, 0.08) !important;
  backdrop-filter: none !important;
}
.skin-cyber .history-item:hover { background: rgba(0, 255, 255, 0.05) !important; }
.skin-cyber .item-title { color: #8899bb !important; }
.skin-cyber .item-sub { color: #445566 !important; }
.skin-cyber .btn-history-download {
  background: linear-gradient(135deg, #00e7ff, #3d7dff);
  color: #04111f;
  border: 1px solid rgba(128, 245, 255, 0.34);
  box-shadow: 0 6px 18px rgba(0, 200, 255, 0.2);
}
.skin-cyber .btn-history-download:hover:not([disabled]) {
  background: linear-gradient(135deg, #31f2ff, #5a8eff);
  box-shadow: 0 8px 22px rgba(0, 220, 255, 0.28);
}
.skin-cyber .btn-clear-history { background: rgba(0,10,20,0.4) !important; border-color: rgba(0,255,255,0.1) !important; color: #556677 !important; }

.skin-cyber .toast-notice { background: rgba(10,14,30,0.95) !important; border-color: rgba(0,255,255,0.2) !important; color: #c0f0ff !important; backdrop-filter: blur(20px) !important; }
.skin-cyber .toast-notice.ok { border-color: #00ff88 !important; color: #00ff88 !important; background: rgba(0,30,20,0.95) !important; }
.skin-cyber .toast-notice.error { border-color: #ff0055 !important; color: #ff0055 !important; background: rgba(30,0,10,0.95) !important; }




/* ==========================================================================
   SKIN: STARFIELD OBSERVATORY (星空观测) — Canvas Rendered
   ========================================================================== */
.buyer-body.skin-starfield {
  --buyer-scroll-thumb: rgba(130, 154, 226, 0.34);
  --buyer-scroll-thumb-hover: rgba(160, 184, 232, 0.58);
  background: radial-gradient(ellipse at 50% 30%, #0f0a28 0%, #08051a 50%, #030208 100%);
  background-attachment: fixed;
  color: #8090b0;
}
.starfield-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

.skin-starfield .buyer-layout { position: relative; z-index: 1; }

.skin-starfield .redeem-card {
  background: #080816;
  border: 1px solid rgba(116, 136, 205, 0.18);
  box-shadow: 0 16px 54px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(120, 144, 220, 0.08);
  backdrop-filter: none;
}

.skin-starfield .redeem-header h2 {
  color: #c0d0f0;
  text-shadow: 0 0 20px rgba(140, 160, 220, 0.2);
}

.skin-starfield .badge {
  background: rgba(100, 120, 180, 0.1);
  color: #8898c8;
  border-color: rgba(100, 120, 180, 0.2);
  backdrop-filter: none;
}

.skin-starfield .form-group label { color: #6878a0; }
.skin-starfield .form-group label .tip { color: #4a5878; opacity: 1; }

.skin-starfield .buyer-layout textarea {
  background: #05050f;
  border-color: rgba(116, 136, 205, 0.14);
  color: #a0b0d0;
  backdrop-filter: none;
}
.skin-starfield .buyer-layout textarea::placeholder { color: #2a3858; opacity: 1; }
.skin-starfield .buyer-layout textarea:focus {
  border-color: rgba(130, 154, 226, 0.38);
  box-shadow: 0 0 0 3px rgba(100, 120, 180, 0.1);
}

.skin-starfield .format-option {
  background: #060611 !important;
  border-color: rgba(116, 136, 205, 0.12) !important;
  backdrop-filter: none !important;
}
.skin-starfield .format-option .title { color: #6878a0 !important; }
.skin-starfield .format-option .desc { color: #4a5878 !important; opacity: 1 !important; }
.skin-starfield .format-option svg { color: #4a5878 !important; }
.skin-starfield .format-option.selected {
  border-color: rgba(130, 154, 226, 0.38) !important;
  background: #11172d !important;
  box-shadow: 0 8px 22px rgba(42, 58, 116, 0.22) !important;
}
.skin-starfield .format-option.selected .title { color: #a0b8e8 !important; }
.skin-starfield .format-option.selected svg { color: #a0b8e8 !important; opacity: 1 !important; }

.skin-starfield #redeemBtn {
  background: linear-gradient(135deg, #3a4a8a 0%, #5a3a8a 50%, #4a5aaa 100%);
  box-shadow: 0 4px 20px rgba(80, 60, 140, 0.3);
}
.skin-starfield #redeemBtn:hover:not(:disabled) {
  box-shadow: 0 6px 30px rgba(80, 60, 140, 0.45);
}

.skin-starfield .btn-clear {
  background: #060611 !important;
  border-color: rgba(116,136,205,0.14) !important;
  color: #6878a0 !important;
  backdrop-filter: none !important;
}

.skin-starfield .history-panel {
  background: #080816;
  border-color: rgba(116, 136, 205, 0.14);
  backdrop-filter: none;
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.34);
}
.skin-starfield .history-header h3 { color: #a0b0d0; }
.skin-starfield .history-item {
  background: #060611 !important;
  border-color: rgba(116,136,205,0.1) !important;
  backdrop-filter: none !important;
}
.skin-starfield .history-item:hover { background: #0d1224 !important; }
.skin-starfield .item-title { color: #8898c8 !important; }
.skin-starfield .item-sub { color: #4a5878 !important; }
.skin-starfield .btn-history-download { background: linear-gradient(135deg, #3a4a8a, #5a3a8a); }
.skin-starfield .btn-clear-history { background: rgba(5,5,15,0.4) !important; border-color: rgba(100,120,180,0.08) !important; color: #4a5878 !important; }
.skin-starfield .toast-notice { background: rgba(8,8,24,0.95) !important; border-color: rgba(100,120,180,0.15) !important; color: #a0b0d0 !important; }


/* ==========================================================================
   SKIN: IVORY MONO (象牙黑白)
   ========================================================================== */
.buyer-body.skin-ivory {
  --primary-buyer: #111111;
  --primary-hover: #2b2b2b;
  --accent-glow: rgba(17, 17, 17, 0.18);
  --text-main: #111111;
  --text-sub: #4d4941;
  --buyer-scroll-thumb: rgba(17, 17, 17, 0.34);
  --buyer-scroll-thumb-hover: rgba(17, 17, 17, 0.54);

  background:
    radial-gradient(circle at 18% 18%, rgba(248, 241, 229, 0.68) 0 16%, transparent 34%),
    radial-gradient(circle at 82% 78%, rgba(222, 211, 192, 0.6) 0 18%, transparent 42%),
    linear-gradient(135deg, #f8f2e8 0%, #f3eadc 52%, #e8dcc9 100%);
  background-attachment: fixed;
  color: var(--text-sub);
}

.skin-ivory::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(rgba(17, 17, 17, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.76), rgba(0,0,0,0.18));
}

.skin-ivory .buyer-layout { position: relative; z-index: 1; }

.skin-ivory .redeem-card,
.skin-ivory .history-panel {
  background: rgba(255, 251, 242, 0.84);
  border: 1px solid rgba(17, 17, 17, 0.12);
  box-shadow: 0 18px 50px rgba(24, 20, 14, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(18px);
}

.skin-ivory .redeem-header h2,
.skin-ivory .history-header h3 {
  color: var(--text-main);
}

.skin-ivory .badge {
  background: rgba(17, 17, 17, 0.06);
  color: #111111;
  border-color: rgba(17, 17, 17, 0.12);
  backdrop-filter: none;
}

.skin-ivory .form-group label { color: #4d4941; }
.skin-ivory .form-group label .tip { color: #777064; opacity: 1; }

.skin-ivory .buyer-layout textarea {
  background: rgba(255, 253, 247, 0.88);
  border-color: rgba(17, 17, 17, 0.13);
  color: #141414;
  backdrop-filter: none;
}
.skin-ivory .buyer-layout textarea::placeholder { color: #8a8377; opacity: 1; }
.skin-ivory .buyer-layout textarea:focus {
  border-color: #111111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.11);
  background: rgba(255, 255, 250, 0.96);
}

.skin-ivory .format-option {
  background: rgba(255, 253, 247, 0.68) !important;
  border-color: rgba(17, 17, 17, 0.1) !important;
  backdrop-filter: none !important;
}
.skin-ivory .format-option .title { color: #3a362f !important; }
.skin-ivory .format-option .desc { color: #777064 !important; opacity: 1 !important; }
.skin-ivory .format-option svg { color: #5c554b !important; opacity: 0.82 !important; }
.skin-ivory .format-option.selected {
  border-color: #111111 !important;
  background: rgba(255, 255, 250, 0.94) !important;
  box-shadow: 0 8px 24px rgba(17, 17, 17, 0.1) !important;
}
.skin-ivory .format-option.selected .title { color: #111111 !important; }
.skin-ivory .format-option.selected svg { color: #111111 !important; opacity: 1 !important; }

.skin-ivory #redeemBtn {
  background: #111111;
  color: #fffaf0;
  box-shadow: 0 12px 26px rgba(17, 17, 17, 0.18);
}
.skin-ivory #redeemBtn:hover:not(:disabled) {
  background: #2b2b2b;
  box-shadow: 0 14px 32px rgba(17, 17, 17, 0.25);
}

.skin-ivory .btn-clear,
.skin-ivory .btn-clear-history {
  background: rgba(255, 253, 247, 0.72) !important;
  border-color: rgba(17, 17, 17, 0.12) !important;
  color: #4d4941 !important;
  backdrop-filter: none !important;
}
.skin-ivory .btn-clear:hover {
  border-color: rgba(17, 17, 17, 0.32) !important;
  color: #111111 !important;
}

.skin-ivory .history-item {
  background: rgba(255, 253, 247, 0.68) !important;
  border-color: rgba(17, 17, 17, 0.1) !important;
  backdrop-filter: none !important;
}
.skin-ivory .history-item:hover { background: rgba(255, 255, 250, 0.94) !important; }
.skin-ivory .item-title { color: #171717 !important; }
.skin-ivory .item-sub { color: #777064 !important; }
.skin-ivory .history-status.active { color: #111111; }
.skin-ivory .btn-history-download {
  background: #111111;
  color: #fffaf0;
  box-shadow: 0 8px 18px rgba(17, 17, 17, 0.14);
}
.skin-ivory .toast-notice {
  background: rgba(255, 253, 247, 0.96) !important;
  border-color: rgba(17, 17, 17, 0.14) !important;
  color: #111111 !important;
}

.buyer-body.skin-ivory.ivory-night {
  --primary-buyer: #f8f1e5;
  --primary-hover: #fff8ed;
  --accent-glow: rgba(248, 241, 229, 0.18);
  --text-main: #fff8ed;
  --text-sub: #c9beb0;
  --buyer-scroll-thumb: rgba(255, 248, 237, 0.34);
  --buyer-scroll-thumb-hover: rgba(255, 248, 237, 0.56);

  background:
    radial-gradient(circle at 50% 18%, rgba(106, 94, 76, 0.34) 0 16%, transparent 38%),
    radial-gradient(circle at 82% 78%, rgba(255, 244, 222, 0.1) 0 14%, transparent 38%),
    linear-gradient(135deg, #050505 0%, #12110f 52%, #211c16 100%);
}

.skin-ivory.ivory-night::before {
  background:
    linear-gradient(rgba(255, 248, 237, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 248, 237, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.62), rgba(0,0,0,0.12));
}

.skin-ivory.ivory-night .redeem-card,
.skin-ivory.ivory-night .history-panel {
  background: rgba(10, 10, 10, 0.82);
  border-color: rgba(255, 248, 237, 0.13);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 248, 237, 0.06);
}

.skin-ivory.ivory-night .badge {
  background: rgba(255, 248, 237, 0.08);
  color: #fff8ed;
  border-color: rgba(255, 248, 237, 0.14);
}

.skin-ivory.ivory-night .form-group label { color: #c9beb0; }
.skin-ivory.ivory-night .form-group label .tip { color: #8c8276; }

.skin-ivory.ivory-night .buyer-layout textarea {
  background: rgba(4, 4, 4, 0.62);
  border-color: rgba(255, 248, 237, 0.12);
  color: #fff8ed;
}
.skin-ivory.ivory-night .buyer-layout textarea::placeholder { color: #635b51; }
.skin-ivory.ivory-night .buyer-layout textarea:focus {
  border-color: rgba(255, 248, 237, 0.62);
  box-shadow: 0 0 0 3px rgba(255, 248, 237, 0.1);
  background: rgba(8, 8, 8, 0.76);
}

.skin-ivory.ivory-night .format-option {
  background: rgba(4, 4, 4, 0.48) !important;
  border-color: rgba(255, 248, 237, 0.1) !important;
}
.skin-ivory.ivory-night .format-option .title { color: #c9beb0 !important; }
.skin-ivory.ivory-night .format-option .desc { color: #766d61 !important; }
.skin-ivory.ivory-night .format-option svg { color: #91877a !important; }
.skin-ivory.ivory-night .format-option.selected {
  border-color: rgba(255, 248, 237, 0.62) !important;
  background: rgba(255, 248, 237, 0.06) !important;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2) !important;
}
.skin-ivory.ivory-night .format-option.selected .title,
.skin-ivory.ivory-night .format-option.selected svg {
  color: #fff8ed !important;
}

.skin-ivory.ivory-night #redeemBtn {
  background: #fff8ed;
  color: #090909;
  box-shadow: 0 12px 28px rgba(255, 248, 237, 0.13);
}
.skin-ivory.ivory-night #redeemBtn:hover:not(:disabled) {
  background: #f0e4d2;
  box-shadow: 0 14px 34px rgba(255, 248, 237, 0.2);
}

.skin-ivory.ivory-night .btn-clear,
.skin-ivory.ivory-night .btn-clear-history {
  background: rgba(4, 4, 4, 0.48) !important;
  border-color: rgba(255, 248, 237, 0.12) !important;
  color: #c9beb0 !important;
}
.skin-ivory.ivory-night .btn-clear:hover {
  border-color: rgba(255, 248, 237, 0.35) !important;
  color: #fff8ed !important;
}

.skin-ivory.ivory-night .history-item {
  background: rgba(4, 4, 4, 0.44) !important;
  border-color: rgba(255, 248, 237, 0.09) !important;
}
.skin-ivory.ivory-night .history-item:hover { background: rgba(255, 248, 237, 0.06) !important; }
.skin-ivory.ivory-night .item-title { color: #fff8ed !important; }
.skin-ivory.ivory-night .item-sub { color: #766d61 !important; }
.skin-ivory.ivory-night .history-status.active { color: #fff8ed; }
.skin-ivory.ivory-night .btn-history-download {
  background: #fff8ed;
  color: #090909;
}
.skin-ivory.ivory-night .toast-notice {
  background: rgba(10, 10, 10, 0.96) !important;
  border-color: rgba(255, 248, 237, 0.14) !important;
  color: #fff8ed !important;
}

.history-item.expired .item-title {
  color: var(--text-main);
}

.history-item.expired .item-sub {
  opacity: 0.7;
}

.history-item.expired .btn-history-download[disabled],
.skin-cyber .history-item.expired .btn-history-download[disabled],
.skin-starfield .history-item.expired .btn-history-download[disabled],
.skin-ivory .history-item.expired .btn-history-download[disabled],
.skin-ivory.ivory-night .history-item.expired .btn-history-download[disabled] {
  background: rgba(148, 163, 184, 0.1) !important;
  border: 1px solid rgba(148, 163, 184, 0.14) !important;
  color: var(--text-sub) !important;
  box-shadow: none !important;
  opacity: 0.94;
}

.skin-cyber .history-item.expired .history-status.expired,
.skin-starfield .history-item.expired .history-status.expired {
  color: #596a90;
  opacity: 0.9;
}

.skin-cyber .history-item.expired .btn-history-download[disabled],
.skin-starfield .history-item.expired .btn-history-download[disabled] {
  color: #64769e !important;
}

.skin-ivory .history-item.expired .history-status.expired {
  color: #6f675c;
}

.skin-ivory .history-item.expired .btn-history-download[disabled] {
  color: #6f675c !important;
}

.skin-ivory.ivory-night .history-item.expired .history-status.expired {
  color: #958a7d;
  opacity: 0.9;
}

.skin-ivory.ivory-night .history-item.expired .btn-history-download[disabled] {
  color: #958a7d !important;
}


/* ==========================================================================
   FLOATING SKIN SWITCHER (屏幕右上角)
   ========================================================================== */
.skin-switcher-fab {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  font-family: 'Inter', sans-serif;
}

.skin-fab-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.skin-fab-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.3s ease;
}
.skin-fab-btn:hover { transform: scale(1.1); }
.skin-fab-btn.open { transform: rotate(45deg) scale(1.1); }

.skin-cyber .skin-fab-btn,
.skin-starfield .skin-fab-btn,
.skin-ivory .skin-fab-btn,
.skin-ivory.ivory-night .skin-fab-btn {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}

.skin-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  animation: panelSlideIn 0.25s ease both;
  min-width: 180px;
}
.skin-panel.show { display: flex; }

@keyframes panelSlideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.skin-cyber .skin-panel {
  background: rgba(10,14,30,0.9);
  border-color: rgba(0,255,255,0.15);
}
.skin-starfield .skin-panel {
  background: rgba(8,8,24,0.9);
  border-color: rgba(100,120,180,0.12);
}
.skin-ivory .skin-panel {
  background: rgba(255, 251, 242, 0.92);
  border-color: rgba(17, 17, 17, 0.1);
  box-shadow: 0 16px 42px rgba(17, 17, 17, 0.12);
}
.skin-ivory.ivory-night .skin-panel {
  background: rgba(10, 10, 10, 0.92);
  border-color: rgba(255, 248, 237, 0.13);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
}


.skin-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}
.skin-option:hover {
  background: rgba(0,0,0,0.04);
}
.skin-cyber .skin-option:hover { background: rgba(0,255,255,0.06); }
.skin-starfield .skin-option:hover { background: rgba(100,120,180,0.06); }
.skin-ivory .skin-option:hover { background: rgba(17, 17, 17, 0.05); }
.skin-ivory.ivory-night .skin-option:hover { background: rgba(255, 248, 237, 0.07); }

.skin-option.active {
  background: rgba(0,0,0,0.06);
}
.skin-cyber .skin-option.active { background: rgba(0,255,255,0.1); }
.skin-starfield .skin-option.active { background: rgba(100,120,180,0.08); }
.skin-ivory .skin-option.active { background: rgba(17, 17, 17, 0.08); }
.skin-ivory.ivory-night .skin-option.active { background: rgba(255, 248, 237, 0.09); }

.skin-swatch {
  width: 28px; height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.8);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.skin-option-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.skin-option-name {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}
.skin-cyber .skin-option-name { color: #aabbcc; }
.skin-starfield .skin-option-name { color: #8898c8; }
.skin-ivory .skin-option-name { color: #111111; }
.skin-ivory.ivory-night .skin-option-name { color: #fff8ed; }

.skin-option-desc {
  font-size: 10px;
  color: #888;
}
.skin-cyber .skin-option-desc { color: #556677; }
.skin-starfield .skin-option-desc { color: #4a5878; }
.skin-ivory .skin-option-desc { color: #777064; }
.skin-ivory.ivory-night .skin-option-desc { color: #766d61; }

.ivory-mode-panel {
  display: none;
  grid-template-columns: 1fr 1fr;
  justify-items: center;
  gap: 2px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  width: 70px;
  height: 30px;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
}
.ivory-mode-panel.show { display: grid; }

.ivory-mode-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #61594e;
  background: transparent;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ivory-mode-btn:hover {
  color: #111111;
  background: rgba(255, 255, 255, 0.52);
}
.ivory-mode-btn.active {
  color: #fffaf0;
  background: #111111;
  border-color: #111111;
}
.skin-ivory.ivory-night .ivory-mode-panel {
  background: transparent;
  border: none;
  box-shadow: none;
}
.skin-ivory.ivory-night .ivory-mode-btn {
  color: #a79d90;
}
.skin-ivory.ivory-night .ivory-mode-btn:hover {
  color: #fff8ed;
  background: rgba(255, 248, 237, 0.08);
}
.skin-ivory.ivory-night .ivory-mode-btn.active {
  color: #090909;
  background: #fff8ed;
  border-color: #fff8ed;
}



/* ==========================================================================
   ADMIN PORTAL LAYOUT & COMPONENTS
   ========================================================================== */
#adminPanel {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-color);
}

/* Sidebar Dashboard Navigation */
.sidebar {
  width: 260px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
}

.sidebar-top {
  flex-shrink: 0;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-title);
  letter-spacing: -0.2px;
}

.tabs {
  padding: 0 0 16px 0;
  flex: 1;
  overflow-y: auto;
}

.tabs button {
  width: 100%;
  height: 44px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  text-align: left;
  font-weight: 500;
  transition: all 0.15s ease;
}

.tabs button:hover {
  color: var(--primary);
  background: #F8FAFC;
}

.tabs button.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-bottom {
  position: relative;
  flex-shrink: 0;
  height: 64px;
  padding: 0 24px;
  border-top: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-bottom::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: var(--admin-footer-rule-offset);
  height: 1px;
  background: var(--border);
  pointer-events: none;
}

.sidebar-bottom a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}
.sidebar-bottom a:hover {
  color: var(--primary);
}

/* Main Area Dashboard Content */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-header {
  height: 64px;
  background: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.page-heading-default {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.page-header h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.page-header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-left: 12px;
  font-weight: normal;
}

.card-batch-header {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  max-width: min(660px, 58vw);
  min-height: 46px;
  padding: 7px 34px 7px 14px;
  border: 1px solid #BFDBFE;
  border-radius: 8px;
  background: #EFF6FF;
  color: #1E3A8A;
}

.card-batch-header h1 {
  color: #1E40AF;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-batch-header p {
  margin: 0;
  color: #475569;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-batch-close-btn {
  position: absolute;
  top: 5px;
  right: 7px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #2563EB;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.card-batch-header:hover .card-batch-close-btn,
.card-batch-header:focus-within .card-batch-close-btn {
  opacity: 1;
  pointer-events: auto;
}

.card-batch-close-btn:hover {
  background: #DBEAFE;
  color: #1D4ED8;
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.page-body {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  background: var(--bg-color);
  height: calc(100vh - 64px);
}

.section {
  display: none;
}
.section.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

#inventory {
  position: relative;
}

.inventory-page-drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #2563EB;
  border-radius: 8px;
  background: rgba(239, 246, 255, 0.96);
  color: #1D4ED8;
  pointer-events: none;
}

.inventory-page-drop-overlay.hidden {
  display: none;
}

.inventory-page-drop-content {
  width: min(360px, calc(100% - 48px));
  min-height: 150px;
  padding: 24px;
  border: 1px solid #BFDBFE;
  border-radius: 8px;
  background: #FFFFFF;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  box-sizing: border-box;
}

.inventory-page-drop-content svg {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.inventory-page-drop-content strong {
  color: #0F172A;
  font-size: 16px;
  line-height: 1.4;
}

.inventory-page-drop-content span {
  color: #475569;
  font-size: 13px;
  line-height: 1.4;
}

/* Toolbars inside subsections */
.toolbar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  background: #FFF;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.toolbar select, .toolbar input {
  height: 32px;
  font-size: 13px;
}

.toolbar select {
  flex: 0 0 auto;
  padding-left: 12px !important;
  padding-right: 28px !important;
  text-align: left;
  text-align-last: center;
  text-overflow: ellipsis;
}

#inventoryBatchFilter,
#cardBatchFilter {
  width: 220px !important;
  min-width: 220px;
}

.batch-select-control {
  position: relative;
  flex: 0 0 auto;
  width: 280px;
  min-width: 280px;
}

.batch-select-control .native-batch-select {
  position: absolute;
  width: 1px !important;
  min-width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  opacity: 0;
  pointer-events: none;
}

.batch-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #0F172A;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  outline: none;
}

.batch-select-trigger:hover {
  border-color: #A5B4FC;
  background: #F8FAFF;
}

.batch-select-control.open .batch-select-trigger,
.batch-select-trigger:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.batch-select-trigger span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-select-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: #64748B;
  transition: transform 0.16s ease;
}

.batch-select-control.open .batch-select-chevron {
  color: var(--primary);
  transform: rotate(180deg);
}

.batch-select-menu {
  position: fixed;
  z-index: 4000;
  top: 0;
  left: 0;
  width: 280px;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
}

.batch-select-menu-scroll {
  max-height: 390px;
  padding: 4px 12px 4px 4px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.batch-select-menu-scroll::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.batch-select-scrollbar {
  position: absolute;
  top: 3px;
  right: 0;
  bottom: 3px;
  width: 4px;
  pointer-events: none;
}

.batch-select-scrollbar-thumb {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  min-height: 24px;
  border-radius: 999px;
  background: #CBD5E1;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.batch-select-menu.is-scrollable .batch-select-scrollbar-thumb {
  opacity: 1;
}

.batch-select-menu:hover .batch-select-scrollbar-thumb {
  background: #94A3B8;
}

.batch-select-option {
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #0F172A;
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.batch-select-option:hover,
.batch-select-option.is-active {
  background: rgba(99, 102, 241, 0.09);
  color: var(--primary);
}

.batch-select-option.is-selected {
  background: var(--primary);
  color: #fff;
}

.toolbar select option {
  text-align: left;
}

.pagination select {
  width: auto !important;
  min-width: 104px;
  padding-right: 30px !important;
}

.log-filter-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.log-clear-btn {
  flex-shrink: 0;
}

.log-table {
  table-layout: fixed;
}

.log-table th,
.log-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: normal;
}

.log-status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 68px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.log-status-pill.success {
  background: #D1FAE5;
  color: #047857;
}

.log-status-pill.error {
  background: #FEE2E2;
  color: #B91C1C;
}

.log-status-pill.muted {
  background: #E2E8F0;
  color: #475569;
}

.product-table {
  table-layout: fixed;
}

.product-table th,
.product-table td {
  vertical-align: middle;
}

.product-stat-group {
  padding-left: 0;
  padding-right: 0;
  text-align: center;
  border-left: 1px solid #D7E0EA;
  border-right: 1px solid #D7E0EA;
}

.product-stat-cell {
  padding: 0;
  border-left: 1px solid #D7E0EA;
  border-right: 1px solid #D7E0EA;
}

.product-stat-block {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  width: 100%;
  height: 100%;
  min-height: 48px;
  min-width: 0;
}

.product-stat-item {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 100%;
  padding: 0 6px;
  border-left: 1px solid #E2E8F0;
}

.product-stat-item:first-child {
  border-left: 0;
}

.product-stat-label {
  color: #64748B;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.product-stat-item strong {
  color: #0F172A;
  font-size: 13px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.product-stat-ok {
  color: #047857;
}

.product-stat-bad {
  color: #B91C1C;
}

.inventory-table {
  table-layout: fixed;
}

.inventory-table th,
.inventory-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-table .inventory-label-cell,
.inventory-table .inventory-product-cell {
  white-space: nowrap;
  word-break: normal;
}

.inventory-table .inventory-label-cell strong,
.inventory-table .inventory-product-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

#inventory .inventory-table th:nth-child(5),
#inventory .inventory-table td:nth-child(5) {
  padding-left: 16px;
  padding-right: 16px;
  text-align: center;
}

.inventory-table .inventory-status-pill {
  box-sizing: border-box;
  width: 68px;
  padding-left: 6px;
  padding-right: 6px;
}

#inventory .cell-center {
  text-align: center;
}

#inventory .cell-mono {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

#inventory .inventory-select-checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  vertical-align: middle;
}

#inventory .inventory-table th:nth-child(1),
#inventory .inventory-table th:nth-child(2),
#inventory .inventory-table th:nth-child(3),
#inventory .inventory-table th:nth-child(4),
#inventory .inventory-table th:nth-child(5),
#inventory .inventory-table th:nth-child(6),
#inventory .inventory-table th:nth-child(7),
#inventory .inventory-table th:nth-child(8),
#inventory .inventory-table th:nth-child(9),
#inventory .inventory-table th:nth-child(10),
#inventory .inventory-table td:nth-child(1),
#inventory .inventory-table td:nth-child(2),
#inventory .inventory-table td:nth-child(3),
#inventory .inventory-table td:nth-child(4),
#inventory .inventory-table td:nth-child(5),
#inventory .inventory-table td:nth-child(6),
#inventory .inventory-table td:nth-child(7),
#inventory .inventory-table td:nth-child(8),
#inventory .inventory-table td:nth-child(9),
#inventory .inventory-table td:nth-child(10),
#cards .card-table th:nth-child(1),
#cards .card-table th:nth-child(2),
#cards .card-table th:nth-child(3),
#cards .card-table th:nth-child(5),
#cards .card-table th:nth-child(6),
#cards .card-table th:nth-child(7),
#cards .card-table th:nth-child(8),
#cards .card-table th:nth-child(9),
#cards .card-table th:nth-child(10),
#cards .card-table th:nth-child(11),
#cards .card-table td:nth-child(1),
#cards .card-table td:nth-child(2),
#cards .card-table td:nth-child(3),
#cards .card-table td:nth-child(5),
#cards .card-table td:nth-child(6),
#cards .card-table td:nth-child(7),
#cards .card-table td:nth-child(8),
#cards .card-table td:nth-child(9),
#cards .card-table td:nth-child(10),
#cards .card-table td:nth-child(11),
.inventory-table .inventory-batch-cell,
.inventory-table .inventory-format-cell,
.inventory-table .inventory-binding-cell {
  text-align: center;
  white-space: nowrap;
  word-break: normal;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  border-top: none !important;
  background: #fff;
  height: 56px;
  box-sizing: border-box;
  margin-top: -1px;
  position: relative;
  z-index: 1;
}

.pagination::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: var(--admin-footer-rule-offset);
  height: 1px;
  background: var(--border);
  pointer-events: none;
}

.card-toolbar {
  gap: 16px;
}

.card-filter-group {
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.card-filter-group::-webkit-scrollbar {
  display: none;
}

.card-batch-toolbar-actions,
.inventory-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.inventory-default-actions,
.inventory-selection-actions,
.card-default-actions,
.card-selection-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-batch-toolbar-actions button,
.inventory-toolbar-actions button {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  margin: 0;
  gap: 4px;
}

.card-batch-toolbar-actions svg,
.inventory-toolbar-actions svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.card-batch-toolbar-actions .btn-danger,
.inventory-toolbar-actions .btn-danger {
  color: var(--error);
  border-color: var(--error);
  background: #FFF5F5;
}

.toolbar-selected-summary {
  display: flex;
  align-items: center;
  height: 28px;
  margin: 0 2px 0 0;
  color: #64748B;
  font-size: 13px;
  white-space: nowrap;
}

.toolbar-selected-summary span {
  margin: 0 3px;
  color: var(--primary);
  font-weight: 700;
}

.table-actions button {
  height: 28px;
  font-size: 12px;
  padding: 0 10px;
}

/* Overlay dialog styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.modal-card {
  position: relative;
  background: #fff;
  width: min(520px, 95%);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-card .notice {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, 90%);
  z-index: 10010;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  margin: 0;
  animation: noticeCenterIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
  text-align: center;
  justify-content: center;
  border-radius: 8px;
}
@keyframes noticeCenterIn {
  from { transform: translate(-50%, -45%) scale(0.95); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-card.wide {
  width: min(760px, 95%);
}

.settings-modal-card {
  max-height: min(94vh, 860px);
}

.settings-modal-card .modal-content {
  max-height: calc(94vh - 72px);
  padding-top: 22px;
  padding-bottom: 20px;
}

.settings-modal-card .grid-2[style*="margin-top: 16px"],
.settings-modal-card .setting-checkbox-grid,
.settings-modal-card .redeem-gate-panel {
  margin-top: 12px !important;
}

.settings-modal-card #settingsForm > div[style*="margin-top: 16px"] {
  margin-top: 12px !important;
}

.settings-modal-card #settingsForm > div[style*="margin-top: 24px"] {
  margin-top: 18px !important;
}

.gate-upload-gallery {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #fff;
  padding: 20px 24px;
}

.gate-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 280px));
  align-items: start;
  gap: 18px;
}

.gate-upload-card {
  min-width: 0;
  line-height: 0;
}

.gate-upload-thumb {
  appearance: none;
  width: 100%;
  display: block;
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.gate-upload-thumb:hover,
.gate-upload-thumb:focus-visible {
  border-color: #93C5FD;
  box-shadow: 0 0 0 2px #DBEAFE;
  outline: 0;
}

.gate-upload-thumb-img {
  display: block;
  width: 100%;
  height: auto;
}

.gate-upload-thumb-img.hidden,
.gate-upload-thumb-placeholder.hidden {
  display: none;
}

.gate-upload-thumb-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1.4;
  text-align: center;
}

.gate-upload-thumb-placeholder.is-error {
  color: var(--error);
}

.gate-upload-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  color: var(--text-secondary);
  font-size: 14px;
}

.gate-upload-modal {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}

.gate-upload-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-bottom: 16px;
  color: var(--text-primary);
  font-size: 13px;
}

.gate-upload-meta div {
  min-width: 0;
}

.gate-upload-meta strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-weight: 500;
}

.gate-upload-meta span {
  display: block;
  overflow-wrap: anywhere;
}

.gate-upload-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 58vh;
  overflow: auto;
  background: #fff;
}

.gate-upload-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.product-modal-card {
  width: min(620px, 95vw);
}

.replenish-card-modal {
  width: min(430px, calc(100vw - 32px));
  min-height: 150px;
  padding: 42px 30px 30px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: #fff;
}

.replenish-card-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #64748B;
  font-size: 24px;
  font-weight: 300;
  line-height: 28px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.replenish-card-close:hover {
  background: transparent;
  color: #0F172A;
}

.replenish-card-code {
  width: 100%;
  min-height: 72px;
  padding: 10px 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  color: #0F172A;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  line-height: 1.25;
}

.replenish-card-code:hover {
  background: transparent;
  color: var(--primary);
}

.replenish-card-code:focus-visible {
  outline: 0;
  color: var(--primary);
}

.product-rule-grid {
  align-items: start;
}

.product-rule-field label {
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-height: 18px;
  white-space: nowrap;
}

.product-rule-field label .desc {
  margin-left: 0;
  flex: 0 0 auto;
}

@media (max-width: 680px) {
  .product-rule-grid {
    grid-template-columns: 1fr;
  }

  .product-rule-field label {
    white-space: normal;
  }
}

.modal-title {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-title);
}

.modal-title button {
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  background: transparent;
}
.modal-title button:hover {
  color: var(--text-title);
}

.modal-content {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(85vh - 120px);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #F8FAFC;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.inventory-detail-footer {
  overflow: visible;
}

.card-detail-grid {
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}

.card-detail-grid strong {
  color: var(--text-title);
}

.card-detail-grid .detail-mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
}

.card-binding-detail-grid {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.card-binding-picker {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.card-binding-picker button {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.card-binding-picker button:hover,
.card-binding-picker button.active {
  border-color: #93C5FD;
  background: #EFF6FF;
  color: #1D4ED8;
}

.inventory-raw-textarea {
  resize: none;
  scrollbar-width: thin;
  scrollbar-color: #CBD5E1 transparent;
}

.inventory-text-block {
  margin-top: 16px;
}

.inventory-text-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.inventory-text-header label {
  margin: 0;
}

.inventory-raw-textarea::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.inventory-raw-textarea::-webkit-scrollbar-button {
  width: 0;
  height: 0;
  display: none;
}

.inventory-raw-textarea::-webkit-scrollbar-track {
  background: transparent;
  margin: 8px 0;
}

.inventory-raw-textarea::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.inventory-raw-textarea::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
  background-clip: padding-box;
}

.split-copy-control {
  position: relative;
  display: inline-flex;
  align-items: stretch;
}

.split-copy-control .split-copy-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin: 0;
  gap: 6px;
}

.split-copy-control .split-copy-main svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.split-copy-control .icon-split-main {
  width: 36px;
  padding: 0;
}

.inventory-copy-icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.inventory-copy-icon-button:hover:not(:disabled),
.inventory-copy-icon-button:focus-visible {
  background: transparent;
  box-shadow: none;
  color: var(--text-primary);
}

.inventory-copy-icon-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.inventory-copy-icon-button svg {
  width: 18px;
  height: 18px;
}

.inventory-pickup-control {
  position: relative;
  display: inline-flex;
}

.inventory-toolbar-pickup-control,
.inventory-row-pickup-control {
  position: relative;
  display: inline-flex;
}

.inventory-toolbar-pickup-control .split-copy-menu,
.inventory-row-pickup-control .split-copy-menu {
  top: calc(100% + 8px);
  bottom: auto;
}

.inventory-row-pickup-control .split-copy-menu {
  position: fixed;
  right: auto;
  bottom: auto;
  z-index: 1200;
}

.inventory-row-pickup-menu:not(.hidden) {
  display: flex;
  flex-direction: column;
}

.inventory-pickup-button {
  gap: 6px;
}

.inventory-pickup-button svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.split-copy-control .split-copy-toggle {
  width: 38px;
  padding: 0;
  margin: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.split-copy-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  width: 156px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.16);
  z-index: 4;
}

.detail-inline-control .split-copy-menu {
  top: calc(100% + 8px);
  bottom: auto;
}

.split-copy-menu button {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  margin: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
}

.split-copy-menu button:hover {
  background: #EEF2FF;
  color: var(--primary);
}

.inventory-download-format-modal {
  width: min(520px, 95vw);
}

.inventory-download-format-summary {
  margin-bottom: 14px;
  color: #475569;
  font-size: 13px;
  font-weight: 500;
}

.inventory-download-format-options {
  display: grid;
  gap: 10px;
}

.inventory-download-format-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.inventory-download-format-option:hover,
.inventory-download-format-option.selected {
  border-color: #A5B4FC;
  background: #F8FAFF;
}

.inventory-download-format-option.selected {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.inventory-download-format-option input {
  display: none;
}

.inventory-download-format-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: #F1F5F9;
  color: #475569;
  flex: 0 0 auto;
}

.inventory-download-format-option.selected .inventory-download-format-icon {
  background: #EEF2FF;
  color: var(--primary);
}

.inventory-download-format-icon svg {
  width: 18px;
  height: 18px;
}

.inventory-download-format-option strong {
  display: block;
  color: var(--text-title);
  font-size: 14px;
  line-height: 1.25;
}

.inventory-download-format-option small {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.25;
}

.form-group {
  margin-bottom: 16px;
}

/* File Upload drag-and-drop box */
.file-area {
  border: 2px dashed var(--border);
  background: #F8FAFC;
  padding: 24px;
  text-align: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: block;
  margin: 16px 0;
}
.file-area:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.file-area:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
.file-area.drag-over {
  border-color: var(--primary);
  background: #EEF2FF;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.file-area input {
  display: none;
}
.file-input-hidden {
  display: none;
}
.file-summary {
  margin-top: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
}
.file-summary.has-files {
  color: var(--text-title);
  border-color: #C7D2FE;
  background: #F8FAFF;
}
textarea.file-drop-over {
  border-color: var(--primary);
  background: #F8FAFF;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.status-cell {
  text-align: center;
}
.status-cell .pill {
  margin: 0 auto;
}

#cards .status-cell {
  position: relative;
  overflow: hidden;
  padding-top: 0;
  padding-bottom: 0;
}

#cards .status-cell .pill {
  box-sizing: border-box;
  width: 68px;
  min-height: 24px;
  padding-left: 6px;
  padding-right: 6px;
}

#cards .card-status-stack {
  position: absolute;
  inset: 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

#cards .card-status-stack .pill {
  flex: 0 0 auto;
}

#cards .card-status-stack .card-binding-pill {
  min-height: 18px;
  height: 18px;
  padding-left: 4px;
  padding-right: 4px;
  font-size: 10px;
}

#cards .card-rule-pill-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
}

#cards .card-rule-pill-row .pill {
  margin: 0;
}

#cards .card-rule-pill-row.is-compact .card-binding-pill {
  width: 34px;
  padding-left: 2px;
  padding-right: 2px;
  font-size: 11px;
}

#cards .card-rule-pill-row.is-compact {
  gap: 0;
}

#cards .card-rule-pill-row.is-compact .card-binding-pill:first-child {
  border-radius: 9999px 0 0 9999px;
}

#cards .card-rule-pill-row.is-compact .card-binding-pill:last-child {
  border-radius: 0 9999px 9999px 0;
}

#cards .card-disabled-reason {
  display: block;
  width: 100%;
  max-width: 92px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  word-break: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

#cards th,
#cards td,
#inventory th,
#inventory td {
  vertical-align: middle;
}

#cards .card-table-container,
#inventory .inventory-table-container {
  --card-scrollbar-width: 12px;
  --card-row-height: calc((100vh - 231px) / 12);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#cards .card-table-head-wrap,
#inventory .inventory-table-head-wrap {
  flex: 0 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable;
  border-bottom: 1px solid var(--border);
  background: #F8FAFC;
}

#cards .card-table-body-scroll,
#inventory .inventory-table-body-scroll {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  background: #fff;
}

#cards .card-table-body-scroll.is-scroll-start::after,
#inventory .inventory-table-body-scroll.is-scroll-start::after {
  content: "";
  position: absolute;
  left: 0;
  right: var(--card-scrollbar-width);
  bottom: 0;
  z-index: 3;
  height: 1px;
  background: #fff;
  pointer-events: none;
}

#cards .card-table-head-wrap::-webkit-scrollbar,
#cards .card-table-body-scroll::-webkit-scrollbar,
#inventory .inventory-table-head-wrap::-webkit-scrollbar,
#inventory .inventory-table-body-scroll::-webkit-scrollbar {
  width: var(--card-scrollbar-width);
}

#cards .card-table-head-wrap::-webkit-scrollbar-button,
#cards .card-table-body-scroll::-webkit-scrollbar-button,
#inventory .inventory-table-head-wrap::-webkit-scrollbar-button,
#inventory .inventory-table-body-scroll::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

#cards .card-table-head-wrap::-webkit-scrollbar-track,
#cards .card-table-body-scroll::-webkit-scrollbar-track,
#inventory .inventory-table-head-wrap::-webkit-scrollbar-track,
#inventory .inventory-table-body-scroll::-webkit-scrollbar-track {
  background: transparent;
}

#cards .card-table-head-wrap::-webkit-scrollbar-thumb,
#cards .card-table-body-scroll::-webkit-scrollbar-thumb,
#inventory .inventory-table-head-wrap::-webkit-scrollbar-thumb,
#inventory .inventory-table-body-scroll::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #94A3B8;
  background-clip: padding-box;
}

#cards .card-table-head-wrap::-webkit-scrollbar-thumb,
#inventory .inventory-table-head-wrap::-webkit-scrollbar-thumb {
  background: transparent;
}

#cards .card-table-body-scroll::-webkit-scrollbar-thumb:hover,
#inventory .inventory-table-body-scroll::-webkit-scrollbar-thumb:hover {
  background: #64748B;
  background-clip: padding-box;
}

#cards .card-table,
#inventory .inventory-table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  height: auto;
}

#cards tbody tr,
#inventory tbody tr {
  height: var(--card-row-height);
  min-height: var(--card-row-height);
}

#cards .card-table-head th,
#inventory .inventory-table-head th {
  border-bottom: none;
}

#cards .cell-center {
  text-align: center;
}

#cards .cell-mono {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

#cards .destroy-countdown {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#cards .card-select-checkbox {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  vertical-align: middle;
}

#inventoryRows tr[data-inventory-id],
#cardRows tr[data-card-id] {
  cursor: pointer;
}

.table-select-id-cell {
  position: relative;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#inventory .inventory-select-checkbox.row-select-input,
#cards .card-select-checkbox.row-select-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.row-id-value,
.row-selected-check {
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
}

.row-id-value {
  display: inline-flex;
}

.row-selected-check {
  display: none;
  color: #16A34A;
}

.row-selected-check svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#inventoryRows tr.is-selected .row-id-value,
#cardRows tr.is-selected .row-id-value {
  display: none;
}

#inventoryRows tr.is-selected .row-selected-check,
#cardRows tr.is-selected .row-selected-check {
  display: inline-flex;
}

#inventoryRows tr.is-selected .row-selected-check,
#cards .card-row.is-selected .row-selected-check,
#cards .card-row.is-exported.is-selected .row-selected-check,
#cards .card-row.is-redeemed.is-selected .row-selected-check {
  color: #16A34A;
}

#cards .card-row.is-exported td {
  color: #94A3B8;
}

#cards .card-row.is-exported td strong,
#cards .card-row.is-exported .cell-mono,
#cards .card-row.is-exported .card-code-text {
  color: #64748B;
}

#cards .card-code-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

#cards .card-code-main {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

#cards .card-code-text {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

#cards .card-code-link {
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}

#cards .card-code-link:hover .card-code-text,
#cards .card-code-link:focus-visible .card-code-text {
  color: var(--primary);
}

#cards .card-code-link:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.35);
  outline-offset: 3px;
  border-radius: 4px;
}

#cards .card-unit-multiplier {
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 18px;
  margin-right: 5px;
  padding: 0 5px;
  border-radius: 999px;
  background: #EEF2FF;
  color: #4338CA;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  pointer-events: none;
}

#cards .card-table th:nth-child(4),
#cards .card-table td:nth-child(4) {
  text-align: center;
}

#cards .card-table-head th:nth-child(4) {
  padding-left: 16px;
  padding-right: 48px;
}

#cards .card-row.is-redeemed .card-code-text {
  color: #64748B;
  text-decoration: line-through;
  text-decoration-color: #94A3B8;
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: none;
}

#cards .card-row .card-code-link:hover .card-code-text,
#cards .card-row .card-code-link:focus-visible .card-code-text {
  color: var(--primary);
}

#cards .copy-card-code-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #64748B;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

#cards .card-code-main:hover .copy-card-code-btn,
#cards .card-code-main:focus-within .copy-card-code-btn,
#cards .copy-card-code-btn.is-copied {
  opacity: 1;
  pointer-events: auto;
}

#cards .copy-card-code-btn:hover {
  background: #F1F5F9;
  color: var(--text-title);
}

#cards .copy-card-code-btn.is-copied,
#cards .copy-card-code-btn.is-copied:hover {
  background: transparent;
  color: #16A34A;
}

.inventory-label-copy-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 32px);
  max-width: calc(100% - 32px);
  min-width: 0;
}

.inventory-label-detail-link {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: center;
}

.inventory-label-detail-link strong {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inventory-label-detail-link:hover strong,
.inventory-label-detail-link:focus-visible strong {
  color: var(--primary);
}

.inventory-label-detail-link:focus-visible {
  outline: 2px solid rgba(79, 70, 229, 0.35);
  outline-offset: 3px;
  border-radius: 4px;
}

.copy-inventory-raw-btn {
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.inventory-label-copy-cell:hover .copy-inventory-raw-btn,
.inventory-label-copy-cell:focus-within .copy-inventory-raw-btn,
.copy-inventory-raw-btn.is-copied {
  opacity: 1;
  pointer-events: auto;
}

.copy-inventory-raw-btn:hover {
  background: #F1F5F9;
  color: var(--text-title);
}

.copy-inventory-raw-btn.is-copied,
.copy-inventory-raw-btn.is-copied:hover {
  background: transparent;
  color: #16A34A;
}

#cards .export-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  background: #F1F5F9;
  color: #64748B;
}

#cards .export-pill.exported {
  background: #E0F2FE;
  color: #0369A1;
}

#cards .table-actions,
#inventory .table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

#cards .table-actions {
  justify-content: flex-start;
}

#inventory .table-actions {
  justify-content: center;
  gap: 4px;
  flex-wrap: nowrap;
}

#inventory .inventory-table th:nth-child(10),
#inventory .inventory-table td:nth-child(10) {
  padding-left: 4px;
  padding-right: 4px;
}

#inventory .table-actions button,
#inventory .table-actions button.danger,
#inventory .table-actions button.secondary {
  width: 24px !important;
  min-width: 24px !important;
  height: 24px !important;
  flex: 0 0 24px !important;
}

/* Admin Portal Login Screen Styling */
#loginPanel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-color);
  padding: 20px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: loginFadeIn 0.3s ease-out;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-title);
  margin-bottom: 8px;
  text-align: center;
}

.login-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  text-align: center;
}

.login-card .form-group {
  margin-bottom: 20px;
}

.login-card .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-title);
  margin-bottom: 8px;
}

.login-card #loginBtn {
  width: 100%;
  height: 40px;
  margin-top: 10px;
  font-size: 15px;
  font-weight: 600;
}

@keyframes loginFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Confirm Modal and Table Button Size Normalization */
#okConfirmBtn {
  background: var(--error) !important;
  color: #fff !important;
  border-color: var(--error) !important;
}
#okConfirmBtn:hover {
  background: #DC2626 !important;
  border-color: #DC2626 !important;
}

#cancelConfirmBtn {
  background: #F1F5F9 !important;
  color: #475569 !important;
  border-color: #E2E8F0 !important;
}
#cancelConfirmBtn:hover {
  background: #E2E8F0 !important;
  color: #334155 !important;
}

.confirm-bubble {
  --bubble-arrow-left: 50%;
  position: fixed;
  z-index: 5000;
  width: min(260px, calc(100vw - 16px));
  padding: 12px;
  border: 1px solid #FECACA;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
  color: var(--text-primary);
  animation: fadeIn 0.14s ease;
}

.confirm-bubble::after {
  content: "";
  position: absolute;
  left: var(--bubble-arrow-left);
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid #FECACA;
  border-bottom: 1px solid #FECACA;
  background: #fff;
  transform: translateX(-50%) rotate(45deg);
}

.confirm-bubble.is-below::after {
  top: -6px;
  bottom: auto;
  border-right: 0;
  border-bottom: 0;
  border-left: 1px solid #FECACA;
  border-top: 1px solid #FECACA;
}

.confirm-bubble-title {
  font-size: 14px;
  font-weight: 700;
  color: #991B1B;
}

.confirm-bubble-message {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: #475569;
}

.confirm-bubble-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.confirm-bubble-actions button {
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.confirm-bubble-cancel {
  border: 1px solid #E2E8F0;
  background: #F8FAFC;
  color: #475569;
}

.confirm-bubble-cancel:hover {
  background: #E2E8F0;
  color: #334155;
}

.confirm-bubble-ok {
  border: 1px solid var(--error);
  background: var(--error);
  color: #fff;
}

.confirm-bubble-ok:hover:not(:disabled) {
  border-color: #DC2626;
  background: #DC2626;
}

.confirm-bubble-ok:disabled {
  opacity: 0.72;
  cursor: wait;
}

.table-actions button,
.table-actions button.danger,
.table-actions button.secondary {
  width: 28px !important;
  height: 28px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: var(--radius-sm) !important;
}

/* Force standard dark border for danger action buttons in lists, highlight only on hover */
.table-actions button.danger {
  border: 1px solid var(--border) !important;
  color: var(--error) !important;
  background: #fff !important;
}
.table-actions button.danger:hover {
  border-color: var(--error) !important;
  background: #FEF2F2 !important;
  color: var(--error) !important;
}

.table-actions .split-copy-menu button {
  width: 100% !important;
  height: 32px !important;
  padding: 0 10px !important;
  display: flex !important;
  justify-content: flex-start !important;
  border: none !important;
  border-radius: 6px !important;
}


/* Custom Global Product Dropdown Component styling */
.custom-dropdown {
  position: relative;
  width: 100%;
}
.custom-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-title);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.custom-dropdown-trigger:hover {
  border-color: var(--primary);
  background: #FAFDFE;
}
.custom-dropdown-trigger .chevron {
  color: #64748B;
  transition: transform 0.2s ease;
}
.custom-dropdown.open .custom-dropdown-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.custom-dropdown.open .chevron {
  transform: rotate(180deg);
  color: var(--primary);
}
.custom-dropdown-options {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
  padding: 6px;
  backdrop-filter: blur(10px);
  animation: dropdownFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-dropdown-option {
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.1s ease;
}
.custom-dropdown-option:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--primary);
}
.custom-dropdown-option.selected {
  background: var(--primary);
  color: #fff;
}
@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
