:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --text: #e8eaf0;
  --muted: #7b80a0;
  --green: #3ecf8e;
  --green-dim: #1d5c41;
  --red: #f05d5d;
  --red-dim: #5c1d1d;
  --yellow: #f0c050;
  --yellow-dim: #5c4a1d;
  --blue: #5b8dee;
  --radius: 10px;
  --radius-sm: 6px;
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Auth Screen --- */
.screen { width: 100%; }
.hidden { display: none !important; }

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-box h1 {
  font-size: 1.5rem;
  letter-spacing: .03em;
  margin-bottom: .4rem;
}

.subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }

.input-row {
  display: flex;
  gap: .5rem;
}

.input-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  padding: .6rem .8rem;
  outline: none;
}

.input-row input:focus { border-color: var(--blue); }

.error { color: var(--red); font-size: .85rem; margin-top: .8rem; }

/* --- Header --- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 1.1rem; letter-spacing: .04em; }

.header-right {
  display: flex;
  align-items: center;
  gap: .6rem;
}

#last-updated { font-size: .78rem; color: var(--muted); }

/* --- Main --- */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.group-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2.5rem 0 .75rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.group-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.group-label:first-child { margin-top: 0; }

.group-label.gameserver { color: #c07040; }

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: .6rem;
  transition: border-color .15s;
}

.service-card:hover { border-color: #404770; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}

.status-dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.stopped { background: var(--red); }
.status-dot.unknown { background: var(--yellow); }

.svc-info { flex: 1; min-width: 0; }

.svc-name {
  font-weight: 600;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: .3rem;
}

.svc-port {
  font-size: .7rem;
  font-family: monospace;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .35rem;
  flex-shrink: 0;
}

.svc-port--live    { color: var(--green); border-color: var(--green-dim); }
.svc-port--static  { color: var(--blue); opacity: .6; }
.svc-port--unknown { color: var(--yellow); border-color: var(--yellow-dim); }

.svc-meta {
  font-size: .78rem;
  color: var(--muted);
  font-family: monospace;
  margin-top: .15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.svc-url {
  color: var(--muted);
  text-decoration: none;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: .75rem;
  transition: color .12s;
}

.svc-url:hover {
  color: var(--blue);
  text-decoration: underline;
}

.svc-state {
  font-size: .82rem;
  padding: .2rem .6rem;
  border-radius: 99px;
  white-space: nowrap;
}

.svc-state.running { background: var(--green-dim); color: var(--green); }
.svc-state.stopped, .svc-state.failed, .svc-state.inactive {
  background: var(--red-dim); color: var(--red);
}
.svc-state.unknown, .svc-state.activating {
  background: var(--yellow-dim); color: var(--yellow);
}

.btn-group { display: flex; gap: .4rem; }

/* --- Buttons --- */
button {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  font-size: .82rem;
  padding: .45rem .85rem;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}

button:hover { background: #2e3350; border-color: #4a5070; }
button:active { opacity: .7; }
button:disabled { opacity: .35; cursor: not-allowed; }

button.start  { border-color: var(--green-dim); color: var(--green); }
button.start:hover  { background: var(--green-dim); }
button.stop   { border-color: var(--red-dim); color: var(--red); }
button.stop:hover   { background: var(--red-dim); }
button.restart { border-color: #2e3a5c; color: var(--blue); }
button.restart:hover { background: #1a2540; }

#refresh-btn {
  font-size: 1rem;
  padding: .3rem .6rem;
  line-height: 1;
}

#logout-btn { font-size: .8rem; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .88rem;
  max-width: 320px;
  padding: .7rem 1rem;
  z-index: 100;
  animation: slideIn .2s ease;
}

.toast.success { border-color: var(--green-dim); color: var(--green); }
.toast.error   { border-color: var(--red-dim); color: var(--red); }

@keyframes slideIn {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.loading { color: var(--muted); text-align: center; padding: 3rem; }

@media (max-width: 600px) {
  .svc-state { display: none; }
  .btn-group button { padding: .4rem .6rem; }
}
