:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #6f7c89;
  --line: #dde3e8;
  --navy: #173b57;
  --navy-2: #225273;
  --gold: #d49b31;
  --green: #118567;
  --red: #cf4b4b;
  --blue: #2f72b7;
  --shadow: 0 10px 32px rgba(28, 47, 64, .08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #102f46;
  color: white;
  border-right: 1px solid rgba(255,255,255,.08);
}
.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  padding: 22px 20px 18px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #e1ad4b, #b47b1e);
  color: #fff;
  font-weight: 800;
  font-family: Georgia, serif;
  font-size: 24px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: .04em; }
.brand p { margin: 4px 0 0; color: #aebfca; font-size: 12px; }

.sidebar-tools { padding: 0 16px 14px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
}
.search-box input {
  width: 100%;
  padding: 10px 0;
  border: 0;
  outline: 0;
  color: white;
  background: transparent;
}
.search-box input::placeholder { color: #9db1bf; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.filter-row select {
  min-width: 0;
  color: #dce7ed;
  background: #19405c;
  border: 1px solid #2a5672;
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
}
.case-summary {
  display: flex;
  justify-content: space-between;
  padding: 10px 18px;
  color: #b9c9d3;
  font-size: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.case-list { overflow-y: auto; padding: 8px; }
.case-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 10px;
  color: #dce7ed;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
}
.case-item:hover { background: rgba(255,255,255,.07); }
.case-item.active { background: #fff; color: var(--ink); box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.ticket {
  font-family: Consolas, monospace;
  font-size: 12px;
  color: #91a8b7;
}
.case-item.active .ticket { color: var(--navy-2); }
.case-item strong { display: block; font-size: 13px; }
.case-item small { display: block; margin-top: 3px; color: #92a8b6; font-size: 11px; }
.case-item.active small { color: var(--muted); }
.pnl { font-weight: 700; font-size: 13px; }
.pnl.win { color: #4fcba1; }
.pnl.loss { color: #ff7d7d; }
.case-item.active .pnl.win { color: var(--green); }
.case-item.active .pnl.loss { color: var(--red); }
.review-dot {
  display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  margin-left: 5px; background: #d7a341;
}

.workspace { min-width: 0; padding: 24px 28px 42px; }
.topbar { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 18px; }
.eyebrow { color: var(--gold); text-transform: uppercase; font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.topbar h2 { margin: 5px 0 0; font-family: Georgia, "Microsoft YaHei", serif; font-size: 27px; font-weight: 600; }
.top-actions { display: flex; gap: 8px; }
.dataset-select {
  max-width: 210px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  background: white;
  color: var(--ink);
}
.ghost-button, .primary-button {
  border-radius: 9px;
  padding: 9px 14px;
  border: 1px solid var(--line);
}
.ghost-button { background: white; color: var(--ink); }
.primary-button { background: var(--navy); color: white; border-color: var(--navy); }
.ghost-button:hover { border-color: #aebbc5; }
.primary-button:hover { background: var(--navy-2); }

.import-dialog {
  width: min(620px, calc(100vw - 36px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(10, 30, 45, .28);
}
.import-dialog::backdrop { background: rgba(12, 29, 42, .55); backdrop-filter: blur(3px); }
.import-dialog form { padding: 24px; }
.import-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.import-heading h3 { margin: 0; font-size: 22px; }
.import-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.dialog-close {
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: #edf1f4; color: #52616d; font-size: 23px; line-height: 1;
}
.file-field { display: block; margin-top: 14px; color: #44515c; font-size: 13px; font-weight: 700; }
.file-field input {
  display: block; width: 100%; margin-top: 7px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: #fafbfc;
  font-weight: 400;
}
.import-status {
  margin-top: 18px; padding: 11px 13px; border-radius: 9px;
  background: #f1f5f7; color: var(--muted); font-size: 13px;
}
.import-status.working { background: #fff7e4; color: #8b6419; }
.import-status.success { background: #e8f7f1; color: #147054; }
.import-status.error { background: #fdecec; color: #a83535; }
.import-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

.metrics-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 14px; }
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 14px;
  box-shadow: 0 3px 14px rgba(30,45,60,.035);
}
.metric span { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; margin-top: 5px; font-size: 18px; font-family: Georgia, "Microsoft YaHei", serif; }
.metric strong.win { color: var(--green); }
.metric strong.loss { color: var(--red); }

.chart-card, .review-card, .insight-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
}
.chart-card { overflow: hidden; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.card-header.compact { padding: 16px 18px 12px; }
.card-header h3 { margin: 0; font-size: 15px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.chart-controls { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
.chart-controls select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.toggle { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.toggle input { display: none; }
.toggle input:not(:checked) + .dot { opacity: .25; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.speed9 { background: #d9822b; }
.speed24 { background: #3978b7; }
.speed48 { background: #8b5ca8; }
.canvas-wrap {
  position: relative;
  width: 100%;
  height: 720px;
  min-height: 720px;
  aspect-ratio: auto;
  background: #0d0f10;
}
#tradeChart { display: block; width: 100%; height: 100%; }
.chart-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  padding: 8px 10px;
  background: rgba(20,34,44,.92);
  color: white;
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.6;
  box-shadow: 0 7px 24px rgba(0,0,0,.22);
}

.lower-grid { display: grid; grid-template-columns: 1.12fr .88fr; gap: 14px; margin-top: 14px; }
.review-card, .insight-card { overflow: hidden; }
.review-card > textarea, .form-section { margin-left: 18px; margin-right: 18px; }
textarea {
  width: calc(100% - 36px);
  min-height: 112px;
  resize: vertical;
  padding: 12px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  line-height: 1.65;
}
textarea:focus, select:focus { border-color: #7095ad; box-shadow: 0 0 0 3px rgba(47,114,183,.09); }
.small-textarea { width: 100%; min-height: 85px; margin: 0 0 18px; }
.save-state { color: var(--green); font-size: 11px; }
.form-section { margin-top: 17px; }
.form-section h4 { margin: 0 0 9px; font-size: 12px; color: var(--muted); }
.tag-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: #52606d;
  font-size: 12px;
}
.tag-button.selected { color: white; background: var(--navy-2); border-color: var(--navy-2); }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-columns label { color: var(--muted); font-size: 12px; }
.two-columns select { width: 100%; margin-top: 6px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.form-section textarea { width: 100%; }
.narrative { padding: 16px 18px 6px; color: #40505d; line-height: 1.75; font-size: 13px; }
.narrative p { margin: 0 0 10px; }
.narrative strong { color: var(--ink); }
.excursion-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 12px 18px 18px; }
.excursion-box { padding: 12px; border-radius: 9px; background: #f6f8fa; border: 1px solid #e5eaee; }
.excursion-box span { color: var(--muted); font-size: 11px; }
.excursion-box strong { display: block; margin-top: 5px; font-size: 16px; }

@media (max-width: 1150px) {
  .app-shell { grid-template-columns: 280px minmax(0, 1fr); }
  .metrics-grid { grid-template-columns: repeat(3, 1fr); }
  .lower-grid { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: 350px; }
  .workspace { padding: 18px 12px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .chart-controls { flex-wrap: wrap; }
  .canvas-wrap {
    height: 380px;
    min-height: 380px;
    aspect-ratio: auto;
  }
}

.two-columns input {
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}
