:root {
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dbe4ef;
  --line-strong: #cbd7e6;
  --text: #111827;
  --muted: #667085;
  --soft: #8a98ad;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --gold: #c78b00;
  --gold-soft: #fff7df;
  --green: #128847;
  --green-soft: #e9f7ef;
  --red: #d92d20;
  --red-soft: #fff0ee;
  --teal: #087f8c;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: linear-gradient(135deg, #eef4fd 0, var(--bg) 38%, #f7f5ef 100%);
}

button,
table {
  font: inherit;
}

button {
  font-variant-numeric: tabular-nums;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1500px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar-status {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 10px;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: #101828;
  font-size: 38px;
  font-weight: 850;
  line-height: 1.1;
}

h2 {
  color: #111827;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
}

.subtitle,
.panel-head p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  min-width: 146px;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #bfe7cf;
  border-radius: 8px;
  padding: 11px 16px;
  color: #166534;
  background: var(--green-soft);
  font-size: 14px;
  font-weight: 800;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(18, 136, 71, 0.12);
}

.temperature-pill {
  display: grid;
  grid-template-columns: auto auto;
  min-width: 142px;
  min-height: 46px;
  align-content: center;
  align-items: baseline;
  justify-content: center;
  gap: 1px 8px;
  border: 1px solid #b9d7e4;
  border-radius: 8px;
  padding: 7px 13px;
  color: #075985;
  background: #edf8fc;
  font-variant-numeric: tabular-nums;
}

.temperature-pill > span {
  font-size: 11px;
  font-weight: 850;
}

.temperature-pill > b {
  font-size: 17px;
  line-height: 1;
}

.temperature-pill > small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.temperature-pill.warm,
.temperature-pill.waiting {
  border-color: #f1d894;
  color: #805c00;
  background: var(--gold-soft);
}

.temperature-pill.hot {
  border-color: #fecaca;
  color: var(--red);
  background: var(--red-soft);
}

.temperature-pill.stale {
  border-color: var(--line-strong);
  color: #475467;
  background: #f8fafc;
}

.status-pill.waiting,
.status-pill.stale {
  border-color: #f1d894;
  color: #805c00;
  background: var(--gold-soft);
}

.status-pill.waiting span,
.status-pill.stale span {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(199, 139, 0, 0.12);
}

.status-pill.error {
  border-color: #fecaca;
  color: var(--red);
  background: var(--red-soft);
}

.status-pill.error span {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.12);
}

.account-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  margin-bottom: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.account-tab {
  display: grid;
  grid-template-columns: auto auto;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  color: #344054;
  background: transparent;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.account-tab span {
  font-size: 16px;
  font-weight: 850;
}

.account-tab small {
  color: var(--soft);
  font-size: 12px;
  font-weight: 700;
}

.account-tab:hover {
  color: var(--blue);
  background: #f2f7ff;
}

.account-tab.active {
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 7px 16px rgba(37, 99, 235, 0.18);
}

.account-tab.active small {
  color: rgba(255, 255, 255, 0.78);
}

.account-tab:focus-visible,
.ghost-button:focus-visible,
.basis-button:focus-visible,
.range-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.23);
  outline-offset: 2px;
}

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

.metric,
.panel,
.loss-context {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  min-height: 132px;
  align-items: stretch;
  gap: 18px;
  overflow: hidden;
  padding: 20px 20px 20px 0;
}

.metric-accent {
  width: 8px;
  min-height: 90px;
  border-radius: 0 5px 5px 0;
  background: var(--blue);
}

.metric-accent.gold {
  background: var(--gold);
}

.metric-accent.green {
  background: var(--green);
}

.metric-accent.blue {
  background: var(--blue);
}

.metric-accent.red {
  background: var(--red);
}

