/**
 * App Finance - AIR-ELEC V2
 * Tableau de bord financier — Palette monochrome vert
 */

/* ─── Layout ─── */
.finance-app {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
  font-family: var(--font-sans);
  position: relative;
}

.finance-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.finance-scroll::-webkit-scrollbar { width: 6px; }
.finance-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

/* ─── Header row (Chantiers style) ─── */
.finance-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 8px;
  background: white;
  flex-shrink: 0;
}
.finance-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
}
.finance-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Tab bar (filterbar style) ─── */
.finance-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 20px 12px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  overflow-x: auto;
}
.finance-tabs::-webkit-scrollbar { height: 0; }
.finance-tab {
  padding: 8px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  font-family: var(--font-sans);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -0.5px;
}
.finance-tab:hover { color: var(--gray-700); }
.finance-tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
  font-weight: 600;
}
.finance-tab-icon { width: 14px; height: 14px; }

/* ─── Tab panels ─── */
.finance-panel { display: none; }
.finance-panel.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ─── KPI cards row — migrated to unified kpi.css ─── */
/* Keep: empty block for backward compat if needed */

/* ─── Card sections ─── */
.finance-card {
  background: white;
  border-radius: 12px;
  border: 0.5px solid var(--gray-200);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.finance-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.finance-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 6px;
}
.finance-card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--green-pale);
  color: var(--green);
}

/* ─── Monthly bar chart ─── */
.finance-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 130px;
  padding: 8px 0 0;
}
.finance-chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.finance-chart-bar {
  width: 100%;
  max-width: 36px;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s var(--ease-ios);
  position: relative;
  cursor: pointer;
}
.finance-chart-bar:hover { opacity: 0.8; }
.finance-chart-bar--realise { background: var(--green); }
.finance-chart-bar--previsionnel { background: #b8d9a0; }
.finance-chart-bar--current { background: linear-gradient(180deg, var(--green-light) 0%, var(--green) 100%); }
.finance-chart-value {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-400);
  font-family: var(--font-mono);
}
.finance-chart-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
}
.finance-chart-legend {
  display: flex;
  gap: 16px;
  padding-top: 10px;
  border-top: 0.5px solid var(--gray-100);
  margin-top: 8px;
}
.finance-chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--gray-600);
}
.finance-chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 4px;
}
.finance-chart-legend-dot--main { background: var(--green); }
.finance-chart-legend-dot--light { background: #b8d9a0; }

/* ─── Transaction list ─── */
.finance-tx-list { }
.finance-tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--gray-100);
  cursor: pointer;
  transition: all 0.15s;
}
.finance-tx-item:last-child { border-bottom: none; }
.finance-tx-item:hover { opacity: 0.7; }
.finance-tx-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}
.finance-tx-icon--main { background: var(--green); }
.finance-tx-icon--dark { background: #3d7a22; }
.finance-tx-icon--light { background: var(--green-light); }
.finance-tx-icon--mid { background: var(--green-mid); }
.finance-tx-info { flex: 1; min-width: 0; }
.finance-tx-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.finance-tx-sub {
  font-size: 11px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.finance-tx-amount {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
.finance-tx-amount--positive { color: var(--green); }
.finance-tx-amount--negative { color: #3d7a22; }

/* ─── Year progress ─── */
.finance-progress-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.finance-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.finance-progress-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  min-width: 70px;
}
.finance-progress-track {
  flex: 1;
  height: 8px;
  background: #e8f0e3;
  border-radius: 4px;
  overflow: hidden;
}
.finance-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s var(--ease-ios);
}
.finance-progress-fill--main { background: var(--green); }
.finance-progress-fill--light { background: var(--green-light); }
.finance-progress-fill--mid { background: var(--green-mid); }
.finance-progress-fill--dark { background: #3d7a22; }
.finance-progress-value {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--gray-700);
  min-width: 70px;
  text-align: right;
}

/* ─── TVA / URSSAF detail grids — migrated to unified kpi.css ─── */
/* Replaced by .kpi-grid--3 / .kpi-card */

/* ─── Data tables ─── */
.finance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.finance-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 0.5px solid var(--gray-200);
  background: var(--gray-50);
}
.finance-table td {
  padding: 10px 12px;
  border-bottom: 0.5px solid var(--gray-100);
  color: var(--gray-900);
}
.finance-table tr:last-child td { border-bottom: none; }
.finance-table .amount {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
}
.finance-table .amount--main { color: var(--green); }
.finance-table .amount--dark { color: #3d7a22; }
.finance-table .amount--light { color: var(--green-light); }
.finance-table .amount--mid { color: var(--green-mid); }
.finance-table tr:hover td { background: rgba(0,0,0,0.02); }
.finance-table .total-row td {
  font-weight: 700;
  border-top: 0.5px solid var(--gray-300);
  border-bottom: 0.5px solid var(--gray-300);
  background: var(--gray-50);
}
.finance-table .sub-header td {
  font-weight: 600;
  color: var(--gray-700);
  background: var(--gray-50);
}

/* ─── Status badges (tables) ─── */
.finance-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}
.finance-badge--paye { background: var(--green-pale); color: var(--green); }
.finance-badge--encours { background: #eaf5e1; color: #5a9e35; }
.finance-badge--avenir { background: var(--gray-100); color: var(--gray-500); }

/* ─── Charges breakdown (donut + list) ─── */
.finance-charges-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: center;
}
.finance-donut {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  position: relative;
  margin: 0 auto;
}
.finance-donut-center {
  position: absolute;
  inset: 30px;
  background: white;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.finance-donut-center-value {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--gray-900);
}
.finance-donut-center-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.finance-cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.finance-cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0.5px solid var(--gray-100);
  transition: all 0.15s;
}
.finance-cat-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-200);
}
.finance-cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.finance-cat-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-800);
}
.finance-cat-amount {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--gray-900);
}
.finance-cat-pct {
  font-size: 11px;
  color: var(--gray-400);
  min-width: 34px;
  text-align: right;
}

