:root {
  color-scheme: dark;
  --bg: #0c1016;
  --panel: #171c25;
  --panel-2: #202733;
  --line: #323b4a;
  --text: #f4f1e8;
  --muted: #aab3c1;
  --accent: #d8aa57;
  --accent-strong: #efc36e;
  --positive: #79d99f;
  --negative: #ff9292;
  --neutral: #8fb8ed;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.30);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 0%, rgba(216, 170, 87, 0.11), transparent 30rem),
    radial-gradient(circle at 90% 20%, rgba(83, 121, 171, 0.08), transparent 26rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-header,
main,
footer {
  width: min(1480px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 48px 0 26px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.17em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 5vw, 4.2rem);
  line-height: 0.96;
}

.subtitle {
  max-width: 780px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

main { padding-bottom: 38px; }

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(23, 28, 37, 0.95);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  grid-template-columns: repeat(8, minmax(125px, 1fr));
  gap: 12px;
  padding: 17px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 680;
}

input,
select,
button { font: inherit; }

input,
select {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #10151d;
  color: var(--text);
  padding: 9px 11px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border-radius: 12px;
  padding: 0 19px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: var(--accent);
  color: #21180a;
}

.primary-button:hover { background: var(--accent-strong); }
.primary-button:disabled { opacity: 0.55; cursor: wait; }

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.secondary-button:hover { border-color: var(--accent); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 13px;
  margin: 15px 0;
}

.summary-card {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  padding: 17px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.35;
}

.summary-card strong {
  display: block;
  margin-top: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 18px 18px 0;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: rgba(216, 170, 87, 0.12);
  color: var(--text);
}

.table-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
}

.status { margin: 0; color: var(--muted); }
.status.error { color: var(--negative); }
.status.success { color: var(--positive); }
.countdown { margin: 5px 0 0; color: var(--muted); font-size: 0.76rem; }

.toolbar-controls {
  display: flex;
  align-items: end;
  gap: 14px;
}

.sort-label { min-width: 210px; }

.text-button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  cursor: pointer;
}

.text-button:hover { color: var(--text); }

.table-wrapper {
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 15px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.71rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.profit { color: var(--positive); font-weight: 800; }
.loss { color: var(--negative); font-weight: 800; }
.trend-up { color: var(--positive); }
.trend-down { color: var(--negative); }
.trend-flat { color: var(--muted); }

.item-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 210px;
}

.item-cell img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.item-name { line-height: 1.25; }
.item-price { display: block; margin-top: 3px; color: var(--muted); font-size: 0.72rem; }

.category-badge,
.confidence-badge,
.stability-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  white-space: nowrap;
  font-size: 0.72rem;
}

.category-badge { color: var(--muted); }
.confidence-high { color: var(--positive); border-color: rgba(121, 217, 159, 0.45); }
.confidence-medium { color: var(--accent-strong); border-color: rgba(239, 195, 110, 0.45); }
.confidence-low { color: var(--negative); border-color: rgba(255, 146, 146, 0.45); }
.stability-badge { color: var(--neutral); }

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

.notice {
  margin-top: 16px;
  border-left: 3px solid var(--accent);
  background: rgba(216, 170, 87, 0.08);
  color: var(--muted);
  padding: 14px 16px;
  line-height: 1.5;
}

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 24px 0 40px;
  font-size: 0.8rem;
}

@media (max-width: 1280px) {
  .controls { grid-template-columns: repeat(4, 1fr); }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  .site-header { align-items: stretch; flex-direction: column; padding-top: 34px; }
  .header-actions { justify-content: flex-start; }
  .controls { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-controls { align-items: stretch; flex-direction: column; }
  .sort-label { min-width: 0; }
}

@media (max-width: 520px) {
  .controls { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .primary-button, .secondary-button { flex: 1 1 auto; }
}

.status.warning { color: var(--accent-strong); }

.control-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 400;
}

.checkbox-control {
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 4px 9px;
  min-height: 64px;
}

.checkbox-control input {
  width: 17px;
  height: 17px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}

.checkbox-control .control-hint {
  grid-column: 2;
  margin: 0;
}

.source-prices {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.68rem;
}

.item-change {
  display: block;
  margin-top: 3px;
  font-size: 0.68rem;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  white-space: nowrap;
  font-size: 0.72rem;
}

.source-one { color: var(--muted); }

.liquidity-cell {
  display: grid;
  gap: 2px;
  min-width: 90px;
}

.liquidity-cell strong { font-size: 0.82rem; }
.liquidity-cell small { color: var(--muted); font-size: 0.66rem; }

.sparkline-wrap {
  display: grid;
  justify-items: end;
  gap: 2px;
  min-width: 86px;
}

.sparkline-wrap small {
  color: var(--muted);
  font-size: 0.66rem;
}

.sparkline {
  width: 82px;
  height: 30px;
  overflow: visible;
}

.sparkline polyline {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.spark-up { color: var(--positive); }
.spark-down { color: var(--negative); }
.spark-flat { color: var(--neutral); }

table { min-width: 1780px; }
