:root {
  --bg: #f2ead8;
  --bg-deep: #dcc7a1;
  --panel: rgba(54, 38, 22, 0.9);
  --panel-soft: rgba(255, 249, 238, 0.84);
  --panel-line: rgba(78, 54, 28, 0.15);
  --text: #24170d;
  --muted: #6d5643;
  --gold: #d8a730;
  --gold-deep: #8e6112;
  --green: #256b39;
  --red: #9f2f2f;
  --shadow: 0 22px 70px rgba(53, 33, 13, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 244, 210, 0.9), transparent 28%),
    radial-gradient(circle at top right, rgba(173, 122, 38, 0.22), transparent 24%),
    linear-gradient(180deg, #f6f0e2 0%, #ead9b7 50%, #d0b080 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(93, 67, 35, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 67, 35, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.9), transparent 85%);
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 28px;
}

.hero-copy,
.hero-panel,
.summary-card,
.controls,
.status-bar,
.table-wrap {
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 32px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255, 248, 233, 0.92), rgba(227, 197, 146, 0.86));
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--gold-deep);
  font-size: 0.74rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 0.95;
}

.hero-text {
  margin: 18px 0 0;
  max-width: 54ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
}

.hero-panel {
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(50, 32, 17, 0.94), rgba(103, 70, 26, 0.92));
  color: #fff5e7;
}

.hero-stat {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 250, 241, 0.08);
}

.hero-stat .label,
.summary-label,
.control span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-stat strong {
  font-size: 1.4rem;
}

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

.tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.tab-button {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid rgba(81, 57, 27, 0.18);
  background: rgba(255, 249, 238, 0.72);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.tab-button:hover {
  transform: translateY(-1px);
}

.tab-button.active {
  background: linear-gradient(135deg, var(--gold), #f2c45c);
  color: #2c1b07;
  box-shadow: 0 12px 24px rgba(165, 114, 22, 0.24);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.summary-card {
  padding: 22px;
  border-radius: 24px;
  background: var(--panel-soft);
}

.summary-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.2rem;
}

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

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(160px, 0.5fr));
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 14px;
  border-radius: 24px;
  background: rgba(255, 249, 238, 0.88);
}

.filter-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto auto;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control input,
.control select,
.refresh-button {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid rgba(81, 57, 27, 0.18);
  font: inherit;
}

.control input,
.control select {
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.9);
}

.refresh-button {
  padding: 0 18px;
  background: linear-gradient(135deg, var(--gold), #f2c45c);
  color: #2c1b07;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.refresh-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(165, 114, 22, 0.24);
}

.refresh-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ghost-button {
  background: rgba(255, 249, 238, 0.94);
}

.status-bar {
  padding: 14px 18px;
  margin-bottom: 14px;
  border-radius: 18px;
  background: rgba(54, 38, 22, 0.92);
  color: #f9eedb;
}

.status-bar p {
  margin: 0;
}

.detail-panel {
  padding: 22px;
  margin-bottom: 18px;
  border-radius: 28px;
  background: rgba(255, 249, 238, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
}

.opportunity-panel {
  padding: 22px;
  margin-bottom: 18px;
  border-radius: 28px;
  background: rgba(255, 249, 238, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
}

.opportunity-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.opportunity-header h2 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: clamp(1.5rem, 2.4vw, 2.2rem);
}

.opportunity-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
  width: min(100%, 720px);
}

.opportunity-status {
  margin: 0 0 14px;
  color: var(--muted);
}

.opportunity-table-wrap {
  overflow: auto;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(81, 57, 27, 0.1);
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.detail-eyebrow {
  margin-bottom: 8px;
}

.detail-header h2 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.detail-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 72ch;
  line-height: 1.5;
}

.detail-range {
  min-width: 180px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.detail-stat {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(81, 57, 27, 0.12);
}

.detail-stat span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.detail-stat strong {
  font-size: 1.15rem;
}

.chart-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(56, 39, 23, 0.96);
  color: #fff4df;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 99px;
}

.legend-swatch.high-line {
  background: #ffca63;
}

.legend-swatch.low-line {
  background: #f4efe8;
}

.legend-swatch.volume-bar {
  background: #7cc0a3;
}

.chart-meta {
  margin-bottom: 12px;
  color: rgba(255, 244, 223, 0.84);
  line-height: 1.5;
}

.chart-area {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-chart,
.loading-chart {
  color: rgba(255, 244, 223, 0.7);
}

.history-chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.history-chart text {
  fill: rgba(255, 244, 223, 0.82);
  font-size: 12px;
  font-family: "Space Grotesk", sans-serif;
}

.chart-axis {
  stroke: rgba(255, 244, 223, 0.18);
  stroke-width: 1;
}

.chart-volume rect {
  fill: rgba(124, 192, 163, 0.4);
}

.chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-line-high {
  stroke: #ffca63;
}

.chart-line-low {
  stroke: #f4efe8;
}

.table-wrap {
  overflow: auto;
  border-radius: 28px;
  background: rgba(255, 249, 240, 0.86);
}

table {
  min-width: 760px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: rgba(108, 74, 31, 0.08);
}

th,
td {
  padding: 16px 18px;
  text-align: left;
  border-bottom: 1px solid rgba(78, 54, 28, 0.1);
}

th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: rgba(255, 237, 193, 0.28);
  cursor: pointer;
}

.item-row.selected {
  background: rgba(216, 167, 48, 0.18);
  outline: 1px solid rgba(142, 97, 18, 0.25);
}

.item-cell strong,
.item-cell span {
  display: block;
}

.item-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.profit.positive,
.roi.positive {
  color: var(--green);
  font-weight: 700;
}

.profit.negative,
.roi.negative {
  color: var(--red);
  font-weight: 700;
}

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

@media (max-width: 960px) {
  .hero,
  .summary-grid,
  .controls,
  .filter-grid,
  .detail-stats {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-direction: column;
  }

  .detail-header {
    flex-direction: column;
  }

  .opportunity-header {
    flex-direction: column;
  }

  .opportunity-filters {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .refresh-button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 18px;
  }

  .hero-copy,
  .hero-panel,
  .summary-card,
  .controls,
  .status-bar,
  .detail-panel,
  .table-wrap {
    border-radius: 20px;
  }

  th,
  td {
    padding: 14px 12px;
  }

  table {
    font-size: 0.94rem;
  }
}