/* ─── Monthly trend chart (charges tab) ─── */
.finance-trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 80px;
  padding: 8px 0;
}
.finance-trend-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 4px;
  transition: height 0.3s var(--ease-ios);
}
.finance-trend-bar--main { background: var(--green); }
.finance-trend-bar--light { background: var(--green-light); }
.finance-trend-bar--mid { background: var(--green-mid); }
.finance-trend-bar--dark { background: #3d7a22; }
.finance-trend-bar--pale { background: #cce9bc; }
.finance-trend-labels {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.finance-trend-labels span {
  flex: 1;
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--gray-500);
}

/* ─── Objectifs tab ─── */
.finance-objectif-card {
  background: white;
  border-radius: 12px;
  border: 0.5px solid var(--gray-200);
  padding: 16px 18px;
  text-align: center;
  flex: 1;
}
.finance-objectif-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}
.finance-objectif-current {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--gray-900);
}
.finance-objectif-target {
  font-size: 13px;
  color: var(--gray-400);
  margin-top: 2px;
}
.finance-objectif-pct {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-top: 6px;
}
.finance-objectif-pct--good { color: var(--green); }
.finance-objectif-pct--warn { color: var(--green-mid); }
.finance-objectif-pct--bad { color: #3d7a22; }

.finance-objectifs-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

/* ─── Timeline ─── */
.finance-timeline {
  position: relative;
  padding-left: 20px;
}
.finance-timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--gray-200);
  border-radius: 1px;
}
.finance-timeline-item {
  position: relative;
  padding: 0 0 20px 20px;
}
.finance-timeline-item:last-child { padding-bottom: 0; }
.finance-timeline-dot {
  position: absolute;
  left: -18px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid;
  background: white;
}
.finance-timeline-dot--main { border-color: var(--green); }
.finance-timeline-dot--light { border-color: var(--green-light); }
.finance-timeline-dot--mid { border-color: var(--green-mid); }
.finance-timeline-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 2px;
}
.finance-timeline-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.finance-timeline-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 1px;
}

/* ─── Simulateur tab ─── */
.finance-sim-params {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.finance-sim-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.finance-sim-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  min-width: 200px;
  flex-shrink: 0;
}
.finance-sim-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: #e8f0e3;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.finance-sim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: all 0.15s;
}
.finance-sim-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.finance-sim-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  cursor: pointer;
}
.finance-sim-value {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--gray-900);
  min-width: 120px;
  text-align: right;
}

