:root {
  --bg: #0b0d10; --tile: #14171c; --tile-2: #1b1f26; --line: #262b33; --line-2: #323843;
  --text: #eef1f5; --text-2: #9aa3af; --text-3: #6b7480;
  --green: #5ad17a; --amber: #f2b84b; --red: #ef6b6b; --blue: #3b82f6;
  --mc: #7ec850; --mc-bg: #14200f; --mc-line: #2c4420;
  color-scheme: dark;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html { -webkit-text-size-adjust: 100% }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent }
button, input { font: inherit; color: inherit }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace }
svg { flex: none }
.wrap { max-width: 1120px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) }

header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; flex-wrap: wrap }
.brand { display: flex; align-items: center; gap: 14px }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .14em; font-weight: 600 }
.brand p { margin: 2px 0 0; color: var(--text-2); font-size: 13px }
.head-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); background: var(--tile); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; white-space: nowrap }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(90, 209, 122, .15); flex: none }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(239, 107, 107, .15) }
.dot.wait { background: var(--text-3); box-shadow: none }
.seg { display: inline-flex; background: var(--tile); border: 1px solid var(--line); border-radius: 999px; padding: 3px }
.seg button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 999px; cursor: pointer }
.seg button.on { background: var(--text); color: var(--bg) }
.seg svg, .icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--tile); color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer }
.icon-btn:hover { color: var(--text); border-color: var(--line-2) }
.icon-btn svg { width: 18px; height: 18px }

.label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 28px 0 12px; font-weight: 500 }
.grid { display: grid; gap: 14px }
.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) }
.two { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); margin-top: 20px }
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: 20px; padding: 18px; position: relative; transition: transform .15s, border-color .15s, background .15s; text-decoration: none; color: inherit; display: block; min-width: 0 }
a.tile:hover { transform: translateY(-2px); border-color: var(--line-2); background: var(--tile-2) }
a.tile:active, .sub:active { transform: scale(.98) }
.stat .k { font-size: 13px; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px }
.stat .v { font-size: 26px; font-weight: 600; margin: 8px 0 12px; letter-spacing: -.01em; font-variant-numeric: tabular-nums }
.stat .v small { font-size: 14px; color: var(--text-2); font-weight: 500 }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden }
.bar i { display: block; height: 100%; border-radius: 6px; background: var(--green); transition: width .6s }
.bar i.warn { background: var(--amber) } .bar i.hot { background: var(--red) }
.info { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 4px 18px; font-size: 13px }
.info div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line) }
.info span:first-child { color: var(--text-2) }
.info span:last-child { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

.apps { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)) }
.app { min-height: 168px; display: flex; flex-direction: column }
.app .ico { width: 56px; height: 56px; border-radius: 14px; display: block; object-fit: cover; background: var(--tile-2) }
.app .ico.ph { display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; color: var(--text-2); border: 1px solid var(--line-2) }
.app h3 { margin: 16px 0 4px; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 20px }
.app p { margin: 0; color: var(--text-2); font-size: 13px; line-height: 1.45 }
.app .foot { margin-top: auto; padding-top: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-3) }
.app .st { position: absolute; top: 18px; right: 18px }
.app.gone { opacity: .55 }
.badge { font-size: 11px; font-weight: 600; color: #c9b3ff; background: #241a3d; border-radius: 999px; padding: 3px 9px }
.app.new { border-color: #4b3a7a }
.app .acts { display: flex; gap: 6px }
.chip { border: 1px solid var(--line-2); background: transparent; color: var(--text-2); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer }
.chip:hover { color: var(--text) }

.mc { grid-column: 1 / -1; background: var(--mc-bg); border-color: var(--mc-line); padding: 20px }
.mc-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap }
.mc-head h2 { margin: 0; font-family: Silkscreen, monospace; font-weight: 400; font-size: 22px; color: var(--mc) }
.mc-head p { margin: 2px 0 0; color: var(--text-2); font-size: 13px }
.mc-servers { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap }
.mc-srv { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); background: rgba(0, 0, 0, .25); border: 1px solid var(--mc-line); border-radius: 12px; padding: 7px 12px; cursor: pointer }
.mc-srv b { color: var(--text); font-weight: 600 }
.mc-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)) }
.sub { display: flex; align-items: center; gap: 14px; background: rgba(0, 0, 0, .28); border: 1px solid var(--mc-line); border-radius: 16px; padding: 14px; text-decoration: none; color: inherit; transition: background .15s, transform .15s; min-width: 0 }
.sub:hover { background: rgba(126, 200, 80, .08); transform: translateY(-2px) }
.sub img { width: 46px; height: 46px; border-radius: 12px; flex: none }
.sub img.px { image-rendering: pixelated }
.sub > div { min-width: 0 }
.sub b { display: block; font-size: 15px; font-weight: 600 }
.sub span.mono { font-size: 12px; color: var(--text-2) }
.sub .dot { margin-left: auto }

