/* ============================================================
   GPT 充值聚合系统 v2.1.1 — Warm & Modern Design System
   ============================================================ */

:root {
  color-scheme: light;
  --bg: #FDFBF7;
  --surface: #FFFFFF;
  --surface-2: #F5F5F4;
  --field: #FFFFFF;
  --border: #E7E5E4;
  --border-hover: #D6D3D1;
  --border-focus: #F59E0B;
  --text-1: #1C1917;
  --text-2: #57534E;
  --text-3: #A8A29E;
  --primary: #F59E0B;
  --primary-hover: #D97706;
  --primary-gradient: linear-gradient(135deg, #F59E0B, #EF4444);
  --accent-soft: rgba(245, 158, 11, 0.08);
  --success: #10B981;
  --success-soft: #ECFDF5;
  --error: #EF4444;
  --error-soft: #FEF2F2;
  --info: #3B82F6;
  --info-soft: #EFF6FF;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-normal: 0.3s;
}

/* Base Reset */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-2); font-family: -apple-system, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.uppercase { text-transform: uppercase; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-3 { color: var(--text-3); }
.site-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 32px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}
.site-footer a { color: inherit; }
.site-footer a:hover { color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }

/* Animation Utils & prefers-reduced-motion */
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: slideUp 0.3s var(--ease-out) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .animate-in { animation: none !important; opacity: 1 !important; transform: none !important; }
}

/* Spinner / Loading Skeleton */
.spinner {
  display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.recharge-shell { min-height: 100vh; padding: 60px 20px; display: flex; justify-content: center; overflow-x: hidden; }
.recharge-wrap { width: 100%; max-width: 480px; min-width: 0; }

/* Header */
.hero-bar { text-align: center; margin-bottom: 40px; }
.hero-bar h1 { margin: 0; font-size: 28px; font-weight: 800; color: var(--text-1); letter-spacing: -0.025em; }
.brand-sub { margin: 4px 0 0; max-width: 100%; font-size: 13px; font-weight: 600; color: var(--text-3); letter-spacing: 0.1em; overflow-wrap: anywhere; }
.hero-links { display: inline-flex; max-width: 100%; min-width: 0; flex-wrap: wrap; background: var(--surface-2); padding: 4px; border-radius: var(--radius-full); margin-top: 24px; }
.hero-links a { min-width: 0; padding: 6px 18px; border-radius: var(--radius-full); font-size: 14px; font-weight: 600; transition: all 0.2s; white-space: nowrap; }
.hero-links a.active { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-sm); }
.trust-strip { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.trust-strip span { padding: 5px 10px; border-radius: var(--radius-full); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text-2); font-size: 12px; font-weight: 700; }

/* Stepper */
.stepper { display: flex; align-items: center; justify-content: space-between; margin-bottom: 32px; padding: 0 20px; }
.step-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-3); font-weight: 700; font-size: 14px; transition: all 0.3s var(--ease-out); border: 2px solid transparent; }
.step-dot-active { background: var(--primary); color: white; box-shadow: 0 0 0 4px var(--accent-soft); }
.step-dot-done { background: var(--success); color: white; box-shadow: 0 0 0 4px var(--success-soft); }
.step-dot-error { background: var(--error); color: white; box-shadow: 0 0 0 4px var(--error-soft); }
.step-line { flex: 1; height: 2px; background: var(--surface-2); margin: 0 12px; position: relative; overflow: hidden; }
.step-line::after { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 0; background: var(--primary); transition: width 0.3s var(--ease-out); }
.step-line-filled::after { width: 100%; }

/* Panels */
.recharge-stack { display: flex; flex-direction: column; gap: 24px; }
.panel { background: var(--surface); border-radius: var(--radius-sm); padding: 32px; border: 1px solid var(--border); box-shadow: var(--shadow-lg); transition: all 0.3s var(--ease-out); }
.panel-active { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.panel:hover:not(.section-disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.section-disabled { opacity: 0.5; filter: grayscale(1); pointer-events: none; }
.wizard-swap { position: relative; }
.wizard-step { position: absolute; inset: 0; width: 100%; opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(8px); transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), visibility 0s linear 200ms; }
.wizard-step.is-active { position: relative; opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0); transition-delay: 0s; z-index: 1; }

