:root {
  --bg: #070b10;
  --bg2: #0a1119;
  --panel: #0e1723;
  --panel2: #121e2d;
  --panel3: #172638;
  --line: #1e3045;
  --text: #e9f2fb;
  --muted: #8fa6bd;
  --muted2: #637a91;
  --accent: #22d3ee;
  --accent2: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(1200px 700px at 20% -10%, #10263a 0%, transparent 55%),
              radial-gradient(900px 600px at 100% 0%, #0d2a2a 0%, transparent 45%),
              var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

.hidden { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.9em; color: var(--accent); }

.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
  color: var(--muted);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 30px 24px 24px;
  background: linear-gradient(180deg, rgba(18, 30, 45, 0.96), rgba(10, 17, 25, 0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.logo {
  width: 78px;
  height: 78px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  color: var(--accent);
  background: radial-gradient(circle at 30% 20%, rgba(34, 211, 238, 0.22), rgba(52, 211, 153, 0.06));
  border: 1px solid rgba(34, 211, 238, 0.35);
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.16);
}
.login h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.tiny { font-size: 11px; }
.error { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 13px; }

#loginForm { display: grid; gap: 10px; margin-top: 18px; }
#pin {
  width: 100%;
  padding: 16px 18px;
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.35em;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
}
#pin:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12); }

#totp {
  width: 100%;
  padding: 13px 16px;
  text-align: center;
  font-size: 18px;
  letter-spacing: 0.22em;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
}
#totp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12); }

.btn {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel2);
  color: var(--text);
  font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--panel3); border-color: #2a4560; }
.btn:active { transform: scale(0.98); }
.btn.primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #041014;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.wide { width: 100%; }
.btn.danger { border-color: rgba(248, 113, 113, 0.35); color: var(--danger); }

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(7, 11, 16, 0.78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(30, 48, 69, 0.7);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: var(--muted2);
  box-shadow: 0 0 0 4px rgba(143, 166, 189, 0.08);
}
.dot.on { background: var(--accent2); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14), 0 0 18px rgba(52, 211, 153, 0.6); }
.dot.off { background: var(--danger); box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.14); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.14); }
.brand-text { min-width: 0; }
.pc-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 18px;
}
.icon-btn:active { transform: scale(0.95); }

.main { padding: 14px 14px 24px; }
.tab { display: none; animation: fade 0.18s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.toolbar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.on {
  color: #041014;
  background: var(--accent);
  border-color: transparent;
}
.chip.select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; }

.screen-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  min-height: 80px;
}
.screen-wrap img {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
}
.screen-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(34, 211, 238, 0.06), transparent 60%);
}
.screen-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(4, 10, 16, 0.72);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.exit-fs {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 120;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  backdrop-filter: blur(10px);
}

.screen-wrap:fullscreen,
.screen-wrap.screen-fs {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  border: 0;
  background: #000;
}
.screen-wrap:fullscreen img,
.screen-wrap.screen-fs img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.screen-wrap:fullscreen .screen-msg,
.screen-wrap.screen-fs .screen-msg { background: transparent; }
.screen-wrap:fullscreen .screen-badge,
.screen-wrap.screen-fs .screen-badge { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }

.quickkeys {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
}
.quickkeys::-webkit-scrollbar { display: none; }
.quickkeys button {
  flex: none;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.quickkeys button:active { background: var(--panel3); }

.hint { margin: 10px 2px 0; color: var(--muted2); font-size: 11px; line-height: 1.5; }
.hint.warn { color: #b48a3c; }

.section-title {
  margin: 22px 2px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted2);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 86px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  color: var(--text);
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}
.action:hover { border-color: #2a4560; background: var(--panel3); }
.action:active { transform: scale(0.975); }
.action .ico { font-size: 20px; line-height: 1.15; margin-bottom: 2px; }
.action span:not(.ico) { font-size: 13px; font-weight: 650; line-height: 1.25; }
.action small { color: var(--muted2); font-size: 10px; }
.action.danger { border-color: rgba(248, 113, 113, 0.25); }
.action.danger span:not(.ico) { color: #fca5a5; }

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
}
.card-label { color: var(--muted2); font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; }
.card-value { margin-top: 3px; font-size: 23px; font-weight: 750; letter-spacing: -0.03em; }
.card-value.small { font-size: 13px; line-height: 1.3; font-weight: 650; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.card-sub { margin-top: 4px; color: var(--muted2); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 5px; margin-top: 8px; border-radius: 99px; background: #0a121b; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.35s ease; }

.info-list {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  overflow: hidden;
}
.info-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  border-bottom: 1px solid rgba(30, 48, 69, 0.55);
  font-size: 12px;
}
.info-list > div:last-child { border-bottom: 0; }
.info-list span { color: var(--muted2); flex: none; }
.info-list b { font-weight: 600; text-align: right; word-break: break-word; }

.row { display: flex; gap: 9px; margin-top: 12px; }
.row .btn { flex: 1; font-size: 12px; padding: 0 8px; }

.login-log { display: grid; gap: 6px; margin-top: 10px; }
.login-log-title {
  margin: 4px 2px;
  color: var(--muted2);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.login-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11px;
}
.login-row b { color: var(--accent2); font-weight: 600; }
.login-row.fail b { color: var(--danger); }

.proc-list { display: grid; gap: 6px; margin-top: 10px; }
.proc {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  font-size: 12px;
}
.proc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proc-meta { color: var(--muted2); font-size: 10px; white-space: nowrap; }
.proc-kill { border: 0; background: transparent; color: var(--danger); font-size: 16px; padding: 2px 4px; }

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.console-out {
  min-height: 45vh;
  max-height: 58vh;
  margin: 0;
  padding: 13px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #04080c;
  color: #c8f7e5;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.console-form { display: flex; gap: 8px; margin-top: 9px; }
.console-form input {
  flex: 1;
  min-width: 0;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel);
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}
.console-form input:focus { border-color: var(--accent); }
.console-form .btn { width: 54px; padding: 0; }

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  background: rgba(7, 11, 16, 0.86);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(30, 48, 69, 0.75);
}
.bottomnav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted2);
  font-size: 10px;
  font-weight: 600;
}
.bottomnav button span { font-size: 18px; line-height: 1.1; filter: grayscale(0.35); }
.bottomnav button.active { color: var(--accent); background: rgba(34, 211, 238, 0.07); }
.bottomnav button.active span { filter: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 200;
  transform: translateX(-50%);
  max-width: calc(100vw - 40px);
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(14, 23, 35, 0.96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12px;
  text-align: center;
  backdrop-filter: blur(14px);
  animation: toastIn 0.18s ease;
}
.toast.err { border-color: rgba(248, 113, 113, 0.35); color: #fca5a5; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 5, 9, 0.68);
  backdrop-filter: blur(6px);
}
.modal-card {
  width: 100%;
  max-width: 440px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 6px; font-size: 17px; }
.modal-card p { margin: 0 0 14px; font-size: 12px; line-height: 1.5; }
.modal-input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}
.modal-input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-actions .btn { min-width: 92px; }

@media (min-width: 620px) {
  .main { padding: 18px 20px 30px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .action { min-height: 92px; }
  .app { padding-bottom: 30px; }
  .bottomnav {
    position: sticky;
    bottom: 12px;
    max-width: 560px;
    margin: 10px auto 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
  }
  .toast { bottom: 24px; }
}
