/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg: #FAFAF8;
  --bg-card: #FFFFFF;
  --bg-secondary: #F4F3F0;
  --accent: #5C7A5C;
  --accent-light: #EEF3EE;
  --accent-amber: #B7860B;
  --accent-amber-light: #FFFBEB;
  --accent-red: #C0392B;
  --accent-red-light: #FEF2F2;
  --text-primary: #1A1A1A;
  --text-secondary: #5A5A5A;
  --text-tertiary: #9B9B9B;
  --border: #E5E4E1;
  --border-focus: #5C7A5C;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}
button { cursor: pointer; font-family: inherit; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.header-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
}

.header-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   PANEL VISIBILITY
   ============================================================ */
.panel { display: none; }
.panel.active { display: flex; flex-direction: column; }

/* ============================================================
   INPUT PANEL
   ============================================================ */
.input-panel {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.input-card {
  width: 100%;
  max-width: 780px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.input-card h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.input-card p {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 28px;
}

/* URL input row */
.url-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.url-input {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.url-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(92,122,92,0.12);
}
.url-input::placeholder { color: var(--text-tertiary); }

.btn-analyze {
  height: 48px;
  padding: 0 24px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn-analyze:hover { background: #4a6349; }
.btn-analyze:active { transform: scale(0.97); }
.btn-analyze:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Service checkboxes */
.services-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.service-check {
  position: relative;
}
.service-check input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.service-check-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
  text-align: center;
  position: relative;
}
.service-check-body:hover { border-color: var(--accent); background: var(--accent-light); }
.service-check input:checked + .service-check-body {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 1px var(--accent);
}

.service-icon { font-size: 22px; }
.service-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.service-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Checkmark indicator at bottom of card */
.service-checkmark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: transparent;
  flex-shrink: 0;
}
.service-checkmark::after {
  content: "";
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid transparent;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: border-color var(--transition);
}
.service-check input:checked + .service-check-body .service-checkmark {
  background: var(--accent);
  border-color: var(--accent);
}
.service-check input:checked + .service-check-body .service-checkmark::after {
  border-color: #fff;
}

/* Example URL chips */
.example-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.url-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.url-chip:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

/* Error message */
.error-msg {
  display: none;
  background: var(--accent-red-light);
  color: var(--accent-red);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-top: 16px;
}
.error-msg.visible { display: block; }

/* ============================================================
   LOADING PANEL
   ============================================================ */
.loading-panel {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.loading-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 24px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.loading-url {
  font-size: 13px;
  color: var(--text-tertiary);
  word-break: break-all;
  margin-bottom: 28px;
}

.loading-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.loading-step {
  font-size: 13px;
  color: var(--text-tertiary);
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition);
}
.loading-step .step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background var(--transition);
}
.loading-step.active { color: var(--accent); font-weight: 500; }
.loading-step.active .step-dot { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.loading-step.done { color: var(--text-primary); }
.loading-step.done .step-dot { background: var(--accent); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   REPORT PANEL
   ============================================================ */
.report-panel {
  flex: 1;
  padding: 32px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.report-meta h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.report-url {
  font-size: 13px;
  color: var(--text-tertiary);
  word-break: break-all;
}

.report-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.report-stat {
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.report-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  align-items: flex-start;
}

.btn-new {
  height: 38px;
  padding: 0 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.btn-new:hover { background: var(--bg-card); color: var(--text-primary); }

.btn-pdf {
  height: 38px;
  padding: 0 18px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  transition: background var(--transition);
}
.btn-pdf:hover { background: #4a6349; }

/* Score cards row */
.score-row {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.score-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 200px;
  box-shadow: var(--shadow-sm);
}

.gauge-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.gauge-svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

.gauge-fill {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 1s ease-out;
}

.gauge-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.gauge-score {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  display: block;
}

.gauge-grade {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  display: block;
}

.score-info {
  flex: 1;
}

.score-service-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.score-service-full {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.score-bar-wrap {
  height: 5px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.score-bar {
  height: 100%;
  border-radius: 10px;
  transition: width 1s ease-out;
}

/* Tabs */
.report-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}

.tab-btn {
  padding: 10px 22px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Tab panels */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Summary */
.result-summary {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

/* Quick wins */
.quick-wins-card {
  background: var(--accent-light);
  border: 1px solid rgba(92,122,92,0.2);
  border-radius: var(--radius-sm);
  padding: 20px 24px;
  margin-bottom: 28px;
}

.quick-wins-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.quick-wins-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-wins-list li {
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.quick-win-num {
  width: 20px;
  height: 20px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Strengths */
.strengths-section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.strengths-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.strengths-list li {
  font-size: 14px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.strength-check {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

/* Issues table */
.issues-section { margin-bottom: 32px; }

.issues-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.issues-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.issues-table th {
  background: var(--bg-secondary);
  padding: 11px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.issues-table td {
  padding: 13px 16px;
  border-top: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}

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

.priority-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.priority-badge.high { background: var(--accent-red-light); color: #991B1B; }
.priority-badge.medium { background: var(--accent-amber-light); color: #92400E; }
.priority-badge.low { background: var(--accent-light); color: var(--accent); }

.issue-category {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.issue-text { color: var(--text-primary); }
.issue-rec { color: var(--text-secondary); }
.issue-impact { color: var(--text-tertiary); font-size: 13px; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* PDF export: section divider titles, hidden in normal view */
.pdf-only { display: none; }
.tab-panel-title {
  font-size: 16px;
  font-weight: 700;
  margin: 32px 0 12px;
  padding-top: 20px;
  border-top: 2px solid var(--border);
  color: var(--text-primary);
}

/* ============================================================
   APP BODY LAYOUT
   ============================================================ */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ============================================================
   HEADER UPDATES
   ============================================================ */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.sidebar-toggle.visible { display: flex; }

.btn-logout {
  height: 32px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: none;
  transition: all var(--transition);
}
.btn-logout:hover {
  background: var(--accent-red-light);
  border-color: #FECACA;
  color: var(--accent-red);
}
.btn-logout.visible { display: block; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--bg-card);
  border-right: 1px solid transparent;
  transition: width 240ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color 240ms ease;
  display: flex;
  flex-direction: column;
}
.sidebar.open {
  width: 270px;
  border-right-color: var(--border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-clear {
  background: none;
  border: none;
  font-size: 11.5px;
  color: var(--text-tertiary);
  padding: 2px 4px;
  border-radius: 4px;
  transition: color var(--transition);
}
.sidebar-clear:hover { color: var(--accent-red); }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.7;
}

.sidebar-empty-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}

.sidebar-run {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 3px;
  border: 1px solid transparent;
}
.sidebar-run:hover { background: var(--bg-secondary); }
.sidebar-run.active {
  background: var(--accent-light);
  border-color: rgba(92,122,92,0.2);
}

.sidebar-run-url {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.sidebar-run-date {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 7px;
}

.sidebar-run-scores {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.sidebar-score {
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.sidebar-score.good { background: var(--accent-light); color: var(--accent); }
.sidebar-score.warn { background: var(--accent-amber-light); color: #92400E; }
.sidebar-score.bad  { background: var(--accent-red-light); color: #991B1B; }

/* ============================================================
   LOGIN PANEL
   ============================================================ */
.login-panel {
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.login-brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.login-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-input {
  height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(92,122,92,0.12);
}
.field-input::placeholder { color: var(--text-tertiary); }

.login-error {
  display: none;
  background: var(--accent-red-light);
  color: var(--accent-red);
  border: 1px solid #FECACA;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
}
.login-error.visible { display: block; }

.btn-signin {
  height: 44px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: background var(--transition), transform var(--transition);
  margin-top: 4px;
}
.btn-signin:hover { background: #4a6349; }
.btn-signin:active { transform: scale(0.98); }
.btn-signin:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
