:root {
  --orange: #f26419;
  --orange-soft: #ff8a4c;
  --orange-dark: #c24e12;
  --black: #0d0d0f;
  --panel: #17171b;
  --panel-2: #1f1f25;
  --border: #2c2c34;
  --gray: #9ca3af;
  --gray-light: #d1d5db;
  --white: #f5f5f7;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 12px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(242, 100, 25, 0.12), transparent 60%), var(--black);
  color: var(--white);
  min-height: 100vh;
  line-height: 1.5;
}

.accent { color: var(--orange); }
.hidden { display: none !important; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  /* Prise en compte de l'encoche iPhone (mode plein écran PWA) */
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
  border-bottom: 1px solid var(--border);
  background: rgba(13, 13, 15, 0.7);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand-mark { font-size: 22px; }
.brand-name { letter-spacing: 0.5px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-tag { color: var(--gray); font-size: 13px; }

.lang-picker { display: inline-flex; }
#lang-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--white);
  padding: 8px 30px 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f26419' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
#lang-select:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(242,100,25,0.18); }

/* Layout */
.wrap { max-width: 920px; margin: 0 auto; padding: 40px 20px 80px; }

.hero { text-align: center; margin-bottom: 32px; }
.hero h1 { font-size: 34px; line-height: 1.2; margin-bottom: 14px; }
.hero .sub { color: var(--gray-light); max-width: 640px; margin: 0 auto; font-size: 15px; }

/* Panel / form */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
}
.scan-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.6px; }
.field input, .field select {
  background: var(--black);
  border: 1px solid var(--border);
  color: var(--white);
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 16px; /* 16px : évite le zoom auto sur iOS */
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.field input:focus, .field select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 100, 25, 0.18);
}
.field select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23f26419' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
#scan-btn {
  background: linear-gradient(180deg, var(--orange-soft), var(--orange));
  color: #1a0d05; font-weight: 700; font-size: 15px;
  border: none; border-radius: 9px; padding: 12px 22px; cursor: pointer;
  white-space: nowrap; transition: transform 0.1s, filter 0.15s; height: 46px;
}
#scan-btn:hover { filter: brightness(1.06); }
#scan-btn:active { transform: translateY(1px); }
#scan-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.disclaimer { margin-top: 16px; color: var(--gray); font-size: 12.5px; }

/* Status */
.status {
  margin-top: 24px; padding: 16px 20px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
}
.status.error { border-color: rgba(248, 113, 113, 0.5); color: var(--red); }
.spinner {
  width: 20px; height: 20px; border: 3px solid var(--border);
  border-top-color: var(--orange); border-radius: 50%;
  animation: spin 0.8s linear infinite; flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Results */
.results { margin-top: 28px; scroll-margin-top: 90px; }
.results-head {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  flex-wrap: wrap; margin-bottom: 22px;
}
.score-card { display: flex; align-items: center; gap: 20px; min-width: 0; }
.score-ring {
  width: 110px; height: 110px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--panel);
  border: 4px solid var(--orange);
  flex: 0 0 auto;
}
.score-ring span { font-size: 38px; font-weight: 800; line-height: 1; }
.score-ring small { color: var(--gray); font-size: 12px; }
.score-meta { min-width: 0; }
.score-meta .grade { font-size: 20px; font-weight: 700; }
.score-meta .target { color: var(--gray-light); font-size: 14px; margin-top: 2px; word-break: break-all; }
.score-meta .counts { margin-top: 8px; font-size: 13px; color: var(--gray); }
.score-meta .counts b { font-weight: 700; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot.fail { background: var(--red); }
.dot.warn { background: var(--amber); }
.dot.pass { background: var(--green); }

.results-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-pdf {
  background: linear-gradient(180deg, var(--orange-soft), var(--orange));
  color: #1a0d05; font-weight: 700; border: none;
  border-radius: 9px; padding: 12px 16px; cursor: pointer; font-size: 14px;
}
.btn-pdf:hover { filter: brightness(1.06); }
.btn-pdf:disabled { opacity: 0.6; cursor: progress; }
.btn-pdf-alt {
  background: transparent; color: var(--orange-soft);
  border: 1px solid var(--orange);
}
.btn-pdf-alt:hover { background: rgba(242,100,25,0.1); filter: none; }
.btn-ghost {
  background: transparent; color: var(--gray-light);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 12px 16px; cursor: pointer; font-size: 14px;
}
.btn-ghost:hover { border-color: var(--orange); color: var(--white); }

.sector-note {
  background: rgba(242, 100, 25, 0.08);
  border: 1px solid rgba(242, 100, 25, 0.25);
  border-left: 4px solid var(--orange);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 24px;
  font-size: 14px; color: var(--gray-light);
}
.sector-note b { color: var(--orange-soft); display: block; margin-bottom: 4px;
  text-transform: uppercase; font-size: 12px; letter-spacing: 0.6px; }

/* Categories & findings */
.category { margin-bottom: 26px; }
.category-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.category-title::before { content: ''; width: 4px; height: 16px; background: var(--orange); border-radius: 2px; flex: 0 0 auto; }
.cat-count { margin-left: auto; font-size: 12px; color: var(--gray); font-weight: 500; }

.finding {
  display: flex; gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 10px;
  position: relative; overflow: hidden;
}
.finding::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.finding.pass::before { background: var(--green); }
.finding.warn::before { background: var(--amber); }
.finding.fail::before { background: var(--red); }
.finding.info::before { background: var(--gray); }

.finding-body { flex: 1; min-width: 0; }
.finding-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.finding-label { font-weight: 600; font-size: 14.5px; }
.badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px;
  padding: 3px 9px; border-radius: 20px; white-space: nowrap; text-transform: uppercase;
}
.badge.pass { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.badge.warn { background: rgba(251, 191, 36, 0.15); color: var(--amber); }
.badge.fail { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.badge.info { background: rgba(156, 163, 175, 0.15); color: var(--gray); }
.finding-detail { color: var(--gray-light); font-size: 13.5px; }
.finding-reco { color: var(--orange-soft); font-size: 13px; margin-top: 5px; font-style: italic; }
.finding-evidence {
  color: var(--gray); font-size: 12px; margin-top: 5px;
  font-family: 'SFMono-Regular', Consolas, monospace; word-break: break-all;
}

.foot {
  text-align: center; color: var(--gray); font-size: 12.5px;
  padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

/* ---- Responsive : tablette ---- */
@media (max-width: 720px) {
  .scan-form { grid-template-columns: 1fr; }
  #scan-btn { width: 100%; }
  .hero h1 { font-size: 26px; }
  .topbar-tag { display: none; }
  .wrap { padding: 28px 16px 64px; }
}

/* ---- Responsive : smartphone ---- */
@media (max-width: 520px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 18px; }
  .hero { margin-bottom: 24px; }
  .hero h1 { font-size: 23px; }
  .hero .sub { font-size: 14px; }
  .panel { padding: 18px; }
  .results-head { flex-direction: column; align-items: stretch; gap: 16px; }
  .score-card { justify-content: flex-start; }
  .score-ring { width: 92px; height: 92px; border-width: 3px; }
  .score-ring span { font-size: 32px; }
  .results-actions { width: 100%; }
  .results-actions button { flex: 1 1 auto; }
  .btn-ghost { flex-basis: 100%; }
  .finding { padding: 12px 12px 12px 16px; }
}
