/* ==========================================================================
   App impôts 2025 — feuille de style
   ========================================================================== */

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #1c2433;
  --text-soft: #5a6a85;
  --primary: #1357d3;
  --primary-soft: #e7efff;
  --primary-dark: #0e3f9c;
  --success: #16703c;
  --success-soft: #e3f5ec;
  --warning: #9d5200;
  --warning-soft: #fff2dc;
  --danger: #c8312a;
  --danger-soft: #fde7e6;
  --info: #345aab;
  --info-soft: #e7eefa;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.06), 0 1px 2px rgba(20, 30, 50, 0.04);
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Mono", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--text); margin-top: 0; }
h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* ============= Topbar ============= */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { font-size: 1.1rem; }
.badge {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.actions button, .btn-import {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 14px;
  min-height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}
.actions button:hover, .btn-import:hover { background: var(--bg); }
.actions button.danger { color: var(--danger); border-color: var(--danger-soft); }
.actions button.danger:hover { background: var(--danger-soft); }
.btn-import { display: inline-flex; align-items: center; }

/* ============= Layout ============= */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  gap: 24px;
  padding: 24px;
  max-width: 1500px;
  margin: 0 auto;
}
.sidebar, .rightbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  align-self: start;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  min-height: 60vh;
  box-shadow: var(--shadow);
}

/* ============= Sidebar ============= */
.sidebar h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-soft); margin-bottom: 12px; }
.sidebar ol { list-style: none; padding: 0; margin: 0 0 24px 0; }
.sidebar li {
  margin-bottom: 4px;
  border-radius: var(--radius);
  position: relative;
}
.sidebar li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text);
  border-radius: var(--radius);
  font-size: 0.92rem;
  text-decoration: none;
  transition: background 0.15s;
}
.sidebar li a:hover { background: var(--bg); text-decoration: none; }
.sidebar li.active a { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.sidebar li.completed a::before {
  content: "✓";
  color: var(--success);
  font-weight: bold;
  margin-right: 4px;
}
.step-num {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-soft);
}
.sidebar li.active .step-num { background: var(--primary); border-color: var(--primary); color: white; }
.sidebar li.completed .step-num { background: var(--success); border-color: var(--success); color: white; }

.progress-wrap { margin-top: 16px; }
.progress-label { font-size: 0.8rem; color: var(--text-soft); margin-bottom: 4px; }
.progress { background: var(--bg); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar { background: var(--primary); height: 100%; transition: width 0.3s; width: 0%; }
.progress-text { font-size: 0.78rem; color: var(--text-soft); margin-top: 4px; text-align: right; }

/* ============= Right sidebar (conseils) ============= */
.rightbar h3 { font-size: 0.95rem; margin-bottom: 12px; }
.conseils-box, .alertes-box { margin-bottom: 24px; }
.conseils-box ul, .alertes-box ul { list-style: none; padding: 0; margin: 0; }
.conseils-box li, .alertes-box li {
  background: var(--info-soft);
  border-left: 3px solid var(--info);
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--text);
}
.alertes-box li { background: var(--danger-soft); border-left-color: var(--danger); }
.alertes-box li.severite-moyenne { background: var(--warning-soft); border-left-color: var(--warning); }
.alertes-box li.severite-info { background: var(--info-soft); border-left-color: var(--info); }
.alertes-box .alerte-titre { font-weight: 600; display: block; margin-bottom: 3px; }

/* ============= Forms ============= */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.form-grid.full-width { grid-template-columns: 1fr; }
fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 20px 0;
  background: var(--bg);
}
fieldset legend {
  font-weight: 600;
  padding: 0 8px;
  color: var(--primary-dark);
}
label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 0.9rem; }
.field { margin-bottom: 14px; }
.field-help {
  font-size: 0.82rem;
  color: var(--text-soft);
  margin-top: 4px;
}
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px; /* 16px évite le zoom auto iOS Safari */
  font-family: inherit;
  box-sizing: border-box;
}
select { text-overflow: ellipsis; }
input[type="number"] { font-family: var(--mono); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
input[type="checkbox"], input[type="radio"] {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.radio-group { display: flex; gap: 16px; }

/* ============= Buttons ============= */
.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-secondary:hover { background: var(--primary-soft); }
.btn-row { display: flex; gap: 12px; justify-content: space-between; margin-top: 24px; }

/* ============= Tables ============= */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0;
}
table th, table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table tr:last-child td { border-bottom: none; }
table .num { text-align: right; font-family: var(--mono); }
table tfoot td { font-weight: 600; background: var(--bg); }

/* ============= Cards ============= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.kpi-label { color: var(--text-soft); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); margin: 6px 0 0 0; font-family: var(--mono); }
.kpi-sub { font-size: 0.8rem; color: var(--text-soft); }
.kpi.warning .kpi-value { color: var(--warning); }
.kpi.danger .kpi-value { color: var(--danger); }
.kpi.success .kpi-value { color: var(--success); }

/* ============= Notices ============= */
.notice {
  border-left: 4px solid var(--info);
  background: var(--info-soft);
  padding: 12px 16px;
  border-radius: 4px;
  margin: 12px 0;
}
.notice.warning { border-left-color: var(--warning); background: var(--warning-soft); }
.notice.danger { border-left-color: var(--danger); background: var(--danger-soft); }
.notice.success { border-left-color: var(--success); background: var(--success-soft); }
.notice strong { display: block; margin-bottom: 4px; }

/* ============= Steps trail ============= */
.calc-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
}
.calc-steps li {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px dashed var(--border);
  font-family: var(--mono);
  font-size: 0.9rem;
}
.calc-steps li.total {
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: var(--radius);
  border-bottom: none;
  margin-top: 8px;
}
.calc-steps .step-name { font-family: inherit; }
.calc-steps .step-value { font-weight: 600; }

