:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f4f4;
  --text: #19212a;
  --muted: #687481;
  --border: #d9e0e6;
  --teal: #087f7a;
  --blue: #2e5aac;
  --amber: #b96f00;
  --red: #b43d3d;
  --shadow: 0 10px 28px rgba(31, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 13px;
  white-space: nowrap;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.is-ok::before {
  background: var(--teal);
}

.status-dot.is-error::before {
  background: var(--red);
}

.icon-button,
.secondary-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
}

.icon-button {
  padding: 0 14px;
}

.secondary-button {
  padding: 0 12px;
}

.icon-button:hover,
.secondary-button:hover,
.entity-row:hover,
.status-segment:hover {
  border-color: #aeb9c3;
  background: #f9fbfb;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.controls-panel,
.content-panel,
.exchange-panel,
.activity-panel,
.vote-panel,
.roi-panel,
.trend-panel,
.chart-panel,
.table-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls-panel {
  align-self: start;
  padding: 18px;
  position: sticky;
  top: 16px;
}

.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(8, 127, 122, 0.18);
  outline-offset: 1px;
}

.entity-list {
  display: grid;
  gap: 8px;
  max-height: 340px;
  margin-bottom: 18px;
  padding-right: 4px;
  overflow: auto;
}

.entity-row {
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  text-align: left;
}

.entity-row.is-selected {
  border-color: var(--teal);
  background: #edf8f7;
}

.entity-row strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-row span,
.loading-row,
.empty-table {
  color: var(--muted);
  font-size: 13px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.segment {
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  background: var(--teal);
  color: #fff;
}

.segment:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.selection-panel {
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
}

.selection-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.selection-panel h2 {
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: 0;
}

.selection-panel p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.content-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  min-height: 110px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.metric-card span,
.metric-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin: 10px 0 7px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.message-area {
  padding: 12px 14px;
  border: 1px solid #e1bd79;
  border-radius: 8px;
  background: #fff7e8;
  color: #6f4700;
  line-height: 1.4;
}

.message-area.is-error {
  border-color: #e2a0a0;
  background: #fff1f1;
  color: #7c2626;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.activity-panel,
.exchange-panel,
.vote-panel,
.roi-panel,
.trend-panel,
.chart-panel,
.table-panel {
  box-shadow: none;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.exchange-panel {
  overflow: hidden;
  border-color: #1d2a35;
  background: #071015;
  color: #d8f6f4;
}

.exchange-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 70px;
  padding: 14px 16px;
  border-bottom: 1px solid #263744;
  background: linear-gradient(180deg, #1b2a36, #0c151c);
}

.exchange-kicker {
  margin-bottom: 4px;
  color: #6de7df;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.exchange-topline h2 {
  margin-bottom: 0;
  color: #f7fffe;
  font-size: 22px;
}

.exchange-market-stats {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 4px;
  color: #9bb7c4;
  font-size: 13px;
  text-align: right;
}

.exchange-market-stats strong {
  color: #4dff7a;
  font-size: 18px;
}

.exchange-ticker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid #263744;
  background: #263744;
}

.exchange-ticker span {
  overflow: hidden;
  padding: 9px 12px;
  background: #0c151c;
  color: #f4d35e;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exchange-controls {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(360px, 1fr);
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #263744;
}

.exchange-panel label {
  color: #9bb7c4;
}

.exchange-panel input {
  border-color: #263744;
  background: #0c151c;
  color: #f7fffe;
}

.exchange-segments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 40px;
  border: 1px solid #263744;
  border-radius: 6px;
  overflow: hidden;
}

.exchange-segment {
  min-width: 0;
  border: 0;
  border-right: 1px solid #263744;
  background: #101d26;
  color: #a9c3cf;
  font-size: 13px;
  font-weight: 900;
}

.exchange-segment:last-child {
  border-right: 0;
}

.exchange-segment:hover {
  background: #172b36;
}

.exchange-segment.is-active {
  background: #244d84;
  color: #fff;
}

.exchange-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.7fr);
  gap: 0;
}

