/* Trade Sheriff
   Layout: header and an icon tab bar for the tools, then one column of rounded cards (1180px).
   On very wide screens a 300px ad rail sits to the right of the column.
   Themes: light is "Mist" (soft grey, white cards, teal), dark is "Night" (charcoal, bordered cards, soft blue). */

:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --card-line: transparent;
  --raised: #f5f7f9;
  --field: #ffffff;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #5b6472;
  --faint: #6b7280;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2f0;
  --win: #067647;
  --win-soft: #dcfae6;
  --win-panel: #f2f9f6;
  --loss: #b42318;
  --loss-soft: #fee4e2;
  --loss-panel: #fef6f5;
  --fair: #b54708;
  --fair-soft: #fef0c7;
  --fair-panel: #fffaeb;
  --bar-give: #d0d5dd;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.10);
  --text: "Sora", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f12; --card: #15171c; --card-line: #24272f; --raised: #1b1e24; --field: #0e0f12; --line: #24272f; --line-2: #2a2e37;
    --ink: #edeef0; --ink-2: #c9cdd4; --muted: #9ba1ac; --faint: #858b97;
    --accent: #8ab4ff; --accent-ink: #0e0f12; --accent-soft: rgba(138, 180, 255, 0.14);
    --win: #4ade80; --win-soft: rgba(74, 222, 128, 0.12); --win-panel: #1b1e24;
    --loss: #f87171; --loss-soft: rgba(248, 113, 113, 0.12); --loss-panel: #1b1e24;
    --fair: #fbbf24; --fair-soft: rgba(251, 191, 36, 0.12); --fair-panel: #1b1e24;
    --bar-give: #3a3f4b; --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0f12; --card: #15171c; --card-line: #24272f; --raised: #1b1e24; --field: #0e0f12; --line: #24272f; --line-2: #2a2e37;
  --ink: #edeef0; --ink-2: #c9cdd4; --muted: #9ba1ac; --faint: #858b97;
  --accent: #8ab4ff; --accent-ink: #0e0f12; --accent-soft: rgba(138, 180, 255, 0.14);
  --win: #4ade80; --win-soft: rgba(74, 222, 128, 0.12); --win-panel: #1b1e24;
  --loss: #f87171; --loss-soft: rgba(248, 113, 113, 0.12); --loss-panel: #1b1e24;
  --fair: #fbbf24; --fair-soft: rgba(251, 191, 36, 0.12); --fair-panel: #1b1e24;
  --bar-give: #3a3f4b; --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--text); min-height: 100vh; display: flex; flex-direction: column; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 60; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.02em; text-wrap: balance; }
h2 { font-size: 20px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 800; }
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
@media (max-width: 560px) { .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); } }

