/* ========== VARIABLES ========== */
:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --success-light: #d1fae5;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #6366f1;
  --info-light: #e0e7ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -2px rgba(0,0,0,0.04);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========== RESET ========== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ========== LAYOUT ========== */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}
.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,0.08);
  color: var(--sidebar-active);
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.version {
  font-size: 0.75rem;
  opacity: 0.5;
}

/* Main */
.main {
  flex: 1;
  margin-left: 240px;
  min-height: 100vh;
}
.main-header {
  padding: 32px 40px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.main-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.main-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.content {
  padding: 28px 40px;
  max-width: 1000px;
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text);
}

/* ========== FORM ========== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.form-group.full-width {
  grid-column: 1 / -1;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.input-with-icon {
  position: relative;
}
.input-with-icon svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.input-with-icon input {
  padding-left: 40px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-lg);
}
.btn-primary:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--border);
}

/* ========== LOADING ========== */
.loading-content {
  text-align: center;
  padding: 40px 20px;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loading-content h3 {
  margin-bottom: 8px;
}
.loading-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ========== ERROR ========== */
.error-content {
  text-align: center;
  padding: 30px 20px;
}
.error-content h3 {
  margin: 12px 0 8px;
  color: var(--danger);
}
.error-content p {
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ========== RESULTS ========== */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.results-header h2 {
  margin-bottom: 0;
}
.results-actions {
  display: flex;
  gap: 10px;
}

/* Score Grid */
.scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.score-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  text-align: center;
}
.score-card .score-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.2;
}
.score-card .score-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 4px;
}
.score-excellent { color: var(--success); }
.score-good { color: #2563eb; }
.score-fair { color: var(--warning); }
.score-poor { color: var(--danger); }

/* Issues */
.quick-issues h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 14px;
}
.issue-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.88rem;
}
.issue-critical {
  background: var(--danger-light);
  color: #991b1b;
}
.issue-warning {
  background: var(--warning-light);
  color: #92400e;
}
.issue-info {
  background: var(--info-light);
  color: #3730a3;
}
.issue-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.issue-critical .issue-badge {
  background: var(--danger);
  color: white;
}
.issue-warning .issue-badge {
  background: var(--warning);
  color: white;
}
.issue-info .issue-badge {
  background: var(--info);
  color: white;
}

/* ========================================= */
/* ========== REPORT STYLES ========== */
/* ========================================= */

.report-page {
  font-family: var(--font);
  background: #dce4f0;
  color: var(--text);
  max-width: 900px;
  margin: 0 auto;
  padding: 0 0 32px 0;
}

/* Report Cover */
.report-cover {
  background: linear-gradient(135deg, #0f172a 0%, #1a3a6e 45%, #2563eb 80%, #7c3aed 100%);
  color: white;
  padding: 80px 60px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.report-cover::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.15);
}
.report-cover::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.1);
}
.report-cover-content {
  position: relative;
  z-index: 1;
}
.report-cover .cover-label {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  margin-bottom: 16px;
}
.report-cover h1 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 10px;
}
.report-cover .cover-subtitle {
  font-size: 1.3rem;
  font-weight: 400;
  color: rgba(255,255,255,0.8);
  margin-bottom: 40px;
}
.cover-meta {
  display: flex;
  gap: 30px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.65);
}
.cover-meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Report Section */
.report-section {
  padding: 44px 52px;
  background: white;
  border-radius: 14px;
  margin: 14px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.04);
  page-break-inside: avoid;
}
.report-section:last-child {
  margin-bottom: 0;
}
/* Even sections: blue-slate gradient */
.report-section:nth-child(even) {
  background: linear-gradient(150deg, #f8faff 30%, #dce8ff 100%);
}
.report-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}
.report-section h2::before {
  content: '';
  display: inline-block;
  width: 4px;
  min-height: 1.5em;
  border-radius: 2px;
  background: linear-gradient(180deg, #2563eb, #7c3aed);
  flex-shrink: 0;
  align-self: stretch;
}
.report-section .section-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 26px;
  padding-left: 14px;
  border-left: 2px solid #e2e8f0;
}

