:root {
  --bg: #eef2f4;
  --bg-elevated: #ffffff;
  --ink: #14212b;
  --muted: #5b6b78;
  --line: #d5dee5;
  --accent: #0f766e;
  --accent-soft: #d9f3ef;
  --accent-ink: #0b4f49;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --ok: #067647;
  --ok-soft: #e3f7ec;
  --warn: #b54708;
  --warn-soft: #fff4e5;
  --shadow: 0 18px 40px rgba(20, 33, 43, 0.08);
  --radius: 14px;
  --font: "Sora", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 36%),
    linear-gradient(180deg, #f7fafb 0%, var(--bg) 100%);
}

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

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  background: var(--accent);
  color: white;
  font-weight: 600;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.7rem;
}
button.danger {
  background: var(--danger);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.25);
  border-color: var(--accent);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 2rem;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}
.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
}
.login-card p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  line-height: 1.5;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px var(--accent-soft);
}
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.error-banner {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sidebar {
  background: #102029;
  color: #e8eef2;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.7rem 1.2rem;
  font-weight: 700;
}
.sidebar nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #b7c6d0;
  border-radius: 10px;
  font-weight: 500;
}
.sidebar nav button.active,
.sidebar nav button:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}
.sidebar .spacer { flex: 1; }
.sidebar .user-box {
  padding: 0.9rem 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: #9fb0bc;
  font-size: 0.85rem;
}

.main {
  padding: 1.5rem;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.topbar h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}
.topbar p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  animation: rise 0.4s ease both;
}
.stat:nth-child(2) { animation-delay: 0.05s; }
.stat:nth-child(3) { animation-delay: 0.1s; }
.stat:nth-child(4) { animation-delay: 0.15s; }
.stat .label {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.45rem;
}
.stat .value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 {
  margin: 0;
  font-size: 1rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: #f8fbfc;
}
.filters > * { max-width: 180px; }
.filters .grow { flex: 1; max-width: none; min-width: 180px; }

table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.9rem;
}
th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #f8fbfc;
}
td.mono, .mono {
  font-family: var(--mono);
  font-size: 0.82rem;
}
.muted { color: var(--muted); }
.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: #eef2f5; color: var(--muted); }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  padding: 1.1rem;
}
.project-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  background: linear-gradient(180deg, #fff, #f7fafb);
}
.project-card h4 {
  margin: 0 0 0.35rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}
.project-card .prefix {
  font-family: var(--mono);
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}
.project-card .url {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  word-break: break-all;
  margin: 0.7rem 0 1rem;
}
.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.secret-box {
  margin-top: 0.75rem;
}
.secret-value {
  display: block;
  word-break: break-all;
  background: #f3f7f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
}
.secret-row {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}
.secret-row input {
  flex: 1;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 32, 41, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 50;
  animation: fade 0.2s ease both;
}
.modal {
  width: min(520px, 100%);
  background: white;
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease both;
}
.modal h3 { margin: 0 0 1rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.raw-box {
  max-height: 280px;
  overflow: auto;
  background: #0f1a22;
  color: #d7e2ea;
  border-radius: 10px;
  padding: 0.9rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
  }
  .sidebar .brand { padding-bottom: 0.4rem; width: 100%; }
  .sidebar nav { display: flex; gap: 0.25rem; flex: 1; }
  .sidebar nav button { width: auto; }
  .sidebar .spacer { display: none; }
  .sidebar .user-box { width: 100%; border-top: 0; padding-top: 0.4rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
