:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b36;
  --text: #e6e8eb;
  --muted: #9aa1ac;
  --accent: #5865f2;
  --green: #23a55a;
  --red: #ed4245;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  align-items: flex-start;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  min-height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0 20px 16px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.nav-group-title {
  padding: 6px 20px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.sidebar a {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 20px;
  font-size: 14px;
}

.sidebar a:hover { color: var(--text); background: var(--bg); }

.container {
  flex: 1;
  min-width: 0;
  max-width: 900px;
  margin: 0;
  padding: 40px;
}

body:has(> main.container:only-child) .container {
  max-width: 720px;
  margin: 40px auto;
}

@media (max-width: 800px) {
  .app-layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px;
    overflow-x: auto;
  }
  .brand { padding: 0 12px 0 0; }
  .nav-group { flex-direction: row; flex-wrap: wrap; margin-bottom: 0; }
  .nav-group-title { display: none; }
  .container { padding: 20px; }
}

h1 { font-size: 22px; margin-bottom: 20px; }

.login-box {
  max-width: 360px;
  margin: 80px auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

input[type="text"], input[type="password"], input[type="datetime-local"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d0f13;
  color: var(--text);
  font-size: 14px;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: white;
  text-decoration: none;
  margin-top: 16px;
}

.btn.blue { background: var(--accent); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.error { color: var(--red); font-size: 14px; }
.success { color: var(--green); font-size: 14px; }
.muted { color: var(--muted); font-size: 13px; }

.status-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

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

.status-card.online .status-dot { background: var(--green); }

.controls {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.controls form { margin: 0; }

.config-form { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }

.checkbox-list { display: flex; flex-direction: column; gap: 8px; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.checkbox input { width: auto; }

textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d0f13;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.stat-card h2 { font-size: 15px; margin: 0 0 10px; color: var(--muted); }

.sparkline { width: 100%; height: 100px; display: block; }

.command-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.command-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.command-list li:last-child { border-bottom: none; }

.command-list form { margin: 0; }

.btn-sm { padding: 4px 10px; font-size: 12px; margin-top: 0; }

pre#log-view {
  background: #0d0f13;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  height: 480px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.section-title { margin-top: 32px; }

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

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: var(--text);
}

.tile:hover { border-color: var(--accent); }
.tile strong { font-size: 14px; }

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.toolbar input[type="text"] { flex: 1; }

.user-card { margin-bottom: 16px; }

.delete-form { margin-top: 8px; }

:root[data-theme="light"] {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e1e4e9;
  --text: #1a1d21;
  --muted: #5b6270;
  color-scheme: light;
}

:root[data-theme="light"] input[type="text"],
:root[data-theme="light"] input[type="password"],
:root[data-theme="light"] input[type="datetime-local"],
:root[data-theme="light"] textarea,
:root[data-theme="light"] select,
:root[data-theme="light"] pre#log-view {
  background: #ffffff;
}