/* ============= Footer ============= */
.bottombar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.footer-legal { margin-top: 4px; font-size: 0.75rem; }

/* ============= Tableau dynamique RSU/dividendes ============= */
.dyn-table {
  margin: 12px 0;
}
.dyn-row { display: grid; grid-template-columns: repeat(6, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.dyn-row input { padding: 6px 8px; font-size: 0.88rem; }
.btn-add-row, .btn-remove-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 4px 12px;
  color: var(--text-soft);
  font-size: 0.85rem;
}
.btn-add-row:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.btn-remove-row { color: var(--danger); }

/* ============= Récap cases (page 8) ============= */
.recap-cases-table .case-num {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--primary-dark);
}
.recap-cases-table .case-link {
  color: var(--primary-dark);
  text-decoration: none;
  border-bottom: 1px dashed var(--primary);
}
.recap-cases-table .case-link:hover {
  background: var(--primary-soft);
  text-decoration: none;
  padding: 0 4px;
  border-radius: 3px;
}

/* Tableau comparatif (page 08) */
.comparatif-table tr.severite-haute { background: var(--warning-soft); }
.comparatif-table tr.severite-haute td:last-child { color: var(--warning); font-weight: 600; }
.comparatif-table tr.severite-info { background: var(--bg); }
.recap-cases-table .case-libelle { font-size: 0.92rem; }
.recap-cases-table .case-formulaire {
  display: inline-block;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.formulaire-section {
  margin-bottom: 24px;
}
.formulaire-section h3 {
  background: var(--primary-soft);
  color: var(--primary-dark);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 0;
}

/* ============= Tooltips (?) ============= */
.tip {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info);
  font-size: 13px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  cursor: help;
  position: relative;
  margin-left: 6px;
  user-select: none;
  vertical-align: middle;
  border: none;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
  /* Hit zone agrandie pour mobile (recommandation Apple HIG ≥ 44px) */
  padding: 0;
  flex-shrink: 0;
}
.tip::before {
  /* Zone tactile invisible étendue à 44x44 */
  content: '';
  position: absolute;
  inset: -11px;
  border-radius: 50%;
}
.tip:hover, .tip:focus, .tip.is-open {
  background: var(--info);
  color: white;
  outline: none;
}
.tip-bubble {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  background: #1c2433;
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: normal;
  width: 280px;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  text-align: left;
  line-height: 1.45;
  white-space: normal;
}
.tip-bubble code {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.95em;
}
.tip-bubble strong { color: #ffd47a; }
.tip-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1c2433;
}
.tip:hover .tip-bubble,
.tip:focus .tip-bubble,
.tip.is-open .tip-bubble {
  display: block;
}
@media (max-width: 600px) {
  .tip-bubble {
    /* Sur mobile, la bulle prend la pleine largeur du conteneur parent */
    width: min(280px, calc(100vw - 60px));
    font-size: 0.88rem;
  }
}

/* ============= Howto (mode d'emploi déroulant) ============= */
.howto {
  background: var(--info-soft);
  border-left: 4px solid var(--info);
  border-radius: 4px;
  margin: 0 0 20px 0;
  padding: 0;
}
.howto > summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--info);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.howto > summary::-webkit-details-marker { display: none; }
.howto > summary::before {
  content: '▶';
  display: inline-block;
  font-size: 0.7em;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.howto[open] > summary::before { transform: rotate(90deg); }
.howto[open] > summary { border-bottom: 1px solid rgba(0, 0, 0, 0.06); }
.howto-body { padding: 12px 18px 14px 36px; }
.howto-body ol, .howto-body ul { margin: 0; padding-left: 18px; }
.howto-body li { margin-bottom: 6px; font-size: 0.92rem; line-height: 1.5; }
.howto-body code {
  background: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--primary-dark);
  border: 1px solid var(--border);
}
.howto-body p { margin: 0 0 8px 0; }

