/*
 * 訂單管理頁面 - Apple Design Language
 * 參考：macOS Sonoma / iOS 17 / Apple.com / App Store Connect
 * 特色：SF Pro 字體、systemGray 色階、hairline separator、
 *       backdrop-filter 毛玻璃、iOS widget 風 KPI、pill 按鈕
 */

/* ============================================
   Scope tokens — Apple System Colors
   ============================================ */
.orders-page {
  /* System Gray（iOS/macOS） */
  --g1: #f2f2f7;   /* systemGroupedBackground */
  --g2: #ffffff;   /* secondarySystemGroupedBackground */
  --g3: #fafafa;
  --g4: #e5e5ea;   /* systemGray5 */
  --g5: #d1d1d6;   /* systemGray4 */
  --g6: #c7c7cc;   /* systemGray3 */
  --g7: #aeaeb2;   /* systemGray2 */
  --g8: #8e8e93;   /* systemGray */
  --g9: #636366;
  --g10: #48484a;
  --g11: #3a3a3c;
  --g12: #1c1c1e;  /* systemGray6 dark / label */

  /* System label text */
  --label: #000000;
  --label-secondary: rgba(60, 60, 67, 0.65);
  --label-tertiary: rgba(60, 60, 67, 0.45);
  --label-quaternary: rgba(60, 60, 67, 0.25);
  --separator: rgba(60, 60, 67, 0.12);
  --separator-opaque: #c6c6c8;

  /* System accent */
  --blue: #0a84ff;          /* systemBlue */
  --blue-hover: #0066cc;
  --blue-soft: rgba(10, 132, 255, 0.1);
  --blue-tint: rgba(10, 132, 255, 0.06);
  --blue-ring: rgba(10, 132, 255, 0.28);

  --green: #30d158;         /* systemGreen */
  --green-soft: rgba(48, 209, 88, 0.12);
  --green-text: #248a3d;

  --orange: #ff9500;        /* systemOrange */
  --orange-soft: rgba(255, 149, 0, 0.12);
  --orange-text: #c93400;

  --red: #ff3b30;           /* systemRed */
  --red-soft: rgba(255, 59, 48, 0.1);
  --red-text: #d70015;

  --purple: #af52de;        /* systemPurple */
  --purple-soft: rgba(175, 82, 222, 0.1);
  --purple-text: #8944ab;

  --indigo: #5856d6;        /* systemIndigo */
  --indigo-soft: rgba(88, 86, 214, 0.1);

  --teal: #5ac8fa;          /* systemTeal */
  --teal-soft: rgba(90, 200, 250, 0.12);

  /* Shadows — very subtle, Apple style */
  --shadow-xs: 0 0.5px 0 rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-elev: 0 6px 20px rgba(0, 0, 0, 0.06);

  /* Font — SF Pro stack */
  font-family: "SF Pro Display", "SF Pro Text", -apple-system,
               BlinkMacSystemFont, "Inter", "Segoe UI",
               "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-feature-settings: "ss01", "cv01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--label);
  letter-spacing: -0.011em;
  background: var(--g1);
}

.orders-page.container-fluid {
  padding: 36px 44px 48px;
  max-width: 1600px;
  min-height: calc(100vh - 70px);
  background: var(--g1);
}

@media (max-width: 768px) {
  .orders-page.container-fluid {
    padding: 20px 16px 32px;
  }
}

.orders-page * { box-sizing: border-box; }

/* ============================================
   Hero — 大標題 Apple 風
   ============================================ */
.orders-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  padding: 0 2px 28px;
  margin-bottom: 24px;
  border-bottom: 0.5px solid var(--separator);
}

.orders-hero__title {
  font-size: 34px;
  font-weight: 700;
  color: var(--label);
  margin: 0 0 4px;
  letter-spacing: -0.032em;
  line-height: 1.08;
}

.orders-hero__subtitle {
  font-size: 15px;
  color: var(--label-secondary);
  margin: 0;
  line-height: 1.45;
  letter-spacing: -0.01em;
}

