:root {
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --dark: #0f172a;
  --slate: #1e293b;
  --muted: #64748b;
  --bg: #f1f5f9;
  --white: #ffffff;
  --border: #e2e8f0;
  --green: #16a34a;
  --green-light: #dcfce7;
  --orange: #d97706;
  --orange-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --gray: #94a3b8;
  --gray-light: #f8fafc;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--dark);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Nav ── */
.nav {
  background: var(--slate);
  color: white;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: white;
  text-decoration: none;
}
.nav-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nav-username {
  font-size: 13px;
  color: #94a3b8;
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  padding: 14px 24px;
}
.breadcrumb a { color: var(--blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--gray); }

/* ── Main layout ── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; }
.btn-secondary { background: white; color: var(--slate); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-light); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #fecaca; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { padding: 7px; }

/* ── Cards ── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 20px; }
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--slate); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
}
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-gray { background: #f1f5f9; color: var(--muted); }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--dark); }
.page-header p { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ── Client grid (dashboard) ── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.client-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.client-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--blue);
}
.client-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--slate);
  margin-bottom: 4px;
}
.client-card-url {
  font-size: 13px;
  color: var(--blue);
  margin-bottom: 12px;
}
.client-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.steps-mini {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.step-dot.completed { background: var(--green); }
.step-dot.error { background: var(--red); }
.step-dot.running { background: var(--orange); }

/* ── Steps grid (client page) ── */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.step-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.step-card.locked { opacity: .65; }
.step-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.step-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.step-icon.blue { background: var(--blue-light); }
.step-icon.green { background: var(--green-light); }
.step-icon.orange { background: var(--orange-light); }
.step-icon.gray { background: #f1f5f9; }
.step-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--slate);
  line-height: 1.3;
}
.step-card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.step-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.tool-tag {
  background: var(--gray-light);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
}
.step-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.time-save {
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}

/* ── Score display ── */
.score-ring {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  border: 6px solid;
  flex-shrink: 0;
}
.score-circle.good { color: var(--green); border-color: var(--green); }
.score-circle.medium { color: var(--orange); border-color: var(--orange); }
.score-circle.bad { color: var(--red); border-color: var(--red); }
.score-circle small { font-size: 11px; font-weight: 400; color: var(--muted); margin-top: -4px; }
.score-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  flex: 1;
  min-width: 200px;
}
.score-stat {
  background: var(--gray-light);
  border-radius: 8px;
  padding: 10px 14px;
}
.score-stat-num {
  font-size: 22px;
  font-weight: 700;
}
.score-stat-label { font-size: 11px; color: var(--muted); }

/* ── Criteria list ── */
.criteria-section { margin-bottom: 20px; }
.criteria-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  user-select: none;
}
.criteria-section-header.red { background: var(--red-light); color: var(--red); }
.criteria-section-header.orange { background: var(--orange-light); color: var(--orange); }
.criteria-section-header.yellow { background: #fef9c3; color: #a16207; }
.criteria-section-header.green { background: var(--green-light); color: var(--green); }
.criteria-list { display: flex; flex-direction: column; gap: 6px; }
.criteria-item {
  background: var(--gray-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.criteria-item-name { font-size: 13px; font-weight: 600; color: var(--slate); }
.criteria-item-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }
.criteria-item-pages {
  margin: 8px 0 0 0;
  padding: 6px 10px;
  list-style: none;
  background: #f8fafc;
  border-left: 3px solid var(--border);
  border-radius: 0 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.criteria-item-pages li { font-size: 11.5px; line-height: 1.4; }
.criteria-item-pages a { color: var(--blue); text-decoration: none; font-family: monospace; word-break: break-all; }
.criteria-item-pages a:hover { text-decoration: underline; }
.criteria-item-pages .more-hint { color: var(--muted); font-style: italic; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,.15);
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate);
  margin-bottom: 5px;
}
.form-label .required { color: var(--red); margin-left: 3px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  color: var(--dark);
  background: white;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--dark) 0%, var(--slate) 100%);
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.login-logo {
  width: 56px;
  height: 56px;
  background: var(--blue);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 20px;
}
.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 4px;
}
.login-sub {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}
.login-error {
  background: var(--red-light);
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 7px;
  margin-bottom: 16px;
  display: none;
}

/* ── Alert / toast ── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-info { background: var(--blue-light); color: var(--blue); }
.alert-success { background: var(--green-light); color: var(--green); }
.alert-error { background: var(--red-light); color: var(--red); }
.alert-warning { background: var(--orange-light); color: var(--orange); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--slate); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* ── Loading spinner ── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner-dark {
  border-color: rgba(37,99,235,.2);
  border-top-color: var(--blue);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.pulsing { animation: pulse 1.5s infinite; }

/* ── Client header (client page) ── */
.client-header {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.client-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.client-header h1 { font-size: 22px; font-weight: 700; color: var(--dark); }
.client-header-url {
  font-size: 14px;
  color: var(--blue);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.client-meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.client-meta-item { font-size: 13px; }
.client-meta-item strong { color: var(--muted); font-weight: 500; display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.client-meta-item span { color: var(--dark); font-weight: 500; }

/* ── Results panel ── */
.results-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 24px;
}

/* ── Collapsible ── */
.collapsible-content { display: none; }
.collapsible-content.open { display: block; }
.chevron { transition: transform .2s; display: inline-block; }
.chevron.rotated { transform: rotate(180deg); }

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .steps-grid { grid-template-columns: 1fr; }
  .clients-grid { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .score-stats { grid-template-columns: repeat(2, 1fr); }
}
