:root {
  --bg: #0a0d13;
  --bg-2: #0f141d;
  --panel: #131a26;
  --panel-2: #182233;
  --border: #223047;
  --border-soft: #1a2434;
  --text: #e6edf7;
  --muted: #8595ad;
  --muted-2: #5d6c85;
  --accent: #4c9aff;
  --accent-2: #2dd4bf;
  --gold: #f5b942;
  --green: #37d67a;
  --red: #ff5c6c;
  --amber: #ffb020;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 600px at 80% -10%, #14203300 0%, var(--bg) 55%), var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121f; box-shadow: 0 6px 18px rgba(76, 154, 255, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.6px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; color: var(--muted);
  padding: 11px 12px; border-radius: var(--radius-sm);
  font-size: 14px; text-align: left; transition: all .15s ease;
}
.nav-item span { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(76,154,255,.16), rgba(76,154,255,.03));
  color: #fff; box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.conn { font-size: 12px; color: var(--muted-2); padding-left: 4px; }
.conn.ok { color: var(--green); }
.conn.bad { color: var(--red); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 26px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 5;
  background: rgba(10, 13, 19, 0.82); backdrop-filter: blur(12px);
}
.stat-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--border-soft);
  padding: 8px 14px; border-radius: 11px; min-width: 92px;
}
.chip b { font-size: 17px; font-variant-numeric: tabular-nums; }
.chip small { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .5px; }
.chip.gold b { color: var(--gold); }
.chip.blue b { color: var(--accent); }
.chip.green b { color: var(--green); }

.view { padding: 24px 26px 74px; animation: fade .25s ease; }
body.console-open .view { padding-bottom: 262px; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:none;} }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 16px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: .2px; }
.section-head .sub { color: var(--muted-2); font-size: 12.5px; }

/* ---------- Buttons ---------- */
.primary-btn {
  background: linear-gradient(135deg, var(--accent), #3f7ee6);
  color: #04121f; border: 0; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 6px 18px rgba(76,154,255,.28); transition: transform .1s ease, filter .15s;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: translateY(1px); }
.ghost-btn {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border); padding: 9px 14px;
  border-radius: 10px; font-size: 13px; transition: all .15s;
}
.ghost-btn:hover { border-color: var(--accent); color: #fff; }
.icon-btn { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--panel-2); color: #fff; }

.mini-btn {
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); padding: 5px 11px; border-radius: 8px; font-size: 12px;
  transition: all .13s;
}
.mini-btn:hover { border-color: var(--accent); }
.mini-btn.danger:hover { border-color: var(--red); color: var(--red); }
.mini-btn.gold:hover { border-color: var(--gold); color: var(--gold); }
.mini-btn.green:hover { border-color: var(--green); color: var(--green); }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 1080px) { .cards-3, .cards-4 { grid-template-columns: repeat(2,1fr); } }

.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 18px;
}
.panel h3 { margin: 0 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; letter-spacing: .3px; }