.orders-hero__crumbs {
  font-size: 13px;
  color: var(--label-tertiary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.005em;
}

.orders-hero__crumbs a {
  color: var(--label-secondary);
  text-decoration: none;
  transition: color 160ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.orders-hero__crumbs a:hover { color: var(--blue); }
.orders-hero__crumbs .sep { color: var(--label-quaternary); font-size: 11px; }

/* ============================================
   KPI — iOS Widget 風
   ============================================ */
.orders-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

@media (max-width: 900px) {
  .orders-kpi { grid-template-columns: repeat(2, 1fr); }
}

.kpi-card {
  background: var(--g2);
  border-radius: 18px;
  padding: 20px 22px;
  transition: all 220ms cubic-bezier(0.25, 0.1, 0.25, 1);
  position: relative;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid var(--separator);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.kpi-card__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-secondary);
  letter-spacing: -0.005em;
}

.kpi-card__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-xs);
}

.kpi-card__icon.brand {
  background: linear-gradient(135deg, var(--blue) 0%, #0066cc 100%);
  color: #fff;
}

.kpi-card__icon.ok {
  background: linear-gradient(135deg, var(--green) 0%, #248a3d 100%);
  color: #fff;
}

.kpi-card__icon.warn {
  background: linear-gradient(135deg, var(--orange) 0%, #c93400 100%);
  color: #fff;
}

.kpi-card__icon.info {
  background: linear-gradient(135deg, var(--teal) 0%, #0071a4 100%);
  color: #fff;
}

.kpi-card__value {
  font-size: 32px;
  font-weight: 700;
  color: var(--label);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.kpi-card__unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--label-tertiary);
  letter-spacing: -0.005em;
}

.kpi-card__sub {
  font-size: 12px;
  color: var(--label-tertiary);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

/* ============================================
   Shell — Apple card container
   ============================================ */
.orders-shell {
  background: var(--g2);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 0.5px solid var(--separator);
}

.orders-shell__section {
  padding: 24px 26px;
  border-bottom: 0.5px solid var(--separator);
}

.orders-shell__section:last-child { border-bottom: none; }

.orders-shell__section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-secondary);
  margin: 0 0 16px;
  letter-spacing: -0.005em;
}

/* ============================================
   Buttons — Apple tinted / filled / plain
   ============================================ */
.orders-page .btn,
.orders-actions .btn {
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 180ms cubic-bezier(0.25, 0.1, 0.25, 1);
  border: none;
  line-height: 1.2;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.orders-page .btn i,
.orders-actions .btn i {
  font-size: 16px;
  line-height: 1;
}

.orders-page .btn:focus-visible,
.orders-actions .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--blue-ring);
}

.orders-page .btn:active,
.orders-actions .btn:active {
  transform: scale(0.97);
}

/* Filled — primary action */
.orders-actions .btn-primary-soft {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.3);
}

.orders-actions .btn-primary-soft:hover {
  background: var(--blue-hover);
  color: #fff;
}

/* Tinted — secondary */
.orders-actions .btn-success-soft {
  background: var(--green-soft);
  color: var(--green-text);
}

.orders-actions .btn-success-soft:hover {
  background: rgba(48, 209, 88, 0.2);
  color: var(--green-text);
}

/* Plain ghost */
.orders-actions .btn-ghost {
  background: var(--g2);
  color: var(--label);
  box-shadow: 0 0 0 0.5px var(--separator-opaque), 0 1px 0 rgba(0, 0, 0, 0.02);
}

.orders-actions .btn-ghost:hover {
  background: var(--g1);
  color: var(--label);
}

.orders-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.orders-actions__divider {
  width: 0.5px;
  height: 22px;
  background: var(--separator-opaque);
  margin: 0 6px;
}

/* ============================================
   Filter
   ============================================ */
.orders-filter {
  background: var(--g1);
  border-radius: 14px;
  padding: 22px 24px;
  border: 0.5px solid var(--separator);
}

.orders-filter__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 18px;
}

.orders-filter__group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.orders-filter__group.span-2 { grid-column: span 2; }

.orders-filter__group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--label-secondary);
  margin-bottom: 7px;
  letter-spacing: -0.005em;
}

