@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #0a0d1a;
  --bg-soft: #10142866;
  --panel: #141a2e;
  --panel-2: #1b2140;
  --border: #2a3156;
  --text: #e7e9f5;
  --text-dim: #9096b5;
  --accent: #8ea2ff;
  --accent-soft: #8ea2ff22;
  --moon: #e8d9ff;
  --good: #5fd9a0;
  --good-soft: #5fd9a01f;
  --bad: #ff7b7b;
  --bad-soft: #ff7b7b1f;
  --radius-sm: 8px;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 85% -10%, #1c2350 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 20%, #171d3d 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

code, .mono { font-family: 'JetBrains Mono', monospace; }

h1, h2, h3, .display {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ---------- layout shell ---------- */

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

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #0d1226, #0a0d1a 70%);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
}

.brand span {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  background: linear-gradient(120deg, var(--moon), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-dim);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-links a:hover { background: var(--panel); color: var(--text); }
.nav-links a.active { background: var(--accent-soft); color: var(--accent); }

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.sidebar-footer .who { color: var(--text); font-weight: 500; }
.sidebar-footer a { color: var(--text-dim); text-decoration: none; }
.sidebar-footer a:hover { color: var(--bad); }

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
}

.topbar-mobile {
  display: none;
}

/* ---------- shared bits ---------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 26px;
}

.page-head p { color: var(--text-dim); margin: 6px 0 0; max-width: 60ch; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(120deg, var(--accent), #6f7ce0);
  border: none;
  color: #0a0d1a;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-danger { border-color: var(--bad-soft); color: var(--bad); background: var(--bad-soft); }
.btn-danger:hover { border-color: var(--bad); }

.btn-sm { padding: 7px 14px; font-size: 0.82rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

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

.app-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-dim);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.app-card:hover { transform: translateY(-2px); }
.app-card.running { border-left-color: var(--good); }
.app-card.stopped { border-left-color: var(--text-dim); }

.app-card .name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 1.05rem; }
.app-card .entry { color: var(--text-dim); font-size: 0.82rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}
.status-pill.running { color: var(--good); background: var(--good-soft); }
.status-pill.stopped { color: var(--text-dim); background: #ffffff0d; }
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.running .dot { box-shadow: 0 0 8px var(--good); }

.empty-state {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-dim);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state h3 { color: var(--text); margin-bottom: 8px; }

form.stack { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }

label {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

input[type="text"], input[type="password"], input[type="number"], input[type="file"], select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--text);
  font-size: 0.94rem;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.flash.success { background: var(--good-soft); color: var(--good); border-color: #5fd9a03a; }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: #ff7b7b3a; }

.log-box {
  background: #06070f;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #c7d0f0;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 0.8rem; }
tr:last-child td { border-bottom: none; }

.badge { font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.admin { background: #ffd98e22; color: #ffd98e; }

.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1000px 600px at 50% -10%, #1c2350 0%, transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 34px 30px;
}

.auth-card .brand { justify-content: center; margin-bottom: 22px; }
.auth-card .brand img { width: 40px; height: 40px; }
.auth-card .brand span { font-size: 1.3rem; }
.auth-card h1 { font-size: 1.15rem; text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--text-dim); font-size: 0.88rem; margin-bottom: 24px; }

/* ---------- mobile ---------- */

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static;
    height: auto;
    width: auto;
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
    display: flex;
  }
  .sidebar .nav-links, .sidebar .sidebar-footer { display: none; }
  .sidebar.open { flex-direction: column; align-items: stretch; height: auto; }
  .sidebar.open .nav-links, .sidebar.open .sidebar-footer { display: flex; }
  .topbar-mobile {
    display: flex;
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
  }
  .main { padding: 22px 16px 50px; }
  .field-row { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; }
}
