:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --ink: #17202a;
  --muted: #5f6b76;
  --line: #d9e1e8;
  --band: #f5f8fb;
  --accent: #1f6fb2;
  --accent-dark: #184f7d;
  --good: #18764a;
  --bad: #b23b3b;
}

* {
  box-sizing: border-box;
}

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

.home-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f5f8fb;
}

.home-panel {
  width: min(720px, 100%);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(23, 32, 42, 0.08);
}

.home-panel h1 {
  margin-bottom: 22px;
  text-align: center;
  font-size: 34px;
}

.current-user {
  margin: -12px 0 18px;
  text-align: center;
  font-size: 14px;
}

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

.login-form button {
  width: 100%;
}

.secondary-link,
.admin-btn {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  text-decoration: underline;
}

.secondary-link {
  width: 100%;
  margin-top: 12px;
}

.new-account-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.login-status {
  min-height: 20px;
  margin-top: 12px;
  text-align: center;
  color: var(--bad);
  font-weight: 700;
}

.home-actions {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.home-choice {
  width: min(420px, 100%);
  min-height: 56px;
  font-size: 16px;
}

.home-choice.primary {
  border-color: #1f6fb2;
  background: #1f6fb2;
  color: #ffffff;
}

.admin-zone {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.admin-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.admin-panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  min-width: 0;
  font-size: 14px;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0;
}

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

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 4px;
  border-bottom: 1px solid var(--line);
}

.tab {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  margin-bottom: -1px;
}

.tab.active {
  border-color: #1f4e78;
  background: #1f4e78;
  color: #ffffff;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

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

button:hover {
  border-color: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--band);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
  font-size: 14px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: calc(100vh - 250px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
  font-size: 14px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  background: #1f4e78;
  color: #ffffff;
  text-align: left;
  padding: 10px;
  white-space: nowrap;
}

td {
  border-top: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:nth-child(even) {
  background: #fbfdff;
}

tbody tr.held-row,
tbody tr.held-row:nth-child(even) {
  background: #d9ead3;
}

tbody tr.open-order-row,
tbody tr.open-order-row:nth-child(even) {
  background: #fff2cc;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tag {
  display: inline-block;
  min-width: 76px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #e8eef5;
  color: #27445f;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.up {
  color: var(--good);
  font-weight: 700;
}

.down {
  color: var(--bad);
  font-weight: 700;
}

.stock-mode #coursesPage th:nth-child(7),
.stock-mode #coursesPage th:nth-child(8),
.stock-mode #coursesPage th:nth-child(9),
.stock-mode #coursesPage td:nth-child(7),
.stock-mode #coursesPage td:nth-child(8),
.stock-mode #coursesPage td:nth-child(9) {
  display: none;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px;
}

.hidden {
  display: none;
}

.orders-entry,
.orders-list {
  margin-top: 22px;
}

.top-threshold-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.top-threshold-btn {
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
}

.top-threshold-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.stock-watchlist-entry {
  display: none;
  gap: 10px;
  align-items: center;
  margin: 10px 0 14px;
}

.stock-mode .stock-watchlist-entry {
  display: flex;
}

.stock-watchlist-entry input {
  min-height: 38px;
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 15px;
  text-transform: uppercase;
}

.watchlist-momentum-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.momentum-watchlist-add {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
}

.section-title {
  margin: 0 0 8px;
  color: #0f5d7a;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.order-form {
  display: grid;
  grid-template-columns: 132px 150px 120px 128px 128px 120px 140px 120px;
  gap: 0;
  align-items: stretch;
  border: 2px solid #1f4e78;
  border-bottom-color: #111111;
  overflow-x: auto;
}

.stock-mode .order-form {
  grid-template-columns: 128px 138px 142px 220px 112px 112px 124px 104px;
}

.order-form input,
.order-form select {
  min-height: 32px;
  border: 0;
  border-radius: 0;
  border-right: 1px solid #d9e1e8;
  padding: 0 8px;
}

.stock-order-name-field,
.stock-order-name-col {
  display: none;
}

.stock-mode .stock-order-name-field {
  display: block;
  background: #f5f8fb;
}

.stock-mode .stock-order-name-col {
  display: table-cell;
}

.order-form .add-order {
  grid-column: 8;
  border: 0;
  border-left: 1px solid #d9e1e8;
  border-radius: 0;
  background: #ffffff;
}

.orders-table-wrap {
  border: 2px solid #33a6df;
  overflow: auto;
}

.orders-table-wrap table {
  min-width: 1080px;
  font-size: 14px;
}

.summary-table {
  min-width: 860px !important;
}

.portfolio-analysis {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.portfolio-analysis-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f5f8fb;
}

.portfolio-analysis-header h3 {
  margin: 0 0 4px;
  color: #0f5d7a;
  font-size: 20px;
}

.portfolio-analysis-header p {
  font-size: 12px;
}

.portfolio-balance-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.portfolio-balance-badge.good {
  border-color: #7ab895;
  background: #e3f3e9;
  color: #17603b;
}

.portfolio-balance-badge.watch {
  border-color: #ddb65a;
  background: #fff3ce;
  color: #73520c;
}

.portfolio-balance-badge.risk {
  border-color: #d38b8b;
  background: #fbe3e3;
  color: #8a2929;
}

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

.portfolio-analysis-metrics > div {
  min-width: 0;
  padding: 13px 16px;
  border-right: 1px solid var(--line);
}

.portfolio-analysis-metrics > div:last-child {
  border-right: 0;
}

.portfolio-analysis-metrics span,
.portfolio-analysis-metrics strong {
  display: block;
}

.portfolio-analysis-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.portfolio-analysis-metrics strong {
  margin-top: 5px;
  font-size: 18px;
}

.portfolio-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

.portfolio-analysis-block {
  min-width: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.portfolio-analysis-block + .portfolio-analysis-block {
  border-left: 1px solid var(--line);
}

.portfolio-analysis h4 {
  margin: 0 0 12px;
  color: #27445f;
  font-size: 15px;
}

.portfolio-analysis ul {
  margin: 0;
  padding-left: 18px;
  color: #33414e;
  line-height: 1.45;
}

.portfolio-analysis li + li {
  margin-top: 7px;
}

.portfolio-allocation-group + .portfolio-allocation-group {
  margin-top: 14px;
}

.portfolio-allocation-group > strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
}

.portfolio-allocation-row {
  display: grid;
  grid-template-columns: minmax(100px, 0.9fr) minmax(90px, 1.2fr) 52px;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-size: 12px;
}

.portfolio-allocation-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-allocation-row > b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.portfolio-allocation-track {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #e6edf3;
}

.portfolio-allocation-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #2e7dab;
}

