:root {
  --bg: #eef3f0;
  --paper: #ffffff;
  --paper-2: #f7faf8;
  --ink: #17211b;
  --muted: #6d7771;
  --line: #dfe8e2;
  --dark: #16251d;
  --green: #159461;
  --green-2: #e4f8ee;
  --yellow: #f3b23c;
  --yellow-2: #fff4db;
  --red: #d94c4c;
  --red-2: #ffe8e8;
  --blue: #3772ff;
  --shadow: 0 18px 45px rgba(23, 33, 27, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--tg-theme-bg-color, var(--bg));
  color: var(--tg-theme-text-color, var(--ink));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1;
}

.muted {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.status-badge {
  min-width: 74px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.status-badge.blocked {
  background: var(--red-2);
  color: var(--red);
}

.hero-card,
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 18px;
  margin-bottom: 14px;
  background: var(--dark);
  color: white;
}

.onboarding-card {
  box-shadow: none;
}

.onboarding-card.completed {
  border-color: #cfe8d8;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.steps button {
  display: grid;
  gap: 7px;
  min-height: 76px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
  color: var(--ink);
  text-align: left;
}

.steps b {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--dark);
  color: white;
  font-size: 12px;
}

.steps span {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.compact-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.hero-status {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.status-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--green-2);
  color: var(--green);
  font-size: 22px;
  font-weight: 950;
}

.status-icon.blocked {
  background: var(--red-2);
  color: var(--red);
}

.hero-status h2 {
  font-size: 22px;
  line-height: 1.1;
}

.hero-status p {
  margin-top: 5px;
  color: #d7e5dc;
  font-size: 13px;
}

