:root {
  --bg: #0a0908;
  --bg-2: #0f0d0c;
  --panel: #15120f;
  --panel-2: #1b1714;
  --edge: #2b2521;
  --edge-bright: #3b322b;
  --text: #ece2d2;
  --muted: #ab9e8f;
  --dim: #83766a;
  --ember: #ff9d45;
  --gold: #f0c75e;
  --green: #74d68f;
  --red: #ff6f61;
  --blue: #7fb6d9;
  --violet: #b58cff;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(255, 157, 69, 0.10), transparent 70%),
    radial-gradient(700px 400px at 92% 0%, rgba(181, 140, 255, 0.07), transparent 70%),
    linear-gradient(180deg, #0b0a09 0%, #0a0908 60%, #080706 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1420px; margin: 0 auto; padding: 0 22px 60px; }

/* ---------- header ---------- */
header.top {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(10, 9, 8, 0.94), rgba(10, 9, 8, 0.72));
  border-bottom: 1px solid var(--edge);
}

.top-inner {
  max-width: 1420px;
  margin: 0 auto;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

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

.mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #3a2a1a, #171310 70%);
  border: 1px solid #4a3826;
  box-shadow: inset 0 0 18px rgba(255, 157, 69, 0.25), 0 0 22px -8px rgba(255, 157, 69, 0.6);
  font-size: 19px;
}

.brand h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  background: linear-gradient(92deg, #ffe9bd, var(--gold) 45%, #b9822f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand p {
  margin: 1px 0 0;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.top-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }

.freshness {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  white-space: nowrap;
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.stale { background: var(--ember); box-shadow: 0 0 8px var(--ember); }
.dot.dead { background: var(--red); box-shadow: 0 0 8px var(--red); }

input[type="checkbox"] { accent-color: #c98b3f; width: 14px; height: 14px; }

select, input[type="text"], input[type="number"], button {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 9px;
  padding: 8px 11px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

select:hover, input:hover { border-color: var(--edge-bright); }
select:focus, input:focus { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255, 157, 69, 0.12); }

button { cursor: pointer; }
button:hover { border-color: var(--ember); background: var(--panel-2); }
button:disabled { opacity: 0.55; cursor: default; }

button.primary {
  background: linear-gradient(180deg, #2a1d12, #1a130e);
  border-color: #6b4a29;
  color: var(--gold);
  font-weight: 600;
}
button.primary:hover { border-color: var(--ember); }

button.ghost { background: transparent; }

/* ---------- controls ---------- */
.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 18px 0 14px;
  padding: 12px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(27, 23, 20, 0.75), rgba(15, 13, 12, 0.6));
}

.field { display: flex; align-items: center; gap: 7px; }
.field label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--dim); }

