:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --ink: #171716;
  --muted: #6f716d;
  --line: #dedbd2;
  --soft-line: #ece8de;
  --sidebar: #121619;
  --sidebar-soft: #1b2227;
  --gold: #bd8b33;
  --gold-soft: #fff4dc;
  --buy-blue: #1e90ff;
  --green: #16835f;
  --red: #ff0000;
  --amber: #ab7b25;
  --shadow: 0 20px 60px rgba(27, 24, 17, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 22px;
  color: #f5f0e7;
  background: linear-gradient(180deg, var(--sidebar) 0%, #0e1214 100%);
  border-right: 1px solid rgba(189, 139, 51, 0.28);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 82px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 58px;
  color: var(--gold);
}

.brand-mark svg,
.upload-icon svg,
.shield-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1.08rem;
}

.brand span {
  color: #d9b76c;
  font-size: 0.92rem;
  font-weight: 700;
}

.steps {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 14px;
  align-items: center;
  color: #d9dfdf;
  text-decoration: none;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.step-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #d4dce0;
  color: #111;
  font-weight: 800;
}

.step.is-active .step-index {
  background: var(--gold);
}

.step.is-active strong {
  color: #fff;
}

.step.is-active small {
  color: #f1d898;
}

.step strong,
.step small {
  display: block;
}

.step strong {
  color: #fff7e7;
}

.step small {
  margin-top: 4px;
  color: #aeb8b8;
}

