/* LinkDepth - App styles */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-hover: #f0f2f5;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-soft: #9ca3af;
  --anthracite: #111827;
  --primary: #1f2937;
  --primary-hover: #111827;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 240px;
  --topbar-h: 54px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
code, .mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; }
a { color: var(--primary); text-decoration: none; }

/* Topbar */
.topbar { background: var(--bg); border-bottom: 1px solid var(--border); height: var(--topbar-h); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 0 24px; height: 100%; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--anthracite); font-size: 15px; }
.brand svg { color: var(--anthracite); }
.topbar-nav { display: flex; gap: 24px; }
.topbar-nav a { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.topbar-nav a:hover { color: var(--anthracite); }

#app { max-width: 1400px; margin: 0 auto; padding: 24px; min-height: calc(100vh - var(--topbar-h)); }

/* Panels */
.panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.screen-title { font-size: 20px; font-weight: 700; color: var(--anthracite); margin-bottom: 4px; }
.screen-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab { background: transparent; border: none; padding: 10px 16px; font-size: 13px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit; font-weight: 500; transition: color .15s, border-color .15s; }
.tab:hover { color: var(--anthracite); }
.tab.active { color: var(--anthracite); border-bottom-color: var(--anthracite); font-weight: 600; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text); }
.field input, .field textarea, .field select {
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--anthracite); box-shadow: 0 0 0 3px rgba(17,24,39,0.08);
}
.field textarea { resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.field .hint { color: var(--text-muted); font-size: 12px; }
.field.small { max-width: 160px; }

.file-input { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.file-input input[type=file] { display: none; }
.file-input label { display: inline-flex; align-items: center; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; }
.file-input label:hover { background: var(--bg-hover); }
.file-input span { color: var(--text-muted); font-size: 12px; }

.checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--anthracite); }

.advanced { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.advanced summary { cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text); user-select: none; }
.advanced-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-top: 16px; align-items: end; }

.actions { display: flex; gap: 12px; margin-top: 8px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--anthracite); color: #fff; border-color: var(--anthracite); }
.btn-primary:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.error-box { background: var(--danger-bg); color: var(--danger); padding: 12px 16px; border-radius: var(--radius); font-size: 13px; border: 1px solid rgba(220,38,38,0.15); }

/* Crawl screen */
.crawl-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 20px; }
.crawl-actions { display: flex; gap: 8px; }
.progress-bar { height: 8px; background: var(--bg-hover); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: var(--anthracite); border-radius: 999px; width: 0%; transition: width .4s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }
.crawl-log { max-height: 260px; overflow-y: auto; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-family: 'JetBrains Mono', monospace; font-size: 11px; line-height: 1.6; color: var(--text-muted); }
.crawl-log div { padding: 2px 0; }