.step-head-flex { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; min-width: 0; }
.step-head-copy { min-width: 0; flex: 1 1 auto; }
.step-head h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-1); }
.step-head p { margin: 6px 0 0; font-size: 14px; color: var(--text-2); }
.step-description { width: 100%; margin: 8px 0 0; color: var(--text-2); font-size: 14px; }
.wizard-back-link { appearance: none; border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 700; padding: 0; margin-bottom: 16px; }
.wizard-back-link:hover { color: var(--primary); }
.verified-card-line { margin: 18px 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-3); font-size: 13px; font-weight: 700; }
.verified-card-value { min-width: 0; overflow-x: auto; text-align: right; }
.verified-card-line strong { color: var(--text-1); font-family: ui-monospace, SFMono-Regular, monospace; white-space: nowrap; }
.session-fetch-btn { width: auto; min-height: 36px; padding: 8px 12px; white-space: nowrap; flex-shrink: 0; line-height: 1.2; }
.session-hint { width: 100%; display: flex; align-items: flex-start; gap: 6px; margin-top: 12px; padding: 8px 10px; border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 700; line-height: 1.45; text-align: left; overflow-wrap: anywhere; }
.session-hint-icon { flex-shrink: 0; color: var(--primary); font-weight: 800; line-height: 1.45; }
.token-substep { display: none; }
.token-substep.is-active { display: block; }
.token-disclosure { margin: 16px 0 12px; font-size: 12px; line-height: 1.6; }
.token-disclosure p { margin: 0; }
.token-disclosure p + p { margin-top: 4px; }
.account-confirm-summary { margin-top: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.confirm-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.confirm-row:last-child { border-bottom: none; }
.confirm-row span { color: var(--text-3); font-size: 13px; font-weight: 700; }
.confirm-row strong { min-width: 0; color: var(--text-1); font-size: 14px; font-weight: 800; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.confirm-force-row { margin-top: 14px; }
.field-label { display: block; margin: 16px 0 8px; color: var(--text-2); font-size: 13px; font-weight: 800; }
.claude-faq-section { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
.faq-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.faq-item h3 { margin: 0; color: var(--text-1); font-size: 14px; font-weight: 800; letter-spacing: 0; }
.faq-item p { margin: 6px 0 0; color: var(--text-2); font-size: 13px; line-height: 1.55; }
.faq-item code { padding: 1px 6px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--primary); font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.faq-item a { color: var(--primary); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.faq-figure { margin: 10px 0 0; }
.faq-figure img { display: block; width: 100%; max-width: 560px; height: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Inputs */
.form-row { display: flex; gap: 12px; margin-top: 20px; }
.input, .textarea, .select { width: 100%; border: 2px solid var(--border); border-radius: var(--radius-md); padding: 12px 16px; background: var(--field); color: var(--text-1); transition: all 0.2s; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--accent-soft); }
.input.uppercase { font-family: ui-monospace, SFMono-Regular, monospace; text-transform: uppercase; }

/* Buttons */
.btn-primary, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-md); padding: 12px 24px; font-weight: 700; cursor: pointer; transition: all 0.2s var(--ease-out); border: none; }
.btn-primary { background: var(--primary-gradient); color: white; box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }
.btn-primary:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-secondary { background: var(--surface-2); color: var(--text-1); }
.btn-secondary:hover { background: var(--border); transform: translateY(-2px) scale(1.02); }
.btn-secondary:active { transform: translateY(0) scale(0.98); }
.btn-wide { width: 100%; }
.btn-mt { margin-top: 24px; }
.btn-sm { font-size: 12px; padding: 6px 12px; }

/* Checkbox */
.token-actions { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; min-width: 0; }
.token-actions-end { justify-content: flex-end; }
.confirm-actions .btn-primary, .confirm-actions .btn-secondary { flex: 1 1 0; min-width: 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; color: var(--text-2); }

/* Progress */
.progress-track { height: 8px; background: var(--surface-2); border-radius: 4px; margin-top: 20px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--primary-gradient); transition: width 0.3s ease-out; }

/* Stock Monitor */
.stock-monitor { background: var(--surface-2); border-radius: var(--radius-md); padding: 16px; border: 1px solid var(--border); transition: all 0.3s; }
.stock-monitor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stock-monitor-title { font-size: 13px; font-weight: 800; color: var(--text-1); text-transform: uppercase; letter-spacing: 0.05em; }
.stock-monitor-meta { font-size: 11px; color: var(--text-3); font-weight: 600; }
.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; overflow-x: auto; }
.stock-card { background: var(--surface); border: 1px solid var(--border); padding: 12px 16px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 12px; min-width: 0; box-shadow: var(--shadow-sm); transition: transform 0.2s, box-shadow 0.2s; }
.stock-card-overview { grid-column: 1 / -1; }
.stock-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stock-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; transition: background-color 0.3s var(--ease-out), box-shadow 0.3s; }
.stock-dot[data-state="ok"] { background: var(--success); box-shadow: 0 0 8px var(--success); }
.stock-dot[data-state="low"] { background: var(--primary); }
.stock-dot[data-state="out"] { background: var(--error); }
.stock-label, .stock-name { flex: 0 0 auto; min-width: max-content; font-size: 12px; font-weight: 700; color: var(--text-1); white-space: nowrap; margin-right: auto; }
.stock-count { flex-shrink: 0; font-size: 11px; color: var(--text-3); margin-left: auto; white-space: nowrap; }
.stock-badge { flex-shrink: 0; white-space: nowrap; padding: 2px 8px; text-align: right; }

/* Result */
.result-card { text-align: center; }
.panel-result-floating { position: sticky; top: 80px; z-index: 10; }
.result-icon-wrap { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-2); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; transition: all 0.3s; }
.svg-success { color: var(--success); }
.svg-error { color: var(--error); }
.result-title { font-size: 24px; font-weight: 800; color: var(--text-1); margin: 0; }
.result-message { margin-top: 8px; font-size: 15px; color: var(--text-2); }
.result-actions { margin-top: 24px; width: 100%; }
.result-actions .btn-primary, .result-actions .btn-secondary { flex: 1 1 0; min-width: 0; }