.orders-filter__group .form-control {
  border-radius: 10px;
  border: 0.5px solid var(--separator-opaque);
  background: var(--g2);
  font-size: 14px;
  padding: 9px 12px;
  height: auto;
  min-height: 38px;
  color: var(--label);
  line-height: 1.4;
  transition: all 160ms cubic-bezier(0.25, 0.1, 0.25, 1);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  letter-spacing: -0.005em;
}

.orders-filter__group .form-control::placeholder {
  color: var(--label-tertiary);
}

.orders-filter__group .form-control:hover {
  border-color: var(--g7);
}

.orders-filter__group .form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-ring);
  outline: none;
}

.orders-filter__group select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238e8e93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='4 6 8 10 12 6'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 36px;
}

.orders-filter__group select[multiple].form-control {
  background-image: none;
  padding-right: 12px;
  min-height: 84px;
}

.orders-filter__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 0.5px solid var(--separator);
  flex-wrap: wrap;
  gap: 10px;
}

.orders-filter__info {
  font-size: 13px;
  color: var(--label-secondary);
  display: flex;
  align-items: center;
  gap: 14px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

/* ============================================
   Toolbar
   ============================================ */
.orders-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 16px;
  flex-wrap: wrap;
}

.orders-batchtoggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 10px;
  border: none;
  background: var(--g2);
  color: var(--label);
  transition: all 180ms cubic-bezier(0.25, 0.1, 0.25, 1);
  cursor: pointer;
  letter-spacing: -0.005em;
  box-shadow: 0 0 0 0.5px var(--separator-opaque), 0 1px 0 rgba(0, 0, 0, 0.02);
}

.orders-batchtoggle i { font-size: 16px; }

.orders-batchtoggle:hover {
  background: var(--g1);
}

.orders-batchtoggle:active {
  transform: scale(0.97);
}

.orders-batchtoggle.is-active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.3);
}

/* ============================================
   Batch bar — frosted glass
   ============================================ */
.orders-batchbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  margin-bottom: 16px;
  background: rgba(28, 28, 30, 0.72);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border-radius: 14px;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 16px;
  z-index: 20;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(255, 255, 255, 0.06);
}

.orders-batchbar.is-visible { display: flex; }

.orders-batchbar__left,
.orders-batchbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.orders-batchbar .form-control {
  border-radius: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 13.5px;
  padding: 7px 12px;
  height: auto;
  min-width: 170px;
  font-family: inherit;
  letter-spacing: -0.005em;
  box-shadow: none;
}

.orders-batchbar .form-control option { color: var(--label); }

.orders-batchbar .badge {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  border: none;
}

.orders-batchbar label {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  letter-spacing: -0.005em;
}

.orders-batchbar input[type="checkbox"] {
  accent-color: var(--blue);
  width: 15px;
  height: 15px;
}

.orders-batchbar .btn-success-soft {
  background: var(--green);
  color: #fff;
  box-shadow: 0 1px 2px rgba(48, 209, 88, 0.3);
}

.orders-batchbar .btn-success-soft:hover {
  background: #248a3d;
  color: #fff;
}

.orders-batchbar .btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

.orders-batchbar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ============================================
   Orders List
   ============================================ */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  background: var(--g2);
  border-radius: 16px;
  transition: all 220ms cubic-bezier(0.25, 0.1, 0.25, 1);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 0.5px solid var(--separator);
}