/* Results layout with sidebar */
[data-screen="results"] { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 20px; align-items: start; }
.sidebar { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); position: sticky; top: calc(var(--topbar-h) + 24px); padding: 20px 0; box-shadow: var(--shadow-sm); }
.sidebar-brand { padding: 0 20px 16px; margin-bottom: 12px; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--anthracite); font-size: 13px; word-break: break-all; }
.sidebar-nav { display: flex; flex-direction: column; padding: 0 8px; }
.sidebar-nav a { padding: 9px 12px; color: var(--text); font-size: 13px; border-radius: var(--radius); font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.sidebar-nav a:hover { background: var(--bg-hover); }
.sidebar-nav a.active { background: var(--anthracite); color: #fff; }
.sidebar-nav .badge { background: rgba(255,255,255,0.2); font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.sidebar-nav a:not(.active) .badge { background: var(--warning); color: #fff; }
.sidebar-nav a:not(.active) .badge:empty { display: none; }
.sidebar-footer { padding: 16px 12px 0; margin-top: 12px; border-top: 1px solid var(--border); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--anthracite); line-height: 1.1; }
.kpi-value.success { color: var(--success); }
.kpi-value.warning { color: var(--warning); }
.kpi-value.danger { color: var(--danger); }
.kpi-sub { font-size: 11px; color: var(--text-soft); margin-top: 4px; }

/* Sections in dashboard */
.dash-section { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.dash-title { font-size: 15px; font-weight: 600; color: var(--anthracite); margin-bottom: 16px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .dash-grid-2 { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { background: var(--bg-soft); font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; position: sticky; top: 0; cursor: pointer; user-select: none; }
table.data th:hover { color: var(--anthracite); }
table.data th.sorted { color: var(--anthracite); }
table.data tbody tr:hover { background: var(--bg-soft); cursor: pointer; }
table.data td.url { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.center { text-align: center; }

.status-pill { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.status-2xx { background: var(--success-bg); color: var(--success); }
.status-3xx { background: var(--info-bg); color: var(--info); }
.status-4xx { background: var(--warning-bg); color: var(--warning); }
.status-5xx { background: var(--danger-bg); color: var(--danger); }
.status-0 { background: var(--bg-hover); color: var(--text-muted); }

.pill { display: inline-flex; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-warn { background: var(--warning-bg); color: var(--warning); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-muted { background: var(--bg-hover); color: var(--text-muted); }

/* Filters bar */
.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; align-items: center; }
.filters input[type="search"] { flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-family: inherit; font-size: 13px; }
.filters select { padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-family: inherit; font-size: 13px; background: var(--bg); }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; font-size: 13px; color: var(--text-muted); }
.pagination .pages { display: flex; gap: 4px; }
.pagination button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); font-size: 12px; cursor: pointer; font-family: inherit; }
.pagination button.active { background: var(--anthracite); color: #fff; border-color: var(--anthracite); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Depth histogram */
.hist { display: flex; align-items: flex-end; gap: 8px; height: 260px; padding: 20px 0; }
.hist-bar { flex: 1; background: var(--anthracite); border-radius: 4px 4px 0 0; position: relative; min-height: 4px; transition: opacity .15s; }
.hist-bar:hover { opacity: 0.8; }
.hist-bar-label { position: absolute; top: -22px; left: 0; right: 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--anthracite); }
.hist-bar-x { position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text-muted); }

/* Recos */
.reco-list { display: flex; flex-direction: column; gap: 8px; }
.reco { background: var(--bg); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius); padding: 14px 16px; }
.reco.critical { border-left-color: var(--danger); }
.reco.important { border-left-color: var(--warning); }
.reco.recommended { border-left-color: var(--info); }
.reco.info { border-left-color: var(--text-soft); }
.reco-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; gap: 12px; }
.reco-level { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.reco.critical .reco-level { color: var(--danger); }
.reco.important .reco-level { color: var(--warning); }
.reco.recommended .reco-level { color: var(--info); }
.reco.info .reco-level { color: var(--text-muted); }
.reco-url { font-size: 12px; color: var(--text-muted); word-break: break-all; }
.reco-msg { font-size: 13px; margin-top: 4px; }

/* Graph */
#graph-svg { width: 100%; height: 600px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius); display: block; }
.graph-node { cursor: pointer; }
.graph-link { stroke: var(--border-strong); stroke-opacity: 0.5; }

/* Export cards */
.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.export-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.export-card:hover { border-color: var(--anthracite); transform: translateY(-2px); }
.export-card strong { display: block; font-weight: 600; color: var(--anthracite); margin-bottom: 4px; }
.export-card span { font-size: 12px; color: var(--text-muted); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-panel { position: relative; background: var(--bg); border-radius: var(--radius-lg); max-width: 900px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 32px; box-shadow: var(--shadow-lg); }
.modal-close { position: absolute; top: 12px; right: 12px; background: transparent; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; padding: 4px 10px; border-radius: 6px; }
.modal-close:hover { background: var(--bg-hover); }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.loading::before { content: ""; display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--anthracite); border-radius: 50%; margin-right: 10px; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* History */
.history-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.history-item:last-child { border-bottom: none; }
.history-item-info { display: flex; flex-direction: column; gap: 2px; }
.history-item-info strong { font-size: 14px; color: var(--anthracite); }
.history-item-info span { font-size: 12px; color: var(--text-muted); }
.history-item-actions { display: flex; gap: 6px; }

/* Responsive */
@media (max-width: 900px) {
  [data-screen="results"] { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; }
  #app { padding: 16px; }
  .panel { padding: 20px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .topbar-nav { display: none; }
}


/* ===== Fiabilite de l'audit (bandeau dashboard + vue dediee) ===== */
.reliab-banner {
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0 0 20px 0;
  border: 1px solid var(--border);
  background: var(--bg);
}
.reliab-banner.warn {
  border-color: #f59e0b;
  background: var(--warning-bg);
}
.reliab-banner.ok {
  border-color: var(--border);
  background: var(--info-bg);
}
.reliab-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}
.reliab-banner.warn .reliab-head { color: #92400e; }
.reliab-banner.ok .reliab-head { color: #075985; }
.reliab-icon { font-size: 18px; line-height: 1; }
.reliab-text {
  font-size: 13px;
  color: var(--text);
  margin: 0;
  line-height: 1.55;
}
.reliab-stats {
  list-style: none;
  margin: 10px 0 0 0;
  padding: 0;
  font-size: 13px;
}
.reliab-stats li {
  padding: 4px 0;
  color: var(--text);
}
.reliab-stats li::before {
  content: "\2022  ";
  color: var(--warning);
  font-weight: bold;
  margin-right: 4px;
}
.reliab-cta {
  margin-top: 10px;
  font-size: 13px;
}
.reliab-cta a {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 500;
}
.reliab-cta a:hover { color: var(--primary-hover); }

/* Document pedagogique dans la vue Fiabilite */
.reliab-doc {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin: 16px 0 24px 0;
  max-width: 900px;
}
.reliab-doc h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--anthracite);
  margin: 20px 0 8px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.reliab-doc h2:first-child { margin-top: 0; }
.reliab-doc p {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 12px 0;
}
.reliab-doc ul {
  margin: 8px 0 16px 0;
  padding-left: 20px;
}
.reliab-doc li {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 8px;
}
.reliab-doc code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  color: var(--anthracite);
  border: 1px solid var(--border);
}
.reliab-doc strong { color: var(--anthracite); }