.workspace {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.workspace span,
.workspace strong {
  display: block;
}

.workspace span {
  color: #aeb8b8;
  font-size: 0.8rem;
}

.workspace strong {
  margin-top: 6px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.topbar h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 3vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.topbar p {
  max-width: 720px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.status-pill {
  flex: 0 0 auto;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.environment-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 0;
  padding: 16px 18px;
  background: var(--gold-soft);
  border: 1px solid #e6c17a;
  border-radius: 8px;
  color: var(--ink);
}

.environment-banner[hidden] {
  display: none;
}

.environment-banner strong,
.environment-banner span {
  display: block;
}

.environment-banner span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.environment-banner a {
  flex: 0 0 auto;
  padding: 10px 14px;
  border: 1px solid var(--gold);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intake-panel,
.plan-panel {
  padding: 22px;
}

.right-rail {
  display: grid;
  gap: 18px;
}

.control-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading.compact {
  align-items: center;
}

.section-heading h2,
.detail-card h3 {
  margin: 0;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.86rem;
}

.shield-icon {
  width: 28px;
  height: 28px;
  color: var(--gold);
}

.dropzone {
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 22px;
  border: 2px dashed #aaa79f;
  border-radius: var(--radius);
  color: var(--muted);
  background: linear-gradient(180deg, #ffffff 0%, #fbfaf6 100%);
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.dropzone.is-dragging {
  border-color: var(--gold);
  background: var(--gold-soft);
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 58px;
  height: 58px;
  color: #333a40;
}

.dropzone strong {
  color: var(--ink);
  font-size: 1.08rem;
}

.upload-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
  color: var(--muted);
}

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

.ghost-button {
  min-height: 38px;
  padding: 0 13px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 800;
}

.ghost-button:hover {
  border-color: var(--gold);
}

.full-width {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
}

.ai-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ai-actions .ghost-button {
  width: 100%;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.chart-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.chart-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-bottom: 1px solid var(--soft-line);
}

.chart-card footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.field span {
  color: #383b3c;
  font-size: 0.88rem;
  font-weight: 750;
}

.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid #d1cec5;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(189, 139, 51, 0.12);
}

.range-field input {
  min-height: auto;
  padding: 0;
  accent-color: var(--gold);
}

.field strong {
  float: right;
  color: var(--ink);
}

.rule-box {
  display: grid;
  gap: 4px;
  margin: 18px 0;
  padding: 14px;
  background: var(--gold-soft);
  border: 1px solid #e2c78d;
  border-radius: var(--radius);
}

.rule-box span {
  color: var(--muted);
  font-size: 0.86rem;
}

.skill-insight {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
}

.skill-insight div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.skill-insight span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.skill-insight strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.skill-insight p {
  margin: 0;
  color: #3b3d3b;
  font-size: 0.88rem;
  line-height: 1.55;
}

.skill-insight ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  background: linear-gradient(180deg, #c79a46 0%, #a97828 100%);
  border: 1px solid #a97828;
  border-radius: 6px;
  color: #fff;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(169, 120, 40, 0.22);
}

.primary-button:disabled {
  cursor: not-allowed;
  color: #9a9a96;
  background: #e7e2d9;
  border-color: #d6d0c3;
  box-shadow: none;
}

.run-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.45;
}

.run-status[data-tone="busy"] {
  color: var(--gold);
}

.run-status[data-tone="success"] {
  color: #1f7a4d;
}

.run-status[data-tone="error"] {
  color: #b64242;
}

.plan-panel {
  margin-top: 18px;
}

.journal-panel {
  margin-top: 18px;
  padding: 22px;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1.5fr;
  gap: 12px;
}

.signal-card,
.metric-card,
.price-table,
.detail-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.signal-card,
.metric-card {
  display: grid;
  align-content: center;
  min-height: 154px;
  padding: 18px;
  text-align: center;
}

.signal-card span,
.metric-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.signal-card strong,
.metric-card strong {
  margin: 10px 0 6px;
  font-size: 2rem;
}

.signal-card small,
.metric-card small {
  color: var(--muted);
}

.signal-card.is-buy strong,
.metric-card.is-pass strong {
  color: var(--buy-blue);
}

.signal-card.is-sell strong,
.metric-card.is-fail strong {
  color: var(--red);
}

.signal-card.is-wait strong,
.metric-card.is-warn strong {
  color: var(--amber);
}

.price-table {
  overflow: hidden;
}

.price-table div {
  display: grid;
  grid-template-columns: 1fr 1fr 0.8fr;
  gap: 10px;
  min-height: 38px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--soft-line);
}

.price-table div:last-child {
  border-bottom: 0;
}

.price-table span {
  color: var(--muted);
  font-size: 0.86rem;
}

.price-table strong {
  font-variant-numeric: tabular-nums;
}

.price-table small {
  color: var(--muted);
  text-align: right;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.detail-card {
  padding: 18px;
}

.detail-card ul {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.detail-card li {
  position: relative;
  padding-left: 24px;
  color: #2d3431;
}

.detail-card li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.25rem;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--green);
}

.invalidation-card {
  border-left: 4px solid var(--gold);
}

.invalidation-card p {
  margin: 14px 0 0;
  color: #3d3c38;
  line-height: 1.65;
}

.journal-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.journal-stats article {
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.journal-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.journal-stats strong {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
  font-variant-numeric: tabular-nums;
}

.journal-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  background: #fbfaf6;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
}

.journal-form .field {
  margin-top: 0;
}

.wide-field {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  align-items: end;
}

.journal-table-wrap {
  overflow-x: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.journal-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.journal-table th,
.journal-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.journal-table th {
  background: #f4f1ea;
  color: #343331;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.journal-table tr:last-child td {
  border-bottom: 0;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 850;
  font-size: 0.78rem;
}

.result-win {
  color: #0f6d4f;
  background: #e4f6ef;
}

.result-loss {
  color: #b10000;
  background: #ffe7e7;
}

.result-be,
.result-pending {
  color: #7c5a19;
  background: #fff4dc;
}

.delete-log {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.delete-log:hover {
  color: var(--red);
}

.empty-row {
  color: var(--muted);
  text-align: center !important;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .steps {
    grid-template-columns: repeat(4, 1fr);
  }

  .content-grid,
  .plan-grid,
  .detail-grid,
  .journal-stats {
    grid-template-columns: 1fr;
  }

  .right-rail {
    grid-template-columns: 1fr 1fr;
  }

  .journal-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .upload-summary {
    flex-direction: column;
  }

  .inline-actions,
  .inline-actions .ghost-button {
    width: 100%;
  }

  .steps,
  .right-rail,
  .chart-grid,
  .journal-form {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }

  .topbar h1 {
    font-size: 2rem;
  }

  .dropzone {
    min-height: 160px;
  }
}
