:root {
  --bg: #090d12;
  --panel: #121922;
  --panel-2: #1a2430;
  --panel-3: #243242;
  --surface: rgba(18, 25, 34, .86);
  --surface-strong: rgba(28, 39, 52, .94);
  --line: #34465a;
  --line-soft: #223040;
  --text: #f3f6f8;
  --muted: #b5c0cc;
  --faint: #7c8996;
  --accent: #4bd6bc;
  --accent-2: #f2bd55;
  --green: var(--accent);
  --gold: var(--accent-2);
  --red: #f27f74;
  --blue: #6ab7ff;
  --violet: #c18cff;
  --rose: #f47c9d;
  --ember: #ff915f;
  --lime: #a9db65;
  --input: #0d141d;
  --shadow: 0 18px 55px rgba(0, 0, 0, .26);
  --shadow-soft: 0 10px 28px rgba(0, 0, 0, .18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(132deg, rgba(75, 214, 188, .085) 0 21%, transparent 21% 100%),
    linear-gradient(230deg, rgba(242, 189, 85, .08) 0 17%, transparent 17% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 96px),
    linear-gradient(180deg, #121925 0, var(--bg) 320px, #090b0f 100%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 24%);
}

::selection {
  background: rgba(75, 214, 188, .28);
  color: #fff;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 32px;
  border: 1px solid rgba(98, 124, 151, .54);
  border-radius: 6px;
  background: linear-gradient(180deg, #263342, #192331);
  color: var(--text);
  padding: 0 11px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 6px 16px rgba(0, 0, 0, .12);
  transition: background .12s ease, border-color .12s ease, color .12s ease, transform .12s ease;
}

button:hover {
  border-color: var(--green);
  background: linear-gradient(180deg, #2c3b4d, #1d2a39);
  transform: translateY(-1px);
}

button.danger {
  border-color: rgba(239, 116, 104, .55);
  color: #ffd4d0;
}

input,
select {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(83, 105, 128, .72);
  border-radius: 6px;
  background: linear-gradient(180deg, #101925, var(--input));
  color: var(--text);
  padding: 0 10px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(75, 214, 188, .18), inset 0 1px 0 rgba(255, 255, 255, .04);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(280px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 12px 20px 11px;
  border-bottom: 1px solid rgba(74, 95, 118, .82);
  border-top: 0;
  background:
    linear-gradient(90deg, rgba(75, 214, 188, .13), transparent 36%, rgba(242, 189, 85, .10)),
    linear-gradient(180deg, rgba(24, 34, 45, .96), rgba(15, 21, 29, .96));
  box-shadow: 0 14px 44px rgba(0, 0, 0, .26);
  backdrop-filter: blur(14px);
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--gold) 48%, var(--violet));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(242, 189, 85, .72);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(242, 189, 85, .22), rgba(75, 214, 188, .11)),
    #121922;
  color: var(--gold);
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 9px 22px rgba(0, 0, 0, .22);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  letter-spacing: 0;
  line-height: 1;
}

.brand p,
.result-count,
#detailMeta {
  color: var(--muted);
}

.brand p:empty {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 16px;
  min-width: 0;
  padding-left: 16px;
  border-left: 1px solid rgba(181, 192, 204, .15);
}

.header-luck {
  display: grid;
  gap: 4px;
  min-width: 92px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
}

.header-luck input {
  width: 86px;
  min-height: 30px;
  margin: 0;
  color: var(--gold);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.header-updated {
  justify-self: end;
  min-width: 128px;
  text-align: right;
}

.header-updated span {
  display: block;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.header-updated strong {
  display: block;
  margin-top: 3px;
  color: var(--gold);
  font-size: 14px;
  line-height: 1;
}

.tabs {
  display: flex;
  gap: 6px;
}

.app-nav {
  justify-self: center;
  justify-content: center;
  align-items: center;
  max-width: 520px;
  margin: 0;
  padding: 4px;
  border: 1px solid rgba(83, 105, 128, .70);
  border-radius: 8px;
  background: rgba(9, 14, 20, .54);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .04), 0 12px 28px rgba(0, 0, 0, .18);
}

.tab {
  position: relative;
  min-height: 36px;
  min-width: 126px;
  padding: 0 18px;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0;
  box-shadow: none;
}

.tab::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(.45);
  transition: opacity .12s ease, transform .12s ease;
}

.tab:hover {
  border-color: rgba(181, 192, 204, .20);
  background: rgba(255, 255, 255, .045);
  color: #eaf0f6;
  transform: none;
}

.tab.active {
  color: #fff;
  border-color: rgba(79, 213, 184, .36);
  background:
    linear-gradient(180deg, rgba(75, 214, 188, .17), rgba(75, 214, 188, .08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 8px 18px rgba(75, 214, 188, .10);
}

.tab.active::after {
  opacity: 1;
  transform: scaleX(1);
}

.tab[data-tab="items"].active {
  border-color: var(--accent);
}

.tab[data-tab="sources"].active {
  border-color: var(--accent-2);
  background: linear-gradient(180deg, rgba(242, 189, 85, .17), rgba(242, 189, 85, .08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 8px 18px rgba(242, 189, 85, .10);
}

.tab[data-tab="sources"]::after {
  background: var(--accent-2);
}

.tab[data-tab="favorites"].active {
  border-color: var(--violet);
  background: linear-gradient(180deg, rgba(193, 140, 255, .17), rgba(193, 140, 255, .08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 8px 18px rgba(193, 140, 255, .10);
}

.tab[data-tab="favorites"]::after {
  background: var(--violet);
}

main {
  padding: 18px 20px 22px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.view-head h2 {
  color: #f8fbfd;
  font-size: 17px;
  font-weight: 800;
}

.view-head h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(240, 199, 106, .13);
  vertical-align: 1px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(83, 105, 128, .50);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(18, 25, 34, .72), rgba(12, 18, 26, .52));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035);
}

.source-filters {
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(150px, 1fr));
}

label {
  display: block;
  color: #c0ccd8;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

label input,
label select {
  margin-top: 4px;
}

.table-wrap {
  width: 100%;
  min-height: 260px;
  max-height: max(300px, calc(100vh - 260px));
  overflow: auto;
  border: 1px solid rgba(83, 105, 128, .62);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 52px),
    rgba(15, 22, 31, .94);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .045);
  scrollbar-gutter: stable;
}

.table-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-wrap::-webkit-scrollbar-track {
  background: rgba(9, 13, 18, .72);
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid rgba(9, 13, 18, .72);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(75, 214, 188, .55), rgba(106, 183, 255, .45));
}

.table-wrap.compact {
  max-height: 520px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.compact table {
  min-width: 560px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom-color: rgba(83, 105, 128, .72);
  background: linear-gradient(180deg, #233247, #1a2635);
  color: #e3ebf2;
  font-size: 12px;
  font-weight: 750;
}

td {
  color: #edf2f6;
}

tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, .014);
}

tr:hover td {
  background: rgba(75, 214, 188, .06);
}

tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 rgba(75, 214, 188, .65);
}

.num {
  text-align: right;
}

.fav-col,
.action-col {
  width: 62px;
}

.action-col {
  width: 104px;
}

.action-cell {
  padding-right: 22px;
}

.action-cell button {
  min-width: 68px;
  border-color: rgba(106, 183, 255, .44);
  background: linear-gradient(180deg, rgba(106, 183, 255, .16), rgba(106, 183, 255, .07));
  color: #eaf5ff;
  padding: 0 10px;
}

.action-cell button:hover {
  border-color: rgba(106, 183, 255, .80);
  background: linear-gradient(180deg, rgba(106, 183, 255, .24), rgba(106, 183, 255, .11));
}

.sort-button {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 0 6px;
  box-shadow: none;
  font-size: 12px;
  font-weight: 750;
  text-align: left;
}

.sort-button:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, .055);
  color: var(--accent);
  transform: none;
}

