:root {
  color-scheme: dark;
  --bg: #161615;
  --panel: #20201f;
  --panel-2: #262625;
  --line: #3f3d39;
  --line-soft: #32312f;
  --text: #f1eee8;
  --muted: #aaa49a;
  --muted-2: #7e786f;
  --gold: #f0b84b;
  --gold-2: #9a6508;
  --green: #81c995;
  --green-bg: #203926;
  --red: #e08f99;
  --red-bg: #4b252d;
  --blue: #8ec5e8;
  --blue-bg: #244252;
  --cyan: #7ccccc;
  --cyan-bg: #24484a;
  --purple: #d3afe9;
  --purple-bg: #3d2c4a;
  --focus: #3f7ee8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

button,
select,
.file-button {
  border: 1px solid var(--line);
  background: #1e1e1d;
  color: var(--text);
}

button,
.file-button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 14px;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 44px rgb(0 0 0 / 0.24);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
}

.auth-brand img {
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.auth-brand h1,
.tools-head h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.auth-brand p,
.tools-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.auth-form input {
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #171716;
  color: var(--text);
}

.auth-error {
  margin: 0;
  color: var(--red);
}

.auth-register {
  width: 100%;
  margin-top: 12px;
}

.tools-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 28px 14px;
}

.tools-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.tool-card {
  min-height: 118px;
  padding: 16px;
  border-radius: 8px;
  text-align: left;
  display: grid;
  align-content: start;
  gap: 9px;
  background: var(--panel);
}

.tool-card:hover {
  border-color: #6f8fc6;
  background: #242628;
}

.tool-card strong {
  font-size: 16px;
}

.tool-card span {
  color: var(--muted);
  line-height: 1.45;
}

.tool-card.is-disabled:hover {
  border-color: var(--line);
  background: var(--panel);
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 14px 9px 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 2px 0 14px;
}

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

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 750;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button,
.ghost-button,
.help-button,
.filter-button,
.icon-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.file-button {
  background: linear-gradient(180deg, #377bea, #2d60be);
  border-color: #5f95f1;
  color: #fff;
  font-weight: 700;
}

.help-button {
  background: linear-gradient(180deg, #f0b84b, #b77810);
  border-color: #f6c86b;
  color: #201609;
  font-weight: 850;
}

.help-button:hover {
  border-color: #ffe0a0;
  filter: brightness(1.05);
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.ghost-button:hover,
.filter-button:hover,
.stat-pill:hover {
  border-color: #69645d;
}

.weight-control {
  min-height: 36px;
  padding: 0 8px 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1e1e1d;
  color: var(--muted);
  white-space: nowrap;
}

.weight-control span {
  font-size: 12px;
}

.weight-control select {
  height: 28px;
  padding: 0 24px 0 8px;
  border-radius: 5px;
  background: #171716;
  color: var(--text);
}

.drop-zone {
  border: 1px dashed var(--line);
  border-radius: 8px;
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px;
  background: #1b1b1a;
  margin-bottom: 14px;
}

.drop-zone.is-drag {
  border-color: var(--focus);
  box-shadow: inset 0 0 0 1px var(--focus);
}

.drop-zone strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.drop-zone span,
.status-line {
  color: var(--muted);
}

.status-line {
  text-align: right;
  min-width: 240px;
}

.status-line.is-error {
  color: var(--red);
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin: 2px 0 14px;
}

select:focus,
button:focus-visible,
.file-button:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(63, 126, 232, 0.25);
}

.stage-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

select {
  height: 34px;
  padding: 0 30px 0 10px;
  border-radius: 6px;
}

.filters-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 12px;
  margin: -12px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.filters-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  min-width: 128px;
}

.filters-panel .checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text);
}

.counter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 11px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(32, 32, 31, 0.78);
}

.filter-menu {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(32, 32, 31, 0.58);
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-right: 8px;
  border-right: 1px solid var(--line-soft);
}

.filter-group:last-of-type {
  border-right: 0;
}

.filter-chip {
  min-height: 31px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--muted);
  background: #1e1e1d;
}

.filter-chip-combo {
  display: inline-flex;
  align-items: center;
}

