* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --faint: #484f58;
  --green: #238636;
  --green2: #2ea043;
  --accent: #58a6ff;
}
[data-theme="light"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface2: #eaeef2;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --faint: #8c959f;
  --green: #1a7f37;
  --green2: #2da44e;
  --accent: #0969da;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .2s, color .2s;
}

body.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.container { max-width: 860px; margin: 0 auto; padding: 28px 18px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
header h1 { font-size: 22px; display: flex; align-items: center; gap: 10px; }
header h1 small { font-size: 12px; color: var(--muted); font-weight: 400; }
header .actions { display: flex; gap: 10px; align-items: center; }
.logo-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--green2));
  box-shadow: 0 0 10px rgba(46,160,67,.7);
}

.btn {
  display: inline-block;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.icon { padding: 8px 11px; font-size: 15px; line-height: 1; }
.btn.blue { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.btn.blue:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: var(--green2); }
.btn.red { color: #f85149; border-color: rgba(248,81,73,.4); }
.btn.red:hover { background: rgba(248,81,73,.12); }
.btn.yellow { color: #d29922; border-color: rgba(210,153,34,.4); }
.btn.yellow:hover { background: rgba(210,153,34,.12); }
.btn.full { width: 100%; padding: 13px; font-size: 15px; }

/* stats bar */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.bar { height: 5px; background: var(--surface2); border-radius: 5px; margin-top: 10px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--green2), var(--green)); transition: width .4s; }
.bar span.warn { background: linear-gradient(90deg, #d29922, #bb8009); }
.bar span.crit { background: linear-gradient(90deg, #f85149, #da3633); }

/* toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.summary { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px; padding: 5px 12px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
}
.pill b { color: var(--text); }
.pill.running b { color: #3fb950; }
.pill.stopped b { color: #d29922; }
.pill.down b { color: #f85149; }
.tb-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.search {
  padding: 8px 12px; font-size: 13px; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); outline: none;
}
.search:focus { border-color: var(--accent); }
.switch-lbl { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.card .info { min-width: 0; }
.card .name {
  font-size: 16px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.card.hidden { display: none; }
.card .controls { display: flex; gap: 8px; flex-wrap: wrap; }

.login-card {
  display: block;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
}
.login-card .logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--green), var(--green2));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  font-size: 26px;
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 26px; }
.login-card input[type="password"] {
  width: 100%;
  padding: 14px;
  font-size: 24px;
  letter-spacing: 12px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
  margin-bottom: 16px;
}
.login-card input[type="password"]:focus { border-color: var(--green2); }
.login-card .error {
  background: rgba(248,81,73,.12);
  border: 1px solid rgba(248,81,73,.4);
  color: #f85149;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.running { background: #3fb950; box-shadow: 0 0 8px rgba(63,185,80,.6); }
.dot.stopped { background: #d29922; }
.dot.down { background: #f85149; box-shadow: 0 0 8px rgba(248,81,73,.5); }

.badge {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .5px; font-weight: 700;
}
.badge.running { background: rgba(63,185,80,.15); color: #3fb950; }
.badge.stopped { background: rgba(210,153,34,.15); color: #d29922; }
.badge.down { background: rgba(248,81,73,.15); color: #f85149; }
.badge.unmanaged { background: rgba(139,148,158,.15); color: #8b949e; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border);
  padding: 12px 22px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .25s;
  max-width: 90vw;
}
.toast.show { opacity: 1; }
.toast.ok { border-color: rgba(63,185,80,.5); }
.toast.err { border-color: rgba(248,81,73,.5); }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.refresh-note { font-size: 11px; color: var(--faint); text-align: center; margin-top: 18px; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.modal.wide { max-width: 760px; }
.modal h2 { font-size: 18px; margin-bottom: 18px; }
.modal .hint { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.modal label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 6px;
}
.modal input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}
.modal input[type="text"]:focus { border-color: var(--green2); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 22px;
}
.modal-actions .switch-lbl { margin-right: auto; }

.logs {
  background: #000;
  color: #c9d1d9;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: 12px;
  line-height: 1.5;
  max-height: 55vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