.portfolio-rebalancing-block {
  padding: 18px;
  background: #fbfdff;
}

.portfolio-rebalancing-block ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.portfolio-rebalancing-block li {
  padding-left: 4px;
}

.portfolio-rebalancing-block li strong,
.portfolio-rebalancing-block li span {
  display: block;
}

.portfolio-rebalancing-block li strong {
  margin-bottom: 2px;
  color: #0f5d7a;
  font-size: 12px;
  text-transform: uppercase;
}

.portfolio-rebalancing-block li span {
  color: #33414e;
  line-height: 1.4;
}

.portfolio-strategy-block {
  padding: 18px;
  border-top: 1px solid var(--line);
}

.portfolio-strategy-heading {
  margin-bottom: 12px;
}

.portfolio-strategy-heading h4 {
  margin-bottom: 4px;
}

.portfolio-strategy-heading p {
  font-size: 12px;
}

.portfolio-stress-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.portfolio-stress-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 11px;
  background: #ffffff;
}

.portfolio-stress-card span,
.portfolio-stress-card strong,
.portfolio-stress-card small {
  display: block;
}

.portfolio-stress-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.portfolio-stress-card strong {
  margin: 5px 0;
  font-size: 17px;
}

.portfolio-stress-card small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.3;
}

.portfolio-stress-card.down-scenario {
  border-left-color: #b23b3b;
}

.portfolio-stress-card.concentration-scenario,
.portfolio-stress-card.recovery-scenario {
  border-left-color: #d19a28;
}

.portfolio-stress-card.positive-scenario {
  border-left-color: #18764a;
}

.portfolio-position-plan h5 {
  margin: 0 0 8px;
  color: #27445f;
  font-size: 13px;
}

.portfolio-position-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.portfolio-position-table {
  min-width: 820px;
  font-size: 12px;
}

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

