:root {
  --bg: #090505; --panel: rgba(20, 11, 11, .88); --panel2: rgba(34, 18, 17, .9); --line: #432421; --text: #f1e9dc; --muted: #a8968b;
  --accent: #f0c36a; --accent2: #ff8a6b; --blood: #c8321f; --good: #4cc38a; --bad: #ff6b57; --warn: #f0c36a;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body::before { content: ""; position: fixed; inset: 0; z-index: -2; background: var(--bg) url(/static/bg.webp) center top / cover no-repeat; }
body::after { content: ""; position: fixed; inset: 0; z-index: -1; background: linear-gradient(180deg, rgba(9, 5, 5, .30) 0%, rgba(9, 5, 5, .72) 38%, rgba(9, 5, 5, .93) 100%); }
@media (max-width: 900px) { body::before { background-image: url(/static/bg-1000.webp); } }
body { margin: 0; color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
header.top { background: rgba(10, 5, 5, .82); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
header.top .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; min-height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); letter-spacing: .4px; }
.brand img { width: 40px; height: 40px; display: block; }
.brand .name span { color: var(--accent); }
.brand:hover { text-decoration: none; }
header.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-left: auto; }
main { padding: 22px 0 40px; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 70ch; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; backdrop-filter: blur(6px); }
textarea { width: 100%; min-height: 260px; resize: vertical; background: rgba(9, 5, 5, .85); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 10px;
           font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
textarea:focus, select:focus, input:focus { outline: 2px solid var(--accent2); outline-offset: 1px; }
select, input[type=text] { background: rgba(9, 5, 5, .85); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit; }
button, .button { background: var(--blood); color: #fff3df; border: 0; border-radius: 6px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; display: inline-block; }
button.secondary, .button.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button:hover, .button:hover { filter: brightness(1.1); text-decoration: none; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.markets { display: flex; flex-wrap: wrap; gap: 8px; }
.markets label { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; display: flex; flex-direction: column; min-width: 96px; }
.markets input { position: absolute; opacity: 0; }
.markets input:checked + span { color: var(--accent); }
.markets label:has(input:checked) { border-color: var(--accent); }
.markets small { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 14px 0; }
.tile { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.tile .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tile .note { color: var(--muted); font-size: 12px; }
.tile.sell .value { color: var(--accent); }
.tile.buy .value { color: var(--accent2); }
.alert { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--panel2); border-radius: 6px; padding: 10px 14px; margin: 10px 0; }
.alert.bad { border-left-color: var(--bad); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; cursor: pointer; user-select: none; position: sticky; top: 0; background: rgba(20, 11, 11, .97); }
thead th[data-sort]::after { content: " \2195"; opacity: .35; }
thead th.asc::after { content: " \25B2"; opacity: 1; }
thead th.desc::after { content: " \25BC"; opacity: 1; }
tbody tr:hover { background: var(--panel2); }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.item { display: flex; align-items: center; gap: 9px; white-space: normal; }
.item img { width: 28px; height: 28px; border-radius: 4px; background: var(--bg); flex: none; }
.item .group { color: var(--muted); font-size: 12px; }
.flag { color: var(--warn); font-size: 12px; }
.flag.bad { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: var(--panel2); color: var(--muted); border: 0; border-radius: 0; padding: 6px 12px; font-weight: 500; }
.seg button.on { background: var(--blood); color: #fff3df; font-weight: 700; }
body[data-mode=imm] .best, body[data-mode=best] .imm { display: none; }
.share { display: flex; gap: 8px; flex: 1 1 360px; }
.share input { flex: 1; min-width: 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
pre { background: rgba(9, 5, 5, .85); border: 1px solid var(--line); border-radius: 6px; padding: 12px; overflow-x: auto; }
footer { color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding: 16px 0 28px; }
.stale { color: var(--bad); font-weight: 600; }
@media (max-width: 640px) { .tile .value { font-size: 18px; } th, td { padding: 6px; } }

/* the start page: the logo next to the headline */
.hero { display: flex; align-items: center; gap: 22px; margin: 6px 0 20px; }
.hero img { width: 150px; height: 150px; flex: none; filter: drop-shadow(0 6px 22px rgba(200, 50, 31, .45)); }
.hero h1 { font-size: 30px; }
.hero .lead { margin-bottom: 0; }
@media (max-width: 640px) { .hero { flex-direction: column; align-items: flex-start; gap: 8px; } .hero img { width: 96px; height: 96px; } }
footer { background: rgba(9, 5, 5, .6); }

/* ---- D-Scan additions */
.alert.danger { border-color: #b3261e; background: rgba(179, 38, 30, .16); }
.alert.warning { border-color: #c98a1b; background: rgba(201, 138, 27, .13); }
.alert.info { border-color: #4b6b8a; background: rgba(75, 107, 138, .12); }
.chip { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 8px; border: 1px solid #3a2a24; border-radius: 12px; background: rgba(255, 255, 255, .04); color: inherit; font-size: .9em; text-decoration: none; }
.chip small { color: #9b8a80; }
a.chip:hover { border-color: #c9a45a; }
details.card summary { cursor: pointer; }
details.card.friendly { border-color: #3d7a4a; }
.cmp-up { color: #e85d4f; font-weight: 600; }
.cmp-down { color: #6bbf7a; font-weight: 600; }
.flag { display: inline-block; padding: 0 6px; border-radius: 4px; background: rgba(61, 122, 74, .3); font-size: .8em; }
.flag.bad { background: rgba(179, 38, 30, .3); }
table.left th, table.left td { text-align: left; }
table.left td:nth-child(2), table.left th:nth-child(2) { width: 5.5em; }

/* the footer sits at the very bottom of the window when a page is short */
body { min-height: 100vh; display: flex; flex-direction: column; }
header.top, footer { flex: none; }
main.wrap { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