.exchange-board-wrap {
  min-width: 0;
  max-height: 620px;
  overflow: auto;
  border-right: 1px solid #263744;
}

.exchange-board {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  background: #05090c;
  color: #e6fffb;
}

.exchange-board th,
.exchange-board td {
  padding: 7px 8px;
  border-bottom: 1px solid #17222b;
  white-space: nowrap;
}

.exchange-board th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #152430;
  color: #a9c3cf;
  font-size: 11px;
  text-transform: uppercase;
}

.exchange-board td {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
}

.exchange-row {
  cursor: pointer;
}

.exchange-row:nth-child(even) {
  background: #090f13;
}

.exchange-row:hover,
.exchange-row.is-selected {
  background: #122a40;
}

.exchange-code {
  color: #49d7ff;
  font-weight: 900;
}

.exchange-party-cell strong {
  display: block;
  max-width: 210px;
  overflow: hidden;
  color: #f7fffe;
  text-overflow: ellipsis;
}

.exchange-party-cell span {
  color: #7f9bab;
  font-size: 11px;
}

.market-up {
  color: #4dff7a;
  font-weight: 900;
}

.market-down {
  color: #ff5a66;
  font-weight: 900;
}

.market-flat {
  color: #e8edf1;
}

.market-warn {
  color: #f4d35e;
  font-weight: 900;
}

.exchange-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #263744;
  border-radius: 999px;
  color: #d8f6f4;
  font-size: 11px;
  font-weight: 900;
}

.exchange-empty {
  height: 120px;
  color: #9bb7c4;
  text-align: center;
}

.exchange-detail {
  min-width: 0;
  padding: 14px;
  background: #081118;
}

.exchange-detail-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.exchange-detail-heading span {
  color: #49d7ff;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-weight: 900;
}

.exchange-detail-heading h3 {
  margin: 4px 0 0;
  color: #f7fffe;
  font-size: 18px;
  line-height: 1.2;
}

.exchange-detail-heading strong {
  align-self: start;
  color: #4dff7a;
  font-size: 14px;
  white-space: nowrap;
}

.exchange-detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.exchange-detail-metrics article {
  min-height: 78px;
  padding: 10px;
  border: 1px solid #263744;
  border-radius: 8px;
  background: #0c151c;
}

.exchange-detail-metrics span {
  display: block;
  color: #9bb7c4;
  font-size: 12px;
  font-weight: 800;
}

.exchange-detail-metrics strong {
  display: block;
  margin-top: 8px;
  color: #f7fffe;
  font-size: 20px;
}

.exchange-mini-chart {
  margin-top: 12px;
  border: 1px solid #263744;
  border-radius: 8px;
  background: #0c151c;
  overflow: hidden;
}

.exchange-mini-chart .panel-heading {
  border-color: #263744;
}

.exchange-mini-chart .panel-heading h2 {
  color: #f7fffe;
}

.exchange-mini-chart .panel-heading span {
  color: #9bb7c4;
}

.compact-chart {
  height: 190px;
}

.activity-heading {
  min-height: 64px;
}

.vote-heading {
  min-height: 64px;
}

.trend-heading {
  min-height: 64px;
}

.roi-heading {
  min-height: 64px;
}

.activity-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px 0;
}

.vote-summary,
.roi-summary,
.trend-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 14px;
}

.vote-card,
.roi-card,
.trend-card {
  min-height: 96px;
}

.activity-card {
  min-height: 96px;
}

.activity-controls,
.vote-controls,
.roi-controls,
.trend-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) minmax(280px, 420px);
  gap: 12px;
  padding: 14px 16px;
}

.vote-controls {
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 320px);
}

.roi-controls {
  grid-template-columns: minmax(240px, 320px) minmax(220px, 280px);
}

.trend-controls {
  grid-template-columns: minmax(220px, 420px);
}

.wide-field {
  min-width: 0;
}