/* ---------- header and tabs ---------- */
.site-head { padding-block: 20px 0; display: grid; gap: 16px; min-height: 140px; }
.head-row { display: flex; align-items: center; gap: 12px 24px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 17px; letter-spacing: -0.01em; text-decoration: none !important; }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 12px; background: var(--card); border: 1px solid var(--card-line); color: var(--ink); font-weight: 700; font-size: 14px; text-decoration: none !important; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.tabs { display: flex; gap: 4px; padding: 5px; background: var(--card); border: 1px solid var(--card-line); border-radius: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 11px; color: var(--muted); font-weight: 700; font-size: 14px; text-decoration: none !important; white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: var(--raised); }
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.tabs svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- page grid (+ ad rail on very wide screens) ---------- */
.page { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding-block: 24px 72px; align-items: start; }
.main { min-width: 0; display: grid; gap: 16px; align-content: start; }
.rail { display: none; }
@media (min-width: 1600px) {
  .wrap { max-width: 1504px; }
  .page { grid-template-columns: minmax(0, 1fr) 300px; }
  .rail { display: block; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 24px); }
}

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--card-line); border-radius: 22px; padding: 24px; display: grid; gap: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--card-line); color: var(--ink-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.soft { background: var(--raised); border-color: transparent; }
.chip.win { background: var(--win-soft); color: var(--win); border-color: transparent; }
.chip.loss { background: var(--loss-soft); color: var(--loss); border-color: transparent; }
.chip.fair { background: var(--fair-soft); color: var(--fair); border-color: transparent; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.label { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); font: 700 14px/1 var(--text); cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.discord { background: #5865f2; border-color: #5865f2; color: #ffffff; }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { color: var(--loss); }
.btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; }
.btn svg { width: 16px; height: 16px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
input[type="text"], input[type="search"], input[type="email"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--field); color: var(--ink); font: 14px/1.4 var(--text); }
textarea { padding: 12px 14px; min-height: 160px; resize: vertical; font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
.field { display: grid; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.empty { display: grid; gap: 6px; justify-items: center; text-align: center; padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 16px; }
.empty strong { color: var(--ink); font-size: 15px; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; border-radius: 16px; background: var(--accent-soft); color: var(--ink-2); font-size: 14px; }
.notice .btn { margin-left: auto; }
.msg { font-size: 14px; } .msg.err { color: var(--loss); } .msg.ok { color: var(--win); }

/* item lines */
.item-line { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--raised); border-radius: 12px; min-width: 0; }
.item-main { flex: 1; min-width: 0; display: grid; gap: 1px; }
.item-name { font-weight: 700; overflow-wrap: anywhere; }
.item-sub { font-size: 12px; color: var(--muted); }
.flag { font-size: 12px; font-weight: 700; color: var(--fair); }
.flag.bad { color: var(--loss); }
.x-btn { width: 30px; height: 30px; flex-shrink: 0; border: 0; border-radius: 8px; background: transparent; color: var(--faint); font-size: 18px; line-height: 1; cursor: pointer; }
.x-btn:hover { color: var(--loss); background: var(--card); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card); flex-shrink: 0; }
.qty button { width: 28px; height: 28px; border: 0; background: none; color: var(--muted); cursor: pointer; font: 700 15px/1 var(--text); border-radius: 9px; }
.qty button:hover { color: var(--ink); }
.qty span { min-width: 20px; text-align: center; font: 600 13px/1 var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ---------- calculator ---------- */
.calc { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.side-total { margin-top: auto; display: flex; justify-content: space-between; align-items: baseline; padding: 8px 2px 0; color: var(--muted); font-size: 14px; }
.side-total .num { color: var(--ink); }
.verdict-panel { background: var(--raised); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.verdict-panel.win { background: var(--win-panel); }
.verdict-panel.loss { background: var(--loss-panel); }
.verdict-panel.fair { background: var(--fair-panel); }
.verdict-big { font: 600 44px/1 var(--mono); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.verdict-panel.win .verdict-big { color: var(--win); }
.verdict-panel.loss .verdict-big { color: var(--loss); }
.verdict-panel.fair .verdict-big { color: var(--fair); }
.verdict-panel.none .verdict-big { color: var(--faint); }
.balance { display: flex; height: 6px; border-radius: 999px; overflow: hidden; gap: 3px; background: transparent; }
.balance span:first-child { background: var(--bar-give); }
.balance span:last-child { background: var(--accent); flex: 1; }
.verdict-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; align-items: center; }

/* item picker */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); max-height: 340px; overflow-y: auto; padding: 6px; }
.picker-opt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.picker-opt[aria-selected="true"], .picker-opt:hover { background: var(--raised); }
.picker-none { padding: 12px; color: var(--muted); font-size: 14px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--raised); }
table.data .r { text-align: right; }
.meter { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.meter-bar { width: 64px; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; display: block; }
.meter-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: 700 13px/1 var(--text); cursor: pointer; }
.pill:hover { color: var(--ink); }
.pill[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 12px; align-items: end; }
@media (max-width: 640px) { .toolbar { grid-template-columns: minmax(0, 1fr); } }

/* ---------- results (deals and offers) ---------- */
.results { display: grid; gap: 12px; }
.result { background: var(--card); border: 1px solid var(--card-line); border-radius: 20px; padding: 20px; display: grid; gap: 14px; min-width: 0; }
.result-head { display: flex; align-items: flex-start; gap: 14px; }
.rank { width: 32px; height: 32px; flex-shrink: 0; border-radius: 10px; background: var(--raised); display: grid; place-items: center; font: 600 13px/1 var(--mono); color: var(--muted); }
.who { flex: 1; min-width: 0; display: grid; gap: 2px; }
.who b { font-weight: 800; overflow-wrap: anywhere; }
.who span { font-size: 13px; color: var(--muted); }
.gain { text-align: right; display: grid; gap: 2px; justify-items: end; }
.gain .num { font-size: 22px; }
.gain.win .num { color: var(--win); } .gain.loss .num { color: var(--loss); } .gain.fair .num { color: var(--fair); }
.gain span:last-child { font-size: 12px; color: var(--muted); }
.sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.side-box { display: grid; gap: 8px; align-content: start; min-width: 0; }
.side-box .side-total { margin-top: 0; padding-top: 0; }
.source { font: 12px/1.5 var(--mono); color: var(--muted); background: var(--raised); border-radius: 10px; padding: 8px 12px; overflow-wrap: anywhere; }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flags .chip { font-size: 12px; padding: 4px 10px; }

/* ---------- history chart ---------- */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .pt { fill: var(--accent); }
.chart text { fill: var(--muted); font: 600 11px var(--text); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--card-line); border-radius: 18px; padding: 16px 18px; display: grid; gap: 6px; min-width: 0; }
.stat .label { font-size: 11px; }
.stat b { font: 600 24px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--win); } .neg { color: var(--loss); }
.log { display: grid; gap: 8px; }
.log-item { display: grid; grid-template-columns: 96px minmax(0, 1fr) minmax(0, 1fr) 110px auto; gap: 14px; align-items: center; padding: 12px 14px; background: var(--raised); border-radius: 12px; font-size: 14px; }
.log-item .when { color: var(--muted); font-size: 13px; }
.log-item .lbl { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.log-item .diff { text-align: right; }
@media (max-width: 760px) { .log-item { grid-template-columns: minmax(0, 1fr) auto; } .log-item .when, .log-item .gave, .log-item .got { grid-column: 1 / -1; } }
.share { font-family: var(--mono); font-size: 13px; min-height: 140px; }

/* ---------- ad slots ---------- */
.ad { display: grid; place-items: center; overflow: hidden; border-radius: 18px; }
.ad.preview { border: 1px dashed var(--line-2); color: var(--faint); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.ad.banner { min-height: 96px; }
.rail .ad { width: 300px; height: 600px; }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--line); padding-block: 28px calc(36px + env(safe-area-inset-bottom, 0px)); }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 32px; font-size: 13px; color: var(--muted); }
.site-foot a { color: var(--muted); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }

