:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-panel: #161922;
  --bg-elevated: #1e222c;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #9096a5;
  --accent: #4f8cff;
  --accent-hover: #6ba0ff;
  --green: #3fbf6f;
  --red: #e5534b;
  --yellow: #d9a441;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  background: var(--bg-elevated);
  color: var(--text);
  transition: background 0.15s;
}
button:hover { background: #262b38; }
button.primary { background: var(--accent); color: white; }
button.primary:hover { background: var(--accent-hover); }
button.danger { background: var(--red); color: white; }
button.danger:hover { background: #f06a62; }
button.success { background: var(--green); color: white; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }

.hidden { display: none !important; }

/* Auth screens */
.auth-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 340px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card p.sub { margin: 0 0 20px; color: var(--text-dim); font-size: 13px; }
.auth-card label { display: block; font-size: 12px; color: var(--text-dim); margin: 12px 0 4px; }
.auth-card input { width: 100%; }
.auth-card button { width: 100%; margin-top: 20px; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }

/* App layout */
#app { display: flex; height: 100vh; }
.sidebar {
  width: 260px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h1 { font-size: 16px; margin: 0; }
.server-list { flex: 1; overflow-y: auto; padding: 8px; }
.server-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.server-item:hover { background: var(--bg-elevated); }
.server-item.active { background: var(--bg-elevated); border: 1px solid var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); flex-shrink: 0; }
.dot.running { background: var(--green); }
.dot.stopped { background: var(--text-dim); }
.server-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); display:flex; justify-content: space-between; align-items:center;}

.host-stats { padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }
.host-stats .bar-bg { background: var(--bg-elevated); border-radius: 4px; height: 6px; margin-top: 4px; overflow: hidden; }
.host-stats .bar-fill { height: 100%; background: var(--accent); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h2 { margin: 0; font-size: 18px; }
.topbar .actions { display: flex; gap: 8px; }
.tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.tab { padding: 10px 14px; cursor: pointer; color: var(--text-dim); border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-content { flex: 1; overflow: auto; padding: 20px 24px; }

.empty-state { display:flex; align-items:center; justify-content:center; height:100%; color: var(--text-dim); flex-direction: column; gap: 12px; }

/* Console */
.console-wrap { display: flex; flex-direction: column; height: 100%; }
#console-output {
  flex: 1;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'Cascadia Code', Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
.console-input-row { display: flex; gap: 8px; margin-top: 10px; }
.console-input-row input { flex: 1; font-family: 'Cascadia Code', Consolas, monospace; }

/* Files */
.file-toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; flex-wrap: wrap; }
.breadcrumbs { color: var(--text-dim); font-size: 13px; }
.breadcrumbs span { cursor: pointer; color: var(--accent); }
table.file-table { width: 100%; border-collapse: collapse; }
table.file-table th { text-align: left; color: var(--text-dim); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.file-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.file-table tr:hover { background: var(--bg-elevated); }
.file-name { cursor: pointer; }
.file-name.dir { color: var(--accent); font-weight: 500; }
.file-actions { display: flex; gap: 6px; justify-content: flex-end; }
.file-actions button { padding: 4px 8px; font-size: 12px; }

/* Editor modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 10px;
  width: 90%; max-width: 800px; max-height: 85vh; display: flex; flex-direction: column;
}
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.modal-body { padding: 16px 18px; overflow: auto; flex: 1; }
.modal-body textarea { width: 100%; height: 400px; font-family: Consolas, monospace; font-size: 13px; resize: vertical; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 640px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 4px; }
.form-grid input, .form-grid select { width: 100%; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

.stat-cards { display: flex; gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; min-width: 140px; }
.stat-card .label { color: var(--text-dim); font-size: 12px; }
.stat-card .value { font-size: 20px; font-weight: 600; margin-top: 4px; }
