:root {
  --bg: #101513;
  --panel: #18211e;
  --panel-2: #202b27;
  --text: #f4f0e7;
  --muted: #a9b4ae;
  --line: #33413b;
  --gold: #d7ad57;
  --green: #64c987;
  --red: #f06f61;
  --blue: #6ba9d8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(rgba(16, 21, 19, 0.86), rgba(16, 21, 19, 0.94)),
    url("https://runescape.wiki/images/Grand_Exchange.png");
  background-attachment: fixed;
  background-position: center top;
  background-size: cover;
  font-family: Arial, Helvetica, sans-serif;
}

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

.topbar,
.tabs,
.controls,
.calculator,
.stats,
.watchlist,
.table-wrap {
  background: rgba(24, 33, 30, 0.94);
  border: 1px solid rgba(215, 173, 87, 0.22);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-radius: 8px 8px 0 0;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-top: 0;
}

.tab-button {
  min-height: 38px;
  padding: 0 16px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.tab-button.active {
  color: #17120a;
  background: var(--gold);
  border-color: var(--gold);
}

.tab-panel {
  display: none;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
}

button,
input {
  font: inherit;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  color: #16110a;
  background: var(--gold);
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.secondary-button,
.watch-button {
  display: inline-grid;
  place-items: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  background: #111815;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.secondary-button.active,
.watch-button.active {
  color: #17120a;
  background: var(--gold);
  border-color: var(--gold);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(450px, auto) minmax(160px, 0.45fr) auto repeat(3, minmax(120px, 0.35fr));
  gap: 16px;
  align-items: end;
  padding: 18px 22px;
  border-top: 0;
}

.calculator {
  padding: 18px 22px;
  border-top: 0;
}

.calculator-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(130px, 0.32fr) repeat(2, minmax(130px, 0.32fr)) auto;
  gap: 16px;
  align-items: end;
}

.search,
.select-filter,
.number {
  display: grid;
  gap: 7px;
}

.search span,
.select-filter span,
.number span,
.segmented legend,
.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input[type="search"],
input[type="number"],
select {
  width: 100%;
  height: 42px;
  color: var(--text);
  background: #111815;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 17px, calc(100% - 12px) 17px;
  background-repeat: no-repeat;
  background-size: 6px 6px;
  padding-right: 34px;
}

.segmented {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  width: 100%;
  margin-bottom: 7px;
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 42px;
  border: 1px solid var(--line);
  background: #111815;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
}

.segmented input:checked + span {
  color: #17120a;
  background: var(--gold);
  border-color: var(--gold);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--text);
  font-size: 14px;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 8px;
}

.calculator-stats {
  grid-template-columns: repeat(4, 1fr);
}

.stats div {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  background: rgba(32, 43, 39, 0.94);
}

.stats strong {
  font-size: 22px;
}

.watchlist {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 8px;
}

.watchlist-head,
.watch-actions,
.share-row {
  display: flex;
  align-items: end;
  gap: 12px;
}

.watchlist-head {
  justify-content: space-between;
}

.share-row .search {
  flex: 1;
}

.table-wrap {
  margin-top: 14px;
  overflow: auto;
  border-radius: 8px;
}

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

.calculator-table {
  min-width: 820px;
}

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

th:first-child,
td.watch-cell {
  text-align: center;
}

td.action-cell {
  text-align: center;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #111815;
  font-size: 12px;
  text-transform: uppercase;
}

.item-col,
td.item-cell {
  text-align: left;
}

tbody tr:hover {
  background: rgba(215, 173, 87, 0.08);
}

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}

.item img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: auto;
}

.item-name {
  display: block;
  font-weight: 800;
}

.item-id {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.profit {
  color: var(--green);
  font-weight: 800;
}

.loss {
  color: var(--red);
}

.remove-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--text);
  background: #111815;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

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

@media (max-width: 920px) {
  .shell {
    width: min(100% - 20px, 1460px);
    padding: 10px 0;
  }

  .topbar,
  .controls,
  .calculator-form {
    grid-template-columns: 1fr;
  }

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

  .controls {
    display: grid;
  }

  .segmented {
    flex-wrap: wrap;
  }

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

  .calculator-stats {
    grid-template-columns: 1fr;
  }

  .watchlist-head,
  .share-row {
    align-items: stretch;
    flex-direction: column;
  }

  .watch-actions {
    flex-wrap: wrap;
  }
}
