/* ==========================================================================
   oCloud Store — Design System & Responsive Stylesheet
   - Hỗ trợ hoàn chỉnh Dark / Light Theme (mặc định theo hệ điều hành, lưu lựa chọn)
   - Bề mặt trung tính chỉn chu kết hợp điểm nhấn Indigo/Violet đồng bộ Price Studio
   - Khung nội dung Discord (Transcript, Embed) giữ nền tối đặc trưng ngay trong Light Theme
   - Đảm bảo độ tương phản chữ >= 4.5:1, nút chạm >= 44px, input mobile >= 16px
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-elevated: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;

  --status-success-bg: #ecfdf5;
  --status-success-text: #065f46;
  --status-success-border: #a7f3d0;

  --status-warning-bg: #fffbeb;
  --status-warning-text: #92400e;
  --status-warning-border: #fde68a;

  --status-danger-bg: #fef2f2;
  --status-danger-text: #991b1b;
  --status-danger-border: #fecaca;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);

  --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.35);

  /* Bề mặt nội dung Discord luôn giữ tông tối đặc trưng */
  --discord-bg: #1e1f22;
  --discord-chat-bg: #313338;
  --discord-embed-bg: #2b2d31;
  --discord-text: #f2f3f5;
  --discord-muted: #b5bac1;
  --discord-mention-bg: rgba(88, 101, 242, 0.3);
  --discord-mention-text: #dee0fc;
}

[data-theme="dark"] {
  --bg-canvas: #0b0f19;
  --bg-surface: #111827;
  --bg-surface-subtle: #1e293b;
  --bg-surface-hover: #334155;
  --bg-elevated: #1f2937;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-subtle: #1e293b;
  --border-strong: #334155;

  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --primary-button-bg: #4f46e5;
  --primary-button-hover: #4338ca;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-text: #a5b4fc;

  --status-success-bg: rgba(16, 185, 129, 0.14);
  --status-success-text: #6ee7b7;
  --status-success-border: rgba(16, 185, 129, 0.35);

  --status-warning-bg: rgba(245, 158, 11, 0.14);
  --status-warning-text: #fcd34d;
  --status-warning-border: rgba(245, 158, 11, 0.35);

  --status-danger-bg: rgba(239, 68, 68, 0.15);
  --status-danger-text: #fca5a5;
  --status-danger-border: rgba(239, 68, 68, 0.35);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.65);

  --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tabular-nums,
.money-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  background: var(--accent-primary);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 9999;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 12px;
}

.hidden {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ==========================================================================
   Thanh công cụ Dev Preview
   ========================================================================== */
.dev-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 8px 16px;
  background: #1e1b4b;
  color: #e0e7ff;
  border-bottom: 1px solid #312e81;
  font-size: 13px;
}

.dev-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dev-badge {
  background: #4f46e5;
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 4px;
}

.dev-bar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dev-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-label {
  font-weight: 600;
  color: #c7d2fe;
}

.dev-select {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #4338ca;
  border-radius: 6px;
  padding: 5px 10px;
  min-height: 34px;
  font-size: 13px;
}

/* ==========================================================================
   Khung Layout Chính (Sidebar + Main Workspace)
   ========================================================================== */
.portal-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: calc(100vh - 51px);
}

.portal-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: calc(100vh - 51px);
  overflow-y: auto;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--accent-text);
  font-weight: 600;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 10px;
}

.nav-group-label.admin-label {
  color: var(--accent-text);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-pill {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
}

.nav-pill.warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
}

.nav-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

/* Sidebar Footer: Đổi theme & Thông tin tài khoản + Rank badge */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface);
}

.theme-switcher-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg-surface-subtle);
  padding: 4px;
  border-radius: 8px;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.theme-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
}

.account-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.account-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.account-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid var(--bg-surface);
}

.account-status-dot.offline {
  background: #ef4444;
}

.account-info {
  min-width: 0;
  flex: 1;
}

.account-display-name {
  display: block;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.account-username {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.rank-mini-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid currentColor;
  white-space: nowrap;
}

/* ==========================================================================
   Workspace Topbar & Nội dung chính
   ========================================================================== */
.portal-main-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.workspace-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.page-heading {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-subheading {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.shop-legit-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--status-success-bg);
  color: var(--status-success-text);
  border: 1px solid var(--status-success-border);
  font-size: 12.5px;
}

.legit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.main-workspace {
  padding: 24px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

.main-workspace[aria-busy="true"] {
  cursor: progress;
}

.customer-detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.customer-detail-toolbar .btn,
.customer-profile-tabs .btn {
  min-height: 44px;
}

.customer-profile-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reconciliation-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 12px;
}

#customer-profile-heading {
  overflow-wrap: anywhere;
  scroll-margin-top: 20px;
}

