:root {
  color-scheme: dark;
  --bg: #15171a;
  --panel: #20252a;
  --panel-2: #272d33;
  --line: #394149;
  --text: #eef3f5;
  --muted: #9aa7af;
  --accent: #40d38b;
  --accent-2: #56a9ff;
  --danger: #ff5e73;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #07120d;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
}

button:hover {
  filter: brightness(1.08);
}

button.ghost,
button.nav,
.icon-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

button.nav {
  text-align: left;
}

button.nav.active {
  background: var(--panel-2);
  border-color: var(--accent-2);
}

button.danger {
  background: var(--danger);
  color: #1f070b;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111417;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(390px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.login-box h1,
.sidebar h1,
.panel h2,
.stat-card strong {
  margin: 0;
}

.login-box h1 {
  line-height: 1.1;
  margin-bottom: 6px;
}

.login-box form,
.settings-form,
.command-form,
.dense-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.error {
  display: none;
  margin: 0;
  color: var(--danger);
  line-height: 1.35;
}

.error:not(:empty) {
  display: block;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #101316;
}

.sidebar p {
  color: var(--muted);
  margin: 6px 0 0;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
}

.sidebar-footer span {
  color: var(--muted);
  font-size: 13px;
}

nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.content {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

#server-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.stat-grid,
.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.stat-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.stat-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  min-height: 84px;
}

.stat-card span,
dt {
  color: var(--muted);
}

.stat-card strong {
  font-size: 24px;
  overflow-wrap: anywhere;
}

.actions,
.quick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions {
  margin-bottom: 18px;
}

.quick-grid {
  margin-top: 14px;
}

.stats {
  display: grid;
  gap: 10px;
  margin: 0;
}

.stats div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.log,
.mini-log {
  overflow: auto;
  background: #0c0f11;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #d8e4e8;
  font-family: Consolas, ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.45;
  padding: 12px;
  white-space: pre-wrap;
}

.log {
  min-height: 280px;
  max-height: 52vh;
}

.mini-log {
  min-height: 88px;
  max-height: 160px;
  margin: 14px 0 0;
}

.command-form {
  grid-template-columns: 1fr auto;
  margin-bottom: 14px;
}

.dense-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.dense-form button {
  grid-column: 1 / -1;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #111417;
  color: var(--text);
  padding: 7px 10px;
}

.files-panel {
  min-height: calc(100vh - 98px);
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 16px;
}

.file-toolbar {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.file-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: auto;
  max-height: calc(100vh - 184px);
}

.file-row {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--text);
  font-weight: 500;
  text-align: left;
  overflow-wrap: anywhere;
}

.file-row:last-child {
  border-bottom: 0;
}

#editor {
  min-height: calc(100vh - 184px);
  resize: vertical;
  font-family: Consolas, ui-monospace, monospace;
  line-height: 1.45;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.user-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1100px) {
  .stat-grid,
  .grid,
  .grid.three,
  .files-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .dense-form,
  .command-form {
    grid-template-columns: 1fr;
  }

  .topbar,
  .stats div,
  .user-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  dd {
    text-align: left;
  }
}
