:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #66717f;
  --line: #d9dee6;
  --accent: #0c6b58;
  --accent-strong: #084d43;
  --warn: #a15c00;
  --bad: #aa2735;
  --good: #127849;
  --chip: #edf2f0;
  --shadow: 0 14px 38px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.floating-quote {
  position: fixed;
  top: 12px;
  right: 18px;
  z-index: 50;
  display: inline-grid;
  grid-template-columns: auto auto auto;
  gap: 10px;
  align-items: center;
  max-width: calc(100vw - 28px);
  border: 1px solid rgba(12, 107, 88, 0.22);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(23, 33, 43, 0.16);
  backdrop-filter: blur(10px);
}

.floating-quote.hidden {
  display: none;
}

.floating-quote span:first-child {
  font-weight: 800;
}

.floating-quote strong {
  font-size: 18px;
}

.floating-quote .good {
  color: var(--good);
}

.floating-quote .bad {
  color: var(--bad);
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

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

.input-panel,
.results-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 18px;
  position: sticky;
  top: 18px;
  overflow-anchor: none;
}

.brand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: 0;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.status {
  display: inline-grid;
  place-items: center;
  width: 92px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 13px;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  color: var(--muted);
  background: #fafafa;
}

.status.live {
  color: var(--accent-strong);
  border-color: #a7cbc1;
  background: #e9f5f1;
}

.status.error {
  color: var(--bad);
  border-color: #efb2ba;
  background: #fff0f2;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
  font-size: 13px;
  color: #394653;
}

.symbol-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.symbol-search input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--ink);
  background: #fbfcfd;
}

.symbol-search button {
  height: 46px;
  min-width: 96px;
}

.track-note {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.track-note h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.track-note p {
  line-height: 1.35;
}

textarea {
  display: block;
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  line-height: 1.35;
  color: var(--ink);
  background: #fbfcfd;
}

textarea:focus,
input:focus {
  outline: 2px solid rgba(12, 107, 88, 0.18);
  border-color: var(--accent);
}

.toolbar,
.settings-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.quick-tickers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quick-tickers button {
  min-height: 36px;
  padding: 0 8px;
  font-weight: 800;
  color: #314139;
  background: #edf2f0;
}

.quick-tickers button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #e9f5f1;
}

.scanner-control {
  margin-top: 14px;
}

.merrill-panel {
  margin-top: 14px;
}

.merrill-panel textarea {
  width: 100%;
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  resize: vertical;
  background: #fbfcfd;
  color: var(--ink);
}

.merrill-panel button {
  width: 100%;
  margin-top: 8px;
}

.save-toggle {
  margin-top: 8px;
  align-items: flex-start;
}

