/* ============================================================
   跨境财务中台 — 企业级设计令牌（大厂交付向：清晰层级、克制配色、可读优先）
   ============================================================ */
:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-surface-2: #f8fafc;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-primary: #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-primary-soft: #eff6ff;
  --color-sidebar: #0f172a;
  --color-sidebar-hover: rgba(255, 255, 255, 0.08);
  --color-sidebar-active: rgba(37, 99, 235, 0.35);
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  --color-success-text: #065f46;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-danger-text: #991b1b;
  --sidebar-width: 260px;
  --topbar-height: 56px;
}

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.55;
}

/* ----- App shell（已登录） ----- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  min-height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: #f8fafc !important;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.app-sidebar-logo:hover {
  color: #fff !important;
}

.app-sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.45);
}

.app-sidebar-env {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
}

.app-sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.6rem;
  overflow-y: auto;
}

.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #cbd5e1 !important;
  text-decoration: none !important;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.app-nav-link i {
  font-size: 1.05rem;
  opacity: 0.9;
  width: 1.25rem;
  text-align: center;
}

.app-nav-link:hover {
  background: var(--color-sidebar-hover);
  color: #f1f5f9 !important;
}

.app-nav-link.is-active {
  background: var(--color-sidebar-active);
  color: #fff !important;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.35);
}

.app-sidebar-footer {
  padding: 0.85rem 1rem;
  font-size: 0.75rem;
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-page-heading {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.app-topbar-crumb {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-muted) !important;
  text-decoration: none !important;
}

.app-topbar-crumb:hover {
  color: var(--color-primary) !important;
}

.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--color-text-secondary) !important;
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text) !important;
}

.app-content {
  flex: 1;
  padding: 1.5rem 1.75rem 2.5rem;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* ----- 未登录（认证页） ----- */
.app-auth-outer {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, 0.12), transparent 50%),
    radial-gradient(800px 400px at 90% 100%, rgba(99, 102, 241, 0.1), transparent 45%),
    linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

/* ----- 告警 ----- */
.app-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.app-alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success-text);
}

.app-alert-danger {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger-text);
}

.app-alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.app-alert i {
  margin-top: 0.1rem;
  flex-shrink: 0;
}

/* ----- 卡片 / 面板 ----- */
.app-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.app-panel + .app-panel {
  margin-top: 1.25rem;
}

/* ----- 筛选工具条 ----- */
.filter-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.filter-toolbar .form-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* ----- 表格 ----- */
.table.data-table {
  margin-bottom: 0;
  font-size: 0.875rem;
  vertical-align: middle;
}

.table.data-table thead th {
  background: var(--color-surface-2) !important;
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border) !important;
  padding: 0.65rem 1rem;
  white-space: nowrap;
}

.table.data-table tbody td {
  padding: 0.65rem 1rem;
  border-color: var(--color-border) !important;
}

.table.data-table tbody tr:hover {
  background: #fafbfc;
}

.table.data-table a:not(.btn) {
  color: var(--color-primary);
  font-weight: 500;
  text-decoration: none;
}

.table.data-table a:not(.btn):hover {
  text-decoration: underline;
}

/* ----- 按钮 ----- */
.btn-primary {
  --bs-btn-bg: var(--color-primary);
  --bs-btn-border-color: var(--color-primary);
  --bs-btn-hover-bg: var(--color-primary-hover);
  --bs-btn-hover-border-color: var(--color-primary-hover);
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
}

.btn-outline-secondary {
  border-color: var(--color-border-strong);
  color: var(--color-text-secondary);
  font-weight: 500;
}

.btn-outline-secondary:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-sm {
  border-radius: var(--radius-sm);
}

/* ----- 表单 ----- */
.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-border-strong);
  font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.form-label {
  font-weight: 500;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* ----- 页面标题行（视图内） ----- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h2,
.page-header .h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--color-text);
}