.filter-chip-combo .filter-chip {
  position: relative;
}

.filter-chip--effmax {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.filter-chip--icon {
  width: 32px;
  min-width: 32px;
  padding: 0;
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  font-size: 14px;
  line-height: 1;
}

.filter-chip.is-active {
  color: var(--text);
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(63, 126, 232, 0.18);
}

.filter-chip--clear {
  margin-left: auto;
  border-color: rgba(224, 143, 153, 0.48);
  color: #dcb0b5;
}

.filter-popover {
  position: absolute;
  z-index: 12;
  min-width: 230px;
  max-width: min(420px, calc(100vw - 20px));
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #242423;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.46);
}

.filter-popover[hidden] {
  display: none;
}

.filter-popover-title {
  margin: 0 0 8px;
  color: #d8d1c8;
  font-weight: 800;
}

.filter-options {
  display: grid;
  gap: 6px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  color: var(--text);
}

.filter-option input {
  accent-color: var(--focus);
}

.score-filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.score-filter-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
}

.score-filter-grid input {
  height: 32px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1b1b1a;
  color: var(--text);
  padding: 0 9px;
}

.filter-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.filter-popover-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  height: 29px;
  padding: 0 11px;
  border-radius: 999px;
  color: var(--muted);
  background: #1e1e1d;
}

.stat-pill-combo {
  display: inline-flex;
  align-items: center;
}

.stat-pill--combo-main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.stat-pill--icon {
  width: 31px;
  min-width: 31px;
  padding: 0;
  margin-left: -1px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}

.stat-pill strong {
  color: var(--text);
  margin-left: 4px;
}

.stat-pill.is-active {
  border-color: var(--focus);
  color: var(--text);
  box-shadow: 0 0 0 2px rgba(63, 126, 232, 0.18);
}

.stat-pill--static {
  border-color: transparent;
  background: transparent;
  color: #c8c0b6;
}

.stat-pill--all {
  border-color: rgba(200, 192, 182, 0.42);
  background: #22211f;
  color: #e5ddd3;
}

.stat-pill--all:hover {
  border-color: var(--focus);
  color: var(--text);
}

.stat-pill--premium {
  border-color: rgba(240, 184, 75, 0.62);
  color: #f1d18a;
  background: #2a2418;
}

.stat-pill--premium.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240, 184, 75, 0.2), 0 0 14px rgba(240, 184, 75, 0.18);
}

.stat-pill--speed {
  border-color: rgba(124, 204, 204, 0.5);
  color: #b6e1e1;
  background: #1a2929;
}

.stat-pill--speed.is-active {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(124, 204, 204, 0.18), 0 0 14px rgba(124, 204, 204, 0.14);
}

.score-filter-grid--single {
  grid-template-columns: 1fr;
}

.result-count {
  margin-left: auto;
  color: var(--muted);
}

.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.table-top-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  border-bottom: 1px solid var(--line-soft);
  background: #1b1b1a;
}

.table-top-scroll-inner {
  width: var(--table-width, 1120px);
  height: 1px;
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 252px);
  scrollbar-gutter: stable;
}