.save-status {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.alert-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.alert-panel button {
  width: 100%;
  margin-top: 8px;
}

.alert-log {
  margin-top: 10px;
  max-height: 150px;
  overflow: auto;
  border: 1px solid #e4e8ee;
  border-radius: 6px;
  padding: 8px;
  color: #384553;
  background: #fff;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.action-popout {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 1000;
  width: min(520px, calc(100vw - 28px));
  transform: translate(-50%, -140%);
  border: 2px solid #c1121f;
  border-radius: 8px;
  padding: 14px 16px;
  color: #a00012;
  background: #fff4f4;
  box-shadow: 0 18px 45px rgba(160, 0, 18, 0.2);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
  pointer-events: none;
}

.action-popout.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.action-popout strong,
.action-popout span {
  display: block;
}

.action-popout strong {
  margin-bottom: 4px;
  font-size: 22px;
  line-height: 1.05;
}

.action-popout span {
  font-size: 15px;
  line-height: 1.35;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.segmented label {
  position: relative;
  min-height: 38px;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #41505f;
  font-weight: 800;
}

.segmented label + label {
  border-left: 1px solid var(--line);
}

.segmented input:checked + span {
  color: #fff;
  background: var(--accent);
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  color: #26313c;
  background: #fff;
  cursor: pointer;
}

button:hover {
  border-color: #b6bec9;
  background: #f9fafb;
}

button.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

.toggle,
.compact-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.compact-field input {
  width: 76px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
}

.results-panel {
  overflow: hidden;
  overflow-anchor: none;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.summary-strip > div {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.summary-strip > div:last-child {
  border-right: 0;
}

.label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-strip strong {
  display: block;
  font-size: 18px;
}

.cards {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.cards.empty {
  min-height: 520px;
  place-items: center;
}

.empty-state {
  text-align: center;
  max-width: 320px;
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

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

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

.order-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.symbol-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.symbol {
  font-size: 24px;
  font-weight: 800;
}

.tag {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  background: var(--chip);
  color: #314139;
}

.trend-tag.good {
  color: #0d5c39;
  background: #dff3e9;
}

.trend-tag.bad {
  color: #8f1f2c;
  background: #ffe2e6;
}

.trend-tag.flat {
  color: #4f5b66;
  background: #edf0f3;
}

.stock-chart-link {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  border: 1px solid #a7cbc1;
  border-radius: 6px;
  padding: 0 9px;
  color: var(--accent-strong);
  background: #e9f5f1;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.stock-chart-link:hover {
  border-color: var(--accent);
  background: #dff1eb;
}

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

.price-box {
  text-align: right;
}

.price {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

.change.good {
  color: var(--good);
}

.change.bad {
  color: var(--bad);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  border-bottom: 1px solid var(--line);
}

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

.choice-card {
  border: 2px solid #0c6b58;
  border-radius: 8px;
  padding: 16px;
  background: #ecf8f4;
  box-shadow: 0 12px 30px rgba(12, 107, 88, 0.12);
}

.reversal-card {
  border: 2px solid #7b5b15;
  border-radius: 8px;
  padding: 16px;
  background: #fff8e8;
  box-shadow: 0 12px 30px rgba(123, 91, 21, 0.11);
}

.next-week-card {
  border: 2px solid #315f86;
  border-radius: 8px;
  padding: 16px;
  background: #eef7ff;
  box-shadow: 0 12px 30px rgba(49, 95, 134, 0.11);
}

.scanner-card {
  border: 2px solid #5c5179;
  border-radius: 8px;
  padding: 16px;
  background: #f6f3ff;
  box-shadow: 0 12px 30px rgba(92, 81, 121, 0.1);
  overflow-x: auto;
}

.overall-card {
  border: 3px solid #0c6b58;
  border-radius: 8px;
  padding: 18px;
  background: #e9f8f2;
  box-shadow: 0 16px 36px rgba(12, 107, 88, 0.16);
  overflow-x: auto;
}

.overall-card .scanner-head strong {
  color: #073f37;
  font-size: 30px;
}

.overall-card .tag {
  color: #073f37;
  background: #cdeee3;
}

.scanner-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.scanner-head strong {
  display: block;
  margin-top: 5px;
  color: #3b3157;
  font-size: 24px;
  line-height: 1.1;
}

.scanner-best {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  border: 1px solid rgba(92, 81, 121, 0.18);
  border-radius: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.scanner-best span {
  color: var(--muted);
  font-size: 13px;
}

.scanner-best .contract-line {
  color: #312846;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 800;
}

.scanner-best span.good {
  color: var(--good);
  font-weight: 800;
}

.scanner-best span.bad {
  color: var(--bad);
  font-weight: 800;
}

.scanner-best b {
  color: #312846;
  font-size: 20px;
}

.action-links {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.scanner-best .action-links {
  justify-content: flex-start;
  margin-top: 4px;
}

.action-links a {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  border: 1px solid #c6bedf;
  border-radius: 6px;
  padding: 0 9px;
  color: #312846;
  background: #fff;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.action-links a:hover {
  border-color: #5c5179;
  background: #eee8ff;
}

.choice-card strong,
.reversal-card strong,
.next-week-card strong {
  display: block;
  margin: 5px 0 8px;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

.choice-card strong {
  color: #073f37;
}

.reversal-card strong {
  color: #5d3f06;
}

.next-week-card strong {
  color: #1f486b;
}

.choice-card p,
.reversal-card p,
.next-week-card p {
  max-width: 860px;
  font-size: 16px;
}

.choice-card p {
  color: #23443d;
}

.reversal-card p {
  color: #4f4025;
}

.next-week-card p {
  color: #27485f;
}

.choice-card p + p,
.reversal-card p + p,
.next-week-card p + p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.choice-card .open-move,
.reversal-card .open-move,
.next-week-card .open-move {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 800;
}

.open-move.good,
.option-table .good {
  color: var(--good);
}

.open-move.bad,
.option-table .bad {
  color: var(--bad);
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(12, 107, 88, 0.22);
}

.reference-grid div {
  min-height: 64px;
  border: 1px solid rgba(12, 107, 88, 0.18);
  border-radius: 6px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.66);
}

.reversal-card .reference-grid {
  border-top-color: rgba(123, 91, 21, 0.24);
}

.reversal-card .reference-grid div {
  border-color: rgba(123, 91, 21, 0.18);
}

.next-week-card .reference-grid {
  border-top-color: rgba(49, 95, 134, 0.24);
}

.next-week-card .reference-grid div {
  border-color: rgba(49, 95, 134, 0.18);
}

.reference-grid b {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.1;
}

.reference-grid .good {
  color: var(--good);
}

.reference-grid .bad {
  color: var(--bad);
}

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

.option-panel.focus {
  border-color: #86b9ab;
  box-shadow: inset 0 0 0 1px #86b9ab;
}

.option-panel h2 {
  margin: 0;
  padding: 12px 14px;
  font-size: 17px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.option-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.option-table th,
.option-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf0f4;
  text-align: right;
  white-space: nowrap;
}

.option-table th:first-child,
.option-table td:first-child {
  text-align: left;
}

.option-table tr.focus-row {
  background: #edf7f3;
}

.option-table tr.practical-row {
  background: #dff3ed;
  box-shadow: inset 4px 0 0 #0c6b58;
  font-weight: 800;
}

.option-table tr.practical-row td:first-child::after {
  content: " choice";
  display: inline-block;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 6px;
  color: #073f37;
  background: #b8ded3;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.option-table tr.reversal-row {
  background: #fff4d9;
  box-shadow: inset 4px 0 0 #9a6c0a;
  font-weight: 800;
}

.option-table tr.reversal-row td:first-child::after {
  content: " reversal";
  display: inline-block;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 6px;
  color: #5d3f06;
  background: #f2d58d;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.option-table tr.scanner-best-row {
  background: #ebe5ff;
  box-shadow: inset 4px 0 0 #5c5179;
  font-weight: 800;
}

.option-table tr.scanner-best-row td:first-child::after {
  content: " best";
  display: inline-block;
  margin-left: 6px;
  border-radius: 999px;
  padding: 2px 6px;
  color: #342a52;
  background: #d7ccff;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
}

.scanner-table {
  display: table;
}

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

.metric {
  min-height: 76px;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.metric:nth-child(4n) {
  border-right: 0;
}

.metric b {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.insight {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 12px;
  padding: 14px 16px;
}

.note {
  padding: 10px 12px;
  border-radius: 6px;
  background: #f7f8fa;
  color: #384553;
  line-height: 1.45;
}

.note.warn {
  background: #fff6e8;
  color: var(--warn);
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.mini-table td {
  padding: 6px 0;
  border-bottom: 1px solid #edf0f4;
}

.mini-table td:last-child {
  text-align: right;
  font-weight: 700;
}

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

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

  textarea {
    min-height: 300px;
  }

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

  .metric:nth-child(2n) {
    border-right: 0;
  }

  .insight {
    grid-template-columns: 1fr;
  }

  .option-columns {
    grid-template-columns: 1fr;
  }

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

}

@media (max-width: 640px) {
  .floating-quote {
    left: 10px;
    right: 10px;
    top: 8px;
    justify-content: space-between;
  }

  .shell {
    width: min(100vw - 20px, 1420px);
    padding: 58px 0 10px;
  }

  .input-panel {
    padding: 14px;
  }

  .brand-row {
    grid-template-columns: minmax(0, 1fr) 92px;
    min-height: 32px;
    margin-bottom: 12px;
    align-items: center;
  }

  .brand-row h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .brand-row p {
    display: none;
  }

  .summary-strip,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .summary-strip > div,
  .metric {
    border-right: 0;
  }

  .metric {
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .order-head {
    display: block;
  }

  .symbol-search {
    grid-template-columns: 1fr;
  }

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

  .option-table {
    font-size: 13px;
  }

  .scanner-head {
    display: block;
  }

  .scanner-card {
    overflow-x: auto;
  }

  .option-table th,
  .option-table td {
    padding: 8px 7px;
  }

  .choice-card strong,
  .reversal-card strong,
  .next-week-card strong {
    font-size: 24px;
  }

  .reference-grid {
    grid-template-columns: 1fr;
  }

  .price-box {
    text-align: left;
    margin-top: 12px;
  }
}