/* ==========================================================================
   Cards, Grids, Buttons, Inputs & Badges
   ========================================================================== */
.surface-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.surface-card + .surface-card {
  margin-top: 20px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.section-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 13px;
}

.btn-primary {
  background: var(--primary-button-bg, var(--accent-primary));
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-button-hover, var(--accent-primary-hover));
}

.btn-secondary {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
}

.btn-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.input-field,
.select-field {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 16px;
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success {
  background: var(--status-success-bg);
  color: var(--status-success-text);
  border: 1px solid var(--status-success-border);
}

.badge-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.badge-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
}

.badge-indigo {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge-neutral {
  background: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Tổng quan & Hồ sơ Khách hàng (Hero Profile + Tiến độ Rank)
   ========================================================================== */
.profile-hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.profile-identity-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.profile-avatar-lg {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
}

.profile-title-wrap {
  min-width: 0;
  flex: 1;
}

.profile-display-name {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  word-break: break-word;
}

.profile-handle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.profile-dates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.meta-stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.meta-stat-value {
  font-size: 14px;
  font-weight: 600;
}

/* Tiến độ Rank */
.rank-progress-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.rank-current-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.rank-total-spent {
  font-size: 24px;
  font-weight: 800;
  margin: 8px 0 12px;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--bg-surface-subtle);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #9333ea);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.rank-milestones-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.milestone-chip {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.milestone-chip.achieved {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-primary);
  font-weight: 600;
}

/* Dải phân biệt 3 đại lượng: Đơn cá nhân, Vouch đã gửi, Tổng Legit toàn shop */
.distinct-metrics-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.metric-strip-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-strip-box.shop-wide {
  border-left: 1px solid #10b981;
}

.metric-strip-box.personal-orders {
  border-left: 1px solid var(--accent-primary);
}

.metric-strip-box.personal-vouches {
  border-left: 1px solid #8b5cf6;
}

.metric-number {
  font-size: 22px;
  font-weight: 800;
}

/* ==========================================================================
   Bảng & Danh sách Đơn hàng (Master-Detail trên Desktop, Card trên Mobile)
   ========================================================================== */
.filter-toolbar {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 12px;
  margin-bottom: 16px;
  align-items: end;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.orders-split-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}

.order-list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.order-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}

.order-row-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-subtle);
}

.order-row-card.selected {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.order-row-main {
  min-width: 0;
  flex: 1;
}

.order-id-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.order-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-text);
}

.order-product-title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 4px;
  word-break: break-word;
}

.order-meta-sub {
  font-size: 12.5px;
  color: var(--text-muted);
}

.order-row-right {
  text-align: right;
  flex-shrink: 0;
}

.order-total-price {
  font-size: 16px;
  font-weight: 800;
  display: block;
  margin-bottom: 6px;
}

.order-detail-pane {
  position: sticky;
  top: 20px;
}

.detail-kv-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 12px;
  margin: 16px 0;
  padding: 14px;
  border-radius: 10px;
  background: var(--bg-surface-subtle);
  font-size: 13.5px;
}

.detail-kv-label {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-kv-val {
  font-weight: 600;
  word-break: break-word;
}

/* ==========================================================================
   Khung Hội thoại Discord & Embed (Giữ bề mặt tối chuẩn Discord)
   ========================================================================== */
.discord-frame {
  background: var(--discord-chat-bg);
  color: var(--discord-text);
  border-radius: 12px;
  border: 1px solid #1e1f22;
  overflow: hidden;
}

.discord-channel-bar {
  background: var(--discord-bg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13.5px;
}

.discord-messages-stream {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 62vh;
  overflow-y: auto;
}

.discord-msg-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.discord-msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.discord-msg-body {
  min-width: 0;
  flex: 1;
}

.discord-msg-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.discord-author-name {
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
}

.discord-role-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: #5865f2;
  color: #ffffff;
}

.discord-timestamp {
  font-size: 11.5px;
  color: var(--discord-muted);
}

.discord-msg-text {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--discord-text);
}

.discord-mention {
  background: var(--discord-mention-bg);
  color: var(--discord-mention-text);
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 600;
}

