/* ============================================
   OFC Supply Chain Management System
   Global Stylesheet
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Brand Colors */
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;

  /* Accent */
  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #6366f1;

  /* Neutrals - Dark Theme */
  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-2: #334155;
  --bg-elevated: #1e293b;
  --bg-hover: #334155;
  --bg-input: #0f172a;

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Borders */
  --border-color: #334155;
  --border-light: #475569;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.35);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-sidebar: 2px 0 12px rgba(0, 0, 0, 0.2);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --content-max: 1920px;

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Override */
[data-theme="light"] {
  --bg-base: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-hover: #f5f7fa;
  --bg-input: #f8fafc;

  --primary: #e60012;
  --primary-dark: #c50010;
  --primary-light: #ff2d3f;
  --primary-50: rgba(230, 0, 18, 0.06);
  --primary-100: rgba(230, 0, 18, 0.12);

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  --border-color: rgba(0, 0, 0, 0.06);
  --border-light: rgba(0, 0, 0, 0.1);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-sidebar: 2px 0 12px rgba(0, 0, 0, 0.04);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary);
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
}

ul, ol {
  list-style: none;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface-2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3a5f 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(37, 99, 235, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(14, 165, 233, 0.1) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-30px, 20px); }
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 940px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.login-hero {
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.login-hero::after {
  content: '';
  position: absolute;
  bottom: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.login-hero::before {
  content: '';
  position: absolute;
  top: -40px;
  right: 20px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.login-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
}

.login-logo .logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  backdrop-filter: blur(10px);
}

.login-hero-content h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.3;
}

.login-hero-content p {
  font-size: 0.95rem;
  opacity: 0.85;
  line-height: 1.7;
}

.login-hero-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-hero-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  opacity: 0.9;
}

.login-hero-features li::before {
  content: '\2713';
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.login-form-side {
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-form-side h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-form-side .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.92rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-select:focus,
[data-theme="light"] .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(230, 0, 18, 0.08);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 6px;
  display: none;
}

.form-error.visible {
  display: block;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .form-input {
  padding-left: 42px;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.input-with-icon .toggle-password {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  font-size: 1rem;
}

.input-with-icon .toggle-password:hover {
  color: var(--text-primary);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  white-space: nowrap;
  border: none;
  cursor: pointer;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(230, 0, 18, 0.25);
}

[data-theme="dark"] .btn-primary:hover {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #0d9d6e;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

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

/* ---------- Login Extras ---------- */
.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-secondary);
}

.checkbox-wrapper input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.login-options a {
  color: var(--primary-light);
  font-size: 0.85rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---------- Alert ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 20px;
  display: none;
  align-items: center;
  gap: 10px;
}

.alert.visible {
  display: flex;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: none;
  box-shadow: var(--shadow-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: width 0.15s ease, transform 0.25s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.hidden {
  transform: translateX(-100%);
  box-shadow: none;
}

/* Sidebar Resize Handle */
.sidebar-resize-handle {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  width: 6px;
  height: 100vh;
  cursor: col-resize;
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateX(-3px);
  transition: left 0.15s ease;
}

.sidebar-resize-handle::before {
  content: '';
  width: 2px;
  height: 40px;
  border-radius: 2px;
  background: var(--border-light);
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar-resize-handle:hover::before,
.sidebar-resize-handle.dragging::before {
  opacity: 0.6;
  height: 100%;
}

.sidebar-resize-handle.dragging::before {
  background: var(--primary);
  opacity: 0.5;
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-header {
  overflow: hidden;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 170px;
  height: auto;
  border-radius: 0;
  flex-shrink: 0;
  object-fit: contain;
}

.sidebar-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-title {
  display: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-nav-section {
  margin-bottom: 24px;
}

.sidebar-nav-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 12px 8px;
  font-weight: 600;
}

.sidebar.collapsed .sidebar-nav-label {
  display: none;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 4px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--primary-50);
  color: var(--primary-light);
}

[data-theme="light"] .sidebar-link.active {
  background: rgba(230, 0, 18, 0.08);
  color: #e60012;
}

[data-theme="light"] .sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: #e60012;
  border-radius: 0 3px 3px 0;
}

.sidebar-link .icon {
  font-size: 1.2rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-link span:not(.icon) {
  display: none;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1.3rem;
  transition: all var(--transition);
}

.topbar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.topbar-breadcrumb .current {
  color: var(--text-primary);
  font-weight: 600;
}

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

.topbar-action {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1.2rem;
  transition: all var(--transition);
  position: relative;
}

.topbar-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.topbar-action .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.topbar-user:hover {
  background: var(--bg-hover);
}

.topbar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
}

.topbar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ---------- Multi-Tab Window Bar ---------- */
.tab-window-bar {
  background: var(--bg-base);
  border-bottom: none;
  display: flex;
  align-items: flex-end;
  padding: 8px 16px 0;
  min-height: 44px;
  flex-shrink: 0;
  overflow: hidden;
  gap: 2px;
}

.tab-window-list {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  scrollbar-width: thin;
}

.tab-window-list::-webkit-scrollbar {
  height: 3px;
}

.tab-window-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--text-muted);
  position: relative;
  flex-shrink: 0;
}

.tab-window-item:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-secondary);
}

