:root {
  color-scheme: dark;
  --bg: #101211;
  --panel: #181b19;
  --panel-2: #20241f;
  --ink: #f4f1e8;
  --muted: #a9aea4;
  --border: #333a33;
  --accent: #42d889;
  --accent-2: #f3b54a;
  --bad: #ff6f61;
  --good: #52e39a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(66, 216, 137, 0.08), transparent 34%),
    radial-gradient(circle at 86% 10%, rgba(243, 181, 74, 0.12), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 0.96;
  letter-spacing: 0;
}

.topbar p,
.table-head p,
.hint,
.wide-card p {
  color: var(--muted);
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.page-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  min-height: 34px;
  border: 1px solid var(--border);
  background: rgba(24, 27, 25, 0.75);
  color: var(--muted);
}

.tab-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #07130c;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.status {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--muted);
  background: rgba(24, 27, 25, 0.75);
  font-size: 13px;
  white-space: nowrap;
}

.status.live {
  color: #0f1712;
  background: var(--accent);
  border-color: var(--accent);
}

.status.error {
  color: #170f0f;
  background: var(--bad);
  border-color: var(--bad);
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.shard-workspace {
  grid-template-columns: 320px 1fr;
}

.controls-panel,
.metric,
.wide-card,
.table-panel {
  background: rgba(24, 27, 25, 0.9);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.controls-panel,
.table-panel {
  border-radius: 8px;
}

.controls-panel {
  padding: 18px;
}

.panel-title,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #07130c;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.secondary-btn {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--border);
  color: var(--ink);
  background: #0d0f0e;
}

.field,
.select-field,
.readout {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.select-field select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 12px;
  background: #0d0f0e;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.select-field select:focus {
  border-color: var(--accent);
}

.readout {
  min-height: 58px;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #0d0f0e;
}

.readout strong {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.15;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.35;
}

.checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.hint {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.5;
}

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

.metric,
.wide-card {
  border-radius: 8px;
  padding: 18px;
}

.metric span,
.wide-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(21px, 2.6vw, 34px);
  line-height: 1.02;
}

.metric.positive strong,
.profit-positive {
  color: var(--good);
}

.metric.negative strong,
.profit-negative {
  color: var(--bad);
}

.wide-card {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  background: linear-gradient(135deg, rgba(66, 216, 137, 0.12), rgba(243, 181, 74, 0.06)), var(--panel-2);
}

.wide-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 3vw, 40px);
}

.wide-card p {
  max-width: 430px;
  line-height: 1.45;
}

.table-panel {
  overflow: hidden;
}

.fusion-panel {
  margin-bottom: 18px;
}

.table-head {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.fusion-summary {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.fusion-summary strong {
  color: var(--good);
  font-size: 22px;
  line-height: 1;
}

.select-field {
  min-width: 190px;
  margin-top: 0;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 14px 16px;
  text-align: right;
  border-bottom: 1px solid rgba(51, 58, 51, 0.72);
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #121512;
}

td {
  color: #ddd9ce;
  font-size: 14px;
}

tbody tr:hover {
  background: rgba(66, 216, 137, 0.055);
}

.item-name {
  color: var(--ink);
  font-weight: 800;
}

td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.market {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #101311;
  font-size: 12px;
  font-weight: 800;
}

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

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

  .top-actions {
    justify-items: start;
  }

  .status-strip {
    justify-content: flex-start;
  }

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

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

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

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

  .table-head,
  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  button,
  .select-field {
    width: 100%;
  }
}
