:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #1a2433;
  --muted: #6b7a90;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --critical: #b91c1c;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 17px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -.5px;
}
.topnav { display: flex; gap: 4px; }
.topnav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.topnav a:hover { background: var(--primary-soft); color: var(--primary); }
.topnav a.active { color: var(--primary); background: var(--primary-soft); }

/* Page head */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 32px 0 24px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.page-head p { margin-top: 4px; font-size: 14px; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}
.card h2 { font-size: 18px; margin-bottom: 8px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.empty-state h2 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbfc; }
.link { color: var(--primary); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #f0f4f9; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
}
.badge-pending { background: #f3f4f6; color: #6b7280; }
.badge-running { background: #fef3c7; color: #92400e; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-low { background: #e0e7ff; color: #3730a3; }

/* Score */
.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
}
.score-good { color: var(--success); background: #dcfce7; }
.score-mid { color: var(--warning); background: #fef3c7; }
.score-bad { color: var(--error); background: #fee2e2; }

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat-unit { font-size: 14px; color: var(--muted); font-weight: 500; }

/* Severity chips */
.sev-row { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }
.sev-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.sev-critical { background: #fee2e2; color: var(--critical); }
.sev-high { background: #ffedd5; color: #9a3412; }
.sev-medium { background: #fef9c3; color: #854d0e; }
.sev-low { background: #e0e7ff; color: #3730a3; }

/* Tree */
.tree {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
}

/* Forms */
.form-card { max-width: 560px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.form input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form small { font-weight: 400; color: var(--muted); font-size: 12px; }
.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-ok { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }

/* Check list */
.check-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.check-list li { padding-left: 24px; position: relative; font-size: 14px; color: var(--muted); }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--success); font-weight: 700; }

.info-card { max-width: 560px; margin-top: 24px; }

/* Progress */
.progress-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  width: 30%;
  animation: indeterminate 1.4s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes indeterminate {
  0% { width: 10%; margin-left: 0; }
  50% { width: 50%; margin-left: 25%; }
  100% { width: 10%; margin-left: 90%; }
}
.progress-log { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* Install */
body.install {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff4ff 0%, #f5f7fa 100%);
  padding: 24px;
}
.install-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  max-width: 480px;
  width: 100%;
}
.install-head { text-align: center; margin-bottom: 28px; }
.install-head .logo-mark { width: 48px; height: 48px; font-size: 18px; margin: 0 auto 14px; border-radius: 12px; }
.install-head h1 { font-size: 24px; font-weight: 700; letter-spacing: -.5px; }
.install-head p { margin-top: 6px; font-size: 13px; }
.install-foot { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); text-align: center; font-size: 12px; }
.done ol { margin: 16px 0 24px 20px; }
.done li { margin-bottom: 8px; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 13px; }

@media (max-width: 640px) {
  .form-row { flex-direction: column; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px; }
}