table {
  width: var(--table-width, 1120px);
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th[data-col="slot"], td[data-col="slot"] { width: 34px; }
th[data-col="markersCol"], td[data-col="markersCol"] { width: 66px; }
th[data-col="topLegend"], td[data-col="topLegend"] { width: 50px; }
th[data-col="set"], td[data-col="set"] { width: 76px; }
th[data-col="main"], td[data-col="main"] { width: 82px; }
th[data-col="grade"], td[data-col="grade"] { width: 62px; }
th[data-col="level"], td[data-col="level"] { width: 34px; }
th[data-col="innate"], td[data-col="innate"] { width: 72px; }
th[data-col="sub1"], td[data-col="sub1"],
th[data-col="sub2"], td[data-col="sub2"],
th[data-col="sub3"], td[data-col="sub3"],
th[data-col="sub4"], td[data-col="sub4"] { width: 152px; }
th[data-col="efficiency"], td[data-col="efficiency"],
th[data-col="effMax"], td[data-col="effMax"],
th[data-col="effMaxHero"], td[data-col="effMaxHero"],
th[data-col="effMaxLegend"], td[data-col="effMaxLegend"],
th[data-col="gain"], td[data-col="gain"] { width: 68px; }
th[data-col="score"], td[data-col="score"],
th[data-col="forge"], td[data-col="forge"] { width: 50px; }
th[data-col="verdict"], td[data-col="verdict"] { width: 64px; }
th[data-col="role"], td[data-col="role"] { width: 80px; }
th[data-col="location"], td[data-col="location"] { width: 96px; }
th[data-col="actions"], td[data-col="actions"] { width: 34px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #2a2927;
  color: #c8c0b6;
  text-align: center;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  height: 32px;
  padding: 0 5px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

thead th[data-col="set"],
thead th[data-col="main"],
thead th[data-col="location"] {
  text-align: left;
}

thead th[data-col="grade"] {
  text-align: right;
}

thead th[data-col="set"] .th-inner,
thead th[data-col="main"] .th-inner,
thead th[data-col="location"] .th-inner {
  justify-content: flex-start;
}

thead th[data-col="grade"] .th-inner {
  justify-content: flex-end;
}

thead th[data-sort] {
  cursor: pointer;
}

.th-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  line-height: 1;
}

.sort-caret {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  flex: 0 0 auto;
}

thead th.sort-asc .sort-caret {
  border-bottom: 5px solid var(--gold);
}

thead th.sort-desc .sort-caret {
  border-top: 5px solid var(--gold);
}

tbody tr {
  background: #20201f;
}

tbody tr:nth-child(odd) {
  background: #242423;
}

tbody tr:hover {
  background: #2c2c2a;
}

tbody tr.is-highlighted,
tbody tr.is-highlighted:nth-child(odd) {
  background: #343128;
  box-shadow: inset 3px 0 0 var(--gold);
}

tbody tr.is-highlighted:hover {
  background: #3b372c;
}

td {
  padding: 6px 5px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  text-align: center;
}

th[data-col="actions"],
td[data-col="actions"] {
  position: sticky;
  right: 0;
  z-index: 1;
  background: inherit;
  box-shadow: -1px 0 0 var(--line-soft);
}

thead th[data-col="actions"] {
  z-index: 3;
  background: #2a2927;
}

td[data-col="set"],
td[data-col="main"],
td[data-col="location"] {
  text-align: left;
}

td[data-col="sub1"],
td[data-col="sub2"],
td[data-col="sub3"],
td[data-col="sub4"] {
  overflow: visible;
  text-overflow: clip;
}

td[data-col="grade"] {
  text-align: right;
}

td.cell-gem-target .sub {
  padding: 3px 5px;
  margin: -3px -5px;
  border: 1px solid #ffd369;
  border-radius: 4px;
}

td.cell-regem-target .sub {
  border-color: #d7b5ff;
}

td.cell-flat-main-warning {
  box-shadow: inset 0 0 0 1px #e06464;
}

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

.num,
.score {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.slot-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--gold-2);
  color: var(--text);
  background: #1d1d1c;
  box-shadow: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.slot-grade.is-rare {
  border-color: var(--blue);
}

.slot-grade.is-hero {
  border-color: var(--purple);
}

.slot-grade.is-legend {
  border-color: var(--gold);
}

.slot-grade.is-classic {
  opacity: 0.78;
  background: #20201f;
}

.slot-grade.is-classic.is-rare {
  border-color: rgba(142, 197, 232, 0.72);
}

.slot-grade.is-classic.is-hero {
  border-color: rgba(211, 175, 233, 0.72);
}

.slot-grade.is-classic.is-legend {
  border-color: rgba(240, 184, 75, 0.72);
}

.slot-grade.is-ancient {
  border-width: 2px;
  opacity: 1;
  background: rgba(24, 24, 23, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.slot-grade.is-ancient.is-rare {
  box-shadow: 0 0 0 2px rgba(128, 183, 212, 0.22), 0 0 10px rgba(128, 183, 212, 0.36), inset 0 0 0 1px rgba(128, 183, 212, 0.2);
}

.slot-grade.is-ancient.is-hero {
  box-shadow: 0 0 0 2px rgba(169, 141, 204, 0.24), 0 0 10px rgba(169, 141, 204, 0.38), inset 0 0 0 1px rgba(169, 141, 204, 0.2);
}

.slot-grade.is-ancient.is-legend {
  box-shadow: 0 0 0 2px rgba(240, 184, 75, 0.28), 0 0 11px rgba(240, 184, 75, 0.42), inset 0 0 0 1px rgba(240, 184, 75, 0.22);
}

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

.grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 48px;
  height: 19px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--gold-2);
  color: #ffd979;
  background: #3a290d;
  font-size: 11px;
}

.grade.is-rare {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: #80b7d4;
}

.grade.is-hero {
  color: var(--purple);
  background: var(--purple-bg);
  border-color: #a98dcc;
}

.grade.is-legend {
  box-shadow: 0 0 0 1px rgba(240, 184, 75, 0.15), 0 0 10px rgba(240, 184, 75, 0.45);
}

.ancient-mark {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 11px;
  flex: 0 0 12px;
}

.ancient-mark::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--gold);
}

