/* Inspired by US market terminals (TradingView / Bloomberg-style desk) */
:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-soft: #182338;
  --bg-row: #0f1726;
  --line: rgba(120, 144, 180, 0.18);
  --text: #f4f7fb;
  --muted: #8fa3bf;
  --accent: #2962ff;
  --accent-hot: #1e88e5;
  --accent-dim: rgba(41, 98, 255, 0.18);
  --danger: #ef5350;
  --up: #26a69a;
  --down: #ef5350;
  --flat: #90a4ae;
  --gold: #ffb74d;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 520px at 8% -8%, rgba(41, 98, 255, 0.22), transparent 58%),
    radial-gradient(800px 420px at 92% 4%, rgba(38, 166, 154, 0.12), transparent 55%),
    radial-gradient(600px 380px at 50% 100%, rgba(30, 136, 229, 0.08), transparent 50%),
    linear-gradient(180deg, #0b1220 0%, #070d18 100%);
  z-index: -1;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.78);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.65rem;
  background: linear-gradient(145deg, #2962ff, #00bcd4);
  box-shadow: 0 0 28px rgba(41, 98, 255, 0.45);
}

.brand h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.tagline {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.seg {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 0.65rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 0.5rem;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-dim);
  color: #90caf9;
  box-shadow: inset 0 0 0 1px rgba(41, 98, 255, 0.35);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.field select,
#searchInput {
  font: inherit;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.5rem 0.7rem;
  min-width: 10rem;
}

.field select:focus,
#searchInput:focus {
  outline: none;
  border-color: rgba(41, 98, 255, 0.65);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.sync-btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 0.65rem;
  padding: 0.65rem 1.05rem;
  cursor: pointer;
  background: linear-gradient(135deg, #2962ff, #1e88e5);
  color: #fff;
  box-shadow: 0 8px 24px rgba(41, 98, 255, 0.3);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.sync-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.sync-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.35);
  box-shadow: none;
}

.sync-msg {
  margin: 0.75rem 1.5rem 0;
  padding: 0.65rem 0.9rem;
  border-radius: 0.6rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.sync-msg.error {
  color: #ff8a80;
  border-color: rgba(239, 83, 80, 0.4);
  background: rgba(239, 83, 80, 0.08);
}

.sync-msg.ok {
  color: #80cbc4;
  border-color: rgba(38, 166, 154, 0.35);
  background: rgba(38, 166, 154, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem 1.25rem;
  height: calc(100vh - 88px);
  min-height: 0;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.breadth-panel,
.table-panel {
  background: linear-gradient(180deg, rgba(18, 26, 43, 0.95), rgba(15, 23, 38, 0.92));
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.75rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.table-panel {
  overflow: hidden;
}

.breadth-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.breadth-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.breadth-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.breadth-stats {
  width: 100%;
  display: grid;
  gap: 0.45rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.breadth-stats div {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.5rem;
  border-radius: 0.45rem;
  background: var(--bg-row);
  border: 1px solid rgba(120, 144, 180, 0.1);
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.4rem;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: end;
  margin-left: auto;
}

.chart-site-field select {
  min-width: 11.5rem;
  border-color: rgba(41, 98, 255, 0.4);
  background: linear-gradient(180deg, #16233a, #121a2b);
}

.chart-hint {
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.chart-hint strong {
  color: #90caf9;
}

.sheet-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: 60%;
}

.chip {
  border: 1px solid var(--line);
  background: var(--bg-row);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.chip.active {
  color: #bbdefb;
  border-color: rgba(41, 98, 255, 0.55);
  background: var(--accent-dim);
}

.table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: none;
  border-radius: 0.55rem;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #152038;
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  color: #a7b8d0;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

thead th:hover {
  color: #90caf9;
}

tbody td {
  padding: 0.32rem 0.5rem;
  border-bottom: 1px solid rgba(120, 144, 180, 0.08);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:nth-child(even) {
  background: rgba(18, 26, 43, 0.55);
}

tbody tr:hover {
  background: rgba(41, 98, 255, 0.1);
}

td.symbol-cell {
  font-family: var(--font);
  font-weight: 700;
  color: #82b1ff;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(130, 177, 255, 0.35);
  text-underline-offset: 2px;
}

td.symbol-cell:hover {
  color: #bbdefb;
  text-decoration-color: #bbdefb;
}

td.cell-up {
  color: var(--up);
  font-weight: 600;
}

td.cell-down {
  color: var(--down);
  font-weight: 600;
}

.row-count {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}