/* ---------- account + prose ---------- */
.auth-box { max-width: 460px; display: grid; gap: 14px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
@media (max-width: 460px) { .inline-form { grid-template-columns: minmax(0, 1fr); } }
.profile { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.profile .avatar { width: 56px; height: 56px; font-size: 22px; border-radius: 14px; }
.profile-name { font-size: 22px; font-weight: 800; }
.prose { max-width: 72ch; display: grid; gap: 14px; color: var(--ink-2); }
.prose h2 { font-size: 18px; margin-top: 8px; color: var(--ink); }
.prose ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }

/* toast */
.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; font-weight: 700; font-size: 14px; border-radius: 12px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

@media (max-width: 560px) {
  .card { padding: 18px; border-radius: 18px; }
  .verdict-big { font-size: 36px; }
  .site-head { min-height: 128px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* home: other tools */
.stack { display: grid; gap: 16px; min-width: 0; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.tool-card { display: flex; gap: 14px; align-items: flex-start; padding: 20px; background: var(--card); border: 1px solid var(--card-line); border-radius: 18px; color: var(--ink); text-decoration: none !important; transition: box-shadow .15s; }
.tool-card:hover { box-shadow: var(--shadow); }
.tool-ico { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.tool-ico svg { width: 20px; height: 20px; }
.tool-card b { display: block; font-weight: 800; }
.tool-card .desc { font-size: 14px; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.opts { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; }
.opts select { width: auto; min-height: 38px; }
.card > *, .main > *, .stack > *, .side > *, .result > * { min-width: 0; }
.table-wrap, .tabs, .picker { position: relative; }
.verdict-actions .btn { padding: 0 14px; }
.field { align-content: start; }
.grid-2 > .field { grid-template-rows: auto 1fr; }   /* the Traderie page box fills down to match "Your item" */
/* title row at the top of the Offer Ranker and Deal Checker */
.tool-head { display: flex; align-items: center; gap: 12px; }
.tool-head h1 { font-size: 20px; font-weight: 800; }
.tool-head p { font-size: 14px; color: var(--muted); }
