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

:root {
  --accent: #FF7A3D;
  --accent-soft: #FFF4EE;
  --accent-mid: #FFE0CC;
  --accent-dark: #E65A1F;
  --text-dark: #1C1917;
  --text-mid: #57534E;
  --text-light: #A8A29E;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --white: #FFFFFF;
  --green: #16A34A;
  --green-soft: #F0FDF4;
  --yellow: #F59E0B;
  --yellow-soft: #FFFBEB;
  --red: #DC2626;
  --red-soft: #FEF2F2;
  --blue: #3B82F6;
  --blue-soft: #EFF6FF;
  --purple: #8B5CF6;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  min-height: 100vh;
  padding: 20px 16px 40px;
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* === Layout === */
.wrapper {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* === Header === */
.header {
  text-align: center;
  margin-bottom: 4px;
  animation: rise 0.4s ease both;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(255, 122, 61, 0.3);
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.sub-label { font-size: 13px; color: var(--text-light); }

/* === Cards === */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  animation: rise 0.4s ease both;
  box-shadow: var(--shadow-sm);
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.20s; }
.card:nth-child(5) { animation-delay: 0.25s; }

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}

/* === Form === */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.form-row:last-of-type { border-bottom: none; }
.form-row label {
  font-weight: 500;
  font-size: 15px;
}
.input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-group input[type=number] {
  width: 76px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  text-align: right;
  font-size: 15px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s;
  background: var(--white);
}
.input-group input[type=number]:focus {
  border-color: var(--accent);
}
.input-group .percent {
  color: var(--text-mid);
  font-size: 14px;
  font-weight: 500;
}

.sum-line {
  display: flex;
  justify-content: space-between;
  padding: 14px 0 0;
  margin-top: 4px;
  font-weight: 600;
  font-size: 14px;
  border-top: 2px solid var(--border);
}
.sum-ok { color: var(--green); }
.sum-bad { color: var(--red); }

/* === Upload zone === */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: block;
}
.upload-zone:hover,
.upload-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.upload-zone.has-file {
  border-color: var(--accent);
  background: var(--accent-soft);
  border-style: solid;
}
.upload-zone .icon { font-size: 40px; margin-bottom: 10px; }
.upload-zone .main-text {
  font-size: 15px;
  font-weight: 500;
}
.upload-zone .hint {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 6px;
}

/* === Buttons === */
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: all 0.15s;
  box-shadow: 0 4px 12px rgba(255, 122, 61, 0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255, 122, 61, 0.35); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--white);
  color: var(--text-dark);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-mid);
}
.loading .spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border: 4px solid var(--accent-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading .main {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 6px;
}

/* === Hero card (总资产 + 健康状态) === */
.hero {
  background: linear-gradient(180deg, var(--white) 0%, var(--bg-alt) 100%);
}
.hero-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-left .sub-label { margin-bottom: 4px; }
.hero-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.hero-period {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.healthy { background: var(--green-soft); color: var(--green); }
.status-pill.drifting { background: var(--yellow-soft); color: var(--yellow); }
.status-pill.triggered { background: var(--red-soft); color: var(--red); }

/* === Bucket comparison bars === */
.bucket-compare {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.bucket-row-v2 {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bucket-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.bucket-header .name {
  font-weight: 600;
  font-size: 14px;
}
.bucket-header .status-note {
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 500;
}
.status-note.status-healthy { color: var(--green); }
.status-note.status-warning { color: var(--yellow); }
.status-note.status-alert { color: var(--red); }

.bar-container {
  position: relative;
  height: 32px;
  background: var(--bg-alt);
  border-radius: 8px;
  overflow: visible;
}
.bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  transition: width 0.6s ease-out;
  white-space: nowrap;
  overflow: hidden;
}
.bar-fill.growth { background: linear-gradient(90deg, #FF7A3D 0%, #E65A1F 100%); }
.bar-fill.stable { background: linear-gradient(90deg, #3B82F6 0%, #1E40AF 100%); }

.target-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  background: var(--text-dark);
  border-radius: 1.5px;
  transition: left 0.6s ease-out;
}
.target-marker::before {
  content: '目标';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-dark);
  font-weight: 600;
  background: var(--white);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
}

/* === Action cards === */
.actions-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.action-card {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  gap: 14px;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}
.action-card:hover { border-color: var(--border-strong); }
.action-num {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.action-label {
  font-size: 12px;
  color: var(--text-mid);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}
.action-ticker {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}
.action-amount {
  font-size: 13px;
  color: var(--text-mid);
  margin-top: 2px;
}

.when-note {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--blue-soft);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-dark);
  border-left: 3px solid var(--blue);
}

/* === Monte Carlo projection === */
.projection-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.projection-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.projection-horizon {
  font-size: 12px;
  color: var(--text-light);
}
.projection-chart-wrap {
  position: relative;
  height: 220px;
  margin: 0 -6px 16px;
}
.projection-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
.proj-stat {
  padding: 14px 16px;
  background: var(--bg-alt);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.proj-stat.better {
  background: var(--green-soft);
  border-color: #BBF7D0;
}
.proj-stat-label {
  font-size: 11px;
  color: var(--text-mid);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.proj-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.01em;
}
.proj-stat-delta {
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 4px;
}
.proj-stat-delta.green { color: var(--green); font-weight: 600; }

.proj-note {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 16px;
  text-align: center;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* === Errors === */
.error-box {
  background: var(--red-soft);
  border: 1px solid #FECACA;
  color: var(--red);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  animation: rise 0.3s ease both;
}

/* === Utility === */
.hidden { display: none !important; }

/* === Responsive === */
@media (max-width: 520px) {
  body { padding: 16px 12px 40px; }
  .card { padding: 20px; }
  .hero-value { font-size: 32px; }
  .projection-summary { grid-template-columns: 1fr; }
  .hero-row { flex-direction: column; align-items: stretch; }
  .status-pill { align-self: flex-start; }
}