.metric > div {
  min-width: 0;
  align-self: center;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric > div > span {
  font-size: 14px;
  font-weight: 750;
}

.metric strong {
  display: block;
  margin: 10px 0 7px;
  overflow-wrap: anywhere;
  color: #101828;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric small {
  min-height: 18px;
  font-size: 13px;
  line-height: 1.4;
}

.metric.primary strong,
.positive {
  color: var(--green) !important;
}

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

.neutral {
  color: var(--muted) !important;
}

.metric-pair {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.metric-pair strong {
  margin-block: 10px 7px;
  font-size: 24px;
}

.risk-metric strong {
  color: var(--red);
}

.loss-context {
  display: grid;
  grid-template-columns: minmax(340px, 1.1fr) minmax(0, 1.9fr);
  align-items: center;
  gap: 24px;
  margin-bottom: 18px;
  padding: 18px 22px;
  border-left: 5px solid var(--red);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 850;
}

.loss-context strong {
  display: block;
  color: #1d2939;
  font-size: 16px;
  line-height: 1.45;
}

.loss-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.fact {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  border: 1px solid #e7d9d7;
  border-radius: 6px;
  padding: 7px 10px;
  color: #344054;
  background: #fffafa;
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.fact b {
  color: var(--muted);
  font-size: 11px;
}

.layout,
.comparison-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.comparison-layout {
  grid-template-columns: minmax(0, 1.45fr) minmax(390px, 0.75fr);
}

.panel {
  padding: 21px;
}

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 17px;
}

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

.basis-group,
.range-group,
.zoom-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid #d4e0ef;
  border-radius: 7px;
  padding: 3px;
  background: #f7faff;
}

.zoom-group {
  gap: 5px;
}

.basis-button,
.range-button,
.icon-button {
  min-width: 40px;
  height: 34px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 850;
  transition: color 160ms ease, background 160ms ease, transform 120ms ease;
}

.basis-button:hover,
.range-button:hover,
.icon-button:hover {
  color: var(--blue);
  background: #edf4ff;
}

.basis-button.active,
.range-button.active {
  color: #ffffff;
  background: var(--blue);
}

.icon-button {
  min-width: 34px;
  font-size: 18px;
  line-height: 1;
}

.ghost-button {
  min-height: 34px;
  border: 1px solid #cbdcf1;
  border-radius: 6px;
  padding: 7px 12px;
  color: var(--blue);
  background: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.ghost-button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.ghost-button:active,
.basis-button:active,
.range-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.chart-meta {
  display: flex;
  min-height: 25px;
  align-items: center;
  margin: -3px 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.chart-panel canvas,
.comparison-chart-panel canvas {
  display: block;
  width: 100%;
  height: 430px;
  border: 1px solid #e5e9f0;
  border-radius: 6px;
  background: #ffffff;
  cursor: crosshair;
}

.live-price {
  border: 1px solid #d7e2ef;
  border-radius: 6px;
  padding: 8px 10px;
  color: #344054;
  background: var(--panel-soft);
  font-size: 13px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.position-list {
  display: grid;
}

.position,
.empty {
  padding: 15px 2px;
  border-bottom: 1px solid #edf1f6;
}

.position:first-child,
.empty:first-child {
  border-top: 1px solid #edf1f6;
}

.position {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.position strong {
  color: #101828;
  font-size: 14px;
}

.position small,
.empty {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.position > div:last-child {
  font-size: 15px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.table-panel {
  margin-top: 18px;
}

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

table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #edf2f7;
  padding: 13px 10px;
  text-align: right;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  background: #fafcff;
  font-size: 12px;
  font-weight: 800;
}

td {
  color: #1f2937;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.extreme-cell strong,
.extreme-cell small {
  display: block;
}

.extreme-cell small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.comparison-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.comparison-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.comparison-legend i {
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.line-one {
  background: var(--blue);
}

.line-two {
  background: var(--teal);
}

.score-head,
.score-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr);
  align-items: center;
  gap: 10px;
}

.score-head {
  min-height: 38px;
  border-bottom: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 12px;
}

.score-head strong,
.score-row strong {
  text-align: right;
}

.score-row {
  min-height: 55px;
  border-bottom: 1px solid #edf1f6;
  color: #344054;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.score-row > span:first-child {
  color: var(--muted);
  font-weight: 750;
}

.comparison-table td:last-child {
  color: var(--blue);
  font-weight: 800;
}

.settings-table th:first-child,
.settings-table td:first-child {
  width: 28%;
}

.settings-table td:first-child {
  color: #344054;
  font-weight: 800;
}

.settings-table td:not(:first-child) {
  font-weight: 700;
}

.settings-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

@media (max-width: 1180px) {
  .ticker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout,
  .comparison-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1500px);
    padding-top: 18px;
  }

  .topbar,
  .panel-head,
  .loss-context {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  .status-pill {
    justify-self: start;
  }

  .topbar-status {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .account-tab {
    grid-template-columns: 1fr;
    gap: 2px;
    padding-inline: 6px;
  }

  .account-tab span {
    font-size: 14px;
  }

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

  .metric {
    min-height: 112px;
    padding-block: 16px;
  }

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

  .loss-context {
    gap: 14px;
    padding: 16px;
  }

  .loss-facts {
    justify-content: flex-start;
  }

  .panel {
    padding: 15px;
  }

  .chart-actions {
    justify-content: flex-start;
  }

  .basis-group,
  .range-group,
  .zoom-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .basis-button,
  .range-button {
    flex: 1 1 44px;
  }

  .zoom-group .ghost-button {
    flex: 1 1 92px;
  }

  .chart-panel canvas,
  .comparison-chart-panel canvas {
    height: 360px;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
  }

  tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 12px;
    background: var(--panel-soft);
  }

  td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 0;
    padding: 7px 0;
    text-align: right;
    white-space: normal;
  }

  td:first-child {
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-align: left;
  }

  .extreme-cell {
    display: flex;
  }

  .extreme-cell > span {
    text-align: right;
  }

  .comparison-table td:last-child {
    color: var(--blue);
  }
}

@media (max-width: 420px) {
  .account-tab small {
    display: none;
  }

  .account-tabs {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .metric-pair {
    flex-wrap: wrap;
    gap: 0 12px;
  }

  .score-head,
  .score-row {
    grid-template-columns: minmax(96px, 1fr) minmax(70px, 0.7fr) minmax(70px, 0.7fr);
    gap: 6px;
  }
}
