:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--blue); }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; background: #0f172a; color: #fff; flex-wrap: wrap;
}
.topbar a { color: #fff; text-decoration: none; }
.brand a { font-weight: 700; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav .who { color: #94a3b8; font-size: 14px; }
.nav .logout { color: #fca5a5; }

.wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 40px; }

h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }

/* Cards & forms */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin: 16px 0;
}
.card.narrow { max-width: 380px; margin: 60px auto; }

label { display: block; margin: 0 0 14px; font-weight: 600; font-size: 14px; }
label code { font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=file], textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 15px;
  font-family: inherit; background: #fff; color: var(--ink);
}
textarea { resize: vertical; }
.confirm-line input { display: inline-block; width: auto; margin-left: 8px; }

.actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-outline { background: #fff; border-color: var(--red); color: var(--red); }

/* Metrics */
.metrics { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.metric {
  flex: 1 1 160px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; text-align: center;
}
.metric .num { display: block; font-size: 34px; font-weight: 800; }
.metric .lbl { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { background: #f9fafb; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  background: #f1f5f9; color: var(--muted); }
.pill.ok { background: #d1fae5; color: var(--green); }
.pill.warn { background: #fef3c7; color: var(--amber); }
.pill.bad { background: #fee2e2; color: var(--red); }

/* Alerts */
.alert { padding: 12px 14px; border-radius: 8px; margin: 12px 0; border: 1px solid var(--line); background: #eff6ff; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.filter { margin: 16px 0; }

/* Preview */
.preview { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 16px 0; }
.preview-meta { padding: 14px 18px; border-bottom: 1px solid var(--line); background: #f9fafb; font-size: 14px; }
.preview-body { padding: 0; }
.preview-frame { width: 100%; min-height: 420px; border: 0; display: block; background: #fff; }
.inline-check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.inline-check input { width: auto; margin: 0; }

.danger-zone { margin-top: 28px; padding-top: 18px; border-top: 1px dashed var(--line); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.foot { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; color: var(--muted); font-size: 13px; }

/* Training page */
.training-body { background: #0f172a; }
.training { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.training-card { background: #fff; border-radius: 14px; max-width: 620px; padding: 32px; }
.training-card .shield { font-size: 44px; }
.training-card h1 { font-size: 22px; }
.training-card ul { padding-left: 20px; }
.training-card li { margin: 8px 0; }

@media (max-width: 600px) {
  .metric .num { font-size: 28px; }
  .table { display: block; overflow-x: auto; }
}
