:root {
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --accent: #e2b96f;
  --accent2: #c8963a;
  --text: #e8e8f0;
  --text2: #9999bb;
  --ok: #4caf82;
  --warn: #e2b96f;
  --err: #e25555;
  --border: #2a2a4a;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* LOGIN */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin: 10px 0 4px;
  letter-spacing: 2px;
}

.login-logo p {
  color: var(--text2);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.error {
  background: rgba(226,85,85,0.15);
  border: 1px solid var(--err);
  border-radius: var(--radius);
  color: var(--err);
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* FORMS */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  color: var(--text2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover { background: var(--accent2); }

.btn-danger {
  background: var(--err);
  color: #fff;
}

.btn-danger:hover { background: #c03030; }

/* NAVBAR */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links a {
  color: var(--text2);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  transition: all 0.2s;
}

.nav-links a:hover { color: var(--text); background: var(--bg3); }
.nav-links a.active { color: var(--accent); background: rgba(226,185,111,0.1); }

/* MAIN */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px;
}

main h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 32px 0 14px;
}

main h2:first-child { margin-top: 0; }

/* CARDS */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.card.loading { color: var(--text2); font-style: italic; }

/* SERVER GRID */
.servers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.server-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.server-card.ok { border-left: 3px solid var(--ok); }
.server-card.warn { border-left: 3px solid var(--warn); }
.server-card.err { border-left: 3px solid var(--err); }

.server-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.server-name {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.server-role {
  font-size: 11px;
  color: var(--text2);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 20px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.metric {
  background: var(--bg3);
  border-radius: 6px;
  padding: 8px 10px;
}

.metric-label {
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.metric-value.ok { color: var(--ok); }
.metric-value.warn { color: var(--warn); }
.metric-value.err { color: var(--err); }

.processes { margin-top: 10px; }

.proc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.proc-item:last-child { border-bottom: none; }

.proc-status {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.proc-status.online { background: rgba(76,175,130,0.2); color: var(--ok); }
.proc-status.stopped, .proc-status.errored { background: rgba(226,85,85,0.2); color: var(--err); }

/* SERVICES */
.services-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.service-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.service-name { font-weight: 600; }
.service-server { color: var(--text2); font-size: 12px; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
}

.badge.ok { background: rgba(76,175,130,0.2); color: var(--ok); }
.badge.err { background: rgba(226,85,85,0.2); color: var(--err); }

/* LOGS */
.log-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 12px;
  max-height: 320px;
  overflow-y: auto;
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-all;
}

/* CONFIG */
.config-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
}

.config-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.config-section.danger { border-color: rgba(226,85,85,0.3); }
.config-section.danger h3 { color: var(--err); }

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.notice {
  position: fixed;
  bottom: 28px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  max-width: 340px;
  animation: slideUp 0.2s ease;
}

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

.notice.ok { background: rgba(76,175,130,0.95); border: 1px solid var(--ok); color: #fff; }
.notice.err { background: rgba(226,85,85,0.95); border: 1px solid var(--err); color: #fff; }

/* CHAT */
.chat-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { display: flex; }
.msg-user { justify-content: flex-end; }
.msg-alfred { justify-content: flex-start; }

.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.msg-user .bubble {
  background: var(--accent);
  color: var(--bg);
  border-bottom-right-radius: 3px;
}

.msg-alfred .bubble {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.bubble.bubble-err { border-color: var(--err); color: var(--err); }

.bubble code {
  background: rgba(0,0,0,0.3);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', 'Fira Mono', monospace;
  font-size: 12px;
}

.bubble.thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.bubble.thinking span {
  width: 7px; height: 7px;
  background: var(--text2);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.bubble.thinking span:nth-child(2) { animation-delay: 0.2s; }
.bubble.thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 0 18px;
  border-top: 1px solid var(--border);
}

#chat-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

#chat-input:focus { outline: none; border-color: var(--accent); }

@media (max-width: 600px) {
  .navbar { padding: 0 16px; }
  main { padding: 20px 16px; }
  .servers-grid { grid-template-columns: 1fr; }
  .bubble { max-width: 90%; }
  .chat-wrap { padding: 0 12px; }
}