/* ============= Soft warnings (validation douce inline) ============= */
.field-warning {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: var(--warning-soft);
  border-left: 3px solid var(--warning);
  padding: 6px 10px;
  border-radius: 4px;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.4;
}
.field-warning::before {
  content: '⚠️';
  flex-shrink: 0;
  font-size: 0.95em;
}

/* Style placeholder uniforme + plus visible */
input::placeholder { color: #a0adc1; opacity: 1; font-style: italic; }

/* ============= Glossaire des cases ============= */
.glossaire-search {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  padding: 12px 0 16px;
  margin: 0 -28px 20px;
  padding-left: 28px;
  padding-right: 28px;
  border-bottom: 1px solid var(--border);
}
#glossaire-q {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#glossaire-q:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.glossaire-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.filter-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-soft);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  min-height: 32px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary-dark); }
.filter-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.glossaire-counter {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.glossaire-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.case-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.case-card:hover { border-color: var(--primary-soft); box-shadow: var(--shadow); }
.case-card-exact {
  border-color: var(--primary);
  border-width: 2px;
  background: var(--primary-soft);
}
.case-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}
.case-card .case-code {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 3px 10px;
  border-radius: 4px;
}
.case-card .case-formulaire {
  background: var(--bg);
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.case-card .case-libelle {
  margin: 4px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1 1 100%;
  color: var(--text);
}
.case-section { margin-top: 10px; }
.case-section h4 {
  font-size: 0.78rem;
  margin: 0 0 4px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.case-section p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
}
.case-section code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.92em;
  color: var(--primary-dark);
}
.case-section-source p { color: var(--text); }
.case-section-source { background: var(--info-soft); padding: 8px 10px; border-radius: 4px; border-left: 3px solid var(--info); margin-top: 10px; }
.case-section-exemple { background: var(--success-soft); padding: 8px 10px; border-radius: 4px; border-left: 3px solid var(--success); }
.case-section-exemple code {
  background: white;
  font-weight: 600;
}
.case-tags {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.case-tag {
  font-size: 0.72rem;
  background: var(--bg);
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.glossaire-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-soft);
}
.glossaire-empty p:first-child { font-size: 1.05rem; margin-bottom: 8px; }

/* Lien outils en sidebar (séparateur visuel) */
.sidebar-tools {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.sidebar-tools h2 {
  font-size: 0.7rem !important;
  color: var(--text-soft);
  margin-bottom: 8px !important;
}
.sidebar-tools ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-tools li { margin-bottom: 2px; }
.sidebar-tools a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  color: var(--text);
  text-decoration: none;
}
.sidebar-tools a:hover { background: var(--bg); text-decoration: none; }
.sidebar-tools li.active a { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

@media (max-width: 700px) {
  .glossaire-list { grid-template-columns: 1fr; }
  .glossaire-search { padding: 10px 0 12px; margin: 0 -14px 16px; padding-left: 14px; padding-right: 14px; }
}

/* ============= Checklist documents (page 00) ============= */
.checklist-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  position: sticky;
  top: 8px;
  z-index: 5;
  box-shadow: var(--shadow);
}
.checklist-progress .progress { height: 8px; }
.checklist-progress .progress-text { font-size: 0.95rem; text-align: left; }
.checklist-progress .progress-text strong { color: var(--primary-dark); font-size: 1.05rem; }

.documents-group { margin-bottom: 18px; }
.documents-group legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.documents-group-counter {
  font-size: 0.8rem;
  color: var(--text-soft);
  font-weight: 500;
}
.documents-group-counter.is-complete { color: var(--success); font-weight: 600; }
.documents-group-counter.is-complete::after { content: ' ✓'; }

.documents-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
}
.document-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  transition: background 0.12s, border-color 0.12s;
}
.document-item:hover { border-color: var(--primary-soft); }
.document-item.is-checked {
  background: var(--success-soft);
  border-color: var(--success);
}
.document-label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  margin: 0;
  font-weight: 500;
}
.document-check {
  width: 22px;
  height: 22px;
  margin: 2px 0 0 0;
  flex-shrink: 0;
  cursor: pointer;
}
.document-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 auto;
}
.document-title {
  color: var(--text);
  line-height: 1.4;
}
.document-item.is-checked .document-title {
  text-decoration: line-through;
  color: var(--text-soft);
}
.document-where {
  font-size: 0.82rem;
  color: var(--text-soft);
  font-weight: normal;
}
.document-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.document-link:hover { text-decoration: underline; }

