:root {
  color-scheme: dark;
  --bg: #090e16;
  --panel: #0e1623;
  --panel-2: #121d2c;
  --line: #223044;
  --line-soft: #182536;
  --text: #e9eef7;
  --muted: #8ea0b9;
  --cyan: #42c7d9;
  --amber: #f4b84a;
  --red: #f06472;
  --green: #48c78e;
  --violet: #7b61ff;
}

* {
  box-sizing: border-box;
}

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

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

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.search-wrap {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
}

input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b121e;
  color: var(--text);
  padding: 0 14px 0 40px;
  outline: none;
}

input:focus {
  border-color: var(--cyan);
}

.ghost-button,
.icon-button,
.analysis-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111b2a;
  color: var(--text);
  cursor: pointer;
}

.ghost-button {
  height: 42px;
  padding: 0 16px;
}

.ghost-button[aria-pressed="true"] {
  border-color: var(--amber);
  color: var(--amber);
}

.status {
  justify-self: end;
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: calc(100vh - 150px);
  overflow: auto;
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  background: #101928;
}

.sort-header {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.sort-header[data-sort="desc"],
.sort-header[data-sort="asc"] {
  color: var(--cyan);
}

th:nth-child(2),
td:nth-child(2),
th:nth-child(10),
td:nth-child(10) {
  text-align: left;
}

tr:hover td {
  background: rgba(66, 199, 217, 0.04);
}

.favorite-col {
  width: 42px;
}

.star {
  border: 0;
  background: transparent;
  color: #617086;
  font-size: 20px;
  cursor: pointer;
}

.star.active {
  color: var(--amber);
}

.stock {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #08111f;
  background: #f4f7fb;
  border: 1px solid rgba(142, 160, 185, 0.28);
  font-weight: 800;
  font-size: 11px;
}

.avatar img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.avatar-fallback {
  background: var(--cyan);
  border-color: transparent;
}

.avatar-fallback::before {
  content: attr(data-fallback);
}

.stock-name {
  font-weight: 700;
}

.ticker {
  color: var(--cyan);
  font-size: 12px;
  margin-top: 2px;
}

.market {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}

.price-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.session-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.session-quote,
.session-change {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.session-quote.active-session {
  color: var(--text);
  font-weight: 700;
}

.session-label {
  display: inline-flex;
  align-items: center;
  height: 16px;
  padding: 0 3px;
  border: 1px solid #46546a;
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.sub-quote,
.sub-change {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.sub-change span {
  display: inline-flex;
  align-items: center;
  height: 16px;
  margin-left: 4px;
  padding: 0 3px;
  border: 1px solid #46546a;
  border-radius: 3px;
  color: var(--muted);
  font-size: 10px;
}

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

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

.rank {
  color: var(--red);
  font-weight: 700;
}

.pe {
  display: inline-flex;
  min-width: 50px;
  justify-content: center;
  border-radius: 4px;
  padding: 3px 6px;
  color: var(--amber);
  background: rgba(244, 184, 74, 0.13);
  font-weight: 700;
}

.note {
  color: var(--muted);
}

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

.analysis-button {
  min-width: 70px;
  height: 30px;
  color: #dcd7ff;
  background: rgba(123, 97, 255, 0.16);
  border-color: rgba(123, 97, 255, 0.35);
}

.loading {
  height: 96px;
  text-align: center;
  color: var(--muted);
}

.analysis-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 18px;
}

.analysis-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.analysis-head p {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
}

.analysis-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-button {
  width: 32px;
  height: 32px;
  font-size: 20px;
}

#analysis-body {
  margin: 14px 0 0;
  color: #cbd6e6;
  line-height: 1.65;
}

@media (max-width: 760px) {
  .shell {
    width: calc(100vw - 20px);
    padding: 14px 0;
  }

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

  .status {
    justify-self: start;
    flex-wrap: wrap;
  }
}