.page-header .text-muted {
  color: var(--color-text-muted) !important;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ----- 登录 / 认证卡片 ----- */
.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 960px;
  width: 100%;
  min-height: 520px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.auth-split-brand {
  background: linear-gradient(145deg, #1e3a8a 0%, #1d4ed8 45%, #0f172a 100%);
  color: #e0e7ff;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-split-brand h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: #fff;
  letter-spacing: -0.03em;
}

.auth-split-brand p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.88;
  line-height: 1.65;
}

.auth-split-form {
  padding: 2.5rem 2.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-form-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--color-text);
}

.auth-form-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

@media (max-width: 767.98px) {
  .auth-split {
    grid-template-columns: 1fr;
    min-height: unset;
  }

  .auth-split-brand {
    padding: 1.75rem 1.5rem;
  }
}

@media (max-width: 991.98px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    position: relative;
    width: 100%;
    min-height: unset;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.5rem;
  }

  .app-sidebar-brand {
    border: none;
    padding: 0.5rem 0.75rem;
    flex: 1;
  }

  .app-sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    padding: 0.25rem;
    gap: 0.15rem;
  }

  .app-nav-link span {
    display: none;
  }

  .app-nav-link {
    padding: 0.5rem;
    justify-content: center;
  }

  .app-sidebar-footer {
    display: none;
  }
}

/* ----- 统计卡片（报表等） ----- */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.stat-card .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 0.25rem;
}

/* ----- 进度条 ----- */
.progress {
  border-radius: 999px;
  background: var(--color-surface-2);
}

.progress-bar {
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

/* ----- 徽章 ----- */
.badge-status-on {
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

.badge-status-off {
  background: #f1f5f9;
  color: #64748b;
  font-weight: 600;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}

/* ----- 订单列表 ----- */
.orders-page .orders-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.75rem 1rem;
  width: 100%;
}

.orders-page .orders-filter-grid .orders-filter-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.65rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--color-border);
}

.orders-page .orders-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

.orders-page .orders-list-head .orders-list-meta {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.orders-page .orders-table-wrap {
  overflow-x: auto;
}

.orders-page .table.orders-table {
  min-width: 52rem;
}

.orders-page .table.orders-table .col-check {
  width: 2.5rem;
}

.orders-page .table.orders-table .col-invoice,
.orders-page .table.orders-table .col-more {
  overflow: visible;
  vertical-align: middle;
}

.orders-page .table.orders-table .col-invoice {
  width: 1%;
  white-space: nowrap;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.orders-page .table.orders-table .col-more {
  width: 1%;
  white-space: nowrap;
}

.orders-page .orders-invoice-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: nowrap;
}

.orders-page .orders-invoice-actions .btn {
  padding: 0.2rem 0.45rem;
  line-height: 1.2;
}

.orders-page .orders-invoice-actions .btn i {
  font-size: 0.95rem;
}

.orders-page .orders-cell-order .orders-order-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.8125rem;
  font-weight: 600;
}

.orders-page .orders-cell-order .orders-sys-id {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.orders-page .orders-cell-shop .orders-shop-name {
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.35;
}

.orders-page .orders-cell-ledger {
  min-width: 9.5rem;
}

.orders-page .orders-ledger-cost {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-top: 0.2rem;
}

.orders-page .orders-ledger-supplier {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.15rem;
}

.orders-page .orders-actions-dropdown .dropdown-menu {
  z-index: 1080;
  min-width: 10rem;
}

.orders-page .orders-actions-dropdown .dropdown-item {
  font-size: 0.8125rem;
  padding: 0.4rem 1rem;
}

.orders-page .orders-actions-dropdown .dropdown-item:disabled {
  opacity: 0.45;
}

.orders-page .orders-actions-dropdown form {
  margin: 0;
}

.orders-page .orders-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
}

.orders-page .orders-admin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.orders-page .orders-selection-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.orders-page .orders-selection-hint strong {
  color: var(--color-primary);
}

.orders-page .orders-invoice-legend i {
  font-size: 0.9rem;
  vertical-align: -0.1em;
}
