:root {
  --bg: #0f1216; --panel: #171b21; --panel2: #1e242c; --line: #2a323d; --text: #e6e9ee; --muted: #8b95a3;
  --accent: #4f8cff; --ok: #33c47f; --warn: #f3b73d; --bad: #f05d5d; --tier0: #4f8cff; --tier1: #b57bff; --tier2: #ff8a5b; --tier3: #33c47f;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: var(--accent); }
header { display: flex; align-items: center; gap: 24px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; font-size: 18px; letter-spacing: .5px; } .brand span { color: var(--accent); }
nav { display: flex; gap: 4px; }
nav button { background: transparent; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; }
nav button.active, nav button:hover { background: var(--panel2); color: var(--text); }
.conn { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn.on .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.conn.scan .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .5 } to { opacity: 1 } }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
h3 { margin: 0 0 10px; font-size: 15px; } h4 { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.muted { color: var(--muted); font-size: 13px; }
.warn { color: var(--warn); font-size: 13px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
button, .btn { background: var(--accent); color: #fff; border: 0; padding: 7px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; text-decoration: none; font-size: 13px; display: inline-block; }
button.ghost, .btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
button.danger { color: var(--bad); } button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 13px; }
input[type=number] { width: 110px; }
.form label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.form label.inline { flex-direction: row; align-items: center; gap: 8px; }
.form .cols { display: flex; gap: 12px; flex-wrap: wrap; } .form .cols label { flex: 1; min-width: 140px; }
.form input:not([type=checkbox]), .form select { width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.tbl tr:hover td { background: rgba(255,255,255,.02); }
.tbl.tiers input { width: 90px; }
.live-grid, .machines-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 900px) { .live-grid, .machines-grid { grid-template-columns: 1fr; } }
.hero { min-height: 220px; display: flex; flex-direction: column; justify-content: center; transition: background .2s; }
.hero.assigned { background: linear-gradient(135deg, #14301f, var(--panel)); border-color: var(--ok); }
.hero.excluded { background: linear-gradient(135deg, #3a1a1a, var(--panel)); border-color: var(--bad); }
.hero.pool { background: linear-gradient(135deg, #3a2f12, var(--panel)); border-color: var(--warn); }
.hero.full { background: linear-gradient(135deg, #4a2a08, var(--panel)); border-color: #ff9f43; }
.hero.full .place { color: #ff9f43; }
.hero .hero-actions { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.hero .complete { display: inline-block; margin-top: 8px; padding: 4px 10px; border-radius: 8px; background: rgba(51,196,127,.2); color: var(--ok); font-weight: 700; }
.quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 14px; }
.quick input[name=name] { flex: 1; min-width: 140px; } .quick input[type=number] { width: 90px; } .quick input[name=quantity] { width: 60px; }
.tbl button.del { padding: 2px 7px; }
.hero-empty { color: var(--muted); font-size: 15px; text-align: center; }
.hero .name { font-size: 30px; font-weight: 800; line-height: 1.1; }
.hero .sub { color: var(--muted); margin-top: 4px; font-size: 14px; }
.hero .price { font-size: 44px; font-weight: 800; margin: 10px 0; }
.hero .place { font-size: 26px; font-weight: 700; }
.hero .place small { display: block; font-size: 14px; font-weight: 500; color: var(--muted); }
.hero.excluded .place { color: var(--bad); } .hero.assigned .place { color: var(--ok); } .hero.pool .place { color: var(--warn); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--text); white-space: nowrap; }
.pill.ok { background: rgba(51,196,127,.18); color: var(--ok); } .pill.bad { background: rgba(240,93,93,.18); color: var(--bad); }
.pill.warn { background: rgba(243,183,61,.18); color: var(--warn); } .pill.info { background: rgba(79,140,255,.18); color: var(--accent); }
.pill.t0 { background: rgba(79,140,255,.2); color: #9cc0ff } .pill.t1 { background: rgba(181,123,255,.2); color: #d4b3ff } .pill.t2 { background: rgba(255,138,91,.2); color: #ffb899 } .pill.t3 { background: rgba(51,196,127,.2); color: #8fe3b8 }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.stat { background: var(--panel2); border-radius: 10px; padding: 10px; }
.stat .v { font-size: 20px; font-weight: 800; } .stat .l { color: var(--muted); font-size: 12px; }
.load { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.load .head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.load .title { font-weight: 800; font-size: 16px; }
.load .money { margin-left: auto; display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.load .money b { color: var(--text); font-size: 15px; }
.mechs { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 12px; }
.mech { background: var(--panel2); border-radius: 10px; padding: 10px; }
.mech .mh { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin: 3px 0 6px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar.full i { background: var(--ok); }
.tierline { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.tierline b { color: var(--text); }
.actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mlist-item { padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mlist-item.sel { border-color: var(--accent); }
.steps li { margin-bottom: 8px; } code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 12px; user-select: all; }
.events { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 420px; overflow: auto; font-size: 11px; white-space: pre-wrap; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(1100px, 95vw); max-height: 90vh; overflow: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 30; }
.toast.bad { border-color: var(--bad); }
.price-edit { width: 80px; padding: 3px 6px; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.tbl td.actions { white-space: nowrap; }

/* mobile */
#logout { font-size: 12px; text-decoration: none; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  header { gap: 10px; padding: 8px 12px; flex-wrap: wrap; }
  nav { overflow-x: auto; flex: 1; } nav button { padding: 8px 10px; white-space: nowrap; }
  .conn #connText { display: none; }
  main { padding: 12px; }
  .hero .name { font-size: 24px; } .hero .price { font-size: 36px; } .hero .place { font-size: 20px; }
  .load .money { margin-left: 0; width: 100%; gap: 10px; flex-wrap: wrap; }
  .toolbar input, .toolbar select { flex: 1; min-width: 120px; }
  .form .cols label { min-width: 100%; }
  .tbl th, .tbl td { padding: 6px 5px; }
  .modal-box { padding: 12px; }
}