.ancient-mark::after {
  content: "!";
  position: absolute;
  left: 0;
  top: 2px;
  width: 12px;
  color: #3a290d;
  font-size: 8px;
  line-height: 10px;
  font-weight: 900;
  text-align: center;
}

.sub {
  display: inline-flex;
  align-items: center;
  max-width: none;
  color: var(--text);
}

.sub.is-grindable {
  color: var(--gold);
}

.sub.is-fixed {
  color: #fff;
}

.sub.is-gem,
.sub.is-grind {
  color: var(--gold);
}

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

.grind-quality-magic {
  color: var(--green);
}

.grind-quality-rare {
  color: var(--blue);
}

.grind-quality-hero {
  color: var(--purple);
}

.grind-quality-legend {
  color: var(--gold);
}

.grind-stock-trigger {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  width: auto;
  min-height: 0;
  margin-left: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  vertical-align: 1px;
}

.grind-stock-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.gem-stock-triangle {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 9px solid var(--gold);
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.35));
}

.gem-stock-rare {
  border-bottom-color: var(--blue);
}

.gem-stock-hero {
  border-bottom-color: var(--purple);
}

.gem-stock-legend {
  border-bottom-color: var(--gold);
}

.grind-stock-rare {
  background: var(--blue);
}

.grind-stock-hero {
  background: var(--purple);
}

.grind-stock-legend {
  background: var(--gold);
}

.grind-stock-popover {
  position: fixed;
  z-index: 30;
  width: 260px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #242423;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.48);
}

.grind-stock-popover[hidden] {
  display: none;
}

.grind-stock-title {
  margin-bottom: 7px;
  color: #d8d1c8;
  font-weight: 800;
}

.grind-stock-list {
  display: grid;
  gap: 5px;
}

.grind-stock-row {
  display: grid;
  grid-template-columns: 10px auto auto auto auto 20px;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  color: var(--text);
}

.grind-stock-row.is-disabled {
  opacity: 0.45;
}

.gem-stock-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.gem-stock-text-rare {
  color: var(--blue);
}

.gem-stock-text-hero {
  color: var(--purple);
}

.gem-stock-text-legend {
  color: var(--gold);
}

.gem-stock-row span:nth-last-child(2) {
  margin-left: auto;
}

.grind-stock-remove,
.icon-x {
  position: relative;
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  color: transparent;
  background: transparent;
  border: 1px solid #5b5550;
  line-height: 1;
}

.grind-stock-remove::before,
.grind-stock-remove::after,
.icon-x::before,
.icon-x::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  top: 9px;
  height: 1.5px;
  border-radius: 2px;
  background: #bdb5aa;
}

.grind-stock-remove::before,
.icon-x::before {
  transform: rotate(45deg);
}

.grind-stock-remove::after,
.icon-x::after {
  transform: rotate(-45deg);
}

