:root {
  --bg: #f7f7f8;
  --bg-elevated: #ffffff;
  --bg-muted: #ececf1;
  --border: #e5e5e5;
  --border-strong: #d1d1d6;
  --text: #0d0d0d;
  --text-secondary: #6e6e80;
  --text-muted: #8e8ea0;
  --accent: #10a37f;
  --accent-hover: #0d8c6d;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 12px;
  --radius-full: 9999px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    'Segoe UI',
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Nav */
.nav-bar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-brand {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text);
  text-decoration: none;
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}

.nav-link:hover {
  background: var(--bg-muted);
  color: var(--text);
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--text);
  color: #fff;
}

.btn-primary:hover {
  background: #2d2d2d;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-muted);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
}

.btn-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--text);
}

/* Centered audit search (page middle) */
.audit-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 4rem);
  padding: 2rem 1.5rem 3rem;
  text-align: center;
}

.audit-hero-header {
  max-width: 32rem;
  margin-bottom: 2rem;
}

.audit-hero-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.audit-hero-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
}

.audit-composer-center {
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
}

/* Chat-style composer (optional fixed bottom variant) */
.composer-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem 1.5rem;
  background: linear-gradient(transparent, var(--bg) 24%);
  pointer-events: none;
}

.composer-inner {
  max-width: 42rem;
  margin: 0 auto;
  pointer-events: auto;
}

.composer-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.35rem 0.35rem 1.25rem;
  box-shadow: var(--shadow-md);
}

.composer-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.composer-input::placeholder {
  color: var(--text-muted);
}

.composer-submit {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.composer-submit:hover:not(:disabled) {
  background: #2d2d2d;
}

.composer-submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer-submit svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Loading */
.loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, #f0f0f3 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Progress */
.progress-track {
  height: 6px;
  background: var(--bg-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Score pills */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.score-pill {
  text-align: center;
  padding: 1rem 1.25rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.score-pill-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-pill-value {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.score-good {
  color: var(--accent);
}
.score-mid {
  color: var(--warning);
}
.score-bad {
  color: var(--danger);
}

/* Charts */
.chart-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-box {
  height: 220px;
  position: relative;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tr:hover td {
  background: var(--bg);
}

/* Report page filter panel (EJS shell) */
.report-page .report-filter-panel {
  margin-bottom: 1.25rem;
  background: #ffffff;
  position: sticky;
  top: 4.25rem;
  z-index: 40;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.report-filter-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.report-filter-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 36rem;
}

.report-filter-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 11rem;
}

.report-filter-select-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.report-filter-select {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.report-filter-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.filter-chip--muted {
  cursor: default;
  opacity: 0.7;
}

.filter-chip--muted:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}

/* Issue accordion */
.issue-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0;
}

.filter-chip {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover,
.filter-chip.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.issue-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  overflow: hidden;
  background: var(--bg-elevated);
}

.issue-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  cursor: pointer;
  user-select: none;
}

.issue-header:hover {
  background: var(--bg);
}

.issue-chevron {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.issue-item.open .issue-chevron {
  transform: rotate(90deg);
}

.issue-body {
  display: none;
  padding: 0 1rem 1rem 3rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.issue-item.open .issue-body {
  display: block;
}

.severity-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.severity-critical {
  background: #fef2f2;
  color: #b91c1c;
}
.severity-warning {
  background: #fffbeb;
  color: #b45309;
}
.severity-info {
  background: #eff6ff;
  color: #1d4ed8;
}

.category-badge {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

/* Layout */
.page-main {
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-main-wide {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.page-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9375rem;
}

.error-text {
  color: var(--danger);
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* Documentation page */
body.docs-page {
  background: #ffffff;
  color: #1a1a1a;
}

body.docs-page .nav-bar {
  background: #ffffff;
  border-bottom: 1px solid #e8e8e8;
}

.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 1120px;
  margin: 0 auto;
  padding: 2.25rem 1.75rem 4rem;
  align-items: start;
}

@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 1.5rem 1.25rem 3rem;
  }

  .docs-sidebar {
    position: static !important;
    top: auto !important;
  }
}

.docs-sidebar {
  position: sticky;
  top: 5.25rem;
  align-self: start;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1.25rem 1rem 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
}

.docs-sidebar-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin: 0 0 1rem;
  padding: 0 0.5rem;
}

.docs-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.docs-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: #4b5563;
  text-decoration: none;
  padding: 0.5rem 0.625rem;
  border-radius: 8px;
  line-height: 1.35;
  border-left: 3px solid transparent;
  margin-left: -3px;
}

.docs-nav a:hover {
  color: #111827;
  background: #f3f4f6;
  text-decoration: none;
}

.docs-content {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 2rem 2.25rem 2.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.docs-hero {
  margin-bottom: 0.5rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.docs-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  color: #111827;
  letter-spacing: -0.02em;
}

.docs-lead {
  color: #374151;
  font-size: 1.0625rem;
  line-height: 1.7;
  margin: 0;
  max-width: 42rem;
}

.docs-lead strong {
  color: #111827;
  font-weight: 600;
}

.docs-lead code {
  background: #f3f4f6;
  color: #0f766e;
  padding: 0.15em 0.45em;
  border-radius: 6px;
  font-size: 0.9em;
}

.docs-section {
  margin-bottom: 2.25rem;
  padding-bottom: 2.25rem;
  border-bottom: 1px solid #e5e7eb;
  scroll-margin-top: 6rem;
}

.docs-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.docs-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 1rem;
  color: #111827;
  letter-spacing: -0.02em;
}

.docs-section h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  margin: 1.5rem 0 0.625rem;
  color: #1f2937;
}

.docs-section p {
  color: #374151;
  line-height: 1.75;
  font-size: 0.9375rem;
  margin: 0 0 1rem;
}

.docs-section li {
  color: #374151;
  line-height: 1.75;
  font-size: 0.9375rem;
  margin-bottom: 0.35rem;
}

.docs-section ul,
.docs-section ol {
  margin: 0.5rem 0 1.25rem;
  padding-left: 1.35rem;
}

.docs-section a {
  color: #0d9488;
  font-weight: 500;
}

.docs-section a:hover {
  color: #0f766e;
}

.docs-section code {
  background: #f3f4f6;
  color: #0f766e;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  font-size: 0.875em;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
}

.docs-steps li {
  margin-bottom: 0.625rem;
}

.docs-steps strong {
  color: #111827;
}

.docs-code {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1.125rem 1.35rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0.875rem 0 1.25rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1f2937;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
}

.docs-note {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 0.875rem 1.125rem;
  font-size: 0.9375rem;
  color: #065f46;
  line-height: 1.65;
  margin: 1rem 0;
}

.docs-note strong {
  color: #047857;
}

.docs-table {
  font-size: 0.875rem;
  margin-top: 0.875rem;
  width: 100%;
  border-collapse: collapse;
}

.docs-page .data-table {
  background: #ffffff;
}

.docs-page .data-table th {
  background: #f9fafb;
  color: #374151;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
}

.docs-page .data-table td {
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
  padding: 0.65rem 0.75rem;
}

.docs-page .data-table tr:hover td {
  background: #f9fafb;
}

.docs-table code {
  font-size: 0.8125rem;
  background: #f3f4f6;
  color: #0f766e;
}