/* Scenario cards */
.finance-sim-scenarios {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.finance-sim-scenario {
  padding: 14px 16px;
  border-radius: 10px;
  border: 0.5px solid var(--gray-200);
  background: var(--gray-50);
  cursor: pointer;
  transition: all 0.15s;
}
.finance-sim-scenario:hover {
  border-color: var(--green);
  background: var(--green-pale);
}
.finance-sim-scenario-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.finance-sim-scenario-detail {
  font-size: 11px;
  color: var(--gray-500);
  font-family: var(--font-mono);
}

/* ─── Factures tab ─── */
.finance-factures-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 0 14px;
  flex-wrap: wrap;
}
.finance-factures-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 0.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 7px 12px;
  flex: 1;
  min-width: 200px;
}
.finance-factures-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--gray-900);
  width: 100%;
  font-family: var(--font-sans);
}
.finance-factures-input::placeholder { color: var(--gray-400); }
.finance-factures-filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.finance-factures-filter {
  padding: 5px 10px;
  border-radius: 6px;
  border: 0.5px solid var(--gray-200);
  background: white;
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.15s;
}
.finance-factures-filter:hover {
  border-color: var(--green);
  color: var(--green);
}
.finance-factures-filter.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

/* ─── Rapports tab ─── */
.finance-rapports-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.finance-rapport-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: white;
  border-radius: 12px;
  border: 0.5px solid var(--gray-200);
  padding: 16px 18px;
  transition: all 0.15s;
}
.finance-rapport-card:hover {
  border-color: var(--green);
  box-shadow: 0 1px 6px rgba(90,158,53,0.1);
}
.finance-rapport-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--green-pale);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.finance-rapport-info {
  flex: 1;
  min-width: 0;
}
.finance-rapport-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 2px;
}
.finance-rapport-desc {
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.finance-rapport-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.finance-rapport-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.3px;
}
.finance-rapport-size {
  font-size: 10px;
  color: var(--gray-400);
  font-family: var(--font-mono);
}

/* ─── TVA / URSSAF — V1-style CA3 + header ─── */
.tva-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}
.tva-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}
.tva-header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.tva-header-source {
  font-size: 11px;
  color: var(--gray-500);
  margin-right: 8px;
}
.tva-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0.5px solid var(--gray-200);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.15s;
}
.tva-nav-btn:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-pale);
}

/* CA3 table */
.ca3-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.ca3-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 420px;
}
.ca3-col-nature { width: 48%; }
.ca3-col-case { width: 20%; }
.ca3-col-montant { width: 32%; }
.ca3-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 0.5px solid var(--gray-200);
  background: var(--gray-50);
}
/* Aligner chaque th avec le contenu de sa colonne */
.ca3-table thead th:nth-child(2) { text-align: center; }
.ca3-table thead th:last-child { text-align: right; }
.ca3-table--full thead th:first-child { text-align: left; }
.ca3-table--full thead th:not(:first-child) { text-align: right; }
.ca3-table td {
  padding: 10px;
  border-bottom: 0.5px solid var(--gray-100);
}
.ca3-table tr:last-child td { border-bottom: none; }
.ca3-label { font-weight: 600; }
.ca3-label--bold { font-weight: 700; }
.ca3-case { text-align: center; }
.ca3-montant {
  text-align: right;
  font-family: var(--font-mono);
  font-weight: 600;
}
.ca3-montant--bold { font-weight: 700; font-size: 14px; }
.ca3-cell-mono {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: right;
  padding: 10px;
}
.ca3-table--full { min-width: 100%; }
.ca3-table--full th { white-space: nowrap; }