[data-theme="dark"] .tab-window-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tab-window-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .tab-window-item.active {
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.15);
}

.tab-window-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

.tab-window-title {
  line-height: 1;
}

.tab-window-close {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  transition: all var(--transition);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.tab-window-close:hover {
  background: var(--danger);
  color: #fff;
}

/* Tab Pane */
.tab-pane {
  animation: fadeIn 0.2s ease;
}

/* ---------- Page Content ---------- */
.page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  overflow-y: auto;
  overflow-x: auto;
}

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

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

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

/* ============================================
   DASHBOARD
   ============================================ */

/* ---------- KPI Cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

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

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

.kpi-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.kpi-icon-blue { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
.kpi-icon-green { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.kpi-icon-orange { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.kpi-icon-purple { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.kpi-icon-red { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.kpi-icon-cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }

.kpi-card-trend {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-trend-up {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.kpi-trend-down {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.kpi-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

.kpi-card-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.kpi-card-spark {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 80px;
  height: 40px;
  opacity: 0.3;
}

/* ---------- Chart Cards ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.chart-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-container {
  position: relative;
  height: 300px;
}

.chart-container-sm {
  position: relative;
  height: 240px;
}

/* ---------- Activity List ---------- */
.activity-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.activity-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
}

.activity-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.activity-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.activity-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ============================================
   DATA TABLE
   ============================================ */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-toolbar {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  margin: 0;
}

