:root {
  --paper: #EEF1F4;
  --panel: #FFFFFF;
  --sunk: #E3E8ED;
  --line: #D5DCE3;
  --ink: #1C2430;
  --ink-2: #4A5563;
  --muted: #6B7685;
  --brass: #B8862B;
  --brass-ink: #8A6316;
  --brass-soft: #F4EAD5;
  --won: #2E7D5B;
  --won-soft: #DDEFE6;
  --lost: #B4443C;
  --lost-soft: #F6E0DE;
  --info: #3A6EA5;
  --info-soft: #DFE9F4;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(28, 36, 48, .06), 0 4px 16px rgba(28, 36, 48, .05);
  --sans: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cond: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171E; --panel: #1A212B; --sunk: #222B37; --line: #2E3946;
    --ink: #E4E8ED; --ink-2: #B4BCC7; --muted: #8893A1;
    --brass: #D4A24A; --brass-ink: #E7BC6A; --brass-soft: #3A3020;
    --won: #5DBB8C; --won-soft: #1E3529; --lost: #E07A70; --lost-soft: #3D2321;
    --info: #7FAEE0; --info-soft: #1F2E40;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: inherit; }
img { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.num { font-family: var(--cond); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.top { background: var(--ink); color: #E4E8ED; }
@media (prefers-color-scheme: dark) { .top { background: #0C1015; border-bottom: 1px solid var(--line); } }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 24px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: .01em; }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { text-decoration: none; padding: 16px 12px; color: #A9B3C0; font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.nav a:hover { color: #fff; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--brass); }
.mode-pill { font-size: 13px; padding: 3px 10px; border-radius: 99px; white-space: nowrap; font-weight: 600; }
.mode-pill.dry { background: #34414F; color: #D7DEE6; }
.mode-pill.live { background: var(--brass); color: #1C2430; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }

/* ---------- add bar ---------- */
.addbar { display: flex; gap: 8px; margin-bottom: 24px; }
.addbar input { flex: 1; min-width: 0; }

/* ---------- forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px var(--brass-soft); }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; color: var(--ink-2); }
.field { margin-bottom: 16px; }
.field .hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--brass); }
.money-in { position: relative; }
.money-in::before { content: '$'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money-in input { padding-left: 24px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-s); padding: 9px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--brass); border-color: var(--brass); color: #1C2430; } }
.btn.primary:hover { filter: brightness(1.15); }
.btn.brass { background: var(--brass); border-color: var(--brass); color: #1C2430; }
.btn.danger { color: var(--lost); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.sm { padding: 5px 10px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.panel-pad { padding: 20px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 16px; font-weight: 700; }
h2 { font-size: 19px; line-height: 1.3; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 16px; margin: 0 0 8px; }
.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

/* ---------- next-to-fire hero ---------- */
.next { display: grid; grid-template-columns: 132px 1fr auto; gap: 20px; align-items: center; padding: 20px; margin-bottom: 16px; }
.next .thumb { width: 132px; height: 132px; }
.next-label { font-size: 14px; color: var(--muted); font-weight: 600; }
.next-title { font-size: 20px; font-weight: 600; line-height: 1.3; margin: 4px 0 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.next-title a { text-decoration: none; }
.next-title a:hover { text-decoration: underline; }
.next-meta { display: flex; gap: 20px; flex-wrap: wrap; color: var(--ink-2); font-size: 15px; }
.next-meta b { font-family: var(--cond); font-size: 19px; font-weight: 600; color: var(--ink); }
.clock { text-align: right; }
.clock-big { font-family: var(--cond); font-weight: 700; font-size: 64px; line-height: 1; color: var(--brass-ink); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.clock-big.hot { color: var(--lost); }
.clock-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* 24h strip */
.strip { position: relative; height: 54px; margin: 0 0 28px; padding: 0 2px; }
.strip-track { position: absolute; left: 0; right: 0; top: 20px; height: 2px; background: var(--line); }
.strip-hour { position: absolute; top: 14px; width: 1px; height: 14px; background: var(--line); }
.strip-hour span { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); font-family: var(--cond); font-size: 12px; color: var(--muted); white-space: nowrap; }
.strip-tick { position: absolute; top: 8px; width: 10px; height: 26px; margin-left: -5px; border-radius: 3px; background: var(--ink-2); border: 2px solid var(--paper); cursor: pointer; padding: 0; }
.strip-tick.first { background: var(--brass); }
.strip-tick.grouped { background: var(--info); }
.strip-now { position: absolute; left: 0; top: 0; font-size: 12px; font-weight: 600; color: var(--brass-ink); }
.strip-empty { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); font-size: 13px; color: var(--muted); background: var(--paper); padding: 0 8px; }

/* ---------- snipe rows ---------- */
.list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; box-shadow: var(--shadow); }
.list-head, .srow { display: grid; grid-template-columns: 28px 64px minmax(0, 1fr) 120px 110px 150px 128px; gap: 14px; align-items: center; padding: 12px 16px; }
.list-head { font-size: 13px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); background: var(--sunk); padding-top: 8px; padding-bottom: 8px; }
.srow { border-top: 1px solid var(--line); }
.srow:first-of-type { border-top: 0; }
.list-head + .srow { border-top: 0; }
.srow.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: var(--brass-soft); } to { background: transparent; } }
.thumb { width: 64px; height: 64px; border-radius: var(--radius-s); object-fit: cover; background: var(--sunk); }
.ttl { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ttl a { text-decoration: none; }
.ttl a:hover { text-decoration: underline; }
.sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.sub .grp { color: var(--info); font-weight: 600; }
.cell-price b { font-family: var(--cond); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-price .over { color: var(--lost); }
.cell-max { font-family: var(--cond); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.maxbtn { background: none; border: 1px dashed transparent; border-radius: 4px; padding: 0 4px; margin-left: -4px; cursor: pointer; font: inherit; }
.maxbtn:hover { border-color: var(--line); }
.cell-time .cd { font-family: var(--cond); font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell-time .cd.hot { color: var(--lost); }
.actions { display: flex; gap: 4px; justify-content: flex-end; }

.chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--sunk); color: var(--ink-2); white-space: nowrap; }
.chip.scheduled { background: var(--brass-soft); color: var(--brass-ink); }
.chip.won { background: var(--won-soft); color: var(--won); }
.chip.lost, .chip.error { background: var(--lost-soft); color: var(--lost); }
.chip.bid_placed, .chip.firing { background: var(--info-soft); color: var(--info); }
.chip.outbid_early { background: var(--lost-soft); color: var(--lost); }
.detail { font-size: 13px; color: var(--ink-2); margin-top: 4px; }

.empty { padding: 40px 20px; text-align: center; color: var(--ink-2); }
.empty h3 { color: var(--ink); font-size: 18px; }

/* ---------- item preview in dialog ---------- */
.preview { display: grid; grid-template-columns: 96px 1fr; gap: 14px; margin-bottom: 18px; }
.preview .thumb { width: 96px; height: 96px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px 16px; margin-top: 8px; }
.fact span { display: block; font-size: 12.5px; color: var(--muted); }
.fact b { font-family: var(--cond); font-size: 18px; font-weight: 600; }

dialog { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 0; background: var(--panel); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(18, 23, 30, .55); }
.dlg-in { padding: 22px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.dlg-x { float: right; margin: -6px -8px 0 0; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; margin-bottom: 20px; }
.stat { background: var(--panel); padding: 14px 16px; }
.stat span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat b { font-family: var(--cond); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 12px 16px 0; }
.bar { flex: 1; max-width: 56px; display: flex; flex-direction: column-reverse; min-width: 10px; position: relative; height: 100%; }
.bar i { display: block; width: 100%; }
.bar i.w { background: var(--won); border-radius: 0 0 2px 2px; }
.bar i.l { background: var(--lost-soft); border-radius: 2px 2px 0 0; }
.bar em { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; color: var(--muted); white-space: nowrap; font-family: var(--cond); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); padding: 28px 16px 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-weight: 500; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- settings ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.settings .panel { padding: 20px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.note { background: var(--brass-soft); color: var(--ink); border-radius: var(--radius-s); padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.note.info { background: var(--info-soft); }
.note.bad { background: var(--lost-soft); }
.utable { width: 100%; border-collapse: collapse; font-size: 15px; }
.utable td, .utable th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.utable th { font-size: 13px; color: var(--muted); }

.events { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.events li { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 8px 16px; border-top: 1px solid var(--line); }
.events li:first-child { border-top: 0; }
.events .lvl-error { color: var(--lost); }
.events .lvl-warn { color: var(--brass-ink); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .panel { width: min(380px, 100%); padding: 28px; }
.login .brand { color: var(--ink); margin-bottom: 20px; font-size: 22px; }
.login .brand svg { width: 32px; height: 32px; }
.err { color: var(--lost); font-size: 14px; margin-bottom: 12px; min-height: 1em; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius-s); box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 15px; }
.toast.bad { background: var(--lost); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .list-head { display: none; }
  .srow { grid-template-columns: 22px 56px minmax(0, 1fr) auto; grid-template-areas: 'chk img ttl ttl' 'chk img price time' 'chk img max act'; row-gap: 6px; }
  .srow > .c-chk { grid-area: chk; align-self: start; }
  .srow > .c-img { grid-area: img; align-self: start; }
  .srow > .c-ttl { grid-area: ttl; }
  .srow > .cell-price { grid-area: price; }
  .srow > .cell-time { grid-area: time; text-align: right; }
  .srow > .cell-max { grid-area: max; }
  .srow > .actions { grid-area: act; }
  .srow .thumb { width: 56px; height: 56px; }
  .settings { grid-template-columns: 1fr; }
  .next { grid-template-columns: 88px 1fr; }
  .next .thumb { width: 88px; height: 88px; }
  .next .clock { grid-column: 1 / -1; text-align: left; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
  .clock-big { font-size: 52px; }
}
@media (max-width: 560px) {
  .top-in { gap: 8px; }
  .nav a { padding: 16px 9px; }
  .srow .ship { display: none; }
  .cell-time .sub { font-size: 12px; }
  .brand span { display: none; }
  .addbar { flex-wrap: wrap; }
  .addbar .btn { flex: 1; }
  .strip-hour:nth-child(odd) span { display: none; }
  .events li { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
