/* ==========================================================================
   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: #1f8c4d;
  --success-soft: #e3f5ec;
  --warning: #b85f00;
  --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; }
.actions button, .btn-import {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  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%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.95rem;
  font-family: inherit;
}
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: auto;
  margin-right: 6px;
  accent-color: var(--primary);
}
.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-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: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--info-soft);
  color: var(--info);
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  cursor: help;
  position: relative;
  margin-left: 4px;
  user-select: none;
  vertical-align: middle;
  border: none;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
}
.tip:hover, .tip:focus {
  background: var(--info);
  color: white;
  outline: none;
}
.tip-bubble {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #1c2433;
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  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;
  pointer-events: none;
  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 {
  display: block;
}
@media (max-width: 600px) {
  .tip-bubble { width: 220px; }
}

/* ============= 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; }

/* ============= Print ============= */
@media print {
  .topbar, .sidebar, .rightbar, .actions, .bottombar, .btn-row, .btn { 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; }
  a { color: var(--text); text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: var(--text-soft); }
}

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