.metric { display: flex; flex-direction: column; gap: 6px; }
.metric .big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .label { color: var(--muted-2); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.metric .delta { font-size: 12px; color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border-soft); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 12px 14px; background: var(--bg-2);
  color: var(--muted-2); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(24,34,51,.5); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid transparent;
}
.badge.on { background: rgba(55,214,122,.12); color: var(--green); border-color: rgba(55,214,122,.3); }
.badge.off { background: rgba(133,149,173,.1); color: var(--muted); border-color: var(--border); }
.badge.warn { background: rgba(255,176,32,.12); color: var(--amber); border-color: rgba(255,176,32,.3); }
.badge.err { background: rgba(255,92,108,.12); color: var(--red); border-color: rgba(255,92,108,.3); }
.badge.prem { background: rgba(245,185,66,.14); color: var(--gold); border-color: rgba(245,185,66,.35); }
.badge.blue { background: rgba(76,154,255,.14); color: var(--accent); border-color: rgba(76,154,255,.32); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.g { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.r { background: var(--red); }
.dot.a { background: var(--amber); }

/* ---------- Account cards ---------- */
.acct-card { display: flex; flex-direction: column; gap: 14px; }
.acct-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.acct-id { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: 16px; color: #04121f;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.acct-name { font-weight: 600; font-size: 15px; }
.acct-sub { font-size: 12px; color: var(--muted-2); }
.acct-balances { display: flex; gap: 10px; }
.bal {
  flex: 1; background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 10px 12px;
}
.bal .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bal .k { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .5px; }
.bal.stars .v { color: var(--gold); }
.bal.ton .v { color: var(--accent); }
.acct-tags { display: flex; gap: 7px; flex-wrap: wrap; }
.acct-proxy-row { display: flex; align-items: center; gap: 10px; }
.acct-proxy-row > span { font-size: 12px; min-width: 44px; }
.acct-proxy-row .acct-proxy { flex: 1 1 auto; min-width: 0; }

/* ---------- Gift cards ---------- */
.gift-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 15px; display: flex; flex-direction: column; gap: 12px;
}
.gift-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.gift-title { font-weight: 600; font-size: 14.5px; }
.gift-meta { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; margin-top: 3px; }
.gift-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gift-price-input { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.gift-price-input input {
  width: 84px; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 6px 8px; font-size: 12.5px;
}

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field > span em { color: var(--muted-2); font-style: normal; }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; outline: none; transition: border .15s;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.suggest-chip {
  font-size: 11.5px; padding: 4px 9px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
}
.suggest-chip:hover { border-color: var(--accent); color: #fff; }
.hint { color: var(--muted-2); font-size: 12px; line-height: 1.5; }

/* ---------- Slideover ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4,7,12,.6); backdrop-filter: blur(2px); z-index: 40; }
.slideover {
  position: fixed; top: 0; right: 0; height: 100vh; width: 420px; max-width: 92vw;
  background: var(--bg-2); border-left: 1px solid var(--border);
  z-index: 50; display: flex; flex-direction: column; box-shadow: var(--shadow);
  animation: slidein .22s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.slideover-head, .modal .slideover-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border-soft);
}
.slideover-head h3 { margin: 0; font-size: 16px; }
.slideover-body { padding: 20px; overflow-y: auto; flex: 1; }
.slideover-foot {
  padding: 16px 20px; border-top: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; gap: 10px;
}

/* ---------- Modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(4,7,12,.62); backdrop-filter: blur(3px);
}
.modal { width: 400px; max-width: 92vw; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  background: var(--panel-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow); min-width: 240px; font-size: 13px; animation: slidein .2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast b { display: block; margin-bottom: 2px; }

/* ---------- Console ---------- */
.console {
  position: fixed; left: 248px; right: 0; bottom: 0; z-index: 30;
  background: rgba(8, 11, 17, 0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 240px; transition: height .18s ease;
  box-shadow: 0 -10px 30px rgba(0,0,0,.35);
}
.console.collapsed { height: 38px; }
.console-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; cursor: pointer; user-select: none; flex-shrink: 0;
  border-bottom: 1px solid var(--border-soft);
}
.console-title { display: flex; align-items: center; gap: 9px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
.console-count { background: var(--panel-2); border: 1px solid var(--border); color: var(--muted-2); font-size: 11px; padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.console-tools { display: flex; align-items: center; gap: 8px; }
.console-tools select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 4px 8px; font-size: 12px;
}
.console-tools .mini-btn.on { border-color: var(--amber); color: var(--amber); }
.console-body {
  flex: 1; overflow-y: auto; padding: 8px 16px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.55;
}
.console.collapsed .console-body { display: none; }
.log-line { display: flex; gap: 10px; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.log-line .lt { color: var(--muted-2); flex-shrink: 0; }
.log-line .ll { flex-shrink: 0; width: 46px; font-weight: 600; }
.log-line .lg { color: var(--muted-2); flex-shrink: 0; }
.log-line .lm { color: var(--text); }
.log-line.INFO .ll { color: var(--accent); }
.log-line.WARNING .ll, .log-line.WARNING .lm { color: var(--amber); }
.log-line.ERROR .ll, .log-line.ERROR .lm, .log-line.CRITICAL .ll { color: var(--red); }
.log-line.DEBUG .ll { color: var(--muted-2); }
@media (max-width: 900px) { .console { left: 0; } }

/* ---------- Rule wizard ---------- */
.modal.wizard {
  width: 860px; max-width: 94vw; display: flex; flex-direction: column;
  max-height: 88vh;
}
.wizard-steps {
  display: flex; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.wstep {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted-2);
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-soft);
  background: var(--panel); white-space: nowrap; cursor: pointer; transition: all .15s;
}
.wstep b {
  display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--border); color: var(--text); font-size: 11px;
}
.wstep.active { color: #fff; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.wstep.active b { background: var(--accent); color: #04121f; }
.wstep.done { color: var(--green); border-color: rgba(55,214,122,.35); }
.wstep.done b { background: var(--green); color: #04121f; }

.wizard-body { padding: 18px 20px; overflow-y: auto; flex: 1; min-height: 280px; }
.wpane { animation: fade .18s ease; }
.wizard-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.wizard-toolbar input {
  flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; outline: none;
}
.wizard-toolbar input:focus { border-color: var(--accent); }
.wizard-foot { display: flex; align-items: center; }

.tile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}
.tile {
  position: relative; display: flex; flex-direction: column; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px;
  padding: 12px 8px; color: var(--text); transition: all .13s ease; overflow: hidden;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 6px 18px rgba(76,154,255,.2); background: var(--panel-2); }
.tile-img {
  position: relative; width: 72px; height: 72px; border-radius: 12px; display: grid; place-items: center;
  background: var(--bg-2); overflow: hidden;
}
.tile-img img { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 1; }
.tile-img .tile-ph {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 0;
  font-size: 22px; font-weight: 700; color: var(--muted-2); text-transform: uppercase;
}
.tile-img.swatch { width: 72px; height: 72px; }
.tile-label {
  font-size: 12px; text-align: center; line-height: 1.25; color: var(--text);
  max-width: 100%; word-break: break-word;
}
.tile-check {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--green); font-size: 13px; font-weight: 700;
}
.tile.sel .tile-check { background: var(--green); color: #04121f; border-color: var(--green); }

.wizard-summary {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px;
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 12px; padding: 14px 16px;
}
.sum-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.sum-row span { color: var(--muted-2); }
.sum-row b { text-align: right; word-break: break-word; }

/* Rules: filters + cards */
.filters-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px;
}
.filter-search {
  flex: 1; min-width: 220px; background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: 10px; padding: 9px 13px; color: var(--text); font-size: 13px;
}
.filter-search:focus { border-color: var(--accent); outline: none; }
.filter-select {
  background: var(--panel); border: 1px solid var(--border-soft); border-radius: 10px;
  padding: 9px 12px; color: var(--text); font-size: 13px; max-width: 220px;
}
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border-soft); border-radius: 10px; overflow: hidden; }
.seg button {
  background: transparent; border: none; color: var(--muted); padding: 9px 14px; font-size: 12.5px;
  cursor: pointer; transition: all .12s ease;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent); color: #04121f; font-weight: 600; }

.rules-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.rule-card { display: flex; flex-direction: column; gap: 13px; transition: border-color .13s ease, transform .13s ease; }
.rule-card:hover { border-color: var(--border); transform: translateY(-1px); }
.rule-card.paused { opacity: .72; }
.rule-card-head { display: flex; align-items: center; gap: 11px; }
.rule-thumb {
  position: relative; width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0;
  background: var(--bg-2); display: grid; place-items: center; overflow: hidden;
}
.rule-thumb img { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 1; }
.rule-thumb .tile-ph {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 0;
  font-size: 14px; font-weight: 700; color: var(--muted-2); text-transform: uppercase;
}
.rule-id-block { flex: 1; min-width: 0; }
.rule-coll { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rule-id { font-size: 10.5px; opacity: .7; }
.rule-chips { display: flex; flex-direction: column; gap: 7px; }
.rchip {
  display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: 9px; padding: 7px 11px;
  word-break: break-word;
}
.rchip i { font-style: normal; color: var(--muted-2); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; min-width: 62px; flex-shrink: 0; }
.rchip.price { color: var(--gold); font-weight: 600; }
.rchip.price i { color: var(--muted-2); font-weight: 400; }
.rule-actions { display: flex; gap: 8px; margin-top: 2px; }
.rule-actions .mini-btn { flex: 1; }

.empty { text-align: center; color: var(--muted-2); padding: 50px 20px; font-size: 14px; }
.loading { color: var(--muted-2); padding: 30px; text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--muted); }

/* ============================ MOBILE ============================ */
@media (max-width: 820px) {
  html, body { -webkit-text-size-adjust: 100%; }
  #app { display: block; min-height: 100vh; }

  /* Sidebar -> sticky top bar with horizontal nav */
  .sidebar {
    flex-direction: row; align-items: center; gap: 8px;
    height: auto; position: sticky; top: 0; z-index: 40;
    padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border-soft);
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .brand { padding: 0 4px 0 2px; flex-shrink: 0; }
  .brand-mark { width: 32px; height: 32px; font-size: 17px; }
  .brand-text { display: none; }
  .nav { flex-direction: row; margin: 0; gap: 4px; flex: 1; }
  .nav-item { padding: 8px 11px; white-space: nowrap; font-size: 13px; }
  .nav-item.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .nav-item span { display: none; }
  .sidebar-foot { margin: 0; flex-direction: row; gap: 6px; flex-shrink: 0; }
  .sidebar-foot .conn { display: none; }
  .ghost-btn { padding: 8px 10px; font-size: 12px; }

  /* Topbar flows normally (not sticky under the nav bar) */
  .topbar { position: static; padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
  .stat-chips { gap: 6px; order: 2; width: 100%; overflow-x: auto; }
  .chip { min-width: 78px; padding: 6px 11px; }
  .topbar .primary-btn { order: 1; margin-left: auto; }

  .view { padding: 16px 13px 84px; }
  body.console-open .view { padding-bottom: 180px; }
  .section-head { flex-wrap: wrap; gap: 10px; }
  .section-head h2 { font-size: 16px; }

  /* Grids collapse */
  .cards-4, .cards-3 { grid-template-columns: repeat(2, 1fr) !important; }
  .cards-auto, .rules-grid { grid-template-columns: 1fr !important; }
  .grid[style*="1fr 1fr"] { grid-template-columns: 1fr !important; }

  /* Wizard = fullscreen sheet */
  .modal-wrap { place-items: stretch; }
  .modal.wizard { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .wizard-steps { overflow-x: auto; padding: 12px 14px; }
  .wstep { white-space: nowrap; }
  .wizard-body { padding: 14px; min-height: 0; }
  .wizard-toolbar { flex-wrap: wrap; }
  .wizard-toolbar input { flex: 1 1 100%; min-width: 0; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
  .tile-img, .tile-img.swatch { width: 60px; height: 60px; }
  .tile-label { font-size: 11px; }
  .field-row { grid-template-columns: 1fr; gap: 4px; }
  .field-row .field { width: 100%; }

  /* Filters stack */
  .filters-bar { gap: 8px; }
  .filter-search { flex: 1 1 100%; min-width: 0; }
  .filter-select, .seg { flex: 1 1 auto; }

  /* Console */
  .console { left: 0; }
  .console-body { max-height: 42vh; font-size: 11px; }
  .console-head { padding: 8px 12px; }

  .toasts { left: 10px; right: 10px; bottom: 10px; }
  .toast { max-width: 100%; }
}

@media (max-width: 420px) {
  .cards-4, .cards-3 { grid-template-columns: 1fr !important; }
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}