.grind-stock-remove:hover,
.icon-x:hover {
  border-color: #d27882;
  background: rgba(224, 143, 153, 0.08);
}

.grind-stock-remove:hover::before,
.grind-stock-remove:hover::after,
.icon-x:hover::before,
.icon-x:hover::after {
  background: #e08f99;
}

.gemmed-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 14px;
  margin-left: 4px;
  color: #f6f4ee;
  vertical-align: -2px;
}

.gemmed-icon svg {
  width: 17px;
  height: 14px;
  display: block;
}

.innate {
  color: #ddd5cb;
}

.score {
  color: #c6f4d3;
  font-weight: 800;
}

.ingame {
  color: var(--gold);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-width: 38px;
  height: 19px;
  padding: 0 7px;
  border-radius: 4px;
  border: 1px solid currentColor;
  font-size: 11px;
  line-height: 1;
}

.badge + .badge {
  margin-left: 4px;
}

.badge-keep {
  color: #9de2aa;
  background: var(--green-bg);
}

.badge-sell {
  color: #f0a0aa;
  background: var(--red-bg);
}

.badge-gem,
.badge-reapp {
  color: #ffd369;
  background: #4a3711;
}

.badge-grind {
  color: #f6b46b;
  background: #4a2e16;
}

.badge-regem {
  color: #d7b5ff;
  background: #332145;
}

.badge-upgrade,
.badge-finish {
  color: #a5d6ff;
  background: #20384d;
}

.role {
  color: #d9edf9;
  background: var(--blue-bg);
  border-color: #80b7d4;
}

.role-fast {
  color: #aeeded;
  background: var(--cyan-bg);
  border-color: #69b7bb;
}

.role-bruiser {
  color: #eec4d1;
  background: #55303b;
  border-color: #bf8092;
}

.role-universal {
  color: #d8c1ee;
  background: var(--purple-bg);
  border-color: #a98dcc;
}

.location {
  color: #fff;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.row-action {
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

.row-remove {
  margin: 0 auto;
}

.row-remove:hover {
  color: transparent;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(1120px, 96vw);
  max-height: min(760px, 92vh);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal h2 {
  margin: 0;
  font-size: 17px;
}

.icon-button {
  min-width: 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  font-weight: 800;
}

.modal-body {
  padding: 12px 14px 14px;
  overflow: auto;
}

.modal-note {
  margin: 0 0 12px;
  color: var(--muted);
}

.help-modal {
  width: min(820px, 94vw);
}

.help-content {
  display: grid;
  gap: 14px;
  line-height: 1.48;
}

.help-content section {
  padding: 0 0 13px;
  border-bottom: 1px solid var(--line-soft);
}

.help-content section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.help-content h3 {
  margin: 0 0 7px;
  color: #f3d08b;
  font-size: 14px;
}

.help-content p {
  margin: 0 0 8px;
  color: #ddd7ce;
}

.help-content p:last-child {
  margin-bottom: 0;
}

.help-content ul {
  margin: 0 0 8px;
  padding-left: 18px;
  color: #ddd7ce;
}

.help-content li + li {
  margin-top: 4px;
}

.graphs-modal {
  width: min(1180px, 98vw);
}

.graphs-body {
  display: grid;
  gap: 12px;
}

.farm-modal {
  width: min(1120px, 96vw);
  height: min(860px, 96vh);
  max-height: 96vh;
}

.farm-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.farm-top-control,
.farm-sort-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.farm-top-control input,
.farm-sort-control select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #171615;
  color: var(--text);
  font: inherit;
}

.farm-top-control input {
  width: 72px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

.farm-sort-control select {
  width: 124px;
  padding: 0 7px;
}

.farm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 10px 12px 12px;
  overflow: hidden;
  flex: 0 0 auto;
  max-height: 1200px;
  transition: max-height 160ms ease, opacity 160ms ease, padding 160ms ease;
}

.farm-grid section {
  min-width: 0;
}

.farm-grid h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 14px;
}

.farm-list {
  display: grid;
  gap: 6px;
}

.farm-row {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #201f1e;
}

.farm-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 12px;
}

