:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #152033;
  --muted: #667085;
  --border: #d8dee9;
  --border-strong: #b8c0cc;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --positive: #0f9f6e;
  --negative: #d64545;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 28px;
  border-radius: 24px;
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
  color: white;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: #bfdbfe;
  text-transform: uppercase;
}

h1, h2 { margin: 0; }
h1 { font-size: 32px; }
.subtitle {
  max-width: 900px;
  margin: 12px 0 0;
  color: #e2e8f0;
  line-height: 1.7;
}

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
}
button:hover { filter: brightness(0.98); }
button.ghost {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.45);
}
.icon-btn {
  padding: 6px 10px;
  font-size: 12px;
  background: #fff;
  color: #334155;
  border-color: var(--border);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  min-height: 128px;
}
.kpi.primary { border-color: #93c5fd; background: linear-gradient(180deg, #eff6ff, #ffffff); }
.kpi span { display: block; color: var(--muted); font-size: 14px; }
.kpi strong { display: block; margin: 10px 0 8px; font-size: 30px; letter-spacing: -0.02em; }
.kpi small { color: var(--muted); line-height: 1.5; }

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.layout.wide-left { grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr); }

.panel, .notes {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.panel-title h2 { font-size: 18px; }
.panel-title span { color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel-title.with-actions { align-items: center; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.form-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(92px, 120px) 18px;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}
.field span { font-size: 13px; color: #344054; }
.field em { font-style: normal; color: var(--muted); font-size: 12px; }
input, select {
  width: 100%;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 4px 8px;
  font: inherit;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--border); padding: 9px 10px; text-align: left; vertical-align: middle; }
th { background: #f1f5f9; color: #344054; font-weight: 800; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.entry-table th:nth-child(1) { min-width: 180px; }
.entry-table th:nth-child(2) { min-width: 110px; }
.entry-table th:nth-child(4) { min-width: 260px; }
.convert-cell { color: #475569; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.summary-item {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 66px;
}
.summary-item span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.summary-item strong { font-size: 17px; }

.gain, .positive { color: var(--positive); }
.negative { color: var(--negative); }
.details-table td:nth-child(3) { color: #475569; }
.notes { color: #344054; line-height: 1.8; margin-bottom: 36px; }
.notes h2 { font-size: 18px; margin-bottom: 8px; }
.notes p { margin: 8px 0; }
.muted { color: var(--muted); }

@media (max-width: 1100px) {
  .dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout, .layout.wide-left { grid-template-columns: 1fr; }
  .hero { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 680px) {
  .app-shell { padding: 14px; }
  .dashboard { grid-template-columns: 1fr; }
  .form-grid, .form-grid.compact, .summary-grid { grid-template-columns: 1fr; }
  .field { grid-template-columns: 1fr; }
  .field em { display: none; }
}

.limit-warning {
  color: #b45309;
  font-weight: 700;
}

.entry-table input.limit-input {
  border-color: #f59e0b;
  background: #fffbeb;
}
