/* OPIFY resource tools (Greeks, Margin, Max Pain, CPR, Fibonacci).
   Everything is namespaced with .rt- so nothing leaks into the site navigation. */

.rt-page {
  margin: 0 15px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  font-family: system-ui, Arial, sans-serif;
  color: #111827;
}
.rt-page > * {
  min-width: 0;
}

.rt-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  padding: 18px;
}

.rt-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.rt-hidden {
  display: none !important;
}

/* ---------- form ---------- */

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

.rt-field {
  position: relative;
}
.rt-field label {
  position: absolute;
  top: -9px;
  left: 12px;
  background: #fff;
  padding: 0 6px;
  font-size: 12px;
  color: #374151;
  z-index: 1;
}
.rt-field input,
.rt-field select {
  width: 100%;
  height: 44px;
  border-radius: 10px;
  border: 1px solid #cfd8e3;
  padding: 0 12px;
  font-size: 15px;
  background: #fff;
  color: #111827;
}
.rt-field input:focus,
.rt-field select:focus {
  outline: none;
  border-color: #2563eb;
}
.rt-field-btn {
  display: flex;
  align-items: stretch;
}
.rt-field-btn .rt-btn {
  width: 100%;
}

.rt-btn {
  height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s;
}
.rt-btn:hover { transform: translateY(-1px); }
.rt-btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.rt-btn-light {
  background: #eef3fa;
  color: #1d4ed8;
  border: 1px solid #cfd8e3;
}

.rt-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.rt-hint {
  font-size: 13px;
  color: #6b7280;
  margin-top: 10px;
}
.rt-actions .rt-hint { margin-top: 0; }

.rt-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  background: #eef3fa;
  border-radius: 10px;
  padding: 4px;
}
.rt-seg-btn {
  border: none;
  background: transparent;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
}
.rt-seg-btn.active {
  background: #fff;
  color: #1d4ed8;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.rt-status {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
}
.rt-status.rt-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

/* ---------- result cards ---------- */

.rt-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.rt-metrics:empty { display: none; }
.rt-metric {
  background: #fff;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  border-left: 4px solid #cfd8e3;
}
.rt-metric.rt-primary { border-left-color: #2563eb; }
.rt-metric.rt-good { border-left-color: #16a34a; }
.rt-metric.rt-warn { border-left-color: #d97706; }
.rt-metric-label {
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.rt-metric-value {
  font-size: 22px;
  font-weight: 600;
  margin-top: 4px;
  word-break: break-word;
}
.rt-metric-sub {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* ---------- tables ---------- */

.rt-table-scroll,
.rt-table-wrap {
  overflow-x: auto;
}
.rt-table {
  width: 100%;
  border-collapse: collapse;
}
.rt-table th {
  background: #eef3fa;
  font-size: 13px;
  font-weight: 600;
  padding: 12px;
  border: 1px solid #d9e1eb;
  text-align: right;
  white-space: nowrap;
}
.rt-table td {
  padding: 10px 12px;
  border: 1px solid #d9e1eb;
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}
.rt-table th:first-child,
.rt-table td:first-child {
  text-align: left;
}
.rt-table tr.rt-hl td {
  background: #fff7ed;
  font-weight: 600;
}
.rt-table td.rt-pos { color: #15803d; }
.rt-table td.rt-neg { color: #b91c1c; }

.rt-legs input,
.rt-legs select {
  height: 38px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 14px;
  background: #fff;
  color: #111827;
  width: 100%;
  min-width: 90px;
}
.rt-legs td { text-align: left; }
.rt-leg-remove {
  border: none;
  background: transparent;
  color: #b91c1c;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.rt-chart-box {
  position: relative;
  height: 320px;
}

/* ---------- guide + FAQ (server rendered) ---------- */

.rt-guide {
  font-family: system-ui, Arial, sans-serif;
  color: #111827;
}
.rt-guide h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 26px 0 10px;
}
.rt-guide h2:first-child { margin-top: 0; }
.rt-guide p {
  font-size: 15px;
  line-height: 1.7;
  opacity: 0.8;
  margin: 0 0 10px;
}
.rt-faq {
  background: #fff;
  border: 1px solid #d9e1eb;
  border-radius: 10px;
  margin-bottom: 8px;
}
.rt-faq summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.rt-faq summary::-webkit-details-marker { display: none; }
.rt-faq summary::after {
  content: "+";
  color: #2563eb;
  font-size: 22px;
  line-height: 1;
  flex: none;
}
.rt-faq[open] summary::after { content: "\2212"; }
.rt-faq p {
  padding: 0 16px 14px;
  margin: 0;
}
.rt-disclaimer {
  font-size: 13px !important;
  opacity: 0.6 !important;
  margin-top: 22px !important;
}

/* ---------- responsive ---------- */

@media (max-width: 1000px) {
  .rt-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rt-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .rt-page { margin: 0 10px; }
  .rt-grid-5,
  .rt-grid-4 { grid-template-columns: minmax(0, 1fr); }
  .rt-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rt-metric-value { font-size: 18px; }
  .rt-chart-box { height: 260px; }
  .rt-seg { display: flex; }
  .rt-seg-btn { flex: 1 1 100%; }
}
