@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
  --bg: #f5f4ef;
  --bg-soft: #ffffffcc;
  --ink: #112017;
  --ink-muted: #44514a;
  --accent: #0f7a5d;
  --accent-soft: #9ddac4;
  --danger: #c2362f;
  --steady: #8a650d;
  --line: #d8e0d8;
  --radius: 14px;
  --shadow: 0 14px 50px rgba(17, 32, 23, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 420px at 0% 0%, #f0f8f3 0%, transparent 72%),
    linear-gradient(180deg, #f9f8f4 0%, var(--bg) 100%);
  min-height: 100vh;
}

.bg-orb {
  position: fixed;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(70px);
  pointer-events: none;
  z-index: -1;
}

.bg-orb-a {
  top: -80px;
  right: -60px;
  background: #c5f0dd;
}

.bg-orb-b {
  bottom: -140px;
  left: -80px;
  background: #ffd8a4;
}

.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding: 2rem 0.7rem 2.5rem;
}

.hero {
  margin-bottom: 1.5rem;
}

.kicker {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.6rem);
  margin: 0;
}

.hero-copy {
  max-width: 700px;
  color: var(--ink-muted);
}

.cards {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.card p {
  margin: 0.45rem 0 0;
  font-size: 1.45rem;
  font-weight: 700;
}

.summary-card {
  min-width: 0;
}

.summary-card-wide {
  grid-column: span 2;
}

.summary-card-breadth {
  grid-column: span 6;
}

.summary-card-chart {
  grid-column: 7 / span 3;
  grid-row: 1 / span 2;
}

.summary-value {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.summary-value-nowrap {
  white-space: nowrap;
}

.summary-move {
  font-size: 0.9rem;
  font-weight: 600;
}

.summary-card-as-of {
  grid-column: 1 / -1;
  padding: 0.2rem 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.summary-card-as-of p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.breadth-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.breadth-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #f8fbf8;
}

.breadth-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.breadth-item strong {
  display: block;
  margin-top: 0.16rem;
  font-size: 1.35rem;
}

.nepse-chart-wrap {
  margin-top: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
}

.nepse-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.nepse-chart-axis {
  stroke: #cfdbd2;
  stroke-width: 1;
}

.nepse-chart-area {
  fill: url(#nepseAreaGradient);
}

.nepse-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.nepse-chart-dot {
  fill: var(--accent);
}

.nepse-chart-meta,
.nepse-chart-levels {
  display: flex;
  justify-content: space-between;
  color: var(--ink-muted);
}

.nepse-chart-meta {
  font-size: 0.74rem;
}

.nepse-chart-levels {
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", "Consolas", monospace;
}

.nepse-chart-empty {
  margin: 0.55rem 0 0;
  font-size: 0.86rem;
}

.breadth-advanced strong {
  color: var(--accent);
}

.breadth-declined strong {
  color: var(--danger);
}

.breadth-unchanged strong {
  color: var(--steady);
}

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 1rem;
  overflow: hidden;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 1rem;
  align-items: end;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 210px;
}

label {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

input,
select,
button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font: inherit;
}

button {
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-panel {
  padding-bottom: 1rem;
}

.table-head {
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1.2rem;
}

.table-head h2 {
  margin: 0;
}

.table-head p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1110px;
  table-layout: fixed;
}

th,
td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  font-size: 0.82rem;
  text-transform: uppercase;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  text-align: center;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.55rem;
}

th.sortable .sort-indicator {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0.9rem;
  text-align: center;
  color: #84948b;
}

th.sortable.is-sorted {
  color: var(--ink);
}

th.sortable.is-sorted .sort-indicator {
  color: var(--accent);
}

th:nth-child(1),
td:nth-child(1) {
  width: 58px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 300px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 140px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 106px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 88px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 132px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 136px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 138px;
  text-align: right;
}

th:nth-child(1),
td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f9faf7;
}

th:nth-child(2),
td:nth-child(2) {
  position: sticky;
  left: 58px;
  z-index: 2;
  background: #f9faf7;
  box-shadow: 1px 0 0 var(--line);
}

th:nth-child(1),
th:nth-child(2) {
  z-index: 4;
}