.portfolio-position-table th:nth-child(2),
.portfolio-position-table th:nth-child(3),
.portfolio-position-table td:nth-child(2),
.portfolio-position-table td:nth-child(3) {
  text-align: center;
}

.portfolio-position-table th:nth-child(4),
.portfolio-position-table td:nth-child(4) {
  text-align: center;
}

.portfolio-dividend {
  min-width: 190px;
}

.portfolio-position-table td strong,
.portfolio-position-table td small {
  display: block;
}

.portfolio-position-table td small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.portfolio-plan-action {
  display: inline-block;
  max-width: 240px;
  border-radius: 4px;
  padding: 4px 6px;
  white-space: normal;
  line-height: 1.25;
  font-weight: 700;
}

.portfolio-plan-action.reduce {
  background: #fbe3e3;
  color: #8a2929;
}

.portfolio-plan-action.review {
  background: #fff3ce;
  color: #73520c;
}

.portfolio-plan-action.balanced {
  background: #e3f3e9;
  color: #17603b;
}

.portfolio-analysis-note {
  padding: 0 18px 16px;
  font-size: 11px;
  line-height: 1.4;
}

.portfolio-empty-analysis {
  padding: 8px 0;
}

.prospection-table {
  min-width: 1680px !important;
}

.watchlist-table {
  min-width: 2300px !important;
}

.stock-mode #watchlistPage .prospection-table {
  table-layout: fixed;
  min-width: 0 !important;
  width: 100%;
}

.stock-mode #watchlistPage th,
.stock-mode #watchlistPage td {
  padding: 6px 7px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-mode #watchlistPage th:nth-child(1),
.stock-mode #watchlistPage td:nth-child(1) {
  width: 13%;
}

.stock-mode #watchlistPage th:nth-child(2),
.stock-mode #watchlistPage td:nth-child(2) {
  width: 11%;
}

.stock-mode #watchlistPage th:nth-child(3),
.stock-mode #watchlistPage td:nth-child(3) {
  width: 25%;
}

.stock-mode #watchlistPage th:nth-child(4),
.stock-mode #watchlistPage td:nth-child(4) {
  width: 13%;
}

.stock-mode #watchlistPage th:nth-child(5),
.stock-mode #watchlistPage td:nth-child(5) {
  width: 13%;
}

.stock-mode #watchlistPage th:nth-child(6),
.stock-mode #watchlistPage td:nth-child(6) {
  width: 13%;
}

.stock-mode #watchlistPage th:nth-child(7),
.stock-mode #watchlistPage td:nth-child(7) {
  width: 12%;
  text-align: center;
}

.stock-mode #watchlistPage .tag {
  min-width: 0;
  max-width: 100%;
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-mode #watchlistPage .watchlist-remove-btn {
  max-width: 100%;
  padding: 0 7px;
  font-size: 12px;
}

.text-cell {
  min-width: 260px;
  max-width: 360px;
  white-space: normal;
  line-height: 1.25;
  vertical-align: top;
}

.probability-scenario {
  min-width: 180px;
  white-space: normal;
}

.scenario-hidden-col {
  display: none;
}

.scenario-stack {
  display: grid;
  gap: 5px;
}

.scenario-pill {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.scenario-pill.bullish {
  background: #15945a;
}

.scenario-pill.bearish {
  background: #c23d4b;
}

.probability-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.probability-bars {
  min-width: 260px;
}

.probability-row {
  display: grid;
  grid-template-columns: 62px 1fr 42px;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 12px;
  font-weight: 800;
}

.probability-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe5ec;
}

.probability-fill {
  height: 100%;
  border-radius: inherit;
}

.probability-row.bullish .probability-fill {
  background: #15945a;
}

.probability-row.bearish .probability-fill {
  background: #c23d4b;
}

.probability-thresholds {
  min-width: 240px;
  white-space: normal;
}

.threshold-scenario {
  border-left: 4px solid #9ca3af;
  padding-left: 8px;
  margin: 4px 0;
  text-align: left;
}

.threshold-scenario.bullish {
  border-left-color: #15945a;
}

.threshold-scenario.bearish {
  border-left-color: #c23d4b;
}

.threshold-scenario strong,
.threshold-scenario span {
  display: block;
  line-height: 1.25;
}

