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

:root {
  --bg: #0d1117;
  --card: #161b22;
  --border: #21262d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --red: #f85149;
  --green: #3fb950;
  --blue: #58a6ff;
  --yellow: #d29922;
  --hover: #1c2128;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
}

.header .back {
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
}

.tabs {
  display: flex;
  gap: 24px;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tabs a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 15px;
  padding-bottom: 8px;
  position: relative;
}

.tabs a.active {
  color: var(--text);
  font-weight: 500;
}

.tabs a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--yellow);
  border-radius: 1px;
}

/* 今日盈亏大数字 */
.today-section {
  margin-bottom: 24px;
}

.today-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.today-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.today-value.negative { color: var(--red); }
.today-value.positive { color: var(--green); }

.today-usd {
  font-size: 14px;
  color: var(--text-muted);
  margin-left: 8px;
  font-weight: 400;
}

/* 三列统计 */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 28px;
}

.stat-item {
  text-align: left;
}

.stat-item .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-item .value {
  font-size: 15px;
  font-weight: 600;
}

.stat-item .value.negative { color: var(--red); }
.stat-item .value.positive { color: var(--green); }

.stat-item .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 时间范围切换 */
.period-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.period-tabs button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.period-tabs button.active {
  background: var(--card);
  border-color: var(--text-muted);
  color: var(--text);
}

/* 汇总卡片 */
.summary-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row .label {
  color: var(--text-muted);
  font-size: 14px;
}

.summary-row .value {
  font-weight: 500;
  font-size: 14px;
}

.summary-row .value.negative { color: var(--red); }
.summary-row .value.positive { color: var(--green); }

/* 日历 */
.calendar-section {
  margin-bottom: 28px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.calendar-header h3 {
  font-size: 15px;
  font-weight: 500;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.month-nav button {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-cell {
  aspect-ratio: 1;
  background: var(--card);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1px solid transparent;
  cursor: default;
  position: relative;
}

.day-cell.empty {
  background: transparent;
}

.day-cell .day-num {
  color: var(--text-muted);
  margin-bottom: 2px;
}

.day-cell.has-data .day-num {
  color: var(--text);
}

.day-cell .day-pnl {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.1;
}

.day-cell .day-pnl.negative { color: var(--red); }
.day-cell .day-pnl.positive { color: var(--green); }

.day-cell.today {
  border-color: var(--yellow);
}

/* 图表区域 */
.chart-section {
  margin-bottom: 28px;
}

.chart-section h3 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.chart-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chart-value {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.chart-value.negative { color: var(--red); }
.chart-value.positive { color: var(--green); }

.chart-container {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  height: 180px;
  position: relative;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* 资产概览 */
.asset-section {
  margin-bottom: 28px;
}

.asset-section h3 {
  font-size: 15px;
  margin-bottom: 16px;
}

.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0% 100%);
  position: relative;
  margin-bottom: 12px;
}

.donut::after {
  content: '';
  position: absolute;
  inset: 28px;
  background: var(--bg);
  border-radius: 50%;
}

.asset-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--card);
  padding: 6px 12px;
  border-radius: 20px;
}

.asset-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}

/* 底部导航提示 */
.footer-note {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
  line-height: 1.6;
}

/* 管理后台样式 */
.admin-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
}

.admin-container h1 {
  font-size: 22px;
  margin-bottom: 24px;
}

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.form-card h2 {
  font-size: 16px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--blue);
}

.btn {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.btn-danger {
  background: var(--red);
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-weight: 500;
}

td.negative { color: var(--red); }
td.positive { color: var(--green); }

.actions {
  display: flex;
  gap: 8px;
}

.msg {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  display: none;
}

.msg.success {
  background: rgba(63, 185, 80, 0.15);
  color: var(--green);
  display: block;
}

.msg.error {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red);
  display: block;
}

/* 响应式 */
@media (min-width: 640px) {
  .container {
    max-width: 560px;
  }
}
/* 预设未生效的日期 */
.day-cell.preset {
  opacity: 0.55;
  border: 1px dashed var(--text-muted);
}

.day-cell.preset .day-pnl {
  font-style: italic;
}

.preset-tag {
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 9px;
  color: var(--yellow);
  background: rgba(210, 153, 34, 0.2);
  padding: 0 3px;
  border-radius: 3px;
  line-height: 1.3;
}
