:root {
  --gold: #B29347;
  --dark: #161717;
  --teal: #00A1B7;
  --red: #911F1E;
  --bg: #f7f6f4;
  --border: #e0ddd6;
  --green: #256029;
  --yellow: #8a5a00;
}

* { box-sizing: border-box; }

body {
  font-family: 'Montserrat', -apple-system, sans-serif;
  margin: 0;
  background: var(--bg);
  color: #222;
  line-height: 1.5;
}

.site-header {
  background: var(--dark);
  color: #fff;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header.brand-only { justify-content: center; }

.site-header a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
}

.site-header span {
  color: var(--gold);
  font-weight: 700;
  font-size: 1.25rem;
}

.site-header .logout-link {
  color: #fff;
  font-weight: 400;
  font-size: 0.9rem;
  opacity: 0.8;
}

.site-header .logout-link:hover { opacity: 1; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

body.login-page main {
  max-width: 400px;
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(22, 23, 23, 0.08);
}

.login-card h1 {
  border-bottom: none;
  margin-bottom: 0.25rem;
  color: var(--gold);
}

.login-sub {
  color: #666;
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.login-card form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--dark);
}

.login-card input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.login-card button {
  margin-top: 0.5rem;
  padding: 0.65rem;
  font-size: 1rem;
}