.farm-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.farm-row-percent {
  color: var(--gold);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.farm-bar {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: #141413;
}

.farm-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--gold));
}

.farm-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 11px;
}

.farm-row-meta span {
  white-space: nowrap;
}

.farm-row-sets {
  color: #b8b1a6;
  font-size: 10px;
  line-height: 1.35;
}

.farm-row-sets strong {
  color: var(--text);
  font-weight: 700;
}

.farm-dungeons-toggle {
  align-self: center;
  width: 44px;
  height: 18px;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #201f1e;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.farm-dungeons-toggle:hover {
  border-color: #8f7b52;
  background: #26231d;
  color: var(--gold);
}

.farm-dungeons-toggle span {
  display: block;
  transform: translateY(-1px);
}

.farm-dungeons-collapsed .farm-grid {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

.farm-dungeons-collapsed .farm-dungeons-toggle {
  margin-top: 0;
}

.farm-dungeons-collapsed .farm-dungeons-toggle span {
  transform: translateY(1px) rotate(180deg);
}

.farm-empty {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #201f1e;
}

.farm-breakdown {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px 12px;
  overflow: hidden;
}

.farm-breakdown h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 14px;
}

.farm-set-breakdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.farm-breakdown-category {
  display: grid;
  gap: 8px;
}

.farm-breakdown-category h4 {
  margin: 0;
  color: #f3d08b;
  font-size: 12px;
}

.farm-breakdown-category > .farm-empty {
  margin: 0;
}

.farm-set-detail {
  display: block;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #201f1e;
}

.farm-set-detail summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
}

.farm-set-detail summary span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.farm-set-detail summary::-webkit-details-marker {
  display: none;
}

.farm-set-total {
  color: var(--gold);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.farm-stat-list {
  display: grid;
  gap: 4px;
  padding: 0 8px 8px;
}

.farm-stat-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.farm-stat-row span {
  white-space: nowrap;
}

.farm-stat-row strong {
  color: var(--text);
  font-weight: 700;
}

.graphs-controls,
.graphs-filter-row,
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.graphs-controls {
  align-items: center;
}

.graphs-filter-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(180px, 0.5fr);
}

.graph-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ddd7ce;
  font-weight: 700;
}

.graph-control input[type="number"] {
  width: 86px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #181817;
  color: var(--text);
  padding: 0 8px;
}

.graph-check {
  min-height: 32px;
}

.graphs-filter-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 800;
}

.graph-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.graph-check-grid label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #1b1b1a;
  color: #ddd7ce;
}

.graph-check-grid--slots label {
  min-width: 45px;
}

.graph-legend {
  align-items: center;
  color: #ddd7ce;
}

.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.graph-legend strong {
  margin-left: auto;
  color: var(--muted);
}

.legend-line {
  width: 24px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.legend-current {
  background: var(--blue);
}

.legend-hero {
  background: var(--purple);
}

.legend-legend {
  background: var(--gold);
}

.graph-canvas-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #181817;
  overflow: hidden;
}

#efficiency-graph {
  display: block;
  width: 100%;
  height: min(520px, 58vh);
}

.graph-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 218px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #242423;
  color: var(--text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  font-size: 12px;
  line-height: 1.45;
}

.graph-tooltip strong {
  display: block;
  margin-bottom: 3px;
  color: #f3d08b;
}

.graph-tooltip span {
  display: block;
  white-space: nowrap;
}

.grind-grid-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.grind-grid {
  min-width: 980px;
  table-layout: auto;
}

.grind-grid th,
.grind-grid td {
  width: auto;
  padding: 7px 8px;
}

.grind-grid input {
  width: 76px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1b1b1a;
  color: var(--text);
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 840px) {
  .app-shell {
    padding: 10px 8px 18px;
  }

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

  .stage-control {
    justify-content: space-between;
  }

  .status-line {
    min-width: 0;
    text-align: left;
  }

  .result-count {
    width: 100%;
    margin-left: 0;
  }

  .table-shell {
    max-height: calc(100vh - 330px);
  }

  .farm-grid,
  .farm-set-breakdown {
    grid-template-columns: 1fr;
  }

  .farm-head-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}
