@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0b0e14;
  --surface: #131722;
  --surface-2: #1a1f2e;
  --border: #262c3d;
  --border-soft: #1e2434;
  --text: #edeef3;
  --text-dim: #8a90a3;
  --text-faint: #565c70;
  --long: #34d399;
  --long-bg: rgba(52, 211, 153, 0.12);
  --short: #fb7185;
  --short-bg: rgba(251, 113, 133, 0.12);
  --primary: #6c8cff;
  --primary-bg: rgba(108, 140, 255, 0.14);
  --amber: #f2a93b;
  --radius: 14px;
  --radius-sm: 9px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Vazirmatn', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

h1, h2, h3 { margin: 0; font-family: 'Vazirmatn', sans-serif; }

.topbar {
  padding: 22px 24px 4px;
  max-width: 1180px;
  margin: 0 auto;
}
.topbar-title { display: flex; align-items: center; gap: 14px; }
.topbar-mark {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #34d3c7);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #0b0e14;
}
.topbar-title h1 { font-size: 19px; font-weight: 700; }
.topbar-title p { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px 60px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}
.form-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.result-col { min-width: 0; }
.result-sticky {
  position: sticky;
  top: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .result-sticky { position: static; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 18px 6px;
}
.card > .field:last-child,
.card > .field-grid:last-child { margin-bottom: 12px; }

.section-eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
  margin-bottom: 12px;
}
.section-eyebrow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-eyebrow-row .section-eyebrow { margin-bottom: 0; }
.section-eyebrow-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
  margin: 4px 0 8px;
}
.estimate-wrap {
  transition: opacity 0.15s;
  border-inline-start: 2px solid var(--border-soft);
  padding-inline-start: 12px;
}
.estimate-wrap.is-overridden { opacity: 0.4; }

.order-fees-grid {
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
  margin-top: 6px;
}
.order-fees-grid .field { margin-bottom: 0; }

.segmented {
  display: flex;
  gap: 6px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.segmented-neutral { margin-bottom: 14px; }
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 0;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--surface); color: var(--text); }
.seg-long.active { background: var(--long-bg); color: var(--long); }
.seg-short.active { background: var(--short-bg); color: var(--short); }
.segmented-neutral .seg-btn.active { background: var(--primary-bg); color: var(--primary); }

.field { margin-bottom: 14px; }
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.field-grid .field { margin-bottom: 0; }

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
}
.opt { color: var(--text-faint); font-weight: 400; }
.rate-tag {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-bg);
  border-radius: 5px;
  padding: 1px 6px;
  margin-inline-start: 4px;
}

input[type="text"], input:not([type]), input[type="file"], select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
input.manual { border-color: var(--amber); }
input::placeholder { color: var(--text-faint); }

.fee-with-currency {
  display: flex;
  gap: 8px;
  align-items: center;
}
.fee-with-currency input {
  flex: 1;
  min-width: 0;
}
.fee-with-currency select {
  width: auto;
  flex-shrink: 0;
  padding: 6px 8px;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}

.hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
}
.hint-manual { color: var(--amber); font-family: 'Vazirmatn', sans-serif; }

.conversion-hint {
  font-size: 11.5px;
  color: var(--primary);
  margin-top: 4px;
  font-family: 'JetBrains Mono', monospace;
  display: none;
}

.time-field { display: flex; gap: 8px; }
.time-field input { flex: 1; min-width: 0; }
.btn-icon {
  flex-shrink: 0;
  width: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
}
.btn-icon:hover { color: var(--text); border-color: var(--primary); }

.picker-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.picker-row select { flex: 1; min-width: 0; padding: 8px 6px; font-size: 13px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 2px 4px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.check-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}
.fee-converter { flex-wrap: wrap; }
.fee-converter select,
.fee-converter input { flex: 1 1 130px; min-width: 110px; font-size: 13px; padding: 9px 10px; }
.fee-converter button { flex: 0 0 auto; padding: 9px 14px; }

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 16px;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn-primary { background: var(--primary); color: #0b0e14; width: 100%; margin: 10px 0 14px; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); }
.btn-success { background: var(--long-bg) !important; color: var(--long) !important; }
.link-btn {
  background: none; border: none; color: var(--primary);
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.upload-card { border-color: var(--primary-bg); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 22px 12px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 10px;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-bg); }
.dropzone-icon { font-size: 22px; }
.dropzone-text { font-size: 13px; color: var(--text-dim); }
.dropzone-filename { font-size: 12.5px; color: var(--primary); font-family: 'JetBrains Mono', monospace; }
.ai-status { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; min-height: 16px; }
.ai-raw {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg);
  border: 1px solid var(--border-soft);
  padding: 10px;
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  display: none;
  margin-bottom: 12px;
  max-height: 200px;
  overflow: auto;
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding-top: 22px;
  text-align: center;
}
.hero-card::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--border);
  transition: background 0.25s;
}
.hero-card.is-profit::before { background: var(--long); }
.hero-card.is-loss::before { background: var(--short); }
.hero-label { font-size: 12px; color: var(--text-dim); font-weight: 600; margin-bottom: 8px; }
.hero-value {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  transition: color 0.25s;
}
.hero-card.is-profit .hero-value { color: var(--long); }
.hero-card.is-loss .hero-value { color: var(--short); }
.hero-pct {
  font-size: 13.5px;
  color: var(--text-dim);
  margin: 8px 0 20px;
  font-weight: 600;
}
.hero-card.is-profit .hero-pct { color: var(--long); }
.hero-card.is-loss .hero-pct { color: var(--short); }

@keyframes heroPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.045); }
  100% { transform: scale(1); }
}
.hero-value.pulse { animation: heroPulse 0.32s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .hero-value.pulse { animation: none; }
}

.stat-list { display: flex; flex-direction: column; margin-bottom: 4px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row .stat-label { color: var(--text-dim); }
.stat-row .stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-row.stat-total .stat-label,
.stat-row.stat-total .stat-value { color: var(--text); font-weight: 700; }
.stat-row.stat-highlight {
  background: var(--primary-bg);
  margin: 4px -18px;
  padding: 10px 18px;
  border-bottom: none;
  border-radius: 8px;
}
.stat-row.stat-highlight .stat-label,
.stat-row.stat-highlight .stat-value { color: var(--primary); font-weight: 600; }

textarea { resize: vertical; font-size: 13px; line-height: 1.7; margin-bottom: 12px; }

.picker-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-weight: 700;
  font-size: 16px;
  padding: 0 8px;
  user-select: none;
}