/* Summary */
.summary-grid { background: var(--surface-2); border-radius: var(--radius-md); margin-top: 20px; overflow: hidden; }
.summary-grid div { padding: 12px 16px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); }
.summary-grid div:last-child { border-bottom: none; }
.summary-grid dt { font-size: 13px; font-weight: 600; color: var(--text-3); }
.summary-grid dd { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-1); font-family: ui-monospace, monospace; }

/* Status Specs (Two systems as requested) */
.status-line { font-size: 13px; margin-top: 8px; font-weight: 600; min-height: 20px; transition: color 0.3s var(--ease-out); }
.status-line.status-ok { color: var(--success); }
.status-line.status-error { color: var(--error); }
.status-line-soft { color: var(--primary); background: var(--accent-soft); border: 1px solid rgba(245, 158, 11, 0.18); border-radius: var(--radius-md); padding: 10px 12px; }
.status-line-warn { color: #C2410C; background: #FFF7ED; border: 1px solid rgba(234, 88, 12, 0.18); border-radius: var(--radius-md); padding: 10px 12px; }
.attempt-copy { margin: 14px auto 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-1); padding: 8px 12px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px; font-weight: 800; cursor: pointer; }
.attempt-copy:hover { border-color: var(--primary); color: var(--primary); }

.status-pill { display: inline-block; padding: 4px 10px; border-radius: var(--radius-full); font-size: 11px; font-weight: 800; text-transform: uppercase; transition: all 0.3s var(--ease-out); }
.status-pill.status-ok, .status-pill.status-active { background: var(--success-soft); color: var(--success); }
.status-pill.status-low { background: var(--accent-soft); color: var(--primary); }
.status-pill.status-out, .status-pill.status-error, .status-pill.status-invalid, .status-pill.status-bound_failed, .status-pill.status-out_of_stock, .status-pill.status-invalid_card, .status-pill.status-token_failed, .status-pill.status-submit_exception, .status-pill.status-submit_failed, .status-pill.status-bound_but_failed { background: var(--error-soft); color: var(--error); }
.status-pill.status-bound_unknown { background: var(--accent-soft); color: var(--primary); }
.status-pill.status-completed { background: var(--success-soft); color: var(--success); }
.status-pill.status-pending { background: var(--surface-2); color: var(--text-2); }
.status-pill.status-used { background: var(--success-soft); color: var(--success); }
.status-pill.status-unused { background: var(--surface-2); color: var(--text-2); }
.status-pill.status-reserved { background: var(--info-soft); color: var(--info); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-unused { background: #F3F4F6; color: #6b7280; }
.badge-reserved { background: #FFFBEB; color: #f59e0b; }
.badge-bound-unknown { background: #f59e0b; color: #fff; }
.badge-used { background: #EFF6FF; color: #2563eb; }
.badge-bound-failed { background: #FEF2F2; color: #dc2626; }
.badge-invalid { background: #F5F3FF; color: #7c3aed; }
.badge-error { background: #FFF7ED; color: #ea580c; }
.badge-completed,
.badge-success,
.badge-active,
.badge-ok { background: #F0FDF4; color: #16a34a; }
.badge-pending,
.badge-processing,
.badge-unknown { background: #F1F5F9; color: #475569; }
.badge-failed,
.badge-rejected,
.badge-disabled,
.badge-out { background: #FEF2F2; color: #dc2626; }
.badge-low { background: #FFFBEB; color: #f59e0b; }
.ttl-hint {
  display: inline-flex;
  margin-left: 6px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

/* Legal pages */
.legal-shell { min-height: calc(100vh - 68px); padding: 48px 20px 28px; }
.legal-page { width: 100%; max-width: 760px; margin: 0 auto; color: var(--text-2); }
.legal-back-link { display: inline-flex; margin-bottom: 20px; color: var(--text-3); font-size: 13px; font-weight: 700; }
.legal-back-link:hover { color: var(--primary); }
.legal-page h1 { margin: 0; color: var(--text-1); font-size: 30px; line-height: 1.2; font-weight: 800; letter-spacing: 0; }
.legal-kicker { margin: 10px 0 28px; color: var(--text-3); font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.legal-page section { padding: 20px 0; border-top: 1px solid var(--border); }
.legal-page h2 { margin: 0 0 8px; color: var(--text-1); font-size: 16px; line-height: 1.35; font-weight: 800; letter-spacing: 0; }
.legal-page p { margin: 0; font-size: 15px; line-height: 1.8; }

@media (max-width: 560px) {
  .legal-shell { padding-top: 32px; }
  .legal-page h1 { font-size: 26px; }
}

.error-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 12px 0 0; }
.ack-toggle { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); font-size: 13px; font-weight: 700; }
.order-id-row { display: inline-flex; gap: 8px; align-items: center; }
.ack-checkbox, #select-all-errors { width: 16px; height: 16px; accent-color: var(--error); }
.ack-checkbox-placeholder { display: inline-block; width: 16px; height: 16px; }
tr.is-acknowledged { opacity: 0.5; background: #fafafa; }
.ack-read-tag { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-3); font-size: 11px; font-weight: 800; }
.force-retry-box { margin-top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.force-retry-help { color: var(--text-3); font-size: 11px; line-height: 1.35; }
.metric-breakdown { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; color: var(--text-3); font-size: 11px; font-weight: 700; line-height: 1.35; }
.metric-breakdown span { padding: 2px 6px; border-radius: var(--radius-sm); background: var(--surface-2); }

/* Responsive */
@media (max-width: 640px) {
  .recharge-shell { padding: 40px 12px; }
  .panel { padding: 24px 20px; }
  .brand-sub { font-size: 11px; letter-spacing: 0.06em; }
  .form-row { flex-direction: column; }
  .hero-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; border-radius: var(--radius-md); }
  .hero-links a { text-align: center; min-width: 0; padding-inline: 12px; }
  .step-head-flex { flex-direction: column; align-items: stretch; }
  .session-fetch-btn { width: 100%; }
  .verified-card-line { flex-direction: column; align-items: stretch; }
  .token-actions:not(.token-actions-end) { flex-direction: column; align-items: stretch; }
  .token-actions-end { justify-content: stretch; }
  .token-actions-end .btn-primary { width: 100%; }
  .verified-card-line strong { text-align: left; }
  .verified-card-value { text-align: left; }
}

@media (max-width: 480px) {
  .confirm-row { align-items: flex-start; flex-direction: column; gap: 4px; }
  .confirm-row strong { max-width: 100%; text-align: left; }
}

/* ============================================================
   QUERY PAGE & TOAST EXTENSIONS (v2.1.1)
   ============================================================ */

.query-container { width: 100%; }
.toolbar-flex { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.results-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.results-stack { display: flex; flex-direction: column; gap: 12px; }
#q-error.status-line { padding: 12px; background: var(--error-soft); border-radius: var(--radius-md); margin-bottom: 16px; border: 1px solid rgba(239, 68, 68, 0.1); }
.textarea-query { min-height: 200px; margin-top: 20px; }
.query-count-label { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.query-count-num { color: var(--primary); font-family: ui-monospace, monospace; }
.toast-notice { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text-1); color: white; padding: 10px 24px; border-radius: var(--radius-full); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 1000; opacity: 0; pointer-events: none; transition: all 0.3s var(--ease-out); }
.toast-notice:not(.hidden) { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.query-result-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; transition: all 0.2s; }
.query-result-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.query-summary { margin-bottom: 12px; font-weight: 700; }
.query-result-group { display: flex; flex-direction: column; gap: 10px; }
.query-group-title { font-size: 13px; font-weight: 800; color: var(--text-1); }
.query-result-compact { padding: 14px 16px; }
.query-card-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.query-card-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.query-card-icon { position: relative; width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; }
.query-card-icon.is-success { background: var(--success-soft); }
.query-card-icon.is-success::before { content: ""; position: absolute; left: 8px; top: 5px; width: 5px; height: 10px; border: solid var(--success); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.query-card-icon.is-failed { background: var(--error-soft); }
.query-card-icon.is-failed::before, .query-card-icon.is-failed::after { content: ""; position: absolute; left: 6px; top: 10px; width: 10px; height: 2px; border-radius: 2px; background: var(--error); }
.query-card-icon.is-failed::before { transform: rotate(45deg); }
.query-card-icon.is-failed::after { transform: rotate(-45deg); }
.query-card-badges { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }
.query-card-sub { margin-top: 6px; padding-left: 32px; color: #888; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.status-pill.query-status-unused { background: var(--success-soft); color: var(--success); }
.status-pill.query-status-used { background: var(--surface-2); color: var(--text-2); }
.status-pill.query-status-refunded, .status-pill.query-status-not-found, .status-pill.query-status-failed { background: var(--error-soft); color: var(--error); }
.status-pill.query-status-processing { background: var(--info-soft); color: var(--info); }
.status-pill.query-type-badge { background: var(--accent-soft); color: var(--primary); }
.query-result-head { padding: 16px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.query-result-key { font-family: ui-monospace, monospace; font-weight: 700; font-size: 14px; color: var(--text-1); overflow-wrap: anywhere; min-width: 0; }
.query-result-body { padding: 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.query-soft-notice { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--info-soft); color: var(--info); font-size: 13px; font-weight: 700; }

@media (max-width: 768px) {
  .toolbar-flex, .results-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar-flex .btn-primary, .results-header .btn-secondary { width: 100%; }
  .query-card-main { flex-direction: column; align-items: flex-start; }
  .query-card-badges { justify-content: flex-start; width: 100%; }
  .query-card-sub { padding-left: 32px; }
  .query-result-compact { padding: 12px; }
}

/* ============================================================
   ADMIN SKELETON RESTORATION (Increment-only FIX)
   ============================================================ */

/* Modal System */
.modal-mask { position: fixed; inset: 0; background: rgba(28, 25, 23, 0.6); backdrop-filter: blur(4px); z-index: 100; display: flex; align-items: center; justify-content: center; transition: opacity 0.3s var(--ease-out); }
.modal-card { background: white; width: min(500px, 90vw); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: modalPop 0.3s var(--ease-out); }
@keyframes modalPop { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }

/* Table & Wrap */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.data-table th { text-align: left; padding: 12px 16px; background: var(--bg); color: var(--text-3); font-size: 12px; text-transform: uppercase; }
.data-table td { padding: 16px; border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2); transition: background-color 0.2s; }
.data-table tr:hover td { background-color: var(--surface-2); }
.empty-cell { text-align: center; color: var(--text-3); padding: 40px !important; }
.col-resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 4px; cursor: col-resize; transition: background 0.2s; }
.col-resizer:hover, .is-dragging .col-resizer { background: var(--primary); }

/* Admin Panels */
.admin-panel { background: white; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px; box-shadow: var(--shadow-sm); margin-bottom: 24px; transition: transform 0.3s; }
.admin-panel:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.panel-title { font-size: 18px; font-weight: 800; color: var(--text-1); margin-bottom: 20px; }
.panel-actions { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Filter & Pager */
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; align-items: flex-end; }
.filter-status-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 2px; }
.filter-status-label { font-size: 12px; font-weight: 800; color: var(--text-3); text-transform: uppercase; letter-spacing: 0; }
.status-chip-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-chip { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; background: white; transition: border-color 0.2s, box-shadow 0.2s; }
.status-chip:hover { border-color: rgba(245, 158, 11, 0.45); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08); }
.status-chip.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.14); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; font-size: 14px; }
.pager-links { display: flex; align-items: center; gap: 8px; }
.pager-full { gap: 16px; flex-wrap: wrap; }
.pager-summary { color: var(--text-3); font-weight: 600; }
.pager-size { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-weight: 600; }
.pager-size-select { width: auto; min-width: 76px; padding: 6px 28px 6px 10px; border-width: 1px; }
.pager-pages { margin-left: auto; }
.pager-number { min-width: 32px; height: 32px; padding: 0 10px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-1); font-weight: 700; }
.pager-number-active { background: var(--primary); color: white; }
.pager-ellipsis { color: var(--text-3); font-weight: 700; padding: 0 2px; }
.pager-arrow { width: 32px; height: 32px; padding: 0; }

/* Textarea Extensions */
.card-code-textarea { min-height: 260px; font-family: ui-monospace, monospace; font-size: 12px; }
.batch-cards-panel { margin-top: 0; }
.last-batch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.last-batch-title { margin-bottom: 4px; }
.last-batch-copy { flex-shrink: 0; }
.last-batch-textarea { min-height: 240px; max-height: 420px; overflow: auto; font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.6; resize: vertical; }
.batch-cards-panel-empty .last-batch-textarea::placeholder { color: var(--text-3); }

/* --- Login Page Extensions (v2.1.2) --- */
.login-shell .login-title { margin-top: 16px; }
.login-shell .form-group { margin-bottom: 4px; }
.login-error-box { background: var(--error-soft); padding: 12px; border-radius: var(--radius-md); margin: 0; border: 1px solid rgba(239, 68, 68, 0.1); }
.login-footer { margin-top: 32px; text-align: center; }
.login-footer a { gap: 8px; }

/* --- Missing Admin Skeleton (v2.1.3) --- */
.btn-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn-loading::after { content: ''; position: absolute; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: currentColor; border-radius: 50%; animation: spin 0.6s linear infinite; left: 50%; top: 50%; margin: -9px 0 0 -9px; }

.detail-grid { display: grid; gap: 12px; }
.detail-row { display: grid; grid-template-columns: 100px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: none; }
.detail-row dt { color: var(--text-3); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.detail-row dd { margin: 0; color: var(--text-1); font-weight: 600; word-break: break-all; }
.detail-section-title { margin-top: 20px; margin-bottom: 10px; color: var(--text-1); font-size: 14px; font-weight: 800; }
.detail-history-wrap { max-height: 320px; overflow: auto; }
.detail-history-table { min-width: 760px; }
.detail-history-table th, .detail-history-table td { padding: 10px 12px; font-size: 12px; }

.stock-detail { font-size: 12px; font-weight: 600; }
.stock-card[data-state="ok"] .stock-detail { color: var(--success); }
.stock-card[data-state="low"] .stock-detail { color: var(--primary); }
.stock-card[data-state="out"] .stock-detail { color: var(--error); }
.stock-card[data-state="error"] .stock-detail { color: var(--error); }

/* ============================================================
   ADMIN LAYOUT EXTENSIONS (v2.1.4)
   ============================================================ */

.admin-shell { display: flex; min-height: 100vh; background: #F9FAFB; }
.admin-sidebar { width: 260px; background: #1C1917; color: white; display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 40; transition: transform 0.3s var(--ease-out); }
.admin-main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }
.sidebar-header { padding: 32px 24px; }
.sidebar-logo { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; color: var(--primary); }
.sidebar-nav { flex: 1; padding: 0 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-footer { padding: 24px; border-top: 1px solid rgba(255,255,255,0.05); }
.sidebar-version-wrap { text-align: center; margin-top: 12px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; color: #A8A29E; transition: all 0.2s; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-link.active { background: var(--primary); color: white; }
.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link.active svg { opacity: 1; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.05); margin: 16px 12px; }
.logout-btn { width: 100%; padding: 10px; border: 1px solid rgba(255,255,255,0.1); background: transparent; color: #FB7185; border-radius: var(--radius-md); cursor: pointer; font-weight: 700; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); border-color: #FB7185; }
.admin-topbar { height: 64px; background: rgba(255,255,255,0.8); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 30; }
.topbar-title { font-weight: 700; color: var(--text-1); font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.admin-content { padding: 32px; flex: 1; }
.version-tag { background: var(--surface-2); padding: 4px 10px; border-radius: 6px; font-size: 11px; font-weight: 700; color: var(--text-3); font-family: ui-monospace, monospace; }
.mobile-toggle { display: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; align-items: center; justify-content: center; color: var(--text-2); }
.admin-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; animation: fadeIn 0.2s ease-out; }

@media (max-width: 1024px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.sidebar-open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .mobile-toggle { display: flex; margin-right: 16px; }
}

/* --- Missing Restore (v2.1.5) --- */
.login-logo { width: 80px; height: 80px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; margin: 0 auto; box-shadow: var(--shadow-md); animation: logoFloat 3s ease-in-out infinite; }

/* --- Dashboard Page Extensions (v2.1.6) --- */
.dashboard-container { display: flex; flex-direction: column; gap: 24px; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.metric-card { background: white; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 24px; box-shadow: var(--shadow-sm); transition: all 0.3s; position: relative; overflow: hidden; }
.metric-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.metric-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; color: var(--text-3); }
.metric-label { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.metric-value { font-size: 32px; font-weight: 800; color: var(--text-1); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.metric-footer { font-size: 12px; font-weight: 600; }
.metric-footer.success { color: var(--success); }
.metric-footer.info { color: var(--info); }
.metric-footer.error { color: var(--error); }
.product-tag { background: var(--surface-2); color: var(--text-2); padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.code-sm { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-1); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); }
.stock-num { font-family: ui-monospace, monospace; font-weight: 700; color: var(--text-1); }
.live-count-badge { background: var(--accent-soft); color: var(--primary); padding: 4px 10px; border-radius: 6px; font-size: 12px; }

.dashboard-range-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.range-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.range-panel-head h2 {
  margin: 0;
  color: var(--text-1);
  font-size: 18px;
  font-weight: 800;
}

.range-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.range-tab {
  min-height: 34px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.range-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.range-tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.range-status {
  width: 100%;
  margin: 0;
}

.range-status.status-error {
  background: var(--error-soft);
  border-color: rgba(239, 68, 68, 0.18);
  color: var(--error);
}

.range-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.range-metric-card {
  min-width: 0;
  padding: 18px;
}

.range-metric-card .metric-value {
  font-size: 28px;
}

.range-metric-card .metric-footer {
  min-width: 0;
  overflow-wrap: anywhere;
}

.range-channel-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.range-channel-title {
  color: var(--text-1);
  font-size: 14px;
  font-weight: 800;
}

.dashboard-range-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.dashboard-range-table {
  min-width: 0;
}

.dashboard-range-table th {
  background: var(--surface-2);
}

.dashboard-range-table th,
.dashboard-range-table td {
  padding: 12px 14px;
}

.dashboard-range-table th:nth-child(2),
.dashboard-range-table th:nth-child(3),
.dashboard-range-table td:nth-child(2),
.dashboard-range-table td:nth-child(3) {
  text-align: right;
}

.range-channel-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.range-channel-label {
  min-width: 0;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.range-table-number {
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  white-space: nowrap;
}

/* --- Missing Skeleton Restore (v2.1.7) --- */
.nav-link-active { background: var(--primary); color: white !important; }
.admin-toast { position: fixed; bottom: 24px; right: 24px; background: #1C1917; color: white; padding: 12px 24px; border-radius: var(--radius-md); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 1000; transition: opacity 0.3s; }

/* --- Inventory Page Table Specs (v2.1.8) --- */
.inv-table-card { padding: 0; overflow: hidden; }
.col-check { width: 44px; }
.col-inventory-code { width: 140px; }
.col-card { width: 180px; }
.col-channel { width: 120px; }
.col-product { width: 80px; }
.col-status { width: 80px; }
.col-invalid-reason { width: 180px; }
.col-batch { width: 120px; }
.col-price { width: 80px; }
.col-time { width: 100px; }
.col-used { width: 150px; }
.col-actions { width: 220px; }

.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toolbar-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inventory-status-tabs { display: inline-flex; gap: 8px; }
.toolbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.toolbar-right .btn-secondary { gap: 8px; }
.inventory-action-group { display: flex; justify-content: center; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.copy-inventory-code,
.mark-inventory-used,
.unmark-inventory-used,
.recover-inventory { white-space: nowrap; }
.reconcile-panel { padding: 0; overflow: hidden; }
.reconcile-toolbar { justify-content: flex-start; }
.reconcile-table { min-width: 1040px; }
.reconcile-table td { vertical-align: top; }
.section-title { font-size: 15px; font-weight: 800; color: var(--text-1); margin-bottom: 4px; }
.modal-card-inv { width: min(600px, 92vw); }
.cards-bulk-toolbar { padding: 16px; border-bottom: 1px solid var(--border); }
.col-select { width: 44px; text-align: center !important; }

/* --- Orders Page Table Specs (v2.1.9) --- */
.label { display: block; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.05em; }

.col-order-id { width: 140px; }
.col-order-account { width: 200px; }
.col-order-card { width: 180px; }
.col-order-upstream-card { width: 220px; }
.col-order-channel { width: 100px; }
.col-order-status { width: 100px; }
.col-order-result { width: 120px; }

.order-id-txt { font-size: 13px; font-weight: 700; color: var(--text-1); }
.order-time-txt { font-size: 11px; color: var(--text-3); margin-top: 2px; font-weight: 500; }
.order-email-txt { font-size: 14px; font-weight: 700; color: var(--text-1); margin-bottom: 4px; }
.channel-badge { display: inline-flex; align-items: center; width: fit-content; max-width: 100%; min-width: 0; padding: 3px 9px; border-radius: var(--radius-full); background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 800; line-height: 1.35; white-space: nowrap; }
.channel-badge-86 { background: #EAF6F0; color: #047857; }
.channel-badge-987ai { background: var(--info-soft); color: var(--info); }
.channel-badge-ow800 { background: #F5F3FF; color: #7C3AED; }
.channel-badge-gift { background: var(--accent-soft); color: var(--primary); }
.channel-badge-unknown { background: var(--surface-2); color: var(--text-3); }
.metric-value.dashboard-metric-updated { animation: dashboardMetricPulse 0.22s ease-out; }
@keyframes dashboardMetricPulse {
  from { opacity: 0.58; transform: translateY(-1px); }
  to { opacity: 1; transform: translateY(0); }
}
.order-feedback-ok { font-size: 12px; font-weight: 600; color: var(--success); }
.order-feedback-err { font-size: 12px; font-weight: 600; color: var(--error); cursor: pointer; text-decoration: underline dotted; }
.order-feedback-wait { font-size: 12px; color: var(--text-3); }

.pager-current { font-weight: 700; padding: 0 16px; color: var(--text-1); font-family: ui-monospace, monospace; }

.btn-icon-left { margin-right: 8px; flex-shrink: 0; }
.btn-icon-right { margin-left: 8px; flex-shrink: 0; }

/* === v2 shared utilities (CLASS-GUARD §1, append-only) === */

/* containers */
.container-narrow    { max-width: 800px; margin: 0 auto; }
.container-narrow-sm { max-width: 600px; margin: 0 auto; }

/* vertical stacks (gap-based) */
.stack-16 { display: flex; flex-direction: column; gap: 16px; }
.stack-20 { display: flex; flex-direction: column; gap: 20px; }
.stack-24 { display: flex; flex-direction: column; gap: 24px; }

/* admin two-column layout */
.admin-split-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: flex-start;
}
@media (max-width: 768px) {
  .admin-split-layout { grid-template-columns: 1fr; }
}

/* two-column form grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 640px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* inline action row */
.action-row {
  display: inline-flex;
  gap: 8px;
  justify-content: center;
}

/* text utilities */
.text-xs       { font-size: 11px; }
.text-sm       { font-size: 12px; }
.text-md       { font-size: 13px; }
.text-lg       { font-size: 15px; }
.text-primary  { color: var(--primary); }
.text-success  { color: var(--success); }
.text-danger   { color: var(--error); }
.text-right    { text-align: right; }
.fw-normal     { font-weight: normal; }

/* spacing utilities */
.ml-1  { margin-left: 4px; }
.ml-2  { margin-left: 10px; }
.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mt-10 { margin-top: 40px; }
.mb-6  { margin-bottom: 24px; }
.d-inline { display: inline; }

/* button size variant */
.btn-xs {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
}

/* admin panel modifiers */
.admin-panel-flush   { padding: 0; overflow: hidden; }
.admin-panel-danger  { border-left: 4px solid var(--error); }
.admin-panel-success { border-color: var(--success); }
.inv-table-card-scroll { max-height: 480px; overflow-y: auto; }

/* tip card */
.admin-tip {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px dashed var(--primary);
  margin-top: 20px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

/* channels page inline group */
.stock-summary-row { display: inline-flex; align-items: baseline; }

/* import page file name tag */
.file-name-tag { display: inline-block; }

/* settings page footer */
.settings-footer { margin-top: 40px; text-align: center; }
.system-version-tag {
  display: inline-block;
  background: var(--surface-2);
  padding: 10px 20px;
  border-radius: var(--radius-full);
}

/* modal variants */
.modal-card-wide { width: min(700px, 92vw); }
.modal-foot      { margin-top: 16px; text-align: right; }

/* --- Admin Mobile Adaptation (v1.5.21) --- */
@media (max-width: 768px) {
  .admin-topbar {
    height: 56px;
    padding: 0 12px;
  }

  .mobile-toggle {
    margin-right: 10px;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .topbar-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-actions {
    display: none;
  }

  .admin-content {
    padding: 16px;
  }

  .admin-panel {
    min-width: 0;
    max-width: 100%;
    padding: 16px;
    margin-bottom: 16px;
  }

  .dashboard-container,
  .inventory-container,
  .orders-container,
  .cards-container,
  .channels-container,
  .settings-container,
  .admin-split-layout,
  .admin-split-layout > *,
  .stack-24,
  .table-wrap {
    min-width: 0;
  }

  .range-panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .range-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }

  .range-tab {
    padding-inline: 10px;
  }

  .range-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .range-metric-card {
    padding: 16px;
  }

  .dashboard-range-table {
    width: 100%;
  }

  .admin-panel-flush,
  .inv-table-card {
    padding: 0;
  }

  .panel-title {
    margin-bottom: 14px;
    gap: 10px;
  }

  .filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .admin-split-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .stack-24,
  .table-wrap {
    width: 100%;
    max-width: 100%;
  }

  .filter-bar.mobile-filter-collapsed > .filter-group:not(.mobile-primary-filter) {
    display: none;
  }

  .filter-bar.mobile-filter-collapsed {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .filter-bar.mobile-filter-collapsed > .filter-actions {
    grid-column: auto;
    display: flex;
    align-items: stretch;
    gap: 8px;
  }

  .filter-bar.mobile-filter-collapsed > .filter-actions > .btn-primary,
  .filter-bar.mobile-filter-collapsed > .filter-actions > .mobile-filter-toggle {
    width: auto;
    white-space: nowrap;
  }

  .filter-bar.mobile-filter-expanded > .filter-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .filter-actions > .btn-primary,
  .filter-actions > .btn-secondary,
  .filter-actions > .mobile-filter-toggle {
    width: 100%;
    min-width: 0;
    padding-inline: 12px;
  }

  .filter-bar.mobile-filter-collapsed > .filter-actions > .btn-secondary:not(.mobile-filter-toggle) {
    display: none;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    align-items: stretch;
  }

  .toolbar-right {
    flex-direction: column;
  }

  .toolbar-right > *,
  .cards-bulk-toolbar > * {
    width: 100%;
  }

  .cards-bulk-toolbar {
    align-items: stretch;
  }

  .inventory-status-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .inventory-column-toggle {
    width: 100%;
  }

  .pager {
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    text-align: center;
  }

  .last-batch-head {
    flex-direction: column;
    align-items: stretch;
  }

  .last-batch-copy {
    width: 100%;
  }

  .pager-links {
    justify-content: center;
    width: 100%;
  }

  .pager-current {
    padding: 0 10px;
  }

  .modal-mask {
    align-items: flex-start;
    padding: 16px 12px;
    overflow-y: auto;
  }

  .modal-card,
  .modal-card-wide,
  .modal-card-inv {
    width: 100%;
    max-width: none;
  }

  .modal-body {
    padding: 16px;
    max-height: calc(100vh - 116px);
  }

  .detail-grid {
    gap: 0;
  }

  .detail-row {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 0;
  }

  .detail-history-cards {
    display: grid;
    gap: 10px;
  }

  .detail-history-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    padding: 12px;
  }

  .detail-history-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    color: var(--text-1);
    font-size: 13px;
    font-weight: 800;
  }

  .detail-history-code {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .detail-history-meta {
    display: grid;
    gap: 8px;
    margin: 12px 0 0;
  }

  .detail-history-meta div {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 8px;
  }

  .detail-history-meta dt,
  .detail-history-meta dd {
    margin: 0;
    font-size: 12px;
  }

  .detail-history-meta dt {
    color: var(--text-3);
    font-weight: 700;
  }

  .detail-history-meta dd {
    color: var(--text-1);
    overflow-wrap: anywhere;
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) {
    overflow: visible;
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) .data-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) thead {
    display: none;
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) tbody {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) td {
    padding: 0;
    border: 0;
  }

  .dashboard-container .table-wrap:has(#dashboard-stock-table) td:first-child {
    grid-column: 1 / -1;
    font-size: 14px;
    color: var(--text-1);
  }
}

@media (max-width: 480px) {
  .range-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.upstream-health-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.upstream-health-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.upstream-health-summary h1 {
  margin: 0;
  color: var(--text-1);
  font-size: 22px;
}

.upstream-health-summary p {
  margin: 4px 0 0;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
}

.upstream-summary-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.upstream-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

.upstream-health-card {
  min-width: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.upstream-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.upstream-card-head h2 {
  margin: 0 0 8px;
  color: var(--text-1);
  font-size: 17px;
  line-height: 1.3;
}

.upstream-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 800;
}

.upstream-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.upstream-status-healthy { background: #F0FDF4; color: #16a34a; }
.upstream-status-degraded { background: #FFFBEB; color: #f59e0b; }
.upstream-status-error { background: #FEF2F2; color: #dc2626; }
.upstream-status-unknown { background: #F1F5F9; color: #475569; }

.upstream-health-main {
  margin-top: 24px;
  color: var(--text-1);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
}

.upstream-health-main-healthy .upstream-health-icon { color: #16a34a; }
.upstream-health-main-degraded .upstream-health-icon { color: #f59e0b; }
.upstream-health-main-error .upstream-health-icon { color: #dc2626; }
.upstream-health-main-unknown .upstream-health-icon { color: #475569; }

.upstream-health-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 20px 0 0;
}

.upstream-health-meta div {
  min-width: 0;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.upstream-health-meta dt {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 800;
}

.upstream-health-meta dd {
  margin: 4px 0 0;
  color: var(--text-1);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.upstream-history {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 800;
}

.upstream-sparkline {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
}

.spark-dot {
  font-size: 13px;
  line-height: 1;
}

.spark-ok { color: #16a34a; }
.spark-fail { color: #dc2626; }
.spark-unknown { color: #64748b; }