.compact-field {
  margin-bottom: 0;
}

.status-segments {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.status-segment {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-segment:last-child {
  border-right: 0;
}

.status-segment.is-active {
  background: var(--blue);
  color: #fff;
}

.activity-table-wrap {
  border-top: 1px solid var(--border);
}

.activity-table {
  min-width: 1060px;
}

.vote-table-wrap {
  border-top: 1px solid var(--border);
}

.vote-table {
  min-width: 920px;
}

.trend-table-wrap {
  border-top: 1px solid var(--border);
}

.roi-table-wrap {
  border-top: 1px solid var(--border);
}

.trend-table {
  min-width: 980px;
}

.roi-table {
  min-width: 1240px;
}

.trend-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
  padding: 0 16px 16px;
}

.embedded-chart {
  border-radius: 8px;
}

.vote-bars {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.trend-bars {
  padding-top: 16px;
}

.roi-bars {
  padding-top: 0;
}

.vote-bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) minmax(90px, auto);
  align-items: center;
  gap: 12px;
}

.vote-bar-label {
  min-width: 0;
  font-weight: 800;
}

.vote-bar-label span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vote-bar-track {
  height: 18px;
  border-radius: 999px;
  background: #e8edf1;
  overflow: hidden;
}

.vote-bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.vote-bar-fill.is-negative {
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.vote-bar-value {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.trend-line {
  fill: none;
  stroke-width: 3;
}

.trend-line-label {
  fill: #19212a;
  font-size: 11px;
  font-weight: 800;
}

.activity-row {
  cursor: pointer;
}

.activity-row:hover {
  background: #f9fbfb;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.active {
  border-color: rgba(8, 127, 122, 0.28);
  background: #edf8f7;
  color: #075d5a;
}

.status-pill.inactive {
  border-color: rgba(185, 111, 0, 0.28);
  background: #fff7e8;
  color: #7a4a00;
}

.status-pill.no_ge_history {
  background: #f4f6f8;
  color: #4d5965;
}

.entity-cell strong {
  display: block;
}

.entity-cell span,
.muted-cell {
  color: var(--muted);
  font-size: 12px;
}

.chart-box {
  height: 280px;
  padding: 12px;
}

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

.axis-label {
  fill: #687481;
  font-size: 11px;
}

.grid-line {
  stroke: #e8edf1;
  stroke-width: 1;
}

.line-seats {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
}

.line-votes {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
}

.chart-dot {
  stroke: #fff;
  stroke-width: 2;
}

.table-heading {
  min-height: 62px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #fafbfc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.numeric {
  text-align: right;
}

.empty-table {
  height: 90px;
  text-align: center;
}

@media (max-width: 1080px) {
  .dashboard-grid,
  .chart-grid,
  .exchange-layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    position: static;
  }

  .exchange-board-wrap {
    border-right: 0;
    border-bottom: 1px solid #263744;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .activity-summary,
  .activity-controls,
  .vote-summary,
  .vote-controls,
  .roi-summary,
  .roi-controls,
  .trend-summary,
  .trend-controls,
  .trend-chart-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .activity-controls .compact-field:last-child {
    grid-column: 1 / -1;
  }

  .exchange-ticker,
  .exchange-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .dashboard-grid {
    padding: 12px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .exchange-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .exchange-market-stats {
    align-items: flex-start;
    text-align: left;
  }

  .exchange-ticker,
  .exchange-controls,
  .exchange-segments,
  .exchange-detail-metrics {
    grid-template-columns: 1fr;
  }

  .activity-summary,
  .activity-controls,
  .vote-summary,
  .vote-controls,
  .roi-summary,
  .roi-controls,
  .trend-summary,
  .trend-controls,
  .trend-chart-grid {
    grid-template-columns: 1fr;
  }

  .activity-controls .compact-field:last-child {
    grid-column: auto;
  }

  .status-segments {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vote-bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .vote-bar-value {
    text-align: left;
  }

  .chart-box {
    height: 240px;
  }
}