.threshold-scenario strong {
  font-size: 12px;
  margin-bottom: 2px;
}

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

.probability-error {
  color: var(--bad);
  font-weight: 700;
}

.probability-loading {
  color: var(--muted);
  font-weight: 700;
}

.analysis-btn,
.watchlist-add-btn,
.watchlist-analysis-btn,
.threshold-btn,
.watchlist-remove-btn {
  min-height: 26px;
  padding: 0 10px;
  white-space: nowrap;
}

.orders-table-wrap th {
  background: #176782;
  text-align: center;
  padding: 1px 5px;
  line-height: 1;
  height: 17px;
}

.orders-table-wrap td {
  border-top: 1px solid #33a6df;
  text-align: center;
  padding: 0 5px;
  line-height: 1;
  height: 16px;
}

.orders-table-wrap tbody tr:nth-child(even) {
  background: #ffffff;
}

.orders-table-wrap tbody tr.closed-position-row,
.orders-table-wrap tbody tr.closed-position-row td {
  background: #eef2f5;
}

.orders-table-wrap td:nth-child(5),
.orders-table-wrap td:nth-child(6) {
  background: #d9eaf7;
}

.orders-table-wrap tbody tr.closed-position-row td:nth-child(5),
.orders-table-wrap tbody tr.closed-position-row td:nth-child(6) {
  background: #e3e8ec;
}

.orders-table-wrap tbody tr.trigger-reached-row,
.orders-table-wrap tbody tr.trigger-reached-row td,
.orders-table-wrap tbody tr.trigger-reached-row td:nth-child(5),
.orders-table-wrap tbody tr.trigger-reached-row td:nth-child(6) {
  background: #39ff14;
  color: #06230b;
  font-weight: 800;
}

.order-select,
.transaction-select {
  width: 12px;
  height: 12px;
  margin: 0;
}

.order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.flash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flash-text {
  width: 100%;
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: #fbfdff;
  font: 14px/1.45 Arial, Helvetica, sans-serif;
  overflow: auto;
  white-space: pre-wrap;
}

.flash-text strong {
  font-weight: 800;
}

.flash-combined-signals {
  margin-top: 18px;
  white-space: normal;
}

.flash-combined-signals h3 {
  margin: 0 0 10px;
  color: #0f5d7a;
  font-size: 18px;
}

.flash-signal-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.flash-signal-rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #1f4e78;
  color: #ffffff;
  font-weight: 800;
}

.flash-signal-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.flash-signal-title strong {
  color: #0f5d7a;
  font-size: 15px;
}

.flash-signal-title span {
  color: var(--ink);
  font-weight: 700;
}

.flash-signal-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
}

.flash-signal-metrics span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  background: #ffffff;
}

.flash-signal-details,
.flash-signal-advice {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.flash-signal-advice {
  color: var(--ink);
}

.flash-add-row {
  min-height: 20px;
  padding: 0 7px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  vertical-align: 1px;
}

.flash-recap {
  margin-top: 24px;
  white-space: normal;
}

.flash-watchlist-shortcuts {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.flash-watchlist-add {
  min-height: 24px;
  padding: 0 8px;
  margin-left: 0;
  border-radius: 999px;
  font-size: 11px;
}

.flash-recap h3 {
  margin: 0 0 10px;
  color: #0f5d7a;
  font-size: 18px;
}

.flash-recap table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 14px;
}

.flash-recap th {
  background: #176782;
  color: #ffffff;
  text-align: left;
  padding: 8px 10px;
}

.flash-recap td {
  border-top: 1px solid #d9e1e8;
  padding: 8px 10px;
}

.flash-delete-row {
  min-height: 26px;
  padding: 0 10px;
  border-radius: 6px;
}

.flash-threshold-row {
  min-height: 26px;
  padding: 0 10px;
  margin-right: 6px;
  border-radius: 6px;
}

.flash-order-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 18px;
}

.flash-order-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.flash-order-tool h3 {
  margin: 0 0 12px;
  color: #0f5d7a;
  font-size: 18px;
}

.trailing-stop-panel,
.oco-panel {
  display: grid;
  gap: 14px;
  max-width: 820px;
}

.trailing-stop-form,
.oco-form {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(180px, 220px) minmax(180px, 260px) auto;
  gap: 10px;
  align-items: end;
}

