/* ── Reset & base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0d0f14;
  --surface:      #161b22;
  --surface2:     #1f2937;
  --border:       #30363d;
  --accent:       #1d8cf8;
  --accent-hover: #1570c4;
  --success:      #2ea043;
  --danger:       #da3633;
  --warning:      #d29922;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --font:         'Segoe UI', system-ui, sans-serif;
  --mono:         'Consolas', 'Courier New', monospace;
  --radius:       8px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; }

/* ── Navbar ──────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 52px;
  background: #010409;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.brand-icon { font-size: 1.3rem; }
.brand-sub  { color: var(--accent); }

.navbar-menu { display: flex; gap: 2px; flex: 1; }

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover  { background: var(--surface2); color: var(--text); }
.nav-btn.active { background: var(--surface2); color: var(--text); font-weight: 600; }

.navbar-right { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }

.connection-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.connection-dot.online  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.connection-dot.offline { background: var(--text-muted); }

/* ── Main content ────────────────────────────────────────────────────── */
.main-content { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.section-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.2rem; }

/* ── Server grid / cards ─────────────────────────────────────────────── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  transition: border-color 0.2s;
}
.server-card:hover { border-color: var(--accent); }
.server-card.running { border-left: 3px solid var(--success); }
.server-card.stopped { border-left: 3px solid var(--text-muted); }
.server-card.external { border-left: 3px solid var(--warning); }

.card-name   { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.card-path   { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
.card-info   { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
.card-status {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  margin-bottom: 12px;
}
.status-running  { background: rgba(46,160,67,.2);  color: #3fb950; }
.status-external { background: rgba(210,153,34,.2); color: #d29922; }
.status-stopped  { background: rgba(139,148,158,.15); color: var(--text-muted); }

.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary   { background: var(--accent);   color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #374151; }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover:not(:disabled) { background: #26893a; }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-warning   { background: var(--warning);  color: #000; }
.btn-warning:hover:not(:disabled) { background: #b07d12; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.data-table th { background: var(--surface2); color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 12px; text-align: left; }
.data-table td { padding: 10px 12px; border-top: 1px solid var(--border); font-size: 0.88rem; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.empty-row { text-align: center; color: var(--text-muted); padding: 2rem; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--text); }

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.82rem;
  color: var(--text-muted);
  gap: 4px;
}
.form-grid label.checkbox-label { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form-grid button { grid-column: span 2; justify-self: start; }

input[type="text"],
input[type="number"],
input[type="password"],
input[type="time"],
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 6px 10px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.form-row { display: flex; gap: 8px; margin-bottom: 1rem; align-items: center; }
.form-row select { max-width: 300px; }

.hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1rem; }

/* ── Log / pre boxes ─────────────────────────────────────────────────── */
.log-box {
  background: #010409;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #7ee787;
  font-family: var(--mono);
  font-size: 0.82rem;
  height: 260px;
  overflow-y: auto;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-all;
}
.console-box { height: 340px; }

/* ── Config split pane ───────────────────────────────────────────────── */
.split-pane { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.pane-fields { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: 500px; }
.pane-fields .field-row { display: flex; gap: 8px; align-items: center; }
.pane-fields .field-key  { width: 40%; font-size: 0.82rem; color: var(--text-muted); }
.pane-fields .field-val  { flex: 1; }
.pane-raw label { font-size: 0.82rem; color: var(--text-muted); display: block; margin-bottom: 4px; }
.raw-editor { height: 480px; resize: vertical; font-family: var(--mono); font-size: 0.82rem; }
.editor-actions { display: flex; gap: 8px; }

/* ── Modals ──────────────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.modal.open { display: flex; }

.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-dialog-lg { max-width: 860px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: var(--surface2); }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* Telnet input row */
.telnet-input-row { display: flex; gap: 6px; margin-top: 10px; }
.telnet-input-row input { flex: 1; }

/* ── Toast notifications ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  padding: 10px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 300;
  max-width: 360px;
}
.toast.show { opacity: 1; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

/* ── Result messages ─────────────────────────────────────────────────── */
.result-msg { font-size: 0.85rem; margin-top: 8px; min-height: 1.2em; }
.result-msg.ok  { color: #3fb950; }
.result-msg.err { color: #f85149; }

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state { color: var(--text-muted); padding: 2rem; text-align: center; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid button { grid-column: span 1; }
  .split-pane { grid-template-columns: 1fr; }
  .navbar-menu .nav-btn { padding: 6px 8px; font-size: 0.8rem; }
}

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-wine  { background: rgba(210,153,34,.2); color: var(--warning); }
.badge-linux { background: rgba(46,160,67,.15); color: #3fb950; }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }

/* ── Table action cell ───────────────────────────────────────────────── */
.action-cell { white-space: nowrap; }