.table-search {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper .form-input {
  padding-left: 40px;
  min-width: 300px;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

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

.table-wrapper {
  overflow-x: auto;
}

/* Order table: independent vertical scroll, sticky header */
.order-table-scroll {
  max-height: calc(100vh - 340px);
  overflow: auto;
  position: relative;
  z-index: 5;
}

.order-table-scroll .data-table {
  border-collapse: separate;
  border-spacing: 0;
}

/* Sticky header & right action column — also enforced via inline styles in pages.js */
/* z-index 层级：普通表头(32) > 操作列数据格(30) > 普通数据格(1)；操作列表头(35) 最高 */
.order-table-scroll .data-table thead th {
  position: sticky;
  top: 0;
  z-index: 32;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

/* Right action column: higher z-index than regular columns */
.order-table-scroll .data-table .action-col-th {
  position: sticky;
  right: 0;
  top: 0;
  z-index: 35;
  background: var(--bg-surface);
  white-space: nowrap;
  border-left: 1px solid var(--border-color);
}

.order-table-scroll .data-table .action-col-td {
  position: sticky;
  right: 0;
  z-index: 30;
  background: var(--bg-surface);
  white-space: nowrap;
  border-left: 1px solid var(--border-color);
  overflow: visible;
}

.order-table-scroll .data-table tbody tr:hover .action-col-td {
  background: var(--bg-hover);
}

.action-btn-group {
  display: flex;
  gap: 6px;
  align-items: center;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  background: var(--bg-surface);
  color: var(--text-primary);
}

.action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.action-btn-detail {
  color: var(--primary);
  border-color: var(--primary-100, rgba(37, 99, 235, 0.3));
}

.action-btn-detail:hover {
  background: var(--primary-50, rgba(37, 99, 235, 0.1));
  color: var(--primary);
  border-color: var(--primary);
}

.action-btn-split {
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

.action-btn-split:hover {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border-color: var(--success);
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th {
  text-align: left;
  padding: 13px 18px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.data-table th.sortable:hover {
  color: var(--text-primary);
}

.data-table th .sort-icon {
  margin-left: 4px;
  opacity: 0.5;
}

.data-table th.sorted .sort-icon {
  opacity: 1;
}

.data-table td {
  padding: 13px 18px;
  font-size: 0.92rem;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.035);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

[data-theme="dark"] .data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.data-table tbody tr {
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr.selected {
  background: var(--primary-50);
}

.data-table .cell-id {
  font-weight: 600;
  color: var(--primary-light);
}

.data-table .cell-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Status Badges ---------- */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-active { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-active::before { background: #34d399; }

.badge-pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-pending::before { background: #fbbf24; }

.badge-shipped { background: rgba(37, 99, 235, 0.15); color: #60a5fa; }
.badge-shipped::before { background: #60a5fa; }

.badge-completed { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.badge-completed::before { background: #818cf8; }

.badge-cancelled { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-cancelled::before { background: #f87171; }

/* ---------- Table Checkbox ---------- */
.table-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ---------- Table Actions ---------- */
.table-row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1rem;
  transition: all var(--transition);
}

.row-action-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.row-action-btn.delete:hover {
  color: var(--danger);
}

/* ---------- Pagination ---------- */
.table-pagination {
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--border-color);
  background: transparent;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.pagination-info {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-secondary);
  transition: all var(--transition);
  padding: 0 10px;
}

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

.page-btn.active {
  background: var(--primary);
  color: #fff;
}

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

/* ============================================
   FORM PAGE
   ============================================ */
.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 900px;
  box-shadow: var(--shadow-card);
}

.form-section {
  padding: 28px 32px;
  border-bottom: none;
}

.form-section:not(:last-child) {
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .form-section:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.form-section:last-child {
  border-bottom: none;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

/* ---------- Line Items Table ---------- */
.line-items {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.line-items-header {
  display: grid;
  grid-template-columns: 40px 2fr 1fr 1fr 1.2fr 40px;
  gap: 0;
  padding: 10px 16px;
  background: var(--bg-surface-2);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.line-item-row {
  display: grid;
  grid-template-columns: 40px 2fr 1fr 1fr 1.2fr 40px;
  gap: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  align-items: center;
}

.line-item-row input,
.line-item-row select {
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  width: 100%;
}

.line-item-row input:focus,
.line-item-row select:focus {
  border-color: var(--primary);
  background: var(--bg-input);
  outline: none;
}

.line-item-remove {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: all var(--transition);
}

.line-item-remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.line-items-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.line-items-total {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.line-items-total .total-value {
  font-size: 1.2rem;
  color: var(--primary-light);
  margin-left: 8px;
}

/* ---------- Form Actions ---------- */
.form-actions {
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-surface-2);
}

/* ---------- Form Select Arrow ---------- */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1024px) {
  .login-container {
    max-width: 420px;
    grid-template-columns: 1fr;
  }

  .login-hero {
    display: none;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }

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

  .main-content {
    margin-left: 0;
  }

  .main-content.sidebar-collapsed {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar-overlay.visible {
    display: block;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .login-form-side {
    padding: 32px 24px;
  }

  .page-content {
    padding: 16px;
  }

  .tab-window-item {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    padding: 16px;
  }

  .search-input-wrapper .form-input {
    min-width: 200px;
  }

  .topbar-user-info {
    display: none;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }

  .line-items-header,
  .line-item-row {
    grid-template-columns: 30px 1.5fr 1fr 1fr 40px;
  }

  .line-items-header > :nth-child(5),
  .line-item-row > :nth-child(5) {
    display: none;
  }
}

/* Small Mobile */
@media (max-width: 480px) {
  .login-form-side {
    padding: 24px 20px;
  }

  .topbar {
    padding: 0 16px;
  }

  .topbar-breadcrumb {
    display: none;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-view {
  animation: fadeIn 0.3s ease;
}

/* Loading spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  min-width: 280px;
  animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast-icon {
  font-size: 1.2rem;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }
.toast.warning .toast-icon { color: var(--warning); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayFade 0.2s ease;
}

.modal-overlay.visible {
  display: flex;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes overlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* Extra-wide modal for detail management */
.modal.modal-xl {
  max-width: 1100px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal.modal-xl .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ---------- Detail Edit Form (明细管理) ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-section {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.detail-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.auto-tag {
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--primary-50);
  color: var(--primary-light);
  font-weight: 600;
  margin-left: 4px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.detail-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-field-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-field-input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 32px;
}

.detail-field-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

[data-theme="light"] .detail-field-input:focus {
  box-shadow: 0 0 0 3px rgba(230, 0, 18, 0.07);
}

.detail-field-input.auto-filled {
  border-color: rgba(37, 99, 235, 0.35);
  background: rgba(37, 99, 235, 0.04);
}

[data-theme="light"] .detail-field-input.auto-filled {
  border-color: rgba(230, 0, 18, 0.25);
  background: rgba(230, 0, 18, 0.02);
}

.detail-field-input[type="date"] {
  color-scheme: dark;
}

[data-theme="light"] .detail-field-input[type="date"] {
  color-scheme: light;
}

/* Full-fields grid (bottom section) */
.detail-fullfields {
  margin-top: 16px;
}

.detail-fullfields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px 12px;
}

/* ---------- Split Dialog (分货弹窗) ---------- */
.modal.modal-split {
  max-width: 760px;
}

.split-row {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.split-row-main {
  display: grid;
  grid-template-columns: 36px 1fr 1.6fr 32px;
  gap: 8px;
  align-items: end;
}

.split-row-num {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-bottom: 8px;
}

.split-row-info {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding-left: 44px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
}

.split-row-info strong {
  color: var(--text-primary);
  font-weight: 600;
}

.split-row-info .split-auto-ref {
  color: var(--primary-light);
}

/* ---------- Batch Create Table (创建整单发货计划) ---------- */
.batch-create-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.batch-create-table thead th {
  padding: 9px 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.batch-create-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  font-size: 0.82rem;
}

.batch-create-table tbody tr {
  transition: background 0.15s ease;
}

.batch-create-table tbody tr:hover {
  background: var(--bg-hover);
}

.batch-create-table .form-input {
  padding: 5px 8px;
  font-size: 0.82rem;
  min-height: 30px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.2rem;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 0.9rem;
}

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.hidden { display: none !important; }

/* ============================================
   ORDER STATS BAR (订单统计卡片栏)
   ============================================ */
.order-stats-bar {
  display: flex;
  align-items: stretch;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.order-stat-item {
  flex: 1;
  padding: 15px 16px;
  border-right: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  text-align: center;
  position: relative;
}

.order-stat-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 22%;
  bottom: 22%;
  width: 1px;
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .order-stat-item:not(:last-child)::after {
  background: rgba(255, 255, 255, 0.06);
}

.order-stat-item:last-child::after {
  display: none;
}

.order-stat-item:hover {
  background: var(--bg-hover);
}

.order-stat-item:active {
  transform: scale(0.98);
}

.order-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.order-stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ============================================
   TAB BAR (状态Tab切换)
   ============================================ */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0;
}

.tab-item {
  padding: 12px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-item:hover {
  color: var(--text-primary);
}

.tab-item.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

[data-theme="light"] .tab-item.active {
  color: var(--primary-dark);
}

.tab-count {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  min-width: 24px;
  text-align: center;
}

.tab-item.active .tab-count {
  background: var(--primary-50);
  color: var(--primary-light);
}

[data-theme="light"] .tab-item.active .tab-count {
  background: var(--primary-100);
  color: var(--primary-dark);
}

/* ============================================
   COMPACT TABLE (紧凑表格)
   ============================================ */
.data-table.compact th {
  padding: 12px 16px;
  font-size: 0.82rem;
}

.data-table.compact td {
  padding: 12px 16px;
  font-size: 0.88rem;
}

.data-table.compact .cell-id {
  font-size: 0.86rem;
}

/* ============================================
   RESPONSIVE - Stats Bar & Tabs
   ============================================ */
@media (max-width: 1024px) {
  .order-stats-bar {
    flex-wrap: wrap;
  }

  .order-stat-item {
    flex: 1 1 calc(33.33% - 1px);
    border-bottom: 1px solid var(--border-color);
  }
}

@media (max-width: 768px) {
  .order-stats-bar {
    flex-direction: column;
  }

  .order-stat-item {
    flex: 1 1 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 12px 16px;
  }

  .order-stat-item:last-child {
    border-bottom: none;
  }

  .order-stat-value {
    font-size: 1.3rem;
    margin-bottom: 0;
  }

  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-item {
    white-space: nowrap;
    padding: 8px 14px;
  }

  .data-table.compact th,
  .data-table.compact td {
    padding: 8px 10px;
    font-size: 0.78rem;
  }
}

/* ============================================
   MULTI-SELECT FILTER (多选筛选器)
   ============================================ */
.ms-filter {
  position: relative;
  width: 100%;
}

.ms-filter-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 36px;
  gap: 8px;
}

.ms-filter-trigger:hover {
  border-color: var(--border-light);
}

.ms-filter-trigger.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

[data-theme="light"] .ms-filter-trigger.active {
  box-shadow: 0 0 0 3px rgba(230, 0, 18, 0.1);
}

.ms-filter-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  color: var(--text-muted);
  font-weight: 400;
}

.ms-filter-label.has-value {
  font-weight: 600;
  color: var(--primary-light);
}

[data-theme="light"] .ms-filter-label.has-value {
  color: var(--primary-dark);
}

.ms-filter-arrow {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.ms-filter-trigger.active .ms-filter-arrow {
  transform: rotate(180deg);
}

.ms-filter-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: none;
  flex-direction: column;
  max-height: 360px;
}

.ms-filter-dropdown.open {
  display: flex;
}

.ms-filter-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  position: relative;
  flex-shrink: 0;
}

.ms-filter-search input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
}

.ms-filter-search input:focus {
  border-color: var(--primary);
}

.ms-filter-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ms-filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.ms-filter-action-btn {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-light);
  cursor: pointer;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

[data-theme="light"] .ms-filter-action-btn {
  color: var(--primary-dark);
}

.ms-filter-action-btn:hover {
  background: var(--bg-hover);
}

.ms-filter-action-btn.clear {
  color: var(--text-muted);
}

.ms-filter-action-btn.clear:hover {
  color: var(--danger);
}

.ms-filter-list {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.ms-filter-list::-webkit-scrollbar {
  width: 6px;
}

.ms-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text-primary);
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-filter-option:hover {
  background: var(--bg-hover);
}

.ms-filter-option input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.ms-filter-option-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-filter-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.filter-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 18px 24px 16px;
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
}

.filter-actions-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 0;
  background: transparent;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  margin: 0;
}

.filter-panel-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-panel-clear-all {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--danger);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.filter-panel-clear-all:hover {
  background: rgba(239, 68, 68, 0.1);
}

.filter-panel-clear-all.hidden {
  display: none;
}

.filter-group-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 5px;
}

.ms-text-input,
.ms-date-input {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.ms-text-input:focus,
.ms-date-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

[data-theme="light"] .ms-text-input:focus,
[data-theme="light"] .ms-date-input:focus {
  box-shadow: 0 0 0 3px rgba(230, 0, 18, 0.1);
}

.ms-text-input::placeholder {
  color: var(--text-muted);
}
