:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #2a2f3a;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); min-height: 1em; margin: .25rem 0; }
.okmsg { color: var(--ok); }

button {
  font: inherit; color: var(--text); background: #232834; border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .9rem; cursor: pointer;
}
button:hover { border-color: #3a4150; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select {
  font: inherit; color: var(--text); background: #0f1218; border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; width: 100%;
}
input[type=checkbox] { width: auto; }
input[type=number] { width: 7rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
.inline { display: flex; align-items: center; gap: .5rem; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chips button { padding: .25rem .6rem; font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: .8rem; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.top-right { display: flex; gap: .75rem; align-items: center; }
.grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; padding: 1rem 1.25rem; max-width: 1200px; margin: 0 auto; }
.span2 { grid-row: span 1; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.section-head h2 { margin: 0; }

.product { border: 1px solid var(--line); border-radius: 10px; padding: .9rem; display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; }
.product + .product { margin-top: .6rem; }
.product.off { opacity: .55; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); }
.dot.available { background: var(--ok); box-shadow: 0 0 0 4px rgba(34,197,94,.2); animation: pulse 1.2s infinite; }
.dot.queue { background: var(--warn); box-shadow: 0 0 0 4px rgba(234,179,8,.2); animation: pulse 1.2s infinite; }
.dot.unavailable { background: var(--bad); }
.dot.error { background: #f97316; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); } }
.product .name { font-weight: 600; }
.product .name a { color: inherit; text-decoration: none; }
.product .name a:hover { text-decoration: underline; }
.product .meta { color: var(--muted); font-size: .85rem; }
.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 99px; background: #232834; margin-left: .4rem; vertical-align: middle; }
.badge.available { background: rgba(34,197,94,.18); color: var(--ok); }
.badge.queue { background: rgba(234,179,8,.18); color: var(--warn); }
.badge.unavailable { background: rgba(239,68,68,.15); color: #f87171; }
.badge.error { background: rgba(249,115,22,.15); color: #fb923c; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.actions button { padding: .35rem .6rem; font-size: .85rem; }
@media (max-width: 560px) { .product { grid-template-columns: auto 1fr; } .actions { grid-column: 1 / -1; justify-content: flex-start; } }

.log { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; font-size: .88rem; }
.log li { padding: .4rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .75rem; }
.log time { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.log .available { color: var(--ok); }
.log .queue { color: var(--warn); }
.log .unavailable { color: #f87171; }
.log .error { color: #fb923c; }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); width: min(520px, 94vw); padding: 1.2rem; }
dialog::backdrop { background: rgba(0,0,0,.6); }