.ca3-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.ca3-badge--green { background: var(--green-pale); color: var(--green); }
.ca3-badge--orange { background: #fff3e0; color: #e65100; }
.ca3-badge--red { background: #fde8e8; color: #c41e1e; }
.ca3-badge--grey { background: var(--gray-100); color: var(--gray-600); }
.ca3-badge--dark { background: var(--gray-800); color: white; }
.ca3-badge--ghost { background: var(--gray-50); color: var(--gray-400); }

.ca3-total td {
  font-weight: 700;
  border-top: 0.5px solid var(--gray-300);
  border-bottom: 0.5px solid var(--gray-300);
  background: var(--gray-50);
}

.ca3-note {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 0.5px solid var(--gray-100);
}

/* Resultat TVA */
.tva-resultat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tva-resultat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.tva-resultat-row--muted { opacity: 0.5; }
.tva-resultat-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}
.tva-resultat-case { flex-shrink: 0; }
.tva-resultat-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
  text-align: right;
  min-width: 100px;
}
.tva-resultat-val--red { color: var(--red); }
.tva-resultat-val--green { color: var(--green); }

/* Step calc (shared TVA + URSSAF) */
.tva-step-calc { }
.tva-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.tva-step-row--total { padding: 8px 0; }
.tva-step-label { color: var(--gray-700); }
.tva-step-label--bold { font-weight: 700; }
.tva-step-note { font-weight: 400; color: var(--gray-500); font-size: 12px; }
.tva-step-val {
  font-family: var(--font-mono);
  text-align: right;
  font-weight: 700;
}
.tva-step-val--bold { font-size: 15px; }
.tva-step-hr {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 4px 0;
}

/* Declaration TVA */
.tva-decl-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* URSSAF specific */
.urssaf-calc { }
.urssaf-solde { }
.urssaf-paiement { }

@media (max-width: 767px) {
  .finance-sim-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .finance-sim-label { min-width: auto; font-size: 12px; }
  .finance-sim-value { min-width: auto; text-align: left; }
  .finance-sim-scenarios { grid-template-columns: 1fr; }
  .finance-rapports-grid { grid-template-columns: 1fr; }
  .finance-rapport-card { padding: 12px 14px; }
  .finance-factures-toolbar { flex-direction: column; align-items: stretch; }
  .finance-factures-filters { justify-content: center; }
}

/* ─── Responsive iOS / mobile ─── */
@media (max-width: 767px) {
  /* ── Padding & spacing ── */
  .finance-scroll { padding: 12px; }
  .finance-card { padding: 14px 15px; }
  .finance-card-header { margin-bottom: 10px; }

  /* ── Tabs ── */
  .finance-tabs { padding: 10px 12px 0; }
  .finance-tab { font-size: 11px; padding: 6px 9px; gap: 4px; }
  .finance-tab-icon { width: 12px; height: 12px; }

  /* KPI cards: handled by kpi.css media query */

  /* ── Tables → horizontal scroll ── */
  .finance-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 12px;
  }
  .finance-table th,
  .finance-table td {
    white-space: nowrap;
    padding: 7px 10px;
  }
  .finance-table .amount { white-space: nowrap; }

  /* ── Chart CA → horizontal scroll ── */
  .finance-chart {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    height: 90px;
    padding: 6px 0 0;
  }
  .finance-chart-col {
    min-width: 40px;
    flex: 0 0 auto;
  }
  .finance-chart-bar { max-width: 28px; }
  .finance-chart-value {
    font-size: 8px;
    white-space: nowrap;
  }
  .finance-chart-label { font-size: 8px; }
  .finance-chart-legend { gap: 10px; font-size: 10px; }

  /* ── Dashboard 2-col layout → stack ── */
  .finance-panel.active > .finance-scroll > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Donut + charges list ── */
  .finance-charges-layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .finance-donut {
    width: 130px;
    height: 130px;
  }
  .finance-donut-center { inset: 22px; }
  .finance-donut-center-value { font-size: 15px; }
  .finance-cat-item { padding: 6px 8px; }
  .finance-cat-name { font-size: 12px; }
  .finance-cat-amount { font-size: 12px; }
  .finance-cat-pct { font-size: 10px; }

  /* ── Trend chart → horizontal scroll ── */
  .finance-trend-chart {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    height: 65px;
    min-width: 320px;
  }
  .finance-trend-bar { min-width: 22px; }
  .finance-trend-labels {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
  }
  .finance-trend-labels span {
    min-width: 22px;
    font-size: 8px;
  }

  /* ── Objectifs ── */
  .finance-objectifs-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }
  .finance-objectif-card { padding: 12px 14px; }
  .finance-objectif-current { font-size: 22px; }
  .finance-objectif-target { font-size: 12px; }
  .finance-objectif-pct { font-size: 12px; }

  /* ── Progress rows ── */
  .finance-progress-row { gap: 8px; }
  .finance-progress-label { font-size: 11px; min-width: 55px; }
  .finance-progress-value { font-size: 10px; min-width: 55px; }

  /* ── Transaction list ── */
  .finance-tx-item { padding: 8px 0; gap: 10px; }
  .finance-tx-icon { width: 30px; height: 30px; }
  .finance-tx-icon i { width: 12px !important; height: 12px !important; }
  .finance-tx-title { font-size: 12px; }
  .finance-tx-sub { font-size: 10px; }
  .finance-tx-amount { font-size: 12px; }

  /* ── Timeline ── */
  .finance-timeline { padding-left: 16px; }
  .finance-timeline-item { padding: 0 0 14px 16px; }
  .finance-timeline-dot { width: 10px; height: 10px; left: -14px; }
  .finance-timeline-date { font-size: 10px; }
  .finance-timeline-title { font-size: 12px; }
  .finance-timeline-sub { font-size: 11px; }

  /* ── Badges ── */
  .finance-badge { font-size: 10px; padding: 1px 6px; }
  .finance-card-badge { font-size: 10px; padding: 2px 7px; }

  /* ── Card title ── */
  .finance-card-title { font-size: 12px; }
}

