/* ============================================================
   AIOB量化管理系统 - 主样式
   深色主题 / 紫色渐变主色
   ============================================================ */

/* ── CSS 变量 ── */
:root {
  --primary:        #667eea;
  --primary-dark:   #764ba2;
  --primary-light:  rgba(102,126,234,0.12);
  --primary-grad:   linear-gradient(135deg, #667eea 0%, #764ba2 100%);

  --bg-base:        #0f1117;
  --bg-card:        #1a1d27;
  --bg-card-hover:  #1e2130;
  --bg-input:       #252836;
  --bg-sidebar:     #13151f;
  --bg-topbar:      #1a1d27;

  --border:         rgba(255,255,255,0.07);
  --border-light:   rgba(255,255,255,0.04);

  --text-primary:   #e8eaf0;
  --text-secondary: #8b90a0;
  --text-muted:     #555a6e;

  --green:   #34d399;
  --red:     #f87171;
  --yellow:  #fbbf24;
  --blue:    #60a5fa;
  --orange:  #fb923c;

  --sidebar-width:      220px;
  --sidebar-width-mini: 64px;
  --topbar-height:      56px;
  --radius:             10px;
  --radius-sm:          6px;
  --radius-lg:          14px;
  --shadow:             0 4px 20px rgba(0,0,0,0.35);
  --shadow-sm:          0 2px 8px rgba(0,0,0,0.25);

  --transition: 0.18s ease;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-size: 14px; }
body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Segoe UI', sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,0.15);
}
table { border-collapse: collapse; width: 100%; }

/* ── 布局 ── */
.layout {
  display: flex;
  min-height: 100vh;
}
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* ── 顶部栏 ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-toggle {
  background: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: none;
}
.topbar-toggle:hover { background: var(--primary-light); color: var(--primary); }
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--primary-light); }
.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-grad);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.topbar-username { font-size: 13px; font-weight: 500; }
.topbar-role {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 20px;
}

/* ── 页面标题行 ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-title i { color: var(--primary); }

/* ── 卡片 ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-light);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-title i { color: var(--primary); font-size: 15px; }

/* ── KPI 网格 ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.kpi-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-sm);
}
.kpi-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.kpi-icon.purple { background: rgba(102,126,234,0.15); color: var(--primary); }
.kpi-icon.green  { background: rgba(52,211,153,0.15);  color: var(--green); }
.kpi-icon.red    { background: rgba(248,113,113,0.15);  color: var(--red); }
.kpi-icon.yellow { background: rgba(251,191,36,0.15);   color: var(--yellow); }
.kpi-icon.blue   { background: rgba(96,165,250,0.15);   color: var(--blue); }
.kpi-icon.orange { background: rgba(251,146,60,0.15);   color: var(--orange); }
.kpi-body { flex: 1; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.kpi-value.green  { color: var(--green); }
.kpi-value.red    { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: var(--primary-grad);
  color: #fff;
  border: none;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger {
  background: rgba(248,113,113,0.12);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.3);
}
.btn-danger:hover { background: rgba(248,113,113,0.2); }
.btn-success {
  background: rgba(52,211,153,0.12);
  color: var(--green);
  border: 1px solid rgba(52,211,153,0.3);
}
.btn-success:hover { background: rgba(52,211,153,0.2); }
.btn-warning {
  background: rgba(251,191,36,0.12);
  color: var(--yellow);
  border: 1px solid rgba(251,191,36,0.3);
}
.btn-warning:hover { background: rgba(251,191,36,0.2); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── 表格 ── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.table-scroll { overflow-x: auto; }
.data-table {
  width: 100%;
  font-size: 13px;
}
.data-table thead th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(255,255,255,0.02); }
.table-empty {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 13px;
}
.table-empty i { font-size: 32px; display: block; margin-bottom: 12px; opacity: 0.4; }

/* ── 分页 ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}
.pagination-info { color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary-grad); color: #fff; border-color: transparent; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── 搜索 / 筛选 ── */
.search-input {
  padding: 7px 12px;
  min-width: 200px;
  font-size: 13px;
}
.filter-select { padding: 7px 12px; font-size: 13px; }
.date-input { padding: 7px 12px; font-size: 13px; }

/* ── 徽章/标签 ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green   { background: rgba(52,211,153,0.12);  color: var(--green);  border: 1px solid rgba(52,211,153,0.25);  }
.badge-red     { background: rgba(248,113,113,0.12); color: var(--red);    border: 1px solid rgba(248,113,113,0.25); }
.badge-yellow  { background: rgba(251,191,36,0.12);  color: var(--yellow); border: 1px solid rgba(251,191,36,0.25);  }
.badge-blue    { background: rgba(96,165,250,0.12);  color: var(--blue);   border: 1px solid rgba(96,165,250,0.25);  }
.badge-gray    { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.badge-purple  { background: var(--primary-light);   color: var(--primary); border: 1px solid rgba(102,126,234,0.3); }

/* 在线状态指示灯 */
.online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: blink 2s infinite;
}
.offline-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* ── 表单 ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* ── 模态框 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  background: none;
  color: var(--text-muted);
  font-size: 18px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-input); color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Toast 通知 ── */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 380px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  pointer-events: auto;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  font-size: 13px;
}
.toast.show { transform: translateX(0); }
.toast.toast-success { border-left: 3px solid var(--green); }
.toast.toast-error   { border-left: 3px solid var(--red); }
.toast.toast-warning { border-left: 3px solid var(--yellow); }
.toast.toast-info    { border-left: 3px solid var(--primary); }
.toast i { font-size: 16px; flex-shrink: 0; }
.toast-success i { color: var(--green); }
.toast-error   i { color: var(--red); }
.toast-warning i { color: var(--yellow); }
.toast-info    i { color: var(--primary); }

/* ── 抽屉（详情侧滑） ── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  opacity: 0; visibility: hidden;
  transition: all var(--transition);
}
.drawer-overlay.show { opacity: 1; visibility: visible; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 40px rgba(0,0,0,0.4);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 901;
}
.drawer-overlay.show .drawer { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title { font-size: 15px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ── 盈亏颜色 ── */
.profit-pos { color: var(--green); font-weight: 600; }
.profit-neg { color: var(--red); font-weight: 600; }
.profit-zero { color: var(--text-muted); }

/* ── 工具类 ── */
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-sm       { font-size: 12px; }
.text-xs       { font-size: 11px; }
.fw-600        { font-weight: 600; }
.fw-700        { font-weight: 700; }
.mono          { font-family: 'Courier New', monospace; font-size: 12px; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.mt-4          { margin-top: 4px; }
.mt-8          { margin-top: 8px; }
.mt-16         { margin-top: 16px; }
.mb-16         { margin-bottom: 16px; }
.w-100         { width: 100%; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 动画 ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinning { animation: spin 1s linear infinite; }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── 响应式 ── */
@media (max-width: 768px) {
  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-row { flex-direction: column; }
  .drawer { width: 100%; }
}