.discord-inline-code {
  background: #1e1f22;
  color: #f2f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.discord-embed-box {
  margin-top: 8px;
  background: var(--discord-embed-bg);
  border-left: 4px solid #5865f2; /* impeccable-disable-line side-tab: user explicitly requires Discord embed fidelity */
  border-radius: 6px;
  padding: 10px 14px;
  max-width: 520px;
}

.discord-embed-title {
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  margin: 0 0 4px;
}

.discord-embed-desc {
  font-size: 13px;
  color: var(--discord-muted);
  white-space: pre-wrap;
}

.discord-attachment-img {
  margin-top: 8px;
  max-width: 100%;
  width: 320px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: zoom-in;
  display: block;
}

/* ==========================================================================
   Bảng giá trực tiếp (Price Catalog Cards)
   ========================================================================== */
.catalog-service-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.catalog-banner {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
}

.catalog-service-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.catalog-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.catalog-custom-emoji {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.catalog-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 20px;
}

.price-item-card {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.price-tag-box {
  display: inline-block;
  background: #1e1f22;
  color: #a5b4fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 6px;
}

/* ==========================================================================
   Bảng Xếp Hạng & Vouch List
   ========================================================================== */
.my-standing-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent-primary);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.leaderboard-row.is-me {
  background: var(--accent-soft);
}

.rank-pos-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13.5px;
  flex-shrink: 0;
}

.rank-pos-badge.top-1 {
  background: #fef08a;
  color: #854d0e;
}

.rank-pos-badge.top-2 {
  background: #e2e8f0;
  color: #1e293b;
}

.rank-pos-badge.top-3 {
  background: #fed7aa;
  color: #9a3412;
}

/* ==========================================================================
   Modal, Lightbox, Status Banners & Pagination
   ========================================================================== */
.status-banner {
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 500;
}

.status-banner.error {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
}

.status-banner.warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-container {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.confirm-dialog-container {
  max-width: 480px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.transcript-viewer-body,
.confirm-dialog-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
}

.lightbox-inner {
  position: relative;
  max-width: 92vw;
  max-height: 88vh;
  text-align: center;
}

.lightbox-image {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 10px;
}

.lightbox-close-btn {
  position: absolute;
  top: -48px;
  right: 0;
  background: #1e293b;
  color: #ffffff;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

/* ==========================================================================
   Responsive Mobile & Tablet (768px, 390px, 360px)
   ========================================================================== */
.mobile-only {
  display: none;
}

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

@media (max-width: 960px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: inline-flex;
  }

  .portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 288px;
    max-width: 86vw;
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    z-index: 35;
  }

  .profile-hero-grid,
  .orders-split-layout,
  .distinct-metrics-strip {
    grid-template-columns: 1fr;
  }

  .filter-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .main-workspace {
    padding: 16px 14px 92px;
  }

  .workspace-topbar {
    padding: 12px 14px;
  }

  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-strong);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 30;
  }

  .mobile-tab-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11.5px;
    font-weight: 600;
    min-height: 44px;
    cursor: pointer;
  }

  .mobile-tab-btn.active {
    color: var(--accent-primary);
  }

  .mobile-more-sheet {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.6);
    z-index: 80;
    display: flex;
    align-items: flex-end;
  }

  .more-sheet-panel {
    width: 100%;
    background: var(--bg-surface);
    border-radius: 16px 16px 0 0;
    padding: 18px 16px 84px;
  }

  .more-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .more-sheet-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .more-sheet-item {
    min-height: 48px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface-subtle);
    text-align: left;
    font-weight: 600;
    cursor: pointer;
  }
}