/* ─── Mobile Finance Header (iOS style) ─── */
@media (max-width: 767px) {
  /* Applied to elements rendered by mobile.js renderFinances() */
  .finance-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    background: white;
  }
  .finance-mobile-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-900);
  }
  .finance-mobile-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .finance-mobile-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--gray-100);
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    transition: all 0.15s;
  }
  .finance-mobile-btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
  }
  .finance-mobile-btn i {
    width: 16px !important;
    height: 16px !important;
  }
}

/* ─── Finance Mobile iOS Cards ─── */
@media (max-width: 767px) {
  /* KPI stat cards (hscroll row) */
  .fm-stat-card {
    flex-shrink: 0;
    width: 140px;
    background: white;
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .fm-stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
  }
  .fm-stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .fm-stat-value {
    font-size: 17px;
    font-weight: 700;
    font-family: var(--font-mono);
    line-height: 1.1;
  }
  .fm-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.2px;
  }
  .fm-stat-sub {
    font-size: 10px;
    color: var(--gray-400);
  }

  /* Chart */
  .fm-chart-wrap {
    background: white;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 0;
  }
  .fm-chart-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 100px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .fm-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 28px;
  }
  .fm-chart-value {
    font-size: 8px;
    color: var(--gray-500);
    white-space: nowrap;
  }
  .fm-chart-bar {
    width: 100%;
    background: var(--green);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    transition: height 0.3s;
  }
  .fm-chart-bar--current { background: var(--green-light); }
  .fm-chart-label {
    font-size: 9px;
    color: var(--gray-400);
    font-weight: 500;
  }
  .fm-chart-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--gray-500);
  }
  .fm-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
  }
  .fm-legend-dot--main { background: var(--green); }
  .fm-legend-dot--current { background: var(--green-light); }

  /* Transactions list */
  .fm-tx-list {
    background: white;
    border-radius: 12px;
    overflow: hidden;
  }
  .fm-tx-list .row {
    padding: 12px 16px;
    border-bottom: 0.5px solid var(--gray-100);
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .fm-tx-list .row:last-child { border-bottom: none; }
  .fm-tx-list .row-main { flex: 1; min-width: 0; }
  .fm-tx-list .row-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .fm-tx-list .row-sub {
    font-size: 11px;
    color: var(--gray-400);
    margin-top: 1px;
  }
  .fm-tx-amount {
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-mono);
    flex-shrink: 0;
  }

  /* Quick links */
  .fm-quicklinks {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: white;
    border-radius: 12px;
    padding: 14px;
  }
  .fm-quicklink {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--gray-50);
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
  }
  .fm-quicklink:hover { background: var(--gray-100); }
  .fm-quicklink i { width: 18px !important; height: 18px !important; color: var(--green); }
}
