:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1d212a; --border: #2a2f3a;
  --text: #d6dbe3; --muted: #7d8590; --accent: #e6b84f; --link: #8ab4f8;
  --up: #ff7b72; --down: #3fb950;
  --q0: #9d9d9d; --q1: #ffffff; --q2: #1eff00; --q3: #0070dd; --q4: #a335ee; --q5: #ff8000; --q6: #e6cc80; --q7: #00ccff;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, "Segoe UI", sans-serif; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { margin: 0 0 4px; font-size: 26px; }
h2 { font-size: 16px; margin: 24px 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }

header.top { display: flex; align-items: center; gap: 24px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { color: var(--accent); font-weight: 700; font-size: 17px; }
.brand .realm { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
header nav a { color: var(--text); margin-right: 14px; }
.status { margin-left: auto; color: var(--muted); font-size: 12px; }
.tag { padding: 1px 6px; border-radius: 8px; font-size: 11px; background: var(--panel2); border: 1px solid var(--border); }
.tag.full { color: var(--down); } .tag.partial { color: var(--accent); } .tag.backfill { color: var(--link); }

/* accounts */
.usermenu { display: flex; align-items: center; gap: 10px; }
.usermenu a { color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.usermenu a.on { color: var(--accent); }
.usermenu form { margin: 0; }
img.avatar { width: 22px; height: 22px; border-radius: 50%; vertical-align: -6px; margin-right: 6px; }
.usermenu img.avatar { margin-right: 0; }
button.linkbtn { background: none; border: none; color: var(--muted); padding: 0; cursor: pointer; }
button.linkbtn:hover { color: var(--text); text-decoration: underline; }
body.center-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { max-width: 420px; width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 28px; text-align: center; margin: 16px; }
.login-card h1 { color: var(--accent); }
.discord-btn { display: inline-block; margin: 18px 0 10px; padding: 10px 22px; border-radius: 8px; background: #5865f2;
  color: #fff !important; font-weight: 600; font-size: 15px; }
.discord-btn:hover { background: #4752c4; text-decoration: none; }
.small { font-size: 12px; }
.keybox { flex-direction: column; align-items: flex-start; }
.keybox code { font-size: 15px; user-select: all; background: var(--bg); padding: 6px 10px; border-radius: 6px; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
ol.steps { padding-left: 22px; } ol.steps li { margin: 6px 0; }
td.actions form, .inline-confirm { margin: 0; display: inline-flex; gap: 6px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
input, select, button { background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font: inherit; }
input[type=search] { flex: 1 1 280px; font-size: 15px; }
input[type=number] { width: 90px; }
label { color: var(--muted); }
button { cursor: pointer; }
button.on, .chip.on { border-color: var(--accent); color: var(--accent); }

.tablehead { display: flex; justify-content: space-between; color: var(--muted); margin: 6px 2px; }
.pager a { margin: 0 8px; }
table.items { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); }
table.items th, table.items td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.items th { position: sticky; top: 49px; background: var(--panel2); font-weight: 600; z-index: 1; }
table.items th a { color: var(--text); }
table.items th.active a { color: var(--accent); }
table.items tbody tr { cursor: pointer; }
table.items tbody tr:hover { background: var(--panel2); }
table.items.small td, table.items.small th { padding: 4px 10px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
td.stale { color: var(--muted); }
.variants { font-size: 11px; color: var(--muted); margin-left: 6px; }

.money .g { color: #ffd24d; } .money .s { color: #c7ccd6; } .money .c { color: #d08a4f; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }

.q0 { color: var(--q0) !important; } .q1 { color: var(--q1) !important; } .q2 { color: var(--q2) !important; }
.q3 { color: var(--q3) !important; } .q4 { color: var(--q4) !important; } .q5 { color: var(--q5) !important; }
.q6 { color: var(--q6) !important; } .q7 { color: var(--q7) !important; }

.itemhead .meta { color: var(--muted); margin-bottom: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.card .label, .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 20px; margin: 2px 0; }
.card .sub { color: var(--muted); font-size: 12px; }
.variants-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip { background: var(--panel2); border: 1px solid var(--border); border-radius: 14px; padding: 3px 10px; color: var(--text); }
.chartbar { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.chartbar label { margin-left: 12px; }
.chart { height: 520px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }

img.icon, .icon.blank { width: 20px; height: 20px; vertical-align: -5px; margin-right: 6px; border-radius: 3px;
  border: 1px solid currentColor; display: inline-block; background: var(--panel2); }
img.icon.big { width: 36px; height: 36px; vertical-align: -8px; margin-right: 10px; border-width: 2px; }
.icon.blank { border-color: var(--border); }
.banner { background: #2a2210; border: 1px solid #5a4818; color: #f0d58a; border-radius: 8px; padding: 8px 12px;
  margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.ok { background: #10291a; border-color: #1f5a33; color: #9be9b0; }
.banner button { border-color: #a8862a; color: #f0d58a; }

header nav a.on { color: var(--accent); }
.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.watchbox { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.watchbox { gap: 12px; }
.watchbox input[type=text] { flex: 1 1 140px; max-width: 280px; }
.money-fields { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.money-fields input { width: 58px !important; padding: 5px 6px; text-align: right; -moz-appearance: textfield; }
.money-fields input.ms { width: 38px !important; }
.money-fields input::-webkit-outer-spin-button,
.money-fields input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.money-fields .g, .money-fields .s, .money-fields .c { font-weight: 600; margin: 0 4px 0 2px; }
.money-fields .c { margin-right: 0; }

/* Watchlist add form: one row on normal widths, wraps on narrow ones */
form.addwatch { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
form.addwatch .suggest-wrap { flex: 1 1 240px; }
.aw-price { color: var(--muted); font-weight: 600; white-space: nowrap; }
.aw-note { flex: 0 1 180px; min-width: 120px; }
#watch-msg:empty { display: none; }
.money-fields .g { color: #ffd24d; } .money-fields .s { color: #c7ccd6; } .money-fields .c { color: #d08a4f; }
.suggest-wrap { position: relative; flex: 1 1 280px; }
.suggest-wrap input[type=search] { width: 100%; }
ul.suggest { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 4px 0;
  list-style: none; background: var(--panel2); border: 1px solid #3a4150; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); max-height: 360px; overflow-y: auto; }
ul.suggest { overflow-x: hidden; }
ul.suggest li { display: flex; align-items: center; gap: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; }
ul.suggest li > span:nth-of-type(1) { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
ul.suggest li .right, ul.suggest li .icon, ul.suggest li .muted { flex-shrink: 0; }
ul.suggest li:hover, ul.suggest li.active { background: #2a3040; }
ul.suggest li .right { margin-left: auto; }
tr.hit td { background: rgba(63, 185, 80, 0.08); }
form.settings fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 14px; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px; background: var(--panel); }
form.settings legend { color: var(--accent); padding: 0 6px; }
form.settings input[type=number] { width: 80px; }
form.settings p { margin: 0; }

code { word-break: break-all; }
/* Plotly's unified hover title ignores hoverlabel.font in some versions; force it to the theme */
.js-plotly-plot .hoverlayer .legend text { fill: #d6dbe3 !important; }
.js-plotly-plot .hoverlayer .legend .bg { fill: #1d212a !important; stroke: #3a4150 !important; }
.js-plotly-plot .modebar-btn path { fill: #7d8590 !important; }
.js-plotly-plot .modebar-btn:hover path, .js-plotly-plot .modebar-btn.active path { fill: #e6b84f !important; }
.js-plotly-plot .modebar { background: transparent !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  table.items { display: block; overflow-x: auto; }
  table.items th { position: static; }
}

@media (max-width: 700px) {
  .status { margin-left: 0; }
  table.items th:nth-child(3), table.items td:nth-child(3), table.items th:nth-child(7), table.items td:nth-child(7) { display: none; }
}