.sort-button.num {
  justify-content: flex-end;
  text-align: right;
}

th.num .sort-button {
  margin-left: auto;
}

.sort-button::after {
  content: "";
  margin-left: 5px;
  color: var(--gold);
  font-size: 11px;
}

.sort-button[data-direction="asc"]::after {
  content: "^";
}

.sort-button[data-direction="desc"]::after {
  content: "v";
}

.sort-button.active {
  color: #ffffff;
}

.favorite {
  width: 32px;
  min-width: 32px;
  padding: 0;
  color: var(--faint);
  background: rgba(255, 255, 255, .035);
}

.favorite.active {
  border-color: rgba(242, 189, 85, .85);
  background: linear-gradient(180deg, #ffd77a, var(--gold));
  color: #19140b;
  box-shadow: 0 0 0 2px rgba(242, 189, 85, .12), 0 8px 18px rgba(0, 0, 0, .18);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05);
}

.kind-chip {
  color: #ffc9ad;
  border-color: rgba(255, 163, 111, .45);
  background: rgba(255, 139, 78, .16);
}

.kind-chip-prop {
  color: #9bdfff;
  border-color: rgba(116, 167, 255, .45);
  background: rgba(72, 144, 220, .18);
}

.map-chip {
  color: #f8d878;
  border-color: rgba(240, 199, 106, .46);
  background: rgba(240, 199, 106, .14);
}