.order-card.is-new {
  border: 2px solid #f2c200;
  background: #fffdf1;
  box-shadow: 0 4px 14px rgba(242, 194, 0, 0.14), var(--shadow-sm);
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.order-card.is-new:hover {
  box-shadow: 0 8px 22px rgba(242, 194, 0, 0.18), var(--shadow-md);
}

.order-card.is-new::before {
  display: none;
}

.order-card__row {
  display: grid;
  grid-template-columns: 1.3fr 1.5fr 1.55fr 1.45fr 1fr;
  gap: 26px;
  padding: 22px 24px;
  align-items: start;
}

@media (max-width: 1280px) {
  .order-card__row { grid-template-columns: 1fr 1fr; gap: 20px; }
}

@media (max-width: 640px) {
  .order-card__row { grid-template-columns: 1fr; gap: 16px; }
}

.order-card__cell {
  min-width: 0;
  font-size: 13.5px;
  color: var(--label);
  line-height: 1.65;
  letter-spacing: -0.005em;
}

.order-card__cell > div {
  margin-bottom: 3px;
}

.order-card__cell strong {
  color: var(--label);
  font-weight: 600;
}

.order-card__cell a {
  color: var(--blue);
  text-decoration: none;
  transition: opacity 140ms ease;
}

.order-card__cell a:hover {
  opacity: 0.72;
}

.order-card__label {
  display: inline-block;
  min-width: 84px;
  color: var(--label-tertiary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.order-card__number {
  font-family: "SF Mono", "JetBrains Mono", "Menlo", monospace;
  font-size: 12.5px;
  color: var(--label);
  font-weight: 600;
  background: var(--g1);
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.order-card__amount {
  font-size: 26px;
  font-weight: 700;
  color: var(--label);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  display: inline-block;
  margin-top: 4px;
  line-height: 1.1;
}

.order-card__amount::before {
  content: "$";
  font-size: 15px;
  font-weight: 500;
  color: var(--label-tertiary);
  margin-right: 3px;
  letter-spacing: 0;
}

.order-card__actions-wrap {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100%;
  gap: 10px;
}

.order-card__actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
}

.order-card__actions .btn {
  font-size: 13px;
  border-radius: 9px;
  padding: 8px 14px;
  font-weight: 500;
  justify-content: center;
}

.order-card__actions .btn-primary-soft {
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: none;
}

.order-card__actions .btn-primary-soft:hover {
  background: rgba(10, 132, 255, 0.18);
  color: var(--blue);
}

.order-card__divider {
  margin: 12px 0;
  border: none;
  border-top: 0.5px solid var(--separator);
}

/* ============================================
   Badges — Apple capsule style
   ============================================ */
.order-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0;
}

.order-card .badge,
.order-card__badges .badge {
  border-radius: 999px;
  font-weight: 500;
  font-size: 11.5px;
  padding: 3px 10px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}

.order-card .badge-info {
  background: var(--teal-soft);
  color: #0071a4;
}

.order-card .badge-primary {
  background: var(--blue-soft);
  color: var(--blue);
}

.order-card .badge-warning {
  background: var(--orange-soft);
  color: var(--orange-text);
}

.order-card .badge-danger {
  background: var(--red-soft);
  color: var(--red-text);
}

.order-card .badge-success {
  background: var(--green-soft);
  color: var(--green-text);
}

.order-card .badge-primary a {
  color: inherit;
  text-decoration: none;
}

.order-card__alert {
  color: var(--red-text);
  font-weight: 500;
  font-size: 12px;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: var(--red-soft);
  border-radius: 8px;
}

.order-card__alert i { font-size: 13px; }

.order-card__hide {
  font-size: 12px;
  padding: 6px 12px;
  color: var(--label-secondary);
  background: var(--g1);
  border: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  transition: all 160ms cubic-bezier(0.25, 0.1, 0.25, 1);
  font-weight: 500;
  letter-spacing: -0.005em;
}

.order-card__hide i { font-size: 13px; }

.order-card__hide:hover {
  background: var(--g4);
  color: var(--label);
  text-decoration: none;
}

.order-card__hide:active {
  transform: scale(0.97);
}

/* 商品列表 */
.order-card__items {
  background: var(--g1);
  border-radius: 10px;
  padding: 11px 14px;
  margin: 6px 0 10px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--label);
  letter-spacing: -0.005em;
}

/* ============================================
   Pagination — Apple style
   ============================================ */
.orders-pagination {
  display: flex;
  justify-content: center;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 0.5px solid var(--separator);
}

.orders-pagination .pagination {
  margin: 0;
  display: flex;
  gap: 4px;
  padding: 0;
  list-style: none;
}

.orders-pagination .pagination a,
.orders-pagination .pagination span {
  border-radius: 9px;
  border: none;
  color: var(--label);
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 500;
  background: var(--g2);
  min-width: 36px;
  text-align: center;
  display: inline-block;
  text-decoration: none;
  transition: all 160ms cubic-bezier(0.25, 0.1, 0.25, 1);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  box-shadow: 0 0 0 0.5px var(--separator-opaque);
}

.orders-pagination .pagination a:hover {
  background: var(--g1);
  color: var(--label);
}

.orders-pagination .pagination .current {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.3);
}