/* ============= Sidebar — section préparation ============= */
.sidebar .prep-list { margin-bottom: 16px; }
.sidebar .prep-list li.active a { background: var(--success-soft); color: var(--success); font-weight: 600; }
.sidebar .prep-list li.active .step-num { background: var(--success); border-color: var(--success); color: white; }

.card-prep {
  border-left: 4px solid var(--success);
  background: linear-gradient(to right, var(--success-soft) 0%, var(--surface) 25%);
}

/* ============= Comparatif "Pré-rempli DGFiP" vs "Réel" ============= */
.compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
.compare-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.compare-cell.compare-prefill {
  background: var(--info-soft);
  border-color: var(--info);
}
.compare-cell.compare-real {
  background: var(--success-soft);
  border-color: var(--success);
}
.compare-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.compare-cell.compare-prefill .compare-label { color: var(--info); }
.compare-cell.compare-real .compare-label { color: var(--success); }
.compare-cell input[type="number"] {
  background: transparent;
  border: none;
  padding: 4px 0;
  min-height: 32px;
  font-weight: 600;
  font-size: 1rem;
  font-family: var(--mono);
}
.compare-cell input[type="number"]:focus {
  background: white;
  box-shadow: none;
  border: 1px solid var(--primary);
  padding: 4px 8px;
}
.compare-action {
  margin-top: 4px;
  display: flex;
  gap: 6px;
  font-size: 0.78rem;
  align-items: center;
}
.compare-action button {
  background: none;
  border: 1px solid var(--info);
  color: var(--info);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
}
.compare-action button:hover { background: var(--info-soft); }
.compare-diff {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  display: none;
  align-items: center;
  gap: 6px;
}
.compare-diff.is-shown { display: flex; }
.compare-diff.is-warning {
  background: var(--warning-soft);
  border-left: 3px solid var(--warning);
  color: var(--text);
}
.compare-diff.is-ok {
  background: var(--success-soft);
  border-left: 3px solid var(--success);
  color: var(--text);
}

@media (max-width: 700px) {
  .compare-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ============= Print ============= */
@media print {
  .topbar, .sidebar, .rightbar, .actions, .bottombar, .btn-row, .btn,
  .howto, .tip, .field-warning, button { display: none !important; }
  .layout { display: block; padding: 0; max-width: 100%; }
  .content { box-shadow: none; border: none; padding: 0; }
  body { background: white; font-size: 11pt; }
  h1 { font-size: 16pt; }
  .formulaire-section h3 { background: #f0f0f0; color: #000; }
  table th { background: #f0f0f0; }
  .notice { border-left-width: 2px; }
  /* Forcer l'impression des fonds colorés (mention expresse, KPIs success/danger) */
  .notice, .kpi { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Code block mention expresse */
  #mention-expresse-text { border: 1px solid #999 !important; padding: 8px !important; }
  a { color: var(--text); text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: var(--text-soft); }
  /* Eviter les coupures inopportunes */
  .formulaire-section, .kpi, .notice { page-break-inside: avoid; break-inside: avoid; }
  h2, h3 { page-break-after: avoid; break-after: avoid; }
}

/* ============= Responsive ============= */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar, .rightbar { position: static; max-height: none; }
}

@media (max-width: 700px) {
  .topbar { padding: 10px 14px; gap: 8px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 0.95rem; }
  .badge { font-size: 0.7rem; padding: 2px 8px; }
  .actions { gap: 6px; }
  .actions button, .btn-import { padding: 8px 10px; font-size: 0.82rem; }
  .layout { padding: 12px; gap: 12px; }
  .content { padding: 18px 14px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  fieldset { padding: 12px 14px; }
  fieldset legend { font-size: 0.95rem; }
  .checkbox-row { padding: 12px 14px; flex-wrap: wrap; }
  .checkbox-row label { flex: 1 1 200px; }
  .btn { padding: 12px 18px; min-height: 44px; }
  .btn-row { flex-direction: column-reverse; gap: 10px; }
  .btn-row .btn, .btn-row .btn-secondary { width: 100%; text-align: center; }
  .card-grid { grid-template-columns: 1fr; }
  table { font-size: 0.88rem; }
  table th, table td { padding: 8px 10px; }
  h1 { font-size: 1.45rem; }
  /* Sidebar : limite la hauteur sur mobile (déroulable) au lieu d'occuper plein écran */
  .sidebar { max-height: 280px; overflow-y: auto; }
  /* Tooltip plus haut pour ne pas être coupé en haut de viewport */
  .tip-bubble { font-size: 0.9rem; }
}

@media (max-width: 480px) {
  .actions { width: 100%; justify-content: stretch; }
  .actions button, .btn-import { flex: 1 1 0; min-width: 0; text-align: center; }
  .topbar { flex-wrap: wrap; }
}
