:root {
  --bg: #0f1419;
  --bg-elev: #1a222c;
  --bg-soft: #232d3a;
  --border: #2e3a49;
  --text: #e7eef7;
  --muted: #8b9bb0;
  --accent: #3d9cf0;
  --accent-2: #2f7d4a;
  --danger: #c84b4b;
  --warn: #c9a227;
  --ok: #3cb371;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2a3d 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #152318 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 20, 25, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand a {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 0.75rem;
  flex: 1;
  flex-wrap: wrap;
}

.topbar nav a {
  color: var(--muted);
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
}

.topbar nav a:hover { background: var(--bg-soft); color: var(--text); }

.user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }

.row { display: flex; gap: 1rem; align-items: center; }
.row.between { justify-content: space-between; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; }
.cards-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}

.section { margin-top: 1.75rem; }
.section > h2 { margin-top: 0; font-size: 1.15rem; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--mono); font-size: 0.9em; }
.break { word-break: break-all; }
.big { font-size: 1.35rem; font-weight: 600; margin: 0.25rem 0; }
.error { color: #f0a0a0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.875rem; }
.btn-primary { background: #1e4f7a; border-color: #2a6aa3; }
.btn-danger { background: #5a2424; border-color: #8a3535; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.inline { display: inline; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.alert-success { background: #163022; border-color: #2f7d4a; color: #b8f0c8; }
.alert-error { background: #2a1515; border-color: #8a3535; color: #f0c0c0; }

.status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  text-transform: lowercase;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.status-running, .status-success, .status-active { color: #9eecc0; border-color: #2f7d4a; }
.status-stopped, .status-inactive, .status-not_found { color: #c0c8d4; }
.status-error, .status-not_installed { color: #f0a0a0; border-color: #8a3535; }
.status-deploying, .status-pending { color: #f0e0a0; border-color: #8a7030; }

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: #3d3210;
  color: #f0e0a0;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  background: var(--bg-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.table tr:last-child td { border-bottom: none; }

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.4rem 0.75rem;
  margin: 0;
}
.kv dt { color: var(--muted); font-size: 0.875rem; }
.kv dd { margin: 0; }

.logbox {
  background: #0a0e12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  overflow: auto;
  max-height: 420px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c5d0dc;
}

.stack { display: flex; flex-direction: column; gap: 0.85rem; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="file"],
textarea {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0d1218;
  color: var(--text);
}

input[type="file"] {
  padding: 0.45rem;
}

.source-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem 1rem;
  margin: 0;
}
.source-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.source-options {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
input:focus, textarea:focus {
  outline: 2px solid #2a6aa3;
  outline-offset: 1px;
}

.hint { font-size: 0.8rem; color: var(--muted); }
.check-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.65rem;
}
.check-row input[type="checkbox"] {
  margin-top: 0.3rem;
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
.check-row .hint { display: block; margin-top: 0.2rem; }
.input-suffix {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.input-suffix input { flex: 1; }
.input-suffix span { color: var(--muted); white-space: nowrap; }

.login-wrap {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}
.login-card {
  width: min(400px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.4rem; }

.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: 0.4rem; }

@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 0.35rem; }
  .table { display: block; overflow-x: auto; }
}