.orders-pagination .pagination .disabled,
.orders-pagination .pagination .gap {
  color: var(--label-quaternary);
  background: transparent;
  box-shadow: none;
}

/* ============================================
   Misc
   ============================================ */
.orders-page hr {
  border-top: 0.5px solid var(--separator);
  opacity: 1;
}

.batch-checkbox-wrapper {
  display: none;
  margin-bottom: 8px;
}

.batch-checkbox-wrapper input[type="checkbox"] {
  accent-color: var(--blue);
  width: 15px;
  height: 15px;
}

/* ============================================
   Focus accessibility
   ============================================ */
.orders-page *:focus { outline: none; }

/* ============================================
   Order detail — premium workspace
   ============================================ */
.order-detail-page {
  --od-bg: #f5f5f7;
  --od-surface: rgba(255, 255, 255, 0.94);
  --od-surface-strong: #ffffff;
  --od-ink: #1d1d1f;
  --od-muted: #6e6e73;
  --od-faint: #a1a1a6;
  --od-border: rgba(0, 0, 0, 0.08);
  --od-border-strong: rgba(0, 0, 0, 0.14);
  --od-shadow: 0 18px 48px rgba(0, 0, 0, 0.07), 0 2px 8px rgba(0, 0, 0, 0.04);
  --od-shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.05);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72) 0%, rgba(245, 245, 247, 0) 260px),
    var(--od-bg);
  color: var(--od-ink);
  letter-spacing: 0;
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 74px);
  padding: 22px 28px 34px;
  margin: 0;
}

.content-wrapper > .order-detail-page.container-fluid,
.main-panel > .content-wrapper > .order-detail-page.container-fluid {
  max-width: none;
}

.order-detail-page .orders-hero__title,
.order-detail-page .orders-hero__subtitle,
.order-detail-page .orders-hero__crumbs {
  letter-spacing: 0;
}

.order-detail-commandbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  padding: 6px 2px 18px;
  margin: 0 0 16px;
  border-bottom: 0.5px solid var(--od-border);
}

.order-detail-actions {
  justify-content: flex-end;
}

.order-detail-page .btn,
.order-detail-page .badge {
  border-radius: 8px;
  letter-spacing: 0;
}

.order-detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.order-detail-chip,
.order-detail-note {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--od-muted);
  border: 0.5px solid var(--od-border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  letter-spacing: 0;
}

.order-detail-mono {
  font-family: "SF Mono", "JetBrains Mono", "Menlo", monospace;
  font-variant-numeric: tabular-nums;
}

.order-detail-overview {
  display: grid;
  grid-template-columns: minmax(360px, 0.76fr) minmax(720px, 1.24fr);
  gap: 16px;
  margin-bottom: 18px;
}

.order-detail-spotlight,
.order-detail-status-console,
.order-detail-panel,
.order-detail-rail-card {
  border: 0.5px solid var(--od-border);
  border-radius: 8px;
  background: var(--od-surface);
  box-shadow: var(--od-shadow-soft);
}

.order-detail-spotlight {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 220px;
  overflow: hidden;
  position: relative;
}

.order-detail-spotlight::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(10, 132, 255, 0.12) 0%, rgba(48, 209, 88, 0.06) 42%, rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.74));
  pointer-events: none;
}

.order-detail-spotlight__content,
.order-detail-spotlight__footer {
  position: relative;
  z-index: 1;
}

.order-detail-spotlight__content {
  padding: 24px 26px 18px;
}

