:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0efea;
  --border: #e2e0d8;
  --text: #1d1c1a;
  --text-2: #5c5b56;
  --text-3: #8a8983;
  --accent: #1d1c1a;
  --accent-text: #ffffff;
  --series-1: #2a78d6;
  --good: #0f7a3d;
  --good-bg: #e3f4e8;
  --warn: #a14a0b;
  --warn-bg: #fdeee0;
  --bad: #b42318;
  --bad-bg: #fde8e6;
  --mine-bg: #eaf2fc;
  --mine-border: #2a78d6;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232322;
    --border: #33322f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8f8e86;
    --accent: #f0efec;
    --accent-text: #121211;
    --series-1: #3987e5;
    --good: #5fd08a;
    --good-bg: #16301f;
    --warn: #f2a35e;
    --warn-bg: #3a2414;
    --bad: #ff8a80;
    --bad-bg: #3b1916;
    --mine-bg: #172a42;
    --mine-border: #3987e5;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.account { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); }
.account strong { color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-open { background: var(--good-bg); color: var(--good); }
.pill-closed { background: var(--bad-bg); color: var(--bad); }
.pill-win { background: var(--good-bg); color: var(--good); }
.pill-outbid { background: var(--warn-bg); color: var(--warn); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: background .15s, transform .05s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); opacity: .88; }
.btn-danger { color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: var(--bad); opacity: .9; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-block { width: 100%; padding: 12px; }

.banner { margin: 20px 0 0; padding: 14px 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.banner strong { color: var(--text); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 16px; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-2); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); min-width: 220px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; padding-bottom: 60px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); cursor: pointer; transition: transform .15s, box-shadow .15s; text-align: left; padding: 0; }
.card:hover { transform: translateY(-2px); }
.card.is-winning { border-color: var(--good); }
.card.is-outbid { border-color: var(--warn); }
.card-img { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); font-size: 13px; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-title { font-size: 16px; font-weight: 700; }
.card-desc { color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-top: 6px; }
.label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.amount { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); font-size: 13px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-3); }

dialog { border: 0; border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10,10,10,.5); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 22px 0; }
.dlg-head h2 { font-size: 20px; }
.dlg-body { padding: 16px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.dlg-img { width: 100%; max-height: 280px; object-fit: cover; border-radius: 12px; display: block; }
.close-x { border: 0; background: var(--surface-2); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; flex-shrink: 0; }
.desc-full { white-space: pre-wrap; color: var(--text-2); margin: 0; }
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat .amount { font-size: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.input:focus, .search:focus { outline: 2px solid var(--series-1); outline-offset: 1px; border-color: transparent; }
textarea.input { min-height: 90px; resize: vertical; }
.money-input { position: relative; }
.money-input span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; }
.money-input .input { padding-left: 28px; font-size: 18px; font-weight: 700; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; }
.form-error { color: var(--bad); font-size: 14px; min-height: 0; margin: 0; }
.form-note { color: var(--text-3); font-size: 13px; margin: 0; }
.confirm-box { background: var(--surface-2); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.code-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-weight: 700; }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; border: 1px solid transparent; }
.history li.mine { background: var(--mine-bg); border-color: var(--mine-border); font-weight: 600; }
.history .who { display: flex; flex-direction: column; }
.history .amt { font-weight: 700; font-variant-numeric: tabular-nums; }

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; width: min(420px, calc(100vw - 24px)); }
.toast { background: var(--accent); color: var(--accent-text); padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 500; transition: opacity .4s, transform .4s; }
.toast-warn { background: var(--warn); color: #fff; }
.toast-good { background: var(--good); color: #fff; }
.toast-bad { background: var(--bad); color: #fff; }
.toast-out { opacity: 0; transform: translateY(8px); }

@media (max-width: 560px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .search { min-width: 0; flex: 1; }
}
.mb-8 { margin-bottom: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- admin ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; }
.admin-main { padding-bottom: 60px; }
.banner-warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.banner-warn strong { color: var(--warn); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 22px 0; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile .value { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile .sub { font-size: 13px; color: var(--text-3); }
.tile-hero { grid-column: span 2; }
.tile-hero .value { font-size: 38px; }
.charts { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; margin-bottom: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head h2 { font-size: 15px; }
.panel-head-tabs { align-items: center; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar-label { fill: var(--text-2); font-size: 12px; }
.chart .bar-value { fill: var(--text); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; }
.chart .series-area { fill: var(--series-1); opacity: .1; }
.chart .series-bar { fill: var(--series-1); }
.chart .bar-hit:hover + .series-bar, .chart .series-bar.hover { opacity: .8; }
.chart .crosshair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart-empty { padding: 50px 10px; text-align: center; color: var(--text-3); }
.tooltip { position: absolute; pointer-events: none; background: var(--accent); color: var(--accent-text); padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.4; white-space: nowrap; z-index: 5; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.tooltip strong { font-size: 14px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.row-win td { background: color-mix(in srgb, var(--good-bg) 55%, transparent); }
table.data tr.row-muted td { color: var(--text-3); }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; padding: 10px 0; }
.filter-select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: 13px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
@media (max-width: 860px) {
  .charts { grid-template-columns: 1fr; }
  .tile-hero { grid-column: span 1; }
}