/* Overall Score */
.overall-score-container {
  display: flex;
  align-items: center;
  gap: 40px;
  margin-bottom: 30px;
}
.overall-score-ring {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}
.overall-score-ring svg {
  transform: rotate(-90deg);
}
.overall-score-ring .score-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.overall-score-ring .score-number {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
}
.overall-score-ring .score-of {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.overall-score-text h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.overall-score-text p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

/* Score Bars */
.score-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.score-bar-item {
  display: flex;
  align-items: center;
  gap: 14px;
}
.score-bar-label {
  width: 120px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.score-bar-track {
  flex: 1;
  height: 10px;
  background: #f1f5f9;
  border-radius: 5px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s ease;
}
.score-bar-value {
  width: 40px;
  text-align: right;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Issue List in Report */
.report-issues {
  margin-top: 20px;
}
.report-issue {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.report-issue-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
}
.report-issue.critical { background: #fef2f2; }
.report-issue.critical .report-issue-icon { background: var(--danger); }
.report-issue.warning { background: #fffbeb; }
.report-issue.warning .report-issue-icon { background: var(--warning); }
.report-issue.info { background: #f0f0ff; }
.report-issue.info .report-issue-icon { background: var(--info); }

/* Opportunity cards */
.opportunities-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
.opportunity-card {
  background: var(--primary-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  padding: 18px;
}
.opportunity-card .opp-number {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.opportunity-card p {
  font-size: 0.88rem;
  color: #1e3a5f;
  line-height: 1.5;
}

/* Why Us Section */
.why-us-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.why-us-card {
  padding: 24px;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
  border: 1px solid #dde5f7;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.why-us-card .why-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 1.5rem;
}
.why-us-card h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.why-us-card p {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* CTA Section */
.report-cta {
  background: linear-gradient(135deg, #0f172a, #1e3a5f);
  color: white;
  text-align: center;
  padding: 60px;
  border-radius: var(--radius);
  margin: 0;
}
.report-cta h2 {
  color: white;
  font-size: 1.8rem;
  margin-bottom: 12px;
}
.report-cta p {
  color: rgba(255,255,255,0.75);
  font-size: 1rem;
  margin-bottom: 30px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.cta-contact {
  display: flex;
  justify-content: center;
  gap: 30px;
  font-size: 0.95rem;
}
.cta-contact a {
  color: #93c5fd;
  text-decoration: none;
}

/* Print Styles */
@media print {
  @page {
    size: A4;
    margin: 12mm 14mm 14mm 14mm;
  }
  @page :first {
    margin-top: 0;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body { background: white; font-size: 10pt; }
  .sidebar, .no-print, .print-bar { display: none !important; }
  .main { margin-left: 0 !important; }

  .report-page {
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: white !important;
  }

  /* ---- Cover: one full page ---- */
  .report-cover {
    min-height: 250mm;
    padding: 60px 50px;
    break-after: page;
    page-break-after: always;
    display: flex;
    align-items: center;
  }

  /* ---- Sections: plain, no card styling, fully breakable ---- */
  .report-section {
    background: none !important;
    border: none !important;
    border-top: 1px solid #cbd5e1 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 16px 0 !important;
    /* Force the browser to allow page breaks inside */
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  /* Headings stick to the content below — never orphaned at page bottom */
  .report-section h2 {
    font-size: 13pt;
    font-weight: 700;
    margin-bottom: 6px;
    break-after: avoid;
    page-break-after: avoid;
  }
  .report-section h2::before { display: none; }
  .report-section h3,
  .report-section h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Strip inline backgrounds on sub-cards so they don't trigger implicit avoid */
  .report-section [style*="background"],
  .report-section [style*="linear-gradient"],
  .insights-grid > div,
  .checklist-grid > div {
    background: none !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 4px !important;
  }

  /* Only truly small atoms get break protection */
  .report-issue {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .overall-score-container {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Grids in print */
  .checklist-grid { grid-template-columns: 1fr 1fr 1fr; }
  .insights-grid { grid-template-columns: 1fr 1fr; }
  .opportunities-grid, .why-us-grid { grid-template-columns: 1fr 1fr; }

  /* Cover keeps its gradient */
  .report-cover {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .overall-score-ring .score-number { font-size: 26pt; }
  .score-bar-label { width: 100px; }
}

/* ========== REPORT INLINE GRID CLASSES ========== */
/* These replace inline grid-template-columns so mobile can override */
.checklist-grid {
  grid-template-columns: 1fr 1fr 1fr;
}
.insights-grid {
  grid-template-columns: 1fr 1fr;
}
.design-banner {
  display: flex;
  align-items: center;
  gap: 24px;
}
.ranking-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .main-header { padding: 20px; }
  .content { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .opportunities-grid,
  .why-us-grid { grid-template-columns: 1fr; }
}

/* Report-specific mobile */
@media (max-width: 640px) {
  .report-page { padding: 0 0 20px 0; }
  .report-cover {
    padding: 44px 24px;
    min-height: auto;
  }
  .report-cover h1 { font-size: 1.7rem; }
  .report-cover .cover-subtitle { font-size: 0.95rem; }
  .cover-meta {
    flex-direction: column;
    gap: 8px;
    font-size: 0.82rem;
  }
  .report-section {
    padding: 26px 18px;
    margin: 10px 8px;
    border-radius: 10px;
  }
  .report-section h2 { font-size: 1.1rem; }
  .overall-score-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
  }
  .score-bar-label {
    width: 90px;
    font-size: 0.76rem;
  }
  .why-us-grid,
  .opportunities-grid,
  .checklist-grid,
  .insights-grid { grid-template-columns: 1fr; }
  .design-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 20px !important;
  }
  .ranking-row h4 {
    font-size: 0.88rem !important;
  }
  .ranking-row span {
    font-size: 0.9rem !important;
  }
}
