:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1f2937;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --primary: #2f81f7;
  --primary-strong: #1f6feb;
  --success: #238636;
  --danger: #da3633;
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

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

.auth-panel {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
}

.auth-panel h1,
.topbar h1,
.section-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.auth-panel p,
.topbar p,
.section-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px;
  background: #101620;
}

.nav-btn {
  width: 100%;
  display: block;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.content {
  padding: 24px;
  overflow: auto;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

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

.panel,
.table-wrap,
.build-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

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

input {
  width: 100%;
  min-height: 40px;
  color: var(--text);
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

input:focus {
  outline: 2px solid rgba(47, 129, 247, 0.35);
  border-color: var(--primary);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary-strong);
}

.btn.secondary {
  background: var(--success);
  border-color: var(--success);
}

.btn.ghost {
  background: transparent;
}

.btn.compact {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 14px;
}

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

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

.empty-cell,
.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

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

.selection-row {
  grid-template-columns: 20px 1fr;
  align-items: center;
  color: var(--text);
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.selection-row input {
  min-height: auto;
}

.selection-row small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.build-list {
  display: grid;
  gap: 12px;
}

.build-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.build-item h3,
.build-item p {
  margin: 0 0 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--success);
  color: white;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.toast.error {
  background: var(--danger);
}

/* ===== Fleet Overview (Server Details) ===== */
.fleet-detail {
  font-size: 13px;
  line-height: 1.7;
}

.fleet-detail .muted,
.muted {
  color: var(--muted);
}

.bar-bg {
  background: var(--bg);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  max-width: 120px;
}

.bar-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.bar-fill.bar-disk {
  background: var(--success);
}

/* ===== Info / Highlight panels ===== */
.info-panel {
  background: var(--surface-2);
  border-left: 4px solid var(--primary);
}

.info-panel ol {
  line-height: 2;
  padding-left: 20px;
}

.info-panel code {
  background: #0b1220;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.highlight-panel {
  background: var(--surface-2);
  border: 2px solid var(--primary);
  text-align: center;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
  width: 100%;
}

.pill-success {
  background: var(--success);
  color: white;
}

.pill-error {
  background: var(--danger);
  color: white;
}

/* ===== Logs ===== */
.log-container {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log-entry {
  display: flex;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--muted);
  flex-shrink: 0;
  min-width: 85px;
}

.log-level {
  flex-shrink: 0;
  min-width: 55px;
  font-weight: 600;
}

.log-level.LOG,
.log-level.INFO {
  color: var(--primary);
}

.log-level.SUCCESS {
  color: var(--success);
}

.log-level.ERROR {
  color: var(--danger);
}

.log-level.WARN {
  color: #d29922;
}

.log-message {
  color: var(--text);
  word-break: break-word;
}

/* ===== Console SSH ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.stat-card h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card p {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

select.input {
  width: 100%;
  min-height: 40px;
  color: var(--text);
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

.help-panel summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}

.help-panel ol {
  padding-left: 20px;
  line-height: 1.8;
}

.help-panel code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

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

.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  gap: 12px;
}

.command-item .cmd-info h4 {
  margin: 0 0 4px;
}

.command-item .cmd-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.command-item .cmd-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

pre#command-result {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

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

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-btn {
    width: auto;
    white-space: nowrap;
  }

  .content,
  .topbar,
  .auth-panel {
    padding: 18px;
  }

  .form-grid.two,
  .section-header {
    grid-template-columns: 1fr;
  }

  .section-header,
  .build-item {
    flex-direction: column;
    align-items: stretch;
  }
}
