:root {
  --bg: #0e0b16; --bg2: #161125; --card: #1c1630; --card2: #241c3d; --line: #2f2650;
  --text: #ece8f6; --muted: #9a90b8; --accent: #b48cff; --accent2: #7c4dff; --ok: #5ee6a0;
  --warn: #ffc857; --bad: #ff6b81; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
body { background: radial-gradient(1200px 600px at 80% -10%, #2a1a55 0%, transparent 60%), var(--bg); min-height: 100vh; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; font-size: 48px; color: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav.side { position: sticky; top: 0; height: 100vh; padding: 18px 12px; border-right: 1px solid var(--line); background: rgba(14,11,22,.6); backdrop-filter: blur(12px); display: flex; flex-direction: column; gap: 4px; }
nav.side .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .5px; padding: 4px 8px 16px; }
nav.side .brand img { width: 32px; height: 32px; border-radius: 8px; image-rendering: pixelated; }
nav a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav a.nav:hover { background: var(--card); color: var(--text); }
nav a.nav.active { background: linear-gradient(90deg, #3a2470, #261a48); color: #fff; }
nav .spacer { flex: 1; }
main { padding: 22px clamp(14px, 3vw, 34px) 100px; max-width: 1400px; width: 100%; }
nav.bottom { display: none; }
h1 { font-size: 24px; margin: 0 0 16px; letter-spacing: -.3px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
h3 { margin: 0 0 6px; font-size: 16px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  nav.side { display: none; }
  nav.bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; background: rgba(18,14,30,.92); backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + var(--safe-b)); justify-content: space-around; }
  nav.bottom a { flex: 1; text-align: center; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; padding: 4px 0; }
  nav.bottom a .ic { display: block; font-size: 20px; line-height: 1.2; }
  nav.bottom a.active { color: var(--accent); }
  main { padding: 16px 14px calc(90px + var(--safe-b)); }
}

/* components */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.card { background: linear-gradient(180deg, var(--card), #191329); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.tight { padding: 12px; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.stat .s { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.dot.bad { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--card2); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 650; display: inline-flex; gap: 7px; align-items: center; transition: transform .06s, background .15s; white-space: nowrap; }
.btn:hover { background: #2e2450; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent2), #a26bff); border-color: transparent; color: #fff; }
.btn.danger { border-color: #5a2433; background: #2b1520; color: #ffb3c0; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: #120e1f; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input.grow, select.grow { flex: 1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: transparent; padding: 6px 12px; border-radius: 99px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--card2); color: #fff; border-color: var(--accent2); }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; gap: 10px; align-items: center; padding: 9px 2px; min-width: 0; }
.item .grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head { width: 34px; height: 34px; border-radius: 8px; image-rendering: pixelated; background: var(--card2); flex: none; }
.head.lg { width: 56px; height: 56px; border-radius: 12px; }
.bar { height: 7px; border-radius: 9px; background: #120e1f; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); }
.bar.red > i { background: linear-gradient(90deg, #c2304a, var(--bad)); }
.bar.food > i { background: linear-gradient(90deg, #a5672a, #f0a04b); }
.feed .ev { display: grid; grid-template-columns: 54px 22px 1fr; gap: 6px; padding: 7px 0; align-items: start; }
.feed .ev .t { color: var(--muted); font-size: 12px; padding-top: 1px; }
.chart { width: 100%; height: 120px; display: block; }
.mapwrap { position: relative; height: calc(100vh - 150px); min-height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.mapwrap iframe { width: 100%; height: 100%; border: 0; background: #000; }
.maptools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.maptools > * { pointer-events: auto; background: rgba(20,15,34,.88) !important; backdrop-filter: blur(8px); }
.console { background: #08060e; border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 260px); min-height: 300px; overflow: auto; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.console .l-warn { color: var(--warn); } .console .l-err { color: var(--bad); } .console .l-chat { color: #d7c2ff; } .console .l-me { color: var(--ok); }
.inv { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.slot { aspect-ratio: 1; background: #120e1f; border: 1px solid var(--line); border-radius: 8px; position: relative; display: grid; place-items: center; font-size: 9.5px; text-align: center; padding: 2px; overflow: hidden; line-height: 1.1; color: #d9d2ee; }
.slot.has { background: #1f1836; }
.slot.ench { box-shadow: inset 0 0 12px rgba(180,140,255,.45); }
.slot b { position: absolute; right: 3px; bottom: 1px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card2); border-radius: 99px; padding: 6px 11px; cursor: pointer; font-size: 13px; font-weight: 600; }
.chip:hover { border-color: var(--accent); }
.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #2a2340; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span:before { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--accent2); }
.switch input:checked + span:before { transform: translateX(17px); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
@media (max-width: 860px) { #toasts { bottom: calc(80px + var(--safe-b)); left: 16px; } }
.toast { background: #251c40; border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: in .2s; white-space: pre-wrap; word-break: break-word; font-size: 13px; }
.toast.err { border-left-color: var(--bad); }
@keyframes in { from { transform: translateY(8px); opacity: 0; } }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: min(400px, 100%); text-align: center; }
.login img { width: 84px; height: 84px; image-rendering: pixelated; border-radius: 18px; box-shadow: 0 10px 40px rgba(124,77,255,.4); }
.login h1 { margin: 18px 0 6px; font-size: 26px; }
.login .btn { width: 100%; justify-content: center; padding: 14px; font-size: 16px; margin-top: 18px; }
.sky { height: 64px; border-radius: 12px; position: relative; overflow: hidden; border: 1px solid var(--line); }
.sky .sun { position: absolute; width: 18px; height: 18px; border-radius: 50%; top: 50%; transform: translate(-50%, -50%); }
dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: 86vh; }
dialog::backdrop { background: rgba(5,3,10,.7); backdrop-filter: blur(3px); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.hide-sm { } @media (max-width: 600px) { .hide-sm { display: none; } }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; padding: 6px 8px; }
table.t td { padding: 7px 8px; border-top: 1px solid var(--line); }
.scroll-x { overflow-x: auto; }