.lamp { display: flex; flex-direction: column }
.switch { margin-top: auto; display: flex; align-items: center; justify-content: space-between; background: var(--tile-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px }
.switch b { font-size: 14px; font-weight: 600 }
.tog { width: 52px; height: 30px; border-radius: 30px; background: var(--line-2); border: 0; position: relative; cursor: pointer; transition: background .2s; flex: none }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s }
.tog.on { background: var(--amber) }
.tog.on::after { transform: translateX(22px) }
.tog:disabled { opacity: .5 }
.lamp.lit .ico { box-shadow: 0 0 0 1px rgba(242, 184, 75, .4), 0 0 28px rgba(242, 184, 75, .35) }

/* Load view */
.k2 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--text-2) }
.k2 b { font-size: 20px; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums }
.spark { width: 100%; height: 70px; margin: 12px 0; display: block }
.cores { display: grid; grid-template-columns: repeat(var(--n, 8), 1fr); gap: 6px; height: 34px; align-items: end }
.cores i { display: block; background: var(--green); border-radius: 4px 4px 2px 2px; min-height: 3px; opacity: .85; transition: height .6s }
.hint { margin-top: 12px; font-size: 12px; color: var(--text-3); line-height: 1.5 }
.stack { display: flex; height: 12px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--line) }
.stack i { display: block; height: 100%; transition: width .6s; min-width: 2px }
.stack.big { height: 18px }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 12px; color: var(--text-2) }
.legend em { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px }
.table { padding: 6px 0 }
.thead, .row { display: grid; grid-template-columns: minmax(0, 2.2fr) 1fr 1.2fr .9fr; gap: 14px; align-items: center; padding: 10px 18px }
.thead { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line) }
.row { border-bottom: 1px solid var(--line) }
.row:last-child { border-bottom: 0 }
.nm { display: flex; align-items: center; gap: 12px; min-width: 0 }
.nm > img, .nm > svg, .nm > .ph { width: 32px; height: 32px; border-radius: 9px; flex: none }
.nm > .ph { display: flex; align-items: center; justify-content: center; background: var(--tile-2); border: 1px solid var(--line); color: var(--text-2) }
.nm > .ph svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.nm > span:last-child { min-width: 0 }
.nm b, .c b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums }
.nm small, .c small { display: block; font-size: 11px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.mb { display: block; height: 4px; border-radius: 4px; background: var(--line); margin-top: 6px; overflow: hidden }
.mb i { display: block; height: 100%; background: var(--green); border-radius: 4px; min-width: 2px; transition: width .6s }
@media (max-width: 640px) {
  .hide-s { display: none }
  .thead, .row { grid-template-columns: minmax(0, 1.8fr) 1fr 1fr; padding: 10px 14px; gap: 10px }
  .head-right { width: 100% }
  .head-right .seg { flex: 1 } .head-right .seg button { flex: 1; justify-content: center }
  .mc-servers { margin-left: 0; width: 100% }
}

/* Login */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(120% 60% at 50% 0%, #1a2230, var(--bg) 60%) }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center }
.login-card h1 { margin: 6px 0 0; font-size: 24px; letter-spacing: .16em; font-weight: 600 }
.login-card p { margin: 0; color: var(--text-2); font-size: 14px }
#pk-box, #pw-form { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 18px }
.faceid { width: 64px; height: 64px; color: var(--green) }
.btn { border: 1px solid var(--line-2); background: var(--tile-2); color: var(--text); border-radius: 14px; padding: 12px 18px; font-weight: 600; font-size: 15px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; justify-content: center }
.btn.primary { background: #fff; color: #000; border-color: #fff; width: 100% }
.btn.small { padding: 7px 14px; font-size: 13px; border-radius: 10px; width: auto }
.btn.danger { color: var(--red) }
.btn:disabled { opacity: .6 }
.link { background: none; border: 0; color: var(--text-2); font-size: 14px; cursor: pointer; padding: 6px }
.link:hover { color: var(--text) }
input[type=password], input[type=text] { width: 100%; background: var(--tile); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none }
input:focus { border-color: #5b6474 }
.err { color: var(--red); font-size: 13px; min-height: 1em; margin: 0 }

.banner { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #15241b; border: 1px solid #23452f; border-radius: 16px; padding: 12px 16px; font-size: 14px; color: #cfeedd }
.banner > div { display: flex; gap: 6px; align-items: center }

/* Settings sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 10 }
@media (min-width: 700px) { .sheet-bg { align-items: center } }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; background: var(--tile); border: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)) }
@media (min-width: 700px) { .sheet { border-radius: 24px } }
.sheet-head { display: flex; justify-content: space-between; align-items: center }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 600 }
.sheet h3 { margin: 24px 0 10px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); font-weight: 500 }
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px }
.li { display: flex; align-items: center; gap: 10px; background: var(--tile-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px }
.li > span { flex: 1; min-width: 0 }
.li small { display: block; color: var(--text-3); font-size: 12px }
.li input[type=text] { padding: 8px 10px; font-size: 14px; background: var(--tile) }
.li label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap }
.li img, .li svg.ti { width: 28px; height: 28px; border-radius: 8px; flex: none }
.stack-form { display: flex; flex-direction: column; gap: 8px }
.stack-form .btn { align-self: flex-start }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; z-index: 20; max-width: calc(100% - 32px) }
