:root {
      --bg-color: #f3f4f6;
      --card-bg: rgba(255, 255, 255, 0.9);
      --text-main: #1f2937;
      --text-muted: #6b7280;
      --primary: #4f46e5;
      --primary-hover: #4338ca;
      --success: #10b981;
      --border-color: #e5e7eb;
      --radius: 16px;
      --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
      --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
      --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    body { 
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
      margin: 0;
      padding: 8px 32px 32px; 
      background: var(--bg-color);
      color: var(--text-main);
      line-height: 1.6;
      -webkit-font-smoothing: antialiased;
    }
    
    .card { 
      background: var(--card-bg); 
      padding: 32px; 
      border-radius: var(--radius); 
      margin-bottom: 24px; 
      box-shadow: var(--shadow); 
      transition: var(--transition);
      border: 1px solid rgba(255, 255, 255, 0.5);
      backdrop-filter: blur(10px);
    }
    .card:hover {
      box-shadow: var(--shadow-hover);
      transform: translateY(-2px);
    }
    
    h1, h2 { 
      margin-top: 0; 
      font-weight: 600; 
      color: var(--text-main);
      margin-bottom: 20px;
      letter-spacing: -0.02em;
    }
    h1 { font-size: 28px; }
    h2 { font-size: 20px; }
    
    form { 
      display: grid; 
      grid-template-columns: repeat(4, minmax(180px, 1fr)); 
      gap: 20px; 
      align-items: end; 
    }
    
    label { 
      display: block; 
      font-size: 14px; 
      font-weight: 500;
      color: var(--text-muted); 
      margin-bottom: 8px; 
    }
    
    input, textarea, select { 
      width: 100%; 
      padding: 12px 14px; 
      box-sizing: border-box; 
      border: 1px solid var(--border-color);
      border-radius: 10px;
      font-family: inherit;
      font-size: 14px;
      transition: var(--transition);
      background: #f9fafb;
      color: var(--text-main);
    }
    input:focus, textarea:focus, select:focus {
      outline: none;
      border-color: var(--primary);
      box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
      background: #ffffff;
    }
    
    textarea { 
      min-height: 80px; 
      resize: vertical;
    }
    
    button { 
      cursor: pointer; 
      background: linear-gradient(135deg, var(--primary), #6366f1); 
      color: #ffffff; 
      border: none; 
      border-radius: 10px; 
      padding: 12px 20px;
      font-size: 14px;
      font-weight: 600;
      transition: var(--transition);
      display: inline-flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
    }
    button:hover {
      background: linear-gradient(135deg, var(--primary-hover), var(--primary));
      transform: translateY(-1px);
      box-shadow: 0 6px 8px -1px rgba(79, 70, 229, 0.4);
    }
    button:disabled {
      background: #9ca3af;
      box-shadow: none;
      cursor: not-allowed;
      transform: none;
    }
    
    table { 
      width: 100%; 
      border-collapse: separate; 
      border-spacing: 0;
      font-size: 14px; 
    }
    th, td { 
      border-bottom: 1px solid var(--border-color); 
      padding: 16px 12px; 
      text-align: left; 
    }
    th {
      font-weight: 600;
      color: var(--text-muted);
      background: #f9fafb;
      text-transform: uppercase;
      font-size: 12px;
      letter-spacing: 0.05em;
    }
    th:first-child { border-top-left-radius: 10px; }
    th:last-child { border-top-right-radius: 10px; }
    
    tbody tr {
      transition: var(--transition);
    }
    tbody tr:hover {
      background: #f9fafb;
    }
    
    .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
    .muted { color: var(--text-muted); font-size: 14px; }
    .ok { color: var(--success); font-weight: 500; }
    .mono { font-family: 'Menlo', 'Monaco', 'Courier New', monospace; font-size: 13px; color: #4b5563; }
    
    .progress-wrap { 
      margin-top: 24px; 
      background: #f9fafb;
      padding: 20px;
      border-radius: 12px;
      border: 1px solid var(--border-color);
    }
    .progress-bar { 
      width: 100%; 
      height: 14px; 
      background: #e5e7eb; 
      border-radius: 999px; 
      overflow: hidden; 
      margin: 16px 0;
      box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    }
    .progress-fill { 
      height: 100%; 
      width: 0%; 
      background: linear-gradient(90deg, var(--primary), var(--success)); 
      transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
      border-radius: 999px;
    }
    .hidden { display: none; }
    
    .pagination {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-top: 24px;
      margin-bottom: -8px;
    }
    .page-btn {
      padding: 6px 12px;
      font-size: 13px;
      background: #f9fafb;
      color: var(--text-main);
      box-shadow: none;
      border: 1px solid var(--border-color);
      border-radius: 6px;
    }
    .page-btn:hover:not(:disabled) {
      background: #e5e7eb;
      transform: none;
      box-shadow: none;
      color: var(--text-main);
    }
    .page-info {
      font-size: 13px;
      color: var(--text-muted);
    }
    
    /* Modal Styles */
    .modal-overlay {
      position: fixed;
      top: 0; left: 0; right: 0; bottom: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.3s ease;
    }
    .modal-overlay.active {
      opacity: 1;
      pointer-events: auto;
    }
    .modal-content {
      background: #fff;
      border-radius: 16px;
      width: 90%;
      max-width: 800px;
      padding: 24px;
      box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
      transform: translateY(20px);
      transition: transform 0.3s ease;
    }
    .modal-overlay.active .modal-content {
      transform: translateY(0);
    }
    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
    }
    .modal-close {
      cursor: pointer;
      color: var(--text-muted);
      border: none;
      background: none;
      font-size: 24px;
      line-height: 1;
      padding: 0;
    }
    .chart-tabs {
      display: flex;
      gap: 12px;
      margin-bottom: 16px;
      background: var(--bg-color);
      padding: 4px;
      border-radius: 8px;
      width: fit-content;
    }
    .chart-tab {
      padding: 6px 16px;
      border-radius: 6px;
      cursor: pointer;
      font-size: 14px;
      font-weight: 500;
      transition: all 0.2s;
    }
    .chart-tab.active {
      background: #fff;
      box-shadow: 0 1px 3px rgba(0,0,0,0.1);
      color: var(--primary);
    }
/* Loading Spinner */
.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: var(--primary);
  animation: spin 1s linear infinite;
  margin: 0 auto 16px auto;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.loading-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 300px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.stat-title {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.stat-subtitle {
  font-size: 12px;
  color: #888;
  margin-top: 6px;
}

.stat-highlight {
  color: var(--danger-color);
}
.stat-highlight.profit {
  color: var(--danger-color); /* Red for profit in CN */
}
.stat-highlight.loss {
  color: var(--success-color); /* Green for loss in CN */
}

/* Make the last card span wider or just fit in grid */
.stat-card.chart-card {
  padding: 10px;
  display: block;
}

@media (max-width: 1200px) {
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
