@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('./fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('./fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

:root {
  --bg-body: #0c0e14;
  --bg-surface: #141720;
  --bg-card: #1b1f2e;
  --bg-elevated: #242938;
  --bg-input: #1b1f2e;
  --text-primary: #f0f2f5;
  --text-secondary: #8b92a5;
  --text-muted: #565d72;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.5);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 24px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
}

/* 标题栏 */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.update-time {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--bg-elevated);
  border-radius: 20px;
}

/* 按钮 */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

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

.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* 汇总栏 */
.summary-bar {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 28px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-item .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.summary-item .value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

.summary-item .value.profit { color: var(--green); }
.summary-item .value.loss { color: var(--red); }

.summary-divider {
  width: 1px;
  height: 28px;
  background: var(--border-hover);
}

/* 饼图区域 */
.chart-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 28px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.chart-svg-wrap {
  position: relative;
  flex-shrink: 0;
}

.chart-center-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.chart-center-label .chart-total-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chart-center-label .chart-total-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px 20px;
  flex: 1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-label {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
}

.legend-pct {
  color: var(--text-muted);
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* 添加表单 */
.add-form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.add-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 110px;
}

.form-group label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* 表格 */
.table-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

th {
  background: var(--bg-surface);
  padding: 12px 14px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

th:first-child, th:nth-child(2) { text-align: left; }

td {
  padding: 12px 14px;
  text-align: right;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

td:first-child, td:nth-child(2) { text-align: left; }

tbody tr { transition: background var(--transition); }
tbody tr:hover td { background: rgba(99, 102, 241, 0.03); }
tbody tr:last-child td { border-bottom: none; }

tr[draggable="true"] { cursor: grab; }
tr[draggable="true"]:active { cursor: grabbing; }
tr.dragging { opacity: 0.35; }
tr.drag-over td { box-shadow: inset 0 2px 0 var(--accent); }

.profit-text { color: var(--green); }
.loss-text { color: var(--red); }

.symbol-cell {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.symbol-tag {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}

.drag-handle {
  color: var(--text-muted);
  font-size: 12px;
  opacity: 0.5;
  transition: opacity var(--transition);
}

tr:hover .drag-handle { opacity: 1; }

.actions-cell {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* 编辑行内输入 */
.inline-input {
  width: 90px;
  padding: 4px 8px;
  background: var(--bg-input);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
  outline: none;
  text-align: right;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state p {
  font-size: 13px;
}

/* Toast 通知 */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 340px;
  backdrop-filter: blur(8px);
}

.toast.success { background: rgba(16, 185, 129, 0.9); }
.toast.error { background: rgba(239, 68, 68, 0.9); }
.toast.info { background: rgba(99, 102, 241, 0.9); }

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

@keyframes fadeOut {
  to { opacity: 0; transform: translateY(-8px); }
}

/* 确认对话框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  animation: fadeInOverlay 0.2s ease;
}

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

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 340px;
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h3 {
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
}

.modal p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Loading 指示器 */
.loading-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

/* 响应式 */
@media (max-width: 768px) {
  body { padding: 14px; }
  .header { flex-wrap: wrap; gap: 12px; }
  .summary-bar { gap: 16px; padding: 14px 18px; }
  .summary-item .value { font-size: 15px; }
  .summary-divider { display: none; }
  .chart-section { flex-direction: column; align-items: center; gap: 16px; }
  .chart-legend { justify-items: center; }
  .add-form { flex-direction: column; }
  .form-group { min-width: 100%; }
}