.map-chip-crypts,
.map-chip-inferno {
  color: #ffd2a3;
  border-color: rgba(255, 145, 84, .45);
  background: rgba(255, 121, 77, .16);
}

.map-chip-goblin-caves {
  color: #cdf28d;
  border-color: rgba(152, 204, 83, .48);
  background: rgba(98, 146, 60, .18);
}

.map-chip-ice-cavern,
.map-chip-ice-abyss {
  color: #b9e7ff;
  border-color: rgba(116, 167, 255, .50);
  background: rgba(80, 140, 210, .18);
}

.map-chip-ruins {
  color: #dfc8ff;
  border-color: rgba(189, 146, 255, .50);
  background: rgba(127, 78, 190, .18);
}

.diff-chip {
  color: #d9e3ec;
  border-color: rgba(169, 181, 193, .38);
  background: rgba(169, 181, 193, .10);
}

.diff-chip-pve {
  color: #90ead7;
  border-color: rgba(97, 217, 188, .50);
  background: rgba(97, 217, 188, .16);
}

.diff-chip-high-roller {
  color: #d8bdff;
  border-color: rgba(189, 146, 255, .52);
  background: rgba(130, 87, 193, .20);
}

.diff-chip-squire {
  color: #ffe39a;
  border-color: rgba(240, 199, 106, .54);
  background: rgba(240, 199, 106, .16);
}

.category-chip {
  color: #b9d1ff;
  border-color: rgba(116, 167, 255, .44);
  background: rgba(116, 167, 255, .14);
}

.category-chip-utility,
.category-chip-consumable {
  color: #90ead7;
  border-color: rgba(97, 217, 188, .48);
  background: rgba(97, 217, 188, .14);
}

.more-chip {
  color: var(--accent-2);
  border-color: rgba(240, 199, 106, .40);
  background: rgba(240, 199, 106, .12);
}

.rarity {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
}

.rarity::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.rarity.Junk::before { background: #787878; }
.rarity.Common::before { background: #e8e2d3; }
.rarity.Uncommon::before { background: #57c66b; }
.rarity.Rare::before { background: #5d94ff; }
.rarity.Epic::before { background: #ae6cff; }
.rarity.Legendary::before { background: #e3a23a; }
.rarity.Unique::before { background: #ffdc73; }
.rarity.Artifact::before { background: #eb5b5b; }

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

.table-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px 12px;
  min-height: 24px;
  margin-top: 8px;
  color: var(--faint);
  font-size: 11px;
}

.table-meta span {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
}

.table-meta b {
  color: #c2ccd6;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-meta .limit-note {
  color: var(--gold);
  font-weight: 700;
}

.favorites-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.favorites-layout h3 {
  margin-bottom: 9px;
  color: var(--gold);
  font-size: 14px;
}

dialog {
  width: min(1120px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  border: 1px solid rgba(83, 105, 128, .70);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 72px),
    var(--panel);
  color: var(--text);
  padding: 0;
  box-shadow: 0 30px 95px rgba(0, 0, 0, .58);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .68);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  border-bottom: 1px solid rgba(83, 105, 128, .62);
  background: linear-gradient(180deg, #1a2634, #131c27);
  padding: 14px;
}

#detailContent {
  padding: 12px 14px 14px;
}

.detail-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.detail-toolbar input {
  max-width: 360px;
}

.detail-search {
  flex: 1 1 320px;
  max-width: 430px;
}

.detail-search input {
  max-width: none;
}

.message-row {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

@media (max-width: 900px) {
  .app-header,
  .view-head,
  .detail-toolbar {
    align-items: stretch;
  }

  .app-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px 12px;
  }

  .app-nav {
    width: 100%;
    max-width: none;
  }

  .tabs {
    width: 100%;
    flex-direction: row;
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: 34px;
    padding: 0 8px;
    font-size: 13px;
  }

  .filters,
  .source-filters,
  .favorites-layout {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-self: stretch;
    justify-content: space-between;
  }

  .header-updated {
    text-align: right;
  }

  main {
    padding: 12px;
  }
}
