:root {
  --bg: #0b0f17;
  --panel: #121826;
  --panel-2: #182133;
  --border: #25324a;
  --text: #e6edf7;
  --muted: #8fa1bc;
  --accent: #3b82f6;
  --accent-h: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  margin-bottom: 10px;
}
.login-card h1 { margin: 0 0 6px; font-size: 1.35rem; }

/* Layout */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  flex-shrink: 0;
}
.brand-title { font-weight: 700; font-size: 1.1rem; }
.brand-sub { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; flex: 1; }
.nav-btn {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-btn:hover { background: var(--panel-2); }
.nav-btn.active { background: rgba(59, 130, 246, 0.18); border-color: rgba(59, 130, 246, 0.45); color: #bfdbfe; }
.sidebar-bottom { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.content { padding: 22px; max-width: 1280px; width: 100%; }

/* Elements */
label { display: block; margin-top: 12px; font-size: 0.86rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
}
textarea { min-height: 85px; resize: vertical; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ok { background: rgba(34, 197, 94, 0.18); border-color: rgba(34, 197, 94, 0.5); color: #86efac; }
.btn-warn { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }
.btn-danger { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.55); color: #fca5a5; }
.btn-ghost { background: transparent; }
.full { width: 100%; margin-top: 12px; }

.pill {
  font-size: 0.74rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill-ok { background: rgba(34, 197, 94, 0.16); border-color: rgba(34, 197, 94, 0.4); color: #86efac; }
.pill-warn { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.45); color: #fcd34d; }
.pill-danger { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { margin: 0 0 8px; font-size: 1rem; }
.kpi { font-size: 1.65rem; font-weight: 700; margin: 4px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.banner {
  padding: 11px 22px;
  background: rgba(239, 68, 68, 0.18);
  border-bottom: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  font-size: 0.9rem;
}
.banner.warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}
.error-msg { color: #fca5a5; font-size: 0.86rem; margin-top: 10px; }
.ok-msg { color: #86efac; font-size: 0.86rem; margin-top: 10px; }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }

.artifact-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  max-height: 260px;
  overflow: auto;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.log-pre {
  margin: 0;
  padding: 14px;
  overflow: auto;
  font-size: 0.78rem;
  color: #cbd5e1;
  background: #070a10;
  flex: 1;
}

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .nav { flex-direction: row; overflow-x: auto; }
}