.login-error {
  background: #f6d4d4;
  color: #7a1f1f;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

h1 {
  color: var(--dark);
  border-bottom: 3px solid var(--gold);
  padding-bottom: 0.5rem;
}

h2, h3 { color: var(--dark); }

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.client-card, .comparison-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.client-card[data-clickable] {
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.client-card[data-clickable]:hover {
  box-shadow: 0 4px 16px rgba(22, 23, 23, 0.1);
  border-color: var(--gold);
}

button, .btn-primary, .btn-small {
  background: var(--gold);
  color: var(--dark);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

button:hover, .btn-primary:hover { opacity: 0.9; }

.btn-primary { font-size: 0.95rem; padding: 0.6rem 1.25rem; }
.btn-small { padding: 0.3rem 0.6rem; font-size: 0.8rem; background: var(--red); color: #fff; }

.status-legend {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #555;
}

.legend-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.dot-done { background: var(--green); }
.dot-running { background: var(--yellow); }
.dot-failed { background: var(--red); }

table.audits-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

table.audits-table th,
table.audits-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
}

table.audits-table th {
  background: var(--dark);
  color: #fff;
}

table.audits-table tbody tr[data-href] {
  cursor: pointer;
}

table.audits-table tbody tr[data-href]:hover {
  background: #fbf8f2;
}

.actions-cell {
  white-space: nowrap;
  font-size: 0.85rem;
}

.actions-cell a { margin-right: 0.5rem; }

.status {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.status-done { background: #d7f0d0; color: var(--green); }
.status-failed { background: #f6d4d4; color: #7a1f1f; }
.status-queued, .status-crawling, .status-auditing, .status-synthesizing { background: #fdf1d6; color: var(--yellow); }

.spinner {
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid rgba(138, 90, 0, 0.3);
  border-top-color: var(--yellow);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

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

.error { color: #7a1f1f; font-weight: 600; }

/* Modal */
.modal { display: none; }
.modal.open { display: block; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 23, 23, 0.5);
  z-index: 40;
}

.modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
  z-index: 41;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  color: var(--dark);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem;
}

.modal-body {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.85rem;
  color: #444;
}

textarea {
  width: 100%;
  font-family: monospace;
  margin-bottom: 0.5rem;
}

.verdict {
  font-weight: 700;
  margin-top: 0.75rem;
}

.verdict-hybrid { color: #8a5a00; }
.verdict-take_redesign { color: #256029; }
.verdict-keep_current { color: #1f4e7a; }

/* ---- Report page ---- */

.hero-band {
  background: var(--dark);
  color: #fff;
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 1.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.grade-circle {
  flex: none;
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 50%;
  background: var(--gold);
  color: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
}

.biggest-problem {
  flex: 1 1 320px;
  font-size: 1.25rem;
  line-height: 1.4;
  margin: 0;
}

.stat-chips {
  display: flex;
  gap: 1rem;
  flex: none;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  text-align: center;
  min-width: 5.5rem;
}

.stat-chip strong {
  display: block;
  font-size: 1.4rem;
  color: var(--gold);
}

.stat-chip span {
  font-size: 0.75rem;
  color: #ddd;
}

.report-section {
  margin-bottom: 2.5rem;
}

.report-section h2 {
  border-bottom: 3px solid var(--gold);
  padding-bottom: 0.4rem;
  margin-bottom: 0.25rem;
}

.section-sub {
  color: #666;
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* Checklist */

.checklist {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.checklist-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.checklist-item input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--gold);
  flex: none;
}

.checklist-item.checked {
  background: #f5f2ea;
  opacity: 0.7;
}

.checklist-item.checked .checklist-text {
  text-decoration: line-through;
}

.checklist-text { flex: 1; }

.qw-where {
  font-size: 0.8rem;
  color: #888;
  flex: none;
}

/* Top fixes */

.top-fixes-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}

.top-fix-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-fix-text {
  margin: 0;
  font-size: 0.9rem;
  flex: 1;
}

.top-fix-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.owner-badge, .effort-chip, .priority-chip {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}

.owner-deb { background: var(--gold); color: var(--dark); }
.owner-meg { background: var(--teal); color: #fff; }
.owner-geekly { background: var(--red); color: #fff; }

.effort-chip { background: #eee; color: #444; }
.priority-chip { background: #f0f0f0; color: #444; }
.priority-P1 { background: #f6d4d4; color: #7a1f1f; }
.priority-P2 { background: #fdf1d6; color: var(--yellow); }
.priority-P3 { background: #e7f0fa; color: #1f4e7a; }

/* Site findings */

.findings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.finding-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.finding-face {
  padding: 1rem 1.25rem;
  cursor: pointer;
}

.finding-face h3 { margin: 0.4rem 0 0.3rem; font-size: 1rem; }
.finding-face p { margin: 0; font-size: 0.88rem; color: #555; }
.finding-icon { font-size: 1.4rem; }

.finding-detail {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.88rem;
  color: #444;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.finding-card.open .finding-face { background: #faf8f3; }

/* Page-by-page grid */

.pages-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.page-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  position: relative;
  padding-right: 4rem;
  transition: box-shadow 0.15s;
}

.page-card:hover { box-shadow: 0 4px 16px rgba(22, 23, 23, 0.08); }

.page-card h3 { margin: 0 0 0.4rem; font-size: 0.95rem; }

.page-card-verdict {
  font-size: 0.85rem;
  color: #555;
  margin: 0 0 0.4rem;
}

.page-card-p1 {
  font-size: 0.78rem;
  color: var(--yellow);
  font-weight: 600;
  margin: 0;
}

.page-card-score {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.ring-red { background: var(--red); }
.ring-yellow { background: var(--yellow); }
.ring-green { background: var(--green); }
.ring-unknown { background: #999; }

/* Slide-in panel */

#panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(22, 23, 23, 0.5);
  z-index: 50;
}

#panel-overlay.open { display: block; }

#page-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: min(560px, 100%);
  height: 100vh;
  background: #fff;
  z-index: 51;
  overflow-y: auto;
  padding: 2rem;
  transition: right 0.25s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

#page-panel.open { right: 0; }

.panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  color: var(--dark);
  font-size: 1.75rem;
  line-height: 1;
  padding: 0.25rem;
  z-index: 1;
}

.panel-url { font-size: 0.85rem; word-break: break-all; }
.panel-verdict { font-size: 1rem; font-weight: 600; color: var(--dark); }

.working-list li { color: var(--green); margin-bottom: 0.4rem; }

.not-working-list li {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.not-working-list .evidence {
  font-style: italic;
  color: #666;
  margin: 0.25rem 0;
}

.not-working-list .why { color: #444; font-size: 0.9rem; }

.fixes-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.fixes-table th, .fixes-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: top;
}

.report-footer {
  text-align: center;
  padding: 1.5rem 0;
  font-size: 0.85rem;
}

.report-footer a { color: #888; }

/* ---- Mobile ---- */

@media (max-width: 700px) {
  main { padding: 1.25rem 1rem; }

  .hero-band {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }

  .stat-chips { width: 100%; justify-content: center; flex-wrap: wrap; }

  .top-fixes-row {
    grid-template-columns: 1fr;
  }

  .findings-grid, .pages-grid {
    grid-template-columns: 1fr;
  }

  #page-panel { width: 100%; }

  table.audits-table { font-size: 0.85rem; }
  table.audits-table th, table.audits-table td { padding: 0.4rem 0.5rem; }
}

@media (min-width: 701px) and (max-width: 960px) {
  .findings-grid, .pages-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