.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 9px; overflow: hidden; }
.seg button {
  border: 0; border-radius: 0; padding: 8px 12px; background: transparent;
  color: var(--muted); font-size: 13px;
}
.seg button + button { border-left: 1px solid var(--edge); }
.seg button.on { background: linear-gradient(180deg, #33220f, #1d150e); color: var(--gold); font-weight: 600; }

.spacer { flex: 1 1 auto; }
.field.grow { flex: 1 1 240px; min-width: 180px; }
.field .unit { color: var(--dim); font-size: 12.5px; margin-left: -3px; }
.field.grow input { width: 100%; }

/* ---------- stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 13px 15px;
  background: linear-gradient(180deg, rgba(24, 20, 17, 0.9), rgba(14, 12, 11, 0.75));
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240, 199, 94, 0.5), transparent);
}

.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.11em; color: var(--dim); }
.stat .v { font-family: var(--mono); font-size: 22px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat.good .v { color: var(--green); }
.stat.bad .v { color: var(--red); }
.stat.gold .v { color: var(--gold); }

/* ---------- table ---------- */
.table-shell {
  border: 1px solid var(--edge);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(14, 12, 11, 0.72);
}

.table-scroll { max-height: calc(100dvh - 452px); min-height: 280px; overflow: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #12100e;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
  padding: 11px 12px;
  border-bottom: 1px solid var(--edge);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

thead th:hover { color: var(--gold); }
thead th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th.sorted { color: var(--gold); }
thead th.sorted::after { content: " ▾"; font-size: 10px; }
thead th.sorted.asc::after { content: " ▴"; }

tbody tr { border-bottom: 1px solid rgba(43, 37, 33, 0.6); cursor: pointer; }
tbody tr:hover { background: rgba(255, 157, 69, 0.05); }
tbody tr.active { background: rgba(255, 157, 69, 0.09); box-shadow: inset 3px 0 0 var(--ember); }
tbody tr.dim { opacity: 0.55; }

td { padding: 10px 12px; vertical-align: middle; }
td.num { font-family: var(--mono); font-size: 13px; }

.rank { color: var(--dim); font-family: var(--mono); font-size: 12px; width: 34px; }

.craft { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.craft .hex {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px;
  display: grid; place-items: center;
  font-size: 14px;
  background: radial-gradient(circle at 35% 30%, #2c231b, #14110f);
  border: 1px solid var(--edge-bright);
}
.craft .names { min-width: 0; }
.craft .cn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.craft .pn { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }

.q1 { color: #e8e8e8; } .q2 { color: #4ade80; } .q3 { color: #60a5fa; }
.q4 { color: #c084fc; } .q5 { color: #f0c75e; } .q0 { color: #9d9082; }

.pill {
  display: inline-block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--edge-bright);
  color: var(--muted);
  white-space: nowrap;
}
.pill.new { color: var(--violet); border-color: rgba(181, 140, 255, 0.4); background: rgba(181, 140, 255, 0.08); }
.pill.ah { color: var(--blue); border-color: rgba(127, 182, 217, 0.35); background: rgba(127, 182, 217, 0.08); }
.pill.vendor { color: var(--gold); border-color: rgba(240, 199, 94, 0.35); background: rgba(240, 199, 94, 0.08); }
.pill.warn { color: var(--ember); border-color: rgba(255, 157, 69, 0.35); background: rgba(255, 157, 69, 0.08); }
.pill.miss { color: var(--red); border-color: rgba(255, 111, 97, 0.35); background: rgba(255, 111, 97, 0.08); }

.pos { color: var(--green); }
.neg { color: var(--red); }
.gold-txt { color: var(--gold); }
.dim-txt { color: var(--dim); }
.mut { color: var(--muted); }

.totals-strip {
  display: flex;
  gap: 22px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--edge-bright);
  background: #12100e;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.totals-strip b { font-family: var(--mono); font-weight: 600; }
.totals-strip .lab { color: var(--dim); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.08em; }
.totals-strip #t-count { margin-right: auto; }

.bar {
  height: 4px; border-radius: 3px; margin-top: 5px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #6b4a29, var(--ember)); }
.bar > i.hot { background: linear-gradient(90deg, #2f6b3d, var(--green)); }

/* ---------- detail drawer ---------- */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 94vw);
  background: linear-gradient(180deg, #14110e, #0c0b09);
  border-left: 1px solid var(--edge-bright);
  box-shadow: -30px 0 60px -30px rgba(0, 0, 0, 0.9);
  transform: translateX(102%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 60;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.drawer-head h2 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.drawer-head .sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.drawer-body { padding: 16px 20px 40px; overflow: auto; }
.close { margin-left: auto; background: transparent; border: 0; color: var(--muted); font-size: 20px; line-height: 1; padding: 2px 6px; }
.close:hover { color: var(--text); }

.dsec { margin-bottom: 20px; }
.dsec h3 {
  font-size: 10.5px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--dim); margin: 0 0 8px;
}

.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: 13.5px; }
.kv .k { color: var(--muted); }
.kv .v { font-family: var(--mono); text-align: right; }

.mini-table { width: 100%; font-size: 13px; }
.mini-table th {
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim);
  text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--edge); position: static; cursor: default;
}
.mini-table td { padding: 7px 6px; border-bottom: 1px solid rgba(43, 37, 33, 0.5); }
.mini-table tr:last-child td { border-bottom: 0; }

.spark { width: 100%; height: 76px; display: block; }
.spark-wrap { border: 1px solid var(--edge); border-radius: 10px; padding: 8px 10px 4px; background: #100e0c; }
.spark-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--dim); padding: 0 2px 2px; }

.planner { display: flex; align-items: center; gap: 10px; }
.planner input { width: 84px; }

/* ---------- misc ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty strong { color: var(--text); display: block; margin-bottom: 6px; font-family: var(--serif); font-size: 18px; }

footer.foot {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--edge);
  font-size: 12px;
  color: var(--dim);
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translate(-50%, 20px);
  background: #1d1712;
  border: 1px solid var(--edge-bright);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 90;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.help {
  font-size: 12px;
  color: var(--dim);
  margin: 0 0 12px;
  line-height: 1.5;
  max-width: 96ch;
}

@media (max-width: 720px) {
  .top-inner { padding: 12px 14px; gap: 10px; }
  .wrap { padding: 0 14px 40px; }
  .brand h1 { font-size: 17px; }
  .table-scroll { max-height: 72vh; overflow: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll table { min-width: 720px; }
  .hide-sm { display: none !important; }
  thead th, td { padding: 9px 8px; }
}