.decision-strip {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.decision-strip span {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.decision-strip strong {
  font-size: 15px;
}

.decision-strip small {
  grid-column: 1 / -1;
  color: #d7e5dc;
  font-size: 12px;
  line-height: 1.35;
}

.primary {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  background: var(--dark);
  color: white;
  font-size: 15px;
  font-weight: 850;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.quick-actions button,
.tabs button,
.secondary-action,
.danger-action {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: white;
  color: var(--ink);
  font-weight: 760;
}

.hero-card .quick-actions button {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  border-color: rgba(255, 255, 255, 0.2);
}

.hero-card .primary {
  background: white;
  color: var(--dark);
}

.danger-action {
  border-color: #f0caca;
  color: var(--red);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  margin-bottom: 14px;
}

.tabs button {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
  border: 0;
}

.tabs button.active {
  background: var(--dark);
  color: white;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.next-action-card {
  border-color: #d7e0ff;
  background: #eef3ff;
  box-shadow: none;
}

.mode-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mode-panel article {
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.mode-panel span {
  display: block;
  margin-bottom: 8px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.mode-panel b {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 1.15;
}

.mode-panel small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.metrics article {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
}

.metrics span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  font-size: 25px;
  line-height: 1;
}

.card {
  padding: 15px;
  margin-bottom: 12px;
}

.risk-preview {
  background: var(--yellow-2);
  box-shadow: none;
}

.risk-preview.allowed {
  background: var(--green-2);
}

.risk-preview.blocked {
  background: var(--red-2);
}

.risk-preview p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 12px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 13px;
}

.section-title h3 {
  font-size: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 12px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips span {
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--green-2);
  color: var(--green);
  font-size: 12px;
  font-weight: 760;
}

.list.empty {
  color: var(--muted);
  font-size: 14px;
}

.trade-row,
.account-row,
.violation-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--paper-2);
  margin-bottom: 9px;
}

.review-result {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.action-title {
  margin-bottom: 7px;
  font-size: 20px;
  line-height: 1.12;
}

.action-text {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-bottom: 12px;
}

.report-grid article {
  min-height: 72px;
  padding: 11px;
  border-radius: 16px;
  background: var(--paper-2);
}

.coach-summary,
.tomorrow-rule {
  grid-column: 1 / -1;
  padding: 13px;
  border-radius: 18px;
}

.coach-summary {
  background: var(--dark);
  color: white;
}

.tomorrow-rule {
  background: var(--yellow-2);
  color: var(--ink);
}

.report-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.report-grid b {
  font-size: 17px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.coach-summary b,
.tomorrow-rule b {
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.coach-summary span {
  color: #a8ceb8;
}

.recommendations {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.recommendations p {
  padding: 10px;
  border-radius: 14px;
  background: var(--green-2);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.split-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.trade-row b,
.account-row b {
  display: block;
  margin-bottom: 3px;
}

.trade-row span,
.account-row span {
  color: var(--muted);
  font-size: 12px;
}

.account-mode-summary {
  box-shadow: none;
}

.account-mode-summary p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.account-details {
  margin-top: 6px;
  line-height: 1.35;
}

.prop-account-fields {
  display: grid;
  gap: 12px;
}

.prop-account-fields[hidden] {
  display: none;
}

.coach-dashboard {
  border-top: 4px solid var(--green);
}

.coach-dashboard h2 {
  margin-bottom: 14px;
  font-size: 20px;
  line-height: 1.3;
}

.coach-insights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 10px;
}

.coach-insights article,
.coach-rule {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
}

.coach-insights span,
.coach-rule span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.coach-insights b,
.coach-rule b {
  display: block;
  font-size: 14px;
  line-height: 1.4;
}

.coach-rule {
  margin-bottom: 12px;
  border-left: 4px solid var(--yellow);
  background: var(--yellow-2);
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.form {
  display: grid;
  gap: 12px;
}

.quick-ticket {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: var(--dark);
  color: white;
}

.quick-ticket div {
  min-width: 0;
}

.quick-ticket span {
  display: block;
  margin-bottom: 5px;
  color: #b9d4c5;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.quick-ticket b {
  display: block;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-block {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-2);
}

.section-title.compact {
  margin-bottom: 0;
}

.section-title.compact h3 {
  font-size: 14px;
}

.quick-picks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.quick-picks.pnl-picks {
  grid-template-columns: repeat(3, 1fr);
}

.quick-picks.setup-picks,
.quick-picks.violation-picks {
  grid-template-columns: repeat(2, 1fr);
}

.trade-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.trade-mode button {
  min-height: 36px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  font-size: 12px;
}

.trade-mode button.active {
  background: var(--dark);
  color: white;
}

.quick-picks button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
  color: var(--ink);
  font-weight: 850;
}

.quick-picks button.active {
  border-color: #b9dec8;
  background: var(--green-2);
  color: var(--green);
}

.pnl-picks button[data-set-value^="-"].active,
.violation-picks button:not([data-set-value="none"]).active {
  border-color: #f0caca;
  background: var(--red-2);
  color: var(--red);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  font-size: 15px;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.checklist {
  display: grid;
  gap: 9px;
  padding: 12px;
  border-radius: 16px;
  background: var(--paper-2);
}

.checklist label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 13px;
}

.checklist input {
  width: 18px;
  height: 18px;
}

.data-details {
  box-shadow: none;
}

.data-details summary {
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 850;
}

.data-details[open] summary {
  margin-bottom: 14px;
}

#tradeForm[data-mode="quick"] .detail-only {
  display: none;
}

#tradeForm:not([data-mode="detail"]) .detail-only {
  display: none;
}

#tradeForm[data-mode="quick"] .risk-fields {
  display: none;
}

#tradeForm[data-mode="detail"] .quick-block,
#tradeForm[data-mode="detail"] .quick-ticket {
  display: none;
}

@media (max-width: 420px) {
  .app {
    padding: 14px;
  }

  h1 {
    font-size: 30px;
  }

  .mode-panel {
    grid-template-columns: 1fr;
  }

  .quick-ticket {
    grid-template-columns: repeat(2, 1fr);
  }

  .quick-picks,
  .quick-picks.pnl-picks,
  .quick-picks.setup-picks,
  .quick-picks.violation-picks {
    grid-template-columns: repeat(2, 1fr);
  }

  .coach-insights {
    grid-template-columns: 1fr;
  }
}
