/* FServerDashboard — тёмная тема (база) */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #4f8cff;
  --accent-hover: #3b73e0;
  --danger: #f85149;
}

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

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

code {
  background: #1c2129;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.9em;
}

/* --- Страница по центру (логин) --- */
.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Шапка --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.logo span { color: var(--accent); }

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 20px;
}

/* --- Карточки --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}

.card h2 {
  font-size: 15px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.login-card { width: 100%; max-width: 400px; }

/* --- Формы --- */
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: ui-monospace, Consolas, monospace;
}
input:focus { outline: none; border-color: var(--accent); }

button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  width: auto;
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
}
.btn-secondary:hover { background: #1c2129; }

/* --- Разное --- */
.error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  color: var(--danger);
  font-size: 13px;
}

.hint {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

.muted { color: var(--muted); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}
.container h1 { font-size: 22px; margin-bottom: 8px; }
.container > .muted { margin-bottom: 22px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* Ключ-значение */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.kv dt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.kv dd { font-size: 13px; font-family: ui-monospace, Consolas, monospace; word-break: break-all; }

/* --- Навигация --- */
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text); background: #1c2129; }
.topbar nav a.active { color: var(--text); background: #1c2129; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Индикатор WS-соединения */
.ws-status { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ws-status.online { background: #3fb950; box-shadow: 0 0 6px #3fb950; }
.ws-status.offline { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* --- Виджеты дашборда --- */
.card.wide { grid-column: 1 / -1; }
.big-value { font-size: 34px; font-weight: 700; font-family: ui-monospace, Consolas, monospace; }
.small { font-size: 12px; }
.muted.small { margin-top: 2px; }

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 4px;
}
.bar {
  background: #1c2129;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.bar > i { display: block; height: 100%; background: var(--accent); transition: width 0.5s; width: 0; }
.bar.warn > i { background: #d29922; }
.bar.crit > i { background: var(--danger); }

.cores { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.core-row { display: flex; align-items: center; gap: 8px; }
.core-name { width: 20px; font-size: 11px; color: var(--muted); text-align: right; font-family: ui-monospace, monospace; }
.core-row .bar { flex: 1; height: 6px; }

.disk-row { margin-bottom: 4px; }

.legend { display: flex; gap: 18px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.dot-cpu { background: #4f8cff; }
.dot-mem { background: #3fb950; }

canvas#chart { width: 100%; height: 120px; display: block; }

/* --- Таблица процессов --- */
.container-wide { max-width: 1400px; margin: 0 auto; padding: 20px 24px; }
.table-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.table-toolbar input {
  flex: 0 1 380px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
.table-toolbar input:focus { outline: none; border-color: var(--accent); }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th {
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
th:hover { color: var(--text); }
th.sort-asc::after { content: ' ▲'; font-size: 9px; }
th.sort-desc::after { content: ' ▼'; font-size: 9px; }
th.num, td.num { text-align: right; }
td.mono, .mono { font-family: ui-monospace, Consolas, monospace; }
td.cmd { max-width: 480px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:hover td { background: #161b22; }
td.actions { white-space: nowrap; }

.btn-xs {
  width: auto;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: #1c2129;
  border: 1px solid var(--border);
  color: var(--text);
  margin-right: 4px;
}
.btn-xs:hover { background: #262d36; }
.btn-xs.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-xs.btn-danger:hover { background: rgba(248, 81, 73, 0.12); }
.btn-xs:disabled { opacity: 0.5; }

/* --- Бейджи статусов --- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  background: #1c2129;
  border: 1px solid var(--border);
  color: var(--muted);
}
.badge.ok { color: #3fb950; border-color: #3fb950; }
.badge.bad { color: var(--danger); border-color: var(--danger); }

/* --- Список приложений --- */
.section-title { font-size: 16px; margin: 24px 0 12px; }
.apps-list { display: flex; flex-direction: column; gap: 8px; }
.app-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}
.app-row:hover { border-color: var(--accent); }
.app-name { font-weight: 600; min-width: 140px; }
.app-row .mono { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Лог-вьювер (терминал) --- */
.log-view {
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  height: 380px;
  overflow-y: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-view-small { height: 220px; }

/* --- Модалка --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
/* display:flex выше перебивает атрибут hidden — возвращаем скрытие */
.modal[hidden] { display: none !important; }
.modal-inner {
  width: min(800px, 92vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; }
.modal-foot { margin-top: 12px; text-align: right; }

/* --- Формы --- */
textarea, select {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 12px;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: ui-monospace, Consolas, monospace;
}
textarea:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="file"] { margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--text); }
label.check input { width: auto; }
label.check.inline { margin: 0; }
.form-row { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }

/* --- Шапка приложения --- */
.app-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.app-head h2 { margin: 0; }
.app-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* --- Файлы --- */
.files-layout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; }
.file-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.file-item {
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  font-family: ui-monospace, monospace;
}
.file-item:hover { background: #1c2129; }
.file-editor { display: flex; flex-direction: column; }
.file-editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#file-content {
  flex: 1;
  min-height: 330px;
  resize: vertical;
  margin-bottom: 0;
}

#stdin-form input {
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
}
#stdin-form input:focus { outline: none; border-color: var(--accent); }

/* --- Настройки --- */
.form-actions { display: flex; gap: 10px; }
.form-actions button { width: auto; padding: 9px 22px; }
.tg-status { font-size: 13px; margin-bottom: 16px; }
.ok-text { color: #3fb950; }

/* --- Справка (markdown) --- */
.docs-content { line-height: 1.65; font-size: 14px; }
.docs-content h1 { font-size: 22px; margin: 0 0 12px; }
.docs-content h2 { font-size: 17px; margin: 26px 0 10px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--text); text-transform: none; letter-spacing: 0; }
.docs-content h3 { font-size: 15px; margin: 18px 0 8px; color: var(--text); }
.docs-content table { margin: 10px 0; }
.docs-content pre {
  background: #0a0d12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  font-size: 12.5px;
}
.docs-content pre code { background: none; border: none; padding: 0; }
.docs-content a { color: var(--accent); }
.docs-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 10px 0;
  padding: 4px 14px;
  color: var(--muted);
}
.docs-content ul, .docs-content ol { padding-left: 22px; }

/* --- Мобильная адаптивность --- */
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .topbar nav a { white-space: nowrap; }
  .container, .container-wide { padding: 14px 12px; }
  .grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr !important; }
  .files-layout { grid-template-columns: 1fr !important; }
  .file-list { max-height: 220px; }
  .big-value { font-size: 26px; }
  .app-row { flex-wrap: wrap; gap: 8px; }
  .log-view { height: 280px; }
  table { font-size: 12px; }
  th, td { padding: 6px 6px; }
  td.cmd { max-width: 200px; }
  .app-actions { margin-left: 0; }
}