@media (max-width: 480px) {
  .order-row-card {
    flex-direction: column;
    align-items: stretch;
  }

  .order-row-card > * {
    min-width: 0;
    max-width: 100%;
  }

  .order-row-right {
    text-align: left;
  }

  .reconciliation-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .discord-channel-bar {
    flex-wrap: wrap;
  }

  .section-desc,
  .order-meta-sub {
    overflow-wrap: anywhere;
  }

  .filter-toolbar {
    grid-template-columns: 1fr;
  }

  .detail-kv-list {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .catalog-items-grid {
    grid-template-columns: 1fr;
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Integrated portal: production shell, complete Discord content and safe dialogs. */
html:not([data-preview]) .portal-shell {
  min-height: 100dvh;
}
html:not([data-preview]) .portal-sidebar {
  height: 100dvh;
}
.portal-dialog-open {
  overflow: hidden;
}
.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}
.portal-native-embed {
  color: var(--discord-text);
  background: var(--discord-embed-bg);
  overflow-wrap: anywhere;
  max-width: 100%;
}
.portal-native-embed::after {
  content: "";
  display: block;
  clear: both;
}
.portal-native-embed p {
  margin: 6px 0;
}
.portal-native-embed pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #1e1f26;
  border: 1px solid #454654;
  border-radius: 6px;
  padding: 12px;
  font-size: 14px;
  color: #f2f3f5;
}
.portal-native-embed a {
  color: #a5b4fc;
  text-underline-offset: 3px;
}
.portal-native-embed .discord-embed-title {
  margin: 8px 0;
  font-size: 17px;
  font-weight: 700;
}
.portal-embed-author,
.portal-embed-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.portal-embed-footer {
  margin-top: 12px;
  color: #c4c6ce;
}
.portal-embed-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.portal-image-button {
  display: block;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  max-width: 100%;
  cursor: zoom-in;
}
.portal-image-button img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}
.portal-thumbnail-button {
  float: right;
  margin: 4px 0 12px 14px;
  width: 80px;
}
.portal-embed-image {
  width: auto;
  max-height: 600px;
  object-fit: contain;
}
.portal-embed-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.portal-embed-field.full {
  grid-column: 1/-1;
}
.portal-discord-catalog {
  background: var(--discord-embed-bg);
  padding: 18px;
  color: var(--discord-text);
}
.portal-requirements {
  margin-top: 12px;
}
.portal-requirements summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
}
.portal-requirements .discord-embed-box {
  margin: 0;
}
.discord-emoji,
.inline-emoji {
  width: 1.35em;
  height: 1.35em;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  object-fit: contain;
}

.portal-media-frame {
  max-width: 100%;
  min-width: 0;
}

.portal-media-frame [hidden] {
  display: none !important;
}

.portal-media-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-top: 8px;
  background: var(--discord-bg);
  color: var(--discord-muted);
  border-radius: 8px;
  font-size: 14px;
}

.discord-msg-text p {
  margin: 0 0 6px;
}

.discord-msg-text a {
  color: #a5b4fc;
  text-underline-offset: 3px;
}

.discord-msg-text pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 10px;
  background: var(--discord-bg);
  border-radius: 6px;
}

.customer-vouch-text .discord-msg-text {
  color: inherit;
}

.customer-vouch-text {
  padding: 12px;
  color: var(--discord-text);
}

.badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.discord-subtext {
  font-size: 12px;
  color: #c4c6ce;
}
.legacy-transcript-frame {
  width: 100%;
  height: 75dvh;
  border: 0;
}
.surface-card .form-input {
  display: block;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 10px 12px;
  margin: 6px 0 16px;
}
.main-workspace,
.portal-main,
.surface-card,
.order-row-main {
  min-width: 0;
}
@media (max-width: 960px) {
  .btn-sm {
    min-height: 44px;
  }
  .modal-container {
    max-height: 95dvh;
  }
  .portal-sidebar {
    height: 100dvh;
  }
  .portal-embed-fields {
    grid-template-columns: 1fr;
  }
  .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(64px + env(safe-area-inset-bottom));
  }
  .main-workspace {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 960px) {
  .workspace-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .topbar-left {
    width: 100%;
    align-items: flex-start;
  }
  .topbar-left > div {
    min-width: 0;
    flex: 1;
  }
  .topbar-left .icon-btn {
    flex-shrink: 0;
  }
  .topbar-right {
    justify-content: space-between;
    width: 100%;
  }
  .page-heading {
    font-size: 18px;
    line-height: 1.35;
    overflow-wrap: normal;
  }
  .page-subheading {
    line-height: 1.45;
  }
  .dev-bar-controls,
  .dev-control-group {
    min-width: 0;
    width: 100%;
  }
  .dev-select {
    min-width: 0;
    max-width: 100%;
    width: 100%;
  }
  .dev-preview-bar {
    flex-wrap: wrap;
  }
  .dev-control-group {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
  }
  .dev-note {
    display: none;
  }
  .order-row-main {
    min-width: 0;
  }
}
@media (max-width: 960px) {
  .input-field,
  .select-field,
  textarea {
    font-size: 16px;
  }
}

::selection {
  background: var(--accent-primary);
  color: #fff;
}
input,
textarea {
  caret-color: var(--accent-primary);
}
a {
  text-underline-offset: 0.18em;
}
* {
  scrollbar-color: var(--border-strong) var(--bg-canvas);
  scrollbar-width: thin;
}
