:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d24;
  --text-muted: #636b78;
  --brand: #3b5bfd;
  --brand-text: #ffffff;
  --danger-bg: #fdecec;
  --danger-text: #8a1f1f;
  --shadow: 0 1px 2px rgba(16, 20, 30, 0.06), 0 1px 8px rgba(16, 20, 30, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141a;
    --surface: #1a1d24;
    --border: #2a2e38;
    --text: #eef0f4;
    --text-muted: #9aa1ad;
    --danger-bg: #3a1f1f;
    --danger-text: #f5b8b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 8px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; color: var(--text); font-size: 1.05rem; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a:not(.btn) { color: var(--text-muted); }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { margin: 0; font-size: 1.5rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--brand); color: var(--brand-text); }
.btn-primary:hover { opacity: 0.92; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}
.empty-state .btn { margin-top: 12px; }

.card-list { display: flex; flex-direction: column; gap: 10px; }

.incident-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  color: var(--text);
  box-shadow: var(--shadow);
}
.incident-card:hover { border-color: var(--brand); text-decoration: none; }
.incident-main { flex: 1; min-width: 0; }
.incident-title { font-weight: 600; }
.incident-meta, .incident-time { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.incident-side { text-align: right; white-space: nowrap; }

.badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-critical { background: #fdecec; color: #a01414; }
.badge-high { background: #fdf1e2; color: #a05a14; }
.badge-medium { background: #fdf8de; color: #8a7414; }
.badge-low { background: #e6f0fd; color: #1450a0; }
.badge-none { background: #e9ebef; color: #5a6270; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--border);
  color: var(--text-muted);
}
.pill-ok { background: #e1f5e6; color: #157a35; }
.pill-warn { background: var(--danger-bg); color: var(--danger-text); }

.form-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 520px;
}
.form-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.form-card input, .form-card select {
  padding: 9px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.92rem;
}
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}
.alert-error { background: var(--danger-bg); color: var(--danger-text); }

.back-link { display: inline-block; margin-bottom: 16px; font-size: 0.88rem; }

.report-header { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.report-header h1 { font-size: 1.4rem; margin: 0; }

.report-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 18px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.report-meta strong { color: var(--text); }

.report-section { margin: 22px 0; }
.report-section h2 { font-size: 1rem; margin: 0 0 8px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
}

.log-excerpt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 480px;
  overflow-y: auto;
}

code {
  background: var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}