.oco-form {
  grid-template-columns: minmax(180px, 220px) minmax(180px, 260px) auto;
}

.trailing-side-toggle,
.trailing-price-toggle,
.oco-side-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f7;
  padding: 4px;
}

.trailing-side-toggle label,
.trailing-price-toggle label,
.oco-side-toggle label {
  cursor: pointer;
}

.trailing-side-toggle input,
.trailing-price-toggle input,
.oco-side-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.trailing-side-toggle span,
.trailing-price-toggle span,
.oco-side-toggle span {
  display: grid;
  place-items: center;
  height: 100%;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.trailing-side-toggle input:checked + span,
.trailing-price-toggle input:checked + span,
.oco-side-toggle input:checked + span {
  background: #176782;
  color: #ffffff;
}

.trailing-side-toggle label:first-child input:checked + span,
.oco-side-toggle label:first-child input:checked + span {
  background: #168761;
}

.trailing-side-toggle label:last-child input:checked + span,
.oco-side-toggle label:last-child input:checked + span {
  background: #bf3f4e;
}

.trailing-stop-form > input,
.oco-form > input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
  text-transform: uppercase;
}

.trailing-stop-result,
.oco-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 16px;
  color: var(--ink);
}

.trailing-stop-summary,
.oco-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.trailing-stop-summary strong,
.oco-summary strong {
  color: #0f5d7a;
  font-size: 18px;
}

.trailing-stop-summary span,
.oco-summary span {
  color: var(--muted);
  font-weight: 700;
}

.trailing-param-grid,
.oco-param-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.trailing-param-grid div,
.oco-param-grid div {
  border: 1px solid #d9e1e8;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.trailing-param-grid span,
.oco-param-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.trailing-param-grid strong,
.oco-param-grid strong {
  font-size: 16px;
}

.trailing-stop-result p,
.oco-result p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.trailing-stop-explanation,
.oco-explanation {
  margin-top: 14px;
  border-top: 1px solid #d9e1e8;
  padding-top: 12px;
}

.trailing-stop-explanation strong,
.oco-explanation strong {
  display: block;
  margin-bottom: 7px;
  color: #0f5d7a;
}

.trailing-stop-explanation p + p,
.oco-explanation p + p {
  margin-top: 8px;
}

.mobile-mode .app-shell {
  width: 100%;
  max-width: none;
  padding: 8px;
  overflow-x: hidden;
}

.mobile-mode .topbar {
  padding-bottom: 10px;
}

.mobile-mode h1 {
  font-size: 22px;
}

.mobile-mode #statusText {
  font-size: 12px;
  line-height: 1.3;
}

.mobile-mode .topbar,
.mobile-mode .actions,
.mobile-mode .tabs,
.mobile-mode .order-actions {
  display: grid;
  gap: 8px;
}

.mobile-mode .tabs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 8px;
  border-bottom: 0;
}

.mobile-mode .tab {
  border-radius: 6px;
  margin-bottom: 0;
  min-height: 34px;
  padding: 0 6px;
  font-size: 12px;
  line-height: 1.1;
  white-space: normal;
}

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

.mobile-mode .actions button {
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  font-size: 12px;
}

.mobile-mode .toolbar,
.mobile-mode .summary-grid,
.mobile-mode .summary-kpis {
  grid-template-columns: 1fr;
}

.mobile-mode .order-form,
.mobile-mode.stock-mode .order-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 0;
  overflow: visible;
}

.mobile-mode .order-form input,
.mobile-mode .order-form select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mobile-mode .order-form .add-order {
  grid-column: 1 / -1;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mobile-mode .table-wrap,
.mobile-mode .orders-table-wrap {
  max-height: none;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
}

.mobile-mode table {
  min-width: 760px;
  font-size: 12px;
}

.mobile-mode th,
.mobile-mode td {
  padding: 6px 6px;
}

.mobile-mode:not(.stock-mode) #coursesPage table {
  min-width: 720px;
}

.mobile-mode:not(.stock-mode) #coursesPage th:nth-child(4),
.mobile-mode:not(.stock-mode) #coursesPage td:nth-child(4),
.mobile-mode:not(.stock-mode) #coursesPage th:nth-child(10),
.mobile-mode:not(.stock-mode) #coursesPage td:nth-child(10) {
  display: none;
}