.order-detail-summary__label,
.order-detail-panel__eyebrow,
.order-detail-status-card span,
.order-detail-field label,
.order-detail-field__title,
.order-detail-ledger span,
.order-detail-rail-list span,
.order-detail-spotlight__footer span,
.order-detail-rail-card__head span {
  color: var(--od-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.order-detail-spotlight__content strong {
  display: block;
  color: var(--od-ink);
  font-size: 42px;
  font-weight: 760;
  line-height: 1.02;
  margin-top: 8px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.order-detail-spotlight__content small {
  display: block;
  color: var(--od-muted);
  font-size: 13px;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.order-detail-spotlight__footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 0.5px solid var(--od-border);
  background: rgba(255, 255, 255, 0.56);
}

.order-detail-spotlight__footer > div {
  min-width: 0;
  padding: 15px 18px;
}

.order-detail-spotlight__footer > div + div {
  border-left: 0.5px solid var(--od-border);
}

.order-detail-spotlight__footer strong {
  display: block;
  color: var(--od-ink);
  font-size: 14px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-detail-status-console {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 0.72fr)) minmax(360px, 1.34fr);
  overflow: hidden;
}

.order-detail-status-card {
  min-height: 104px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.72);
  border-right: 0.5px solid var(--od-border);
}

.order-detail-status-card .badge {
  align-self: flex-start;
  border-radius: 999px;
  border: 0;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
}

.order-detail-ledger {
  grid-column: 4;
  grid-row: 1;
  display: grid;
  grid-template-columns: 1fr;
  border-top: 0;
  border-left: 0.5px solid var(--od-border);
  background: linear-gradient(180deg, rgba(248, 248, 250, 0.88), rgba(255, 255, 255, 0.82));
}

.order-detail-ledger > div {
  min-width: 0;
  padding: 15px 18px;
}

.order-detail-ledger > div + div {
  border-left: 0;
  border-top: 0.5px solid var(--od-border);
}

.order-detail-ledger strong,
.order-detail-rail-list strong,
.order-detail-profile strong {
  display: block;
  color: var(--od-ink);
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.order-detail-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 18px;
  align-items: start;
}

.order-detail-main {
  min-width: 0;
}

.order-detail-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-detail-panel {
  padding: 22px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(253, 253, 253, 0.92));
}

.order-detail-panel__header,
.order-detail-rail-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 15px;
  margin-bottom: 18px;
  border-bottom: 0.5px solid var(--od-border);
}

.order-detail-panel__header h5 {
  color: var(--od-ink);
  font-size: 18px;
  font-weight: 760;
  line-height: 1.2;
  margin: 4px 0 0;
  letter-spacing: 0;
}

