:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --card: #1c2333;
  --border: #2d3a4d;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #4f8cff;
  --accent2: #2dd4bf;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }

/* ---------- auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(79,140,255,.12), transparent),
    var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark {
  width: 44px; height: 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: #06121f;
}
.brand-text h1 { font-size: 20px; letter-spacing: .5px; }
.brand-text p { color: var(--muted); font-size: 12px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: filter .15s, border-color .15s;
}
.btn:hover { filter: brightness(1.15); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn-danger { background: transparent; border-color: rgba(248,81,73,.5); color: var(--red); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert {
  background: rgba(248,81,73,.12);
  border: 1px solid rgba(248,81,73,.4);
  color: #ffb3ae;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}
.alert.ok { background: rgba(63,185,80,.12); border-color: rgba(63,185,80,.4); color: #7ee787; }

.qrcode { display: flex; justify-content: center; margin: 18px 0; }
.qrcode img, .qrcode canvas { border-radius: 8px; background: #fff; padding: 8px; }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand-side { margin-bottom: 20px; }
.brand-side .brand-mark { width: 36px; height: 36px; font-size: 18px; }
.brand-side h1 { font-size: 16px; }
#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.nav-item:hover { color: var(--text); background: var(--card); }
.nav-item.active { color: var(--text); background: var(--card); border-left: 3px solid var(--accent); }
.sidebar-foot { margin-top: 12px; }
.user-chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.content { flex: 1; padding: 24px; min-width: 0; }

.page h2 { font-size: 18px; margin-bottom: 16px; }
.page h3 { font-size: 15px; margin: 20px 0 10px; }

/* ---------- cards / grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: var(--bg2); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(79,140,255,.05); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.on { background: rgba(63,185,80,.15); color: var(--green); }
.badge.off { background: rgba(139,152,169,.15); color: var(--muted); }
.badge.kill { background: rgba(248,81,73,.15); color: var(--red); }
.badge.paused { background: rgba(210,153,34,.15); color: var(--amber); }

/* ---------- log viewer ---------- */
.logbox {
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 62vh;
  overflow: auto;
}
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar select, .toolbar input {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; outline: none;
}

/* ---------- file manager ---------- */
.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.breadcrumb .crumb { color: var(--accent); cursor: pointer; }
.breadcrumb .sep { color: var(--muted); }
.file-icon { color: var(--muted); margin-right: 8px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5,8,12,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%; max-width: 420px;
  overflow: hidden;
}
.modal-card.wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
#editor-text {
  width: 100%;
  min-height: 55vh;
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 12px;
  outline: none;
  white-space: pre;
}
#editor-hint { margin-left: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--card);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  z-index: 100;
  max-width: 360px;
}
.toast.err { border-color: var(--red); }

@media (max-width: 760px) {
  .sidebar { width: 64px; padding: 12px 8px; }
  .brand-side .brand-text, .user-chip, .nav-item { font-size: 0; }
  .nav-item { padding: 10px; text-align: center; }
  .content { padding: 14px; }
}

.upload-btn { display: inline-block; }
.logbox.short { max-height: 30vh; }
p.hint { margin-top: 10px; }
.num-input { width: 80px; }
.qr-note { text-align: center; margin-top: 8px; }
.hidden-input { display: none; }