tbody tr:hover td:nth-child(1),
tbody tr:hover td:nth-child(2) {
  background: #ebf6f0;
}

.security-cell {
  white-space: normal;
  line-height: 1.2;
}

.security-name,
.security-symbol {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.security-name {
  font-weight: 400;
}

.security-symbol {
  margin-top: 0.16rem;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.ltp-cell {
  text-align: right;
}

.market-cap-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.symbol-trend-cell {
  text-align: right;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  text-overflow: clip;
  white-space: normal;
  overflow: visible;
}

.symbol-trend-wrap {
  display: inline-block;
  width: 120px;
}

.symbol-trend-svg {
  display: block;
  width: 100%;
  height: 32px;
}

.symbol-trend-line {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.symbol-trend-line-up {
  stroke: var(--accent);
}

.symbol-trend-line-down {
  stroke: var(--danger);
}

.symbol-trend-line-flat {
  stroke: var(--steady);
}

.symbol-trend-empty {
  display: inline-block;
  min-width: 120px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.ltp-value {
  display: inline-flex;
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
}

.ltp-decimal-slot {
  display: inline-block;
  visibility: hidden;
}

table.hide-sector-column {
  min-width: 960px;
}

table.hide-sector-column th:nth-child(3),
table.hide-sector-column td:nth-child(3) {
  display: none;
}

tbody tr {
  cursor: pointer;
  transition: background 150ms ease;
}

tbody tr:hover {
  background: #ebf6f0;
}

.value-positive {
  color: var(--accent);
  font-weight: 700;
}

.value-negative {
  color: var(--danger);
  font-weight: 700;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1rem;
  margin-top: 0.8rem;
}

.pager button {
  min-width: 90px;
}

.sector-bars {
  padding: 0 1rem 1rem;
}

.sector-item {
  margin-top: 0.65rem;
}

.sector-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
  color: var(--ink-muted);
  font-size: 0.87rem;
}

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

.sector-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transform-origin: left;
  animation: fillGrow 0.7s ease both;
}

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

.mono {
  font-family: "IBM Plex Mono", "Consolas", monospace;
}

.detail-wrap {
  max-width: 960px;
}

.detail-chart-wrap {
  padding: 0 1rem 1rem;
}

.detail-chart-box {
  margin-top: 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.detail-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.detail-chart-axis {
  stroke: #cfdbd2;
  stroke-width: 1;
}

.detail-chart-grid {
  stroke: #dbe5de;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.detail-chart-y-label {
  fill: var(--ink-muted);
  font-size: 0.72rem;
  text-anchor: end;
  dominant-baseline: middle;
  font-family: "IBM Plex Mono", "Consolas", monospace;
}

.detail-chart-area {
  fill: url(#detailAreaGradient);
}

.detail-chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  vector-effect: non-scaling-stroke;
}

.detail-chart-dot {
  fill: var(--accent);
}

.detail-chart-meta,
.detail-chart-levels {
  display: flex;
  justify-content: space-between;
  color: var(--ink-muted);
}

.detail-chart-meta {
  font-size: 0.78rem;
}

.detail-chart-empty {
  margin: 0.3rem 0 0;
  font-size: 0.88rem;
}

.back-link {
  display: inline-flex;
  margin-bottom: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem;
  padding: 0 1rem 1rem;
}

.kv {
  background: #f8fbf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
}

.kv p:first-child {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.kv p:last-child {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  font-weight: 600;
}

@keyframes fillGrow {
  from {
    transform: scaleX(0.15);
    opacity: 0.5;
  }
  to {
    transform: scaleX(1);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .layout {
    padding: 1.2rem 0.8rem 2rem;
  }

  table {
    min-width: 1050px;
  }

  table.hide-sector-column {
    min-width: 910px;
  }

  th:nth-child(1),
  td:nth-child(1),
  th:nth-child(2),
  td:nth-child(2) {
    position: static;
    left: auto;
    box-shadow: none;
    background: transparent;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: 260px;
  }

  .summary-card-wide,
  .summary-card-breadth,
  .summary-card-chart {
    grid-column: 1 / -1;
  }

  .summary-card-chart {
    grid-row: auto;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .control-row {
    min-width: 100%;
  }

  .pager {
    justify-content: space-between;
  }
}