.order-detail-panel__meta {
  color: var(--od-muted);
  background: #f5f5f7;
  border: 0.5px solid var(--od-border);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 650;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-detail-grid {
  display: grid;
  gap: 16px;
}

.order-detail-grid.four {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.order-detail-grid.three {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.order-detail-field {
  min-width: 0;
}

.order-detail-field.span-2 {
  grid-column: span 2;
}

.order-detail-field.span-3 {
  grid-column: span 3;
}

.order-detail-field label,
.order-detail-field__title {
  display: block;
  margin-bottom: 7px;
}

.order-detail-page .form-control {
  width: 100%;
  min-height: 40px;
  height: auto;
  border-radius: 8px;
  border: 0.5px solid var(--od-border-strong);
  background: #ffffff;
  color: var(--od-ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
  padding: 9px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.order-detail-page textarea.form-control {
  min-height: 118px;
  resize: vertical;
}

.order-detail-page .form-control:hover {
  border-color: rgba(0, 0, 0, 0.28);
}

.order-detail-page .form-control:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-ring);
}

.order-detail-page .form-control[readonly],
.order-detail-page .form-control:disabled {
  background: #f5f5f7;
  color: var(--od-muted);
}

.order-detail-input-action {
  display: flex;
  gap: 8px;
}

.order-detail-input-action .form-control {
  min-width: 0;
}

.order-detail-inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.order-detail-page .btn-primary-soft {
  background: #1d1d1f;
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
}

.order-detail-page .btn-primary-soft:hover {
  background: #000;
  color: #fff;
}

.order-detail-page .btn-warning {
  background: var(--orange-soft);
  color: var(--orange-text);
}

.order-detail-page .btn-danger {
  background: var(--red-soft);
  color: var(--red-text);
}

.order-detail-note.ok {
  background: var(--green-soft);
  color: var(--green-text);
}

.order-detail-note.strong {
  background: var(--blue-soft);
  color: var(--blue);
  margin: 0 8px 8px 0;
}

.order-detail-warning {
  color: var(--red-text);
  background: var(--red-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 650;
}

.order-detail-cart {
  overflow-x: auto;
  border: 0.5px solid var(--od-border);
  border-radius: 8px;
}

.order-detail-cart .table {
  margin: 0;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.order-detail-cart .table thead th {
  color: var(--od-muted);
  background: #f5f5f7;
  border: 0;
  font-size: 12px;
  font-weight: 650;
  padding: 11px 13px;
  letter-spacing: 0;
}

.order-detail-cart .table tbody td {
  border-top: 0.5px solid var(--od-border);
  color: var(--od-ink);
  font-size: 13px;
  vertical-align: middle;
  padding: 14px 13px;
}

.order-detail-cart .table img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: #f5f5f7;
  border: 0.5px solid var(--od-border);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.08);
}

.order-detail-cart h3 {
  margin: 0 0 5px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0;
}

.order-detail-cart a {
  color: var(--od-ink);
  text-decoration: none;
}

.order-detail-cart a:hover {
  color: var(--blue);
}

.order-detail-cart .price {
  color: var(--od-muted);
  font-variant-numeric: tabular-nums;
}

.order-detail-empty,
.order-detail-flow {
  color: var(--od-muted);
  background: #f5f5f7;
  border-radius: 8px;
  border: 0.5px solid var(--od-border);
}

.order-detail-empty {
  padding: 18px;
  font-size: 14px;
}

.order-detail-discounts {
  color: var(--od-ink);
  font-size: 14px;
  line-height: 1.7;
}

.order-detail-invoice-status {
  margin-top: 18px;
}

.order-detail-invoice-status .row {
  row-gap: 14px;
}

.order-detail-timeline ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.order-detail-timeline li {
  position: relative;
  padding: 0 0 12px 18px;
  color: var(--od-muted);
  font-size: 13px;
  line-height: 1.5;
}

.order-detail-timeline li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
}

.order-detail-timeline li::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 17px;
  bottom: 2px;
  width: 1px;
  background: var(--od-border);
}

.order-detail-timeline li:last-child::after {
  display: none;
}

.order-detail-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.order-detail-submit {
  display: flex;
  justify-content: center;
  margin: 2px 0 18px;
}

.order-detail-flow {
  min-height: 20rem;
  overflow: auto;
  padding: 12px;
}

.order-detail-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-detail-rail-card {
  padding: 18px;
}

.order-detail-rail-card.is-sticky {
  position: sticky;
  top: 18px;
  z-index: 2;
  box-shadow: var(--od-shadow);
}

.order-detail-rail-list,
.order-detail-profile {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-detail-rail-list > div {
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--od-border);
}

.order-detail-rail-list > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.order-detail-profile span {
  color: var(--od-muted);
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

@media (max-width: 1280px) {
  .order-detail-workspace {
    grid-template-columns: 1fr;
  }

  .order-detail-overview {
    grid-template-columns: minmax(320px, 0.82fr) minmax(520px, 1.18fr);
  }

  .order-detail-status-console {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .order-detail-ledger {
    grid-column: 1 / -1;
    grid-row: auto;
    grid-template-columns: 1fr 1fr 1.4fr;
    border-left: 0;
    border-top: 0.5px solid var(--od-border);
  }

  .order-detail-ledger > div + div {
    border-top: 0;
    border-left: 0.5px solid var(--od-border);
  }

  .order-detail-rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .order-detail-rail-card.is-sticky {
    position: static;
  }
}

@media (max-width: 1100px) {
  .order-detail-overview,
  .order-detail-grid.four,
  .order-detail-grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .order-detail-field.span-3 {
    grid-column: span 2;
  }

  .order-detail-status-console,
  .order-detail-ledger,
  .order-detail-rail {
    grid-template-columns: 1fr;
  }

  .order-detail-status-card,
  .order-detail-ledger > div + div {
    border-left: 0;
    border-right: 0;
  }

  .order-detail-status-card + .order-detail-status-card,
  .order-detail-ledger > div + div {
    border-top: 0.5px solid var(--od-border);
  }
}

@media (max-width: 720px) {
  .order-detail-page {
    padding: 16px 12px 28px;
  }

  .order-detail-overview,
  .order-detail-grid.four,
  .order-detail-grid.three,
  .order-detail-spotlight__footer {
    grid-template-columns: 1fr;
  }

  .order-detail-field.span-2,
  .order-detail-field.span-3 {
    grid-column: auto;
  }

  .order-detail-panel {
    padding: 18px;
  }

  .order-detail-panel__header {
    flex-direction: column;
  }

  .order-detail-panel__meta {
    max-width: 100%;
  }

  .order-detail-input-action {
    flex-direction: column;
  }

  .order-detail-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .order-detail-spotlight__footer > div + div {
    border-left: 0;
    border-top: 0.5px solid var(--od-border);
  }
}

/* ============================================
   Dark mode ready (optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
  /* 若後台支援深色模式再開啟。目前保留 light mode only */
}

/* ============================================
   Sales statistics reports
   ============================================ */
.sales-report-page {
  letter-spacing: 0;
}

.reports-filter,
.reports-section {
  background: var(--g2);
  border: 0.5px solid var(--separator);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.reports-filter {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 20px;
}

.reports-filter__form {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.reports-filter__field {
  min-width: 180px;
}

.reports-filter__field label {
  display: block;
  color: var(--label-secondary);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.reports-filter__actions {
  display: flex;
  gap: 8px;
}

.reports-filter__meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--label-secondary);
  font-size: 13px;
}

.reports-filter__meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.reports-kpi {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card__icon.danger {
  background: linear-gradient(135deg, var(--red) 0%, #b42318 100%);
  color: #fff;
}

.kpi-card__icon.muted {
  background: linear-gradient(135deg, var(--g8) 0%, var(--g10) 100%);
  color: #fff;
}

.kpi-card__icon.purple {
  background: linear-gradient(135deg, var(--purple) 0%, #7f32a8 100%);
  color: #fff;
}

.kpi-card__icon.teal {
  background: linear-gradient(135deg, var(--teal) 0%, #177e9f 100%);
  color: #fff;
}

.reports-grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.reports-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reports-section {
  padding: 20px;
  margin-bottom: 18px;
}

.reports-section__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.reports-section__head h2 {
  color: var(--label);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 4px;
}

.reports-section__head h3,
.split-tables h3 {
  color: var(--label-secondary);
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
}

.reports-section__head p {
  color: var(--label-secondary);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

.reports-section__downloads {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.reports-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.reports-table-wrap--compact {
  max-height: 460px;
  overflow-y: auto;
}

.reports-table {
  margin: 0;
  min-width: 680px;
}

.reports-table thead th {
  background: var(--g3);
  border-bottom: 0.5px solid var(--separator);
  color: var(--label-secondary);
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.reports-table tbody td {
  border-bottom: 0.5px solid var(--separator);
  color: var(--label);
  font-size: 13px;
  vertical-align: middle;
}

.reports-table tbody tr:last-child td {
  border-bottom: 0;
}

.trend-cell {
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 10px;
}

.trend-cell__bar {
  display: block;
  height: 8px;
  min-width: 90px;
  background: var(--g4);
  border-radius: 999px;
  overflow: hidden;
}

.trend-cell__bar span {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--blue);
  border-radius: inherit;
}

.split-tables {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-hover);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .reports-grid--2,
  .split-tables,
  .reports-kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .reports-filter,
  .reports-section__head {
    align-items: stretch;
    flex-direction: column;
  }

  .reports-filter__form,
  .reports-filter__field,
  .reports-filter__actions,
  .reports-filter__actions .btn {
    width: 100%;
  }

  .reports-grid--2,
  .split-tables,
  .reports-kpi {
    grid-template-columns: 1fr;
  }

  .reports-section {
    padding: 16px;
  }
}