.mobile-mode:not(.stock-mode) #watchlistPage table {
  min-width: 860px !important;
}

.mobile-mode:not(.stock-mode) #watchlistPage th:nth-child(1),
.mobile-mode:not(.stock-mode) #watchlistPage td:nth-child(1),
.mobile-mode:not(.stock-mode) #watchlistPage th:nth-child(4),
.mobile-mode:not(.stock-mode) #watchlistPage td:nth-child(4),
.mobile-mode:not(.stock-mode) #watchlistPage th:nth-child(10),
.mobile-mode:not(.stock-mode) #watchlistPage td:nth-child(10) {
  display: none;
}

.mobile-mode:not(.stock-mode) #prospectionPage table {
  min-width: 1180px !important;
}

.mobile-mode:not(.stock-mode) #prospectionPage th:nth-child(1),
.mobile-mode:not(.stock-mode) #prospectionPage td:nth-child(1),
.mobile-mode:not(.stock-mode) #prospectionPage th:nth-child(4),
.mobile-mode:not(.stock-mode) #prospectionPage td:nth-child(4),
.mobile-mode:not(.stock-mode) #prospectionPage th:nth-child(10),
.mobile-mode:not(.stock-mode) #prospectionPage td:nth-child(10) {
  display: none;
}

.mobile-mode .flash-text {
  min-height: 360px;
  padding: 10px;
  font-size: 12px;
}

.mobile-mode .flash-recap table {
  min-width: 900px;
  font-size: 12px;
}

.mobile-mode .trailing-stop-form,
.mobile-mode .trailing-param-grid,
.mobile-mode .oco-form,
.mobile-mode .oco-param-grid {
  grid-template-columns: 1fr;
}

.mobile-mode .flash-order-tool {
  padding: 10px;
}

.mobile-mode .trailing-param-grid,
.mobile-mode .oco-param-grid {
  gap: 6px;
}

.mobile-mode .trailing-param-grid div,
.mobile-mode .oco-param-grid div {
  padding: 8px;
}

.stock-mode.mobile-mode #watchlistPage .prospection-table {
  min-width: 0 !important;
  font-size: 11px;
}

.stock-mode.mobile-mode #watchlistPage th,
.stock-mode.mobile-mode #watchlistPage td {
  padding: 5px 4px;
}

.stock-mode.mobile-mode #watchlistPage .watchlist-remove-btn {
  min-height: 24px;
  padding: 0 5px;
  font-size: 11px;
}

.mobile-mode .portfolio-analysis-header,
.mobile-mode .portfolio-analysis-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.mobile-mode .portfolio-balance-badge {
  justify-self: start;
}

.mobile-mode .portfolio-analysis-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-mode .portfolio-analysis-metrics > div:nth-child(2) {
  border-right: 0;
}

.mobile-mode .portfolio-analysis-metrics > div:nth-child(-n + 2) {
  border-bottom: 1px solid var(--line);
}

.mobile-mode .portfolio-analysis-block + .portfolio-analysis-block {
  border-left: 0;
}

.mobile-mode .portfolio-stress-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-mode .portfolio-allocation-row {
  grid-template-columns: minmax(90px, 0.9fr) minmax(70px, 1fr) 48px;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 8px;
  }

  .topbar {
    display: grid;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }

  .flash-header {
    align-items: stretch;
    display: grid;
  }

  .summary-grid,
  .summary-kpis,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .order-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    border: 0;
    overflow: visible;
  }

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

  .order-form input,
  .order-form select {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
  }

  .order-form .add-order {
    grid-column: 1 / -1;
    border: 1px solid var(--line);
    border-radius: 6px;
    min-height: 38px;
  }

  .orders-table-wrap table {
    min-width: 820px;
    font-size: 12px;
  }

  .summary-table {
    min-width: 760px !important;
  }

  .section-title {
    font-size: 20px;
  }

  .metric {
    padding: 10px;
  }

  .metric strong {
    font-size: 17px;
  }

  .home-actions {
    grid-template-columns: 1fr;
  }

  .home-page {
    padding: 16px;
  }

  .home-panel h1 {
    font-size: 28px;
  }

  .home-choice {
    min-height: 48px;
    font-size: 14px;
  }
}
