/* ============================================================
   SOLVA — Design System (shadcn-inspired, pure CSS)
   ============================================================ */

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Couleurs Solva (teal) */
  --solva-50: #E1F5EE;
  --solva-100: #9FE1CB;
  --solva-200: #5DCAA5;
  --solva-400: #1D9E75;
  --solva-600: #0F6E56;
  --solva-800: #085041;
  --solva-900: #04342C;

  /* Surfaces */
  --background: #FFFFFF;
  --background-secondary: #F9FAFB;
  --foreground: #09090B;
  --muted: #F4F4F5;
  --muted-foreground: #71717A;

  /* Borders */
  --border: #E4E4E7;
  --border-hover: #A1A1AA;

  /* Semantic */
  --success: #16A34A;
  --success-bg: #F0FDF4;
  --warning: #CA8A04;
  --warning-bg: #FEFCE8;
  --danger: #DC2626;
  --danger-bg: #FEF2F2;
  --info: #2563EB;
  --info-bg: #EFF6FF;

  /* Typography */
  --font-sans: 'Inter', -apple-system, sans-serif;
  --text-base: 17px;
  --text-sm: 14px;
  --text-xs: 12px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;

  /* Spacing */
  --radius: 0.5rem;
  --radius-lg: 0.75rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--foreground);
  background: var(--background-secondary);
  line-height: 1.5;
}

a { color: var(--solva-600); text-decoration: none; }
a:hover { color: var(--solva-800); }

.font-mono { font-family: var(--font-sans); }

/* ============================================================
   Layout
   ============================================================ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  min-width: 220px;
  background: #18181B;
  color: white;
  padding: 1.5rem;
  flex-shrink: 0;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.2s ease;
}

.main {
  flex: 1;
  padding: 1.5rem 2.5rem;
  max-width: 1440px;
  margin-left: 260px;
  min-height: 100vh;
}

.main.main-wide {
  max-width: 100%;
}

.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 101;
  background: #18181B;
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar-header { margin-bottom: 1.25rem; }

.sidebar-logo {
  font-size: var(--text-xl);
  font-weight: 600;
  color: white;
  text-decoration: none;
  display: block;
}
.sidebar-logo:hover { color: white; }

.sidebar-group-name {
  display: block;
  font-size: var(--text-xs);
  color: #A1A1AA;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.sidebar-back {
  display: block;
  font-size: 12px;
  color: #71717A;
  text-decoration: none;
  margin-top: 4px;
}
.sidebar-back:hover { color: white; }

.impersonate-badge {
  background: rgba(254, 249, 195, 0.15);
  color: #FDE68A;
  border: 1px solid rgba(253, 230, 138, 0.3);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin: 0 0 12px 0;
  font-size: var(--text-xs);
  line-height: 1.4;
  text-align: center;
}
.impersonate-exit {
  color: #FDE68A;
  text-decoration: underline;
  font-weight: 500;
  margin-left: 6px;
}
.impersonate-exit:hover { color: white; }

.sidebar-site-link {
  display: block;
  font-size: var(--text-xs);
  color: #A1A1AA;
  text-decoration: none;
  margin-top: 2px;
}
.sidebar-site-link:hover { color: white; }

.sidebar-group-logo {
  max-width: 120px;
  max-height: 32px;
  margin-top: 8px;
}

.sidebar-site-switch {
  margin-bottom: 0.75rem;
}

.sidebar-site-switch select {
  width: 100%;
  padding: 6px 8px;
  background: #27272A;
  color: white;
  border: 1px solid #3F3F46;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}

.sidebar-search {
  margin-bottom: 0.75rem;
}

.sidebar-search input {
  width: 100%;
  padding: 6px 8px 6px 32px;
  background: #27272A;
  color: white;
  border: 1px solid #3F3F46;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}
.sidebar-search input::placeholder { color: #71717A; }

.sidebar-nav {
  list-style: none;
  flex: 1;
}

.sidebar-nav a,
.sidebar-link {
  color: #A1A1AA;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all 0.15s;
}
.sidebar-nav a:hover,
.sidebar-link:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}
.sidebar-nav a.active,
.sidebar-link.active {
  background: var(--solva-600);
  color: white;
}

.sidebar-divider {
  height: 1px;
  background: #27272A;
  margin: 8px 0;
}

.sidebar-badge {
  background: var(--danger);
  color: white;
  border-radius: 9999px;
  font-size: 11px;
  padding: 1px 6px;
  margin-left: auto;
  font-weight: 500;
}

.sidebar-sub {
  padding-left: 2rem;
}
.sidebar-sub a {
  font-size: var(--text-xs);
  padding: 4px 12px;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid #27272A;
  padding-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-footer span {
  font-size: var(--text-sm);
  color: #A1A1AA;
}

.sidebar-footer a {
  font-size: var(--text-xs);
  color: #71717A;
  text-decoration: none;
}
.sidebar-footer a:hover { color: white; }
.sidebar-footer-link {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-select-site {
  border-top: 1px solid #27272A;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}
.sidebar-select-site a {
  color: #71717A;
  font-size: var(--text-sm);
  text-decoration: none;
}
.sidebar-select-site a:hover { color: white; }

/* ============================================================
   Page
   ============================================================ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 600;
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-card {
  background: var(--background-secondary);
  border-radius: var(--radius);
  padding: 1rem;
}
.stat-card .label { font-size: var(--text-xs); color: var(--muted-foreground); }
.stat-card .value { font-size: var(--text-2xl); font-weight: 500; }
a.stat-card { transition: border-color 0.15s, box-shadow 0.15s; border: 1px solid transparent; }
a.stat-card:hover { border-color: var(--solva-400); box-shadow: var(--shadow-sm); }

/* ============================================================
   Badge
   ============================================================ */
.badge {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius);
  font-weight: 500;
  display: inline-block;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: var(--muted); color: var(--muted-foreground); }
.badge-subtle { background: transparent; color: var(--muted-foreground); border: 1px solid var(--border); }

/* Contract badges uniform size */
.badge-subtle, .badge-info, .badge-muted {
  font-size: 10px;
  padding: 1px 6px;
  line-height: 1.4;
  vertical-align: middle;
}

/* ============================================================
   Button
   ============================================================ */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--background);
  transition: all 0.15s;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--foreground);
  line-height: 1.5;
  box-sizing: border-box;
}
.btn:hover { background: var(--muted); border-color: var(--border-hover); }
.btn-primary { background: var(--solva-600); color: white; border-color: var(--solva-600); }
.btn-primary:hover { background: var(--solva-800); border-color: var(--solva-800); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #B91C1C; border-color: #B91C1C; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   Table
   ============================================================ */
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 500;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.table tr:hover { background: var(--background-secondary); }

/* Sortable headers */
th.sortable { cursor: pointer; user-select: none; position: relative; }
th.sortable:hover { color: var(--foreground); }
th.sortable::after { content: ' ⇅'; font-size: 10px; opacity: 0.3; }
th.sorted-asc::after { content: ' ↑'; opacity: 0.8; }
th.sorted-desc::after { content: ' ↓'; opacity: 0.8; }

/* Filter bar */
.filter-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.filter-btn.active { background: var(--solva-600); color: white; border-color: var(--solva-600); }

/* ============================================================
   Dot (pastille conformité matrice)
   ============================================================ */
.dot { width: 20px; height: 20px; border-radius: 50%; display: inline-block; }
.dot-green { background: #BBF7D0; }
.dot-orange { background: #FDE68A; }
.dot-red { background: #FECACA; }
.dot-gray { background: #E4E4E7; }

/* ============================================================
   Tour message (encart première visite)
   ============================================================ */
.tour-message {
  background: var(--solva-50);
  border: 1px solid var(--solva-200);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  position: relative;
}
.tour-message .close {
  position: absolute;
  top: 8px;
  right: 12px;
  cursor: pointer;
  color: var(--solva-600);
  background: none;
  border: none;
  font-size: var(--text-lg);
}

/* ============================================================
   Search bar
   ============================================================ */
.search-bar {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  background: var(--background-secondary);
  font-family: var(--font-sans);
}
.search-bar:focus { border-color: var(--solva-400); outline: none; background: var(--background); }

/* ============================================================
   Form
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: var(--text-sm); font-weight: 500; margin-bottom: 4px; }
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-family: var(--font-sans);
}
.form-input:focus { border-color: var(--solva-400); outline: none; }

/* Select custom Solva */
.form-select {
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2371717A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s ease;
}
.form-select:hover { border-color: var(--border-hover); }
.form-select:focus { border-color: var(--solva-400); outline: none; }
.form-select-sm {
  padding: 6px 32px 6px 10px;
  font-size: var(--text-sm);
}

/* ============================================================
   Detail grid (fiche employé, profil, etc.)
   ============================================================ */
.detail-grid { display: flex; flex-direction: column; gap: 0; }
.detail-row {
  display: flex;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  width: 180px;
  flex-shrink: 0;
  color: var(--muted-foreground);
  font-weight: 500;
}
.detail-value { flex: 1; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: var(--text-sm);
}
.flash-success { background: var(--success-bg); color: var(--success); border: 1px solid #BBF7D0; }
.flash-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #FECACA; }

/* ============================================================
   Login page
   ============================================================ */
.login-container {
  max-width: 400px;
  margin: 15vh auto 0;
  padding: 0 1rem;
}

.login-logo {
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--solva-600);
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin-bottom: 2rem;
}

.login-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.login-separator {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.25rem 0;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}
.login-separator::before,
.login-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-hint {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 30px var(--background) inset;
  -webkit-text-fill-color: var(--foreground);
}

.login-dev {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
}

/* ============================================================
   Error page
   ============================================================ */
.error-container {
  max-width: 500px;
  margin: 20vh auto 0;
  text-align: center;
  padding: 0 1rem;
}

.error-code {
  font-size: 72px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
}

.error-title {
  font-size: var(--text-xl);
  font-weight: 600;
  margin: 0.5rem 0;
}

.error-message {
  color: var(--muted-foreground);
  margin-bottom: 1.5rem;
}

/* ============================================================
   Dashboard
   ============================================================ */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ============================================================
   SOC — Barre sante systeme
   ============================================================ */
.health-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.health-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.875rem;
  border-radius: 8px;
  min-width: 80px;
  font-size: var(--text-xs);
  border: 1px solid transparent;
}
.health-item-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.health-item-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.health-item-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.health-label { font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.health-value { font-size: var(--text-sm); font-weight: 700; margin: 0.15rem 0 0; }
.health-sub { font-size: 0.65rem; opacity: 0.7; margin-top: 0.1rem; }

/* Tendances stats */
.trend-up { color: var(--destructive-600, #dc2626); font-size: 0.75rem; }
.trend-down { color: var(--success-600, #16a34a); font-size: 0.75rem; }
.trend-neutral { color: var(--muted-foreground); font-size: 0.75rem; }

/* Ligne double-blocage */
.row-warning td { background: #fffbeb; }

/* Panneau investigation IP */
.ip-panel {
  position: fixed; top: 0; right: 0;
  width: 480px; max-width: 90vw; height: 100vh;
  background: var(--background); border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.1);
  z-index: 1000; overflow-y: auto; padding: 1.5rem;
}
.ip-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.ip-panel-header h2 { margin: 0; font-size: 1.25rem; }
.ip-panel-section { margin-bottom: 1.5rem; }
.ip-panel-section h3 {
  font-size: 0.875rem; font-weight: 600; color: var(--muted-foreground);
  text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 0.5rem 0;
}
.ip-panel-table { width: 100%; font-size: 0.875rem; }
.ip-panel-table td { padding: 0.375rem 0; border-bottom: 1px solid var(--border); }
.ip-panel-table td:first-child { color: var(--muted-foreground); width: 40%; }
.ip-panel-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.ip-link { text-decoration: none; cursor: pointer; }
.ip-link:hover code { background-color: rgba(15, 110, 86, 0.1); }
.ip-history-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.8125rem; }
.ip-history-date { color: var(--muted-foreground); font-size: 0.75rem; }

/* Severite lignes */
.severity-critical td { background: rgba(220, 38, 38, 0.06); }
.severity-high td { background: rgba(234, 88, 12, 0.06); }
.severity-warning td { background: rgba(234, 179, 8, 0.04); }

/* Filtres */
.filters-bar {
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.filters-form { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }
.filter-group label {
  font-size: 0.75rem; font-weight: 600;
  color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.05em;
}
.filter-group select,
.filter-group input[type="text"] {
  padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 0.5rem;
  font-size: 0.875rem; background: var(--background); color: var(--foreground); min-width: 140px;
}
.filter-group input[type="text"] { min-width: 120px; }
.filter-actions { flex-direction: row; gap: 0.5rem; }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 1rem; }
.pagination-info { font-size: 0.875rem; color: var(--muted-foreground); }

/* Section header avec bouton export */
.section-header { display: flex; justify-content: space-between; align-items: center; }
.section-header h2 { margin: 0; }

/* Graphiques */
.chart-container {
  padding: 1.5rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.chart-canvas-wrapper {
  position: relative;
  height: 300px;
}
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}
.chart-half {
  padding: 1.5rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.chart-half h3 { margin: 0 0 1rem 0; font-size: 1rem; font-weight: 600; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.dashboard-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 0.75rem;
}

/* Alert items */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.alert-item:last-child { border-bottom: none; }

.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.alert-danger .alert-dot { background: var(--danger); }
.alert-warning .alert-dot { background: var(--warning); }
.alert-info .alert-dot { background: var(--info); }

/* Alert action buttons */
.btn-alert-action {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
}
.btn-alert-action:hover { background: var(--muted); border-color: var(--border-hover); }
.btn-alert-muted { color: var(--muted-foreground); }

/* Alert dots in table cells */
.alert-dot-cell { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.alert-dot-danger { background: var(--danger); }
.alert-dot-warning { background: var(--warning); }
.alert-dot-info { background: var(--info); }

.alert-content { flex: 1; }
.alert-text { display: block; }
.alert-detail {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  margin-top: 2px;
}

/* Event items */
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.event-item:last-child { border-bottom: none; }

.event-content { flex: 1; }
.event-title { display: block; }
.event-date {
  display: block;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  margin-top: 2px;
}

/* Matrix preview (mini matrice dans le dashboard) */
.matrix-preview { overflow-x: auto; }
.matrix-preview .table th { font-size: var(--text-xs); }
.matrix-preview .dot { width: 16px; height: 16px; }

/* ============================================================
   Matrix page (full training matrix)
   ============================================================ */
.matrix-scroll { overflow-x: auto; padding: 0.75rem; }
.matrix-scroll.card { padding: 0.75rem; }

.matrix-legend {
  display: flex;
  gap: 1.5rem;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  align-items: center;
  flex-wrap: wrap;
}
.matrix-bar-sample {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}
.matrix-bar-sample.status-green { background: var(--success); }
.matrix-bar-sample.status-orange { background: var(--warning); }
.matrix-bar-sample.status-red { background: var(--danger); }
.matrix-bar-sample.status-gray { background: var(--border); }

.matrix-table { font-size: var(--text-sm); border-collapse: collapse; width: 100%; table-layout: auto; }

/* Colonne employé sticky */
.matrix-name-col {
  min-width: 150px;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: var(--background);
  z-index: 10;
}
.matrix-name-col::after {
  content: '';
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to right, rgba(0,0,0,0.06), transparent);
  pointer-events: none;
}
thead .matrix-name-col { z-index: 11; }

.matrix-col { text-align: center; }
.matrix-table th { text-align: center; }
.matrix-table th.matrix-name-col { text-align: left; }
.matrix-cell { padding: 6px 12px !important; vertical-align: middle; position: relative; text-align: center; }

.matrix-cell-inner {
  padding: 8px 12px;
  border-bottom: 3px solid transparent;
  text-align: center;
  min-height: 36px;
}
.matrix-clickable { cursor: pointer; border-radius: var(--radius) var(--radius) 0 0; }
.matrix-clickable:hover { background: var(--background-secondary); }

.matrix-cell-inner.status-green { border-bottom-color: var(--success); }
.matrix-cell-inner.status-orange { border-bottom-color: var(--warning); }
.matrix-cell-inner.status-red { border-bottom-color: var(--danger); }
.matrix-cell-inner.status-gray { border-bottom-color: var(--border); }

.matrix-valid-date {
  display: block;
  font-size: 13px;
  color: var(--foreground);
  font-family: var(--font-sans);
  font-weight: 500;
  white-space: nowrap;
}
.matrix-empty {
  color: var(--muted-foreground);
  font-size: 13px;
}

.matrix-emp-link {
  color: var(--foreground);
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.matrix-emp-link:hover { color: var(--solva-600); }

/* Popover */
.matrix-popover {
  display: none;
  position: fixed;
  z-index: 300;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1rem;
  width: 280px;
  font-size: var(--text-sm);
}
.matrix-popover.open { display: block; }

/* Popover arrow */
.popover-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}
.popover-arrow-up {
  top: -8px;
  border-bottom: 8px solid var(--border);
}
.popover-arrow-up::after {
  content: '';
  position: absolute;
  top: 1px;
  left: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--background);
}
.popover-arrow-down {
  bottom: -8px;
  border-top: 8px solid var(--border);
}
.popover-arrow-down::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--background);
}

.popover-title {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.popover-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: var(--text-xs);
}
.popover-label { color: var(--muted-foreground); }
.popover-value { font-weight: 500; font-family: var(--font-sans); }
.popover-section {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ============================================================
   Side panel (panneau latéral droit)
   ============================================================ */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background: var(--background);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 1.5rem;
}
.side-panel.open { transform: translateX(0); }

.side-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 199;
}
.side-panel-overlay.open { display: block; }

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.summary-name { font-size: var(--text-xl); font-weight: 600; }
.summary-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted-foreground);
  padding: 4px 8px;
}
.summary-close:hover { color: var(--foreground); }

.summary-info { margin-bottom: 1.25rem; }
.summary-info .detail-row { padding: 6px 0; }
.summary-info .detail-label { width: 100px; }

.summary-section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}

.summary-trainings { display: flex; flex-direction: column; gap: 0; }

.summary-training-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.summary-training-row:last-child { border-bottom: none; }

.summary-training-bar {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}
.summary-training-bar.status-green { background: var(--success); }
.summary-training-bar.status-orange { background: var(--warning); }
.summary-training-bar.status-red { background: var(--danger); }
.summary-training-bar.status-gray { background: var(--border); }

.summary-training-info { flex: 1; }
.summary-training-label { display: block; font-size: var(--text-sm); font-weight: 500; }
.summary-training-date { display: block; font-size: var(--text-xs); color: var(--muted-foreground); }

@media (max-width: 768px) {
  .side-panel { width: 100%; }
}

/* ============================================================
   Document viewer modal
   ============================================================ */
.doc-viewer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
}
.doc-viewer-overlay.open { display: block; }

.doc-viewer {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80vw;
  height: 85vh;
  background: var(--background);
  border-radius: var(--radius-lg);
  z-index: 501;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.doc-viewer.open { display: flex; }

.doc-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.doc-viewer-title { font-weight: 600; font-size: var(--text-sm); }
.doc-viewer-actions { display: flex; gap: 8px; align-items: center; }

.doc-viewer-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-viewer-body iframe { width: 100%; height: 100%; border: none; }
.doc-viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }

.doc-viewer-nopreview {
  text-align: center;
  color: var(--muted-foreground);
  padding: 3rem;
}

/* ============================================================
   Upload / Drop zone
   ============================================================ */
.upload-card { padding: 1.25rem; }

.drop-zone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.15s;
}
.drop-zone:hover { border-color: var(--border-hover); }
.drop-zone.drag-over {
  border-color: var(--solva-400);
  background: var(--solva-50);
}

.drop-zone-icon {
  font-size: 18px;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-right: 4px;
}
.drop-zone-link {
  color: var(--solva-600);
  font-weight: 500;
  text-decoration: underline;
}
.drop-zone-hint { color: var(--muted-foreground); }

.file-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--background-secondary);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.file-preview-left { display: flex; align-items: center; gap: 12px; }
.file-preview-right { display: flex; align-items: center; gap: 12px; }

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-foreground);
  background: var(--muted);
  flex-shrink: 0;
}
.file-icon-pdf { background: #FAECE7; color: #993C1D; }
.file-icon-doc { background: #E6F1FB; color: #185FA5; }
.file-icon-img { background: #EAF3DE; color: #3B6D11; }
.file-icon-xls { background: #E6F9E6; color: #1A7A1A; }

.file-meta { display: flex; flex-direction: column; }
.file-name { font-weight: 500; font-size: var(--text-sm); }
.file-size { font-size: 12px; color: var(--muted-foreground); }

.file-remove {
  color: var(--danger);
  font-weight: 500;
  font-size: var(--text-sm);
  cursor: pointer;
  text-decoration: none;
}
.file-remove:hover { text-decoration: underline; }

.upload-file-list { margin-top: 8px; }

.upload-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.upload-file-row:last-child { border-bottom: none; }

.upload-file-size {
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

/* ============================================================
   FCo page
   ============================================================ */
.fco-days {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
}
.fco-days-green { color: var(--success); }
.fco-days-orange { color: var(--warning); }
.fco-days-red { color: var(--danger); }
.fco-days-gray { color: var(--muted-foreground); }

/* Cycle steps */
.fco-cycle {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  padding: 1rem 0;
}
.fco-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 120px;
  text-align: center;
}
.fco-step-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--muted);
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 6px;
}
.fco-step-active .fco-step-circle {
  background: var(--solva-600);
  color: white;
}
.fco-step-done .fco-step-circle {
  background: var(--success);
  color: white;
}
.fco-step-label { font-size: var(--text-sm); font-weight: 500; }
.fco-step-desc { font-size: var(--text-xs); color: var(--muted-foreground); margin-top: 2px; }

.fco-step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin-top: 18px;
  flex-shrink: 0;
}
.fco-step-line-done { background: var(--success); }

/* Progress bar */
.fco-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--muted);
  border-radius: 4px;
  overflow: hidden;
}
.fco-progress-fill {
  height: 100%;
  background: var(--solva-600);
  border-radius: 4px;
  transition: width 0.3s;
}

/* Checklist rows */
.fco-checklist { display: flex; flex-direction: column; }

.fco-cl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  border-radius: var(--radius);
  margin-bottom: 2px;
}
.fco-cl-row:last-child { border-bottom: none; }

.fco-cl-auto { background: var(--background-secondary); }
.fco-cl-ok:not(.fco-cl-auto) { }
.fco-cl-no:not(.fco-cl-auto) { }

.fco-cl-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.fco-cl-icon-ok { background: var(--success-bg); color: var(--success); }
.fco-cl-icon-no { background: var(--danger-bg); color: var(--danger); }

.fco-cl-cb { width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; }
.fco-cl-content { flex: 1; }
.fco-cl-label { font-weight: 500; }
.fco-cl-detail { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }

.fco-cl-auto-badge {
  display: inline-block;
  background: var(--solva-50);
  color: var(--solva-600);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  margin-right: 6px;
  vertical-align: middle;
}

.fco-cl-actions { flex-shrink: 0; }

/* ============================================================
   Group cards (portefeuille auditeur)
   ============================================================ */
.group-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.group-card {
  text-decoration: none;
  color: var(--foreground);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.group-card:hover {
  border-color: var(--solva-400);
  box-shadow: var(--shadow-md);
}

.group-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.group-card-name { font-weight: 600; font-size: var(--text-lg); }

.group-card-stats {
  display: flex;
  gap: 1.5rem;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}

.group-card-sites {
  display: flex;
  flex-wrap: wrap;
}

/* ============================================================
   Session form — employee suggestion list
   ============================================================ */
.session-emp-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
}
.session-emp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  cursor: pointer;
}
.session-emp-item:last-child { border-bottom: none; }
.session-emp-item:hover { background: var(--background-secondary); }
.session-emp-item input[type="checkbox"] { flex-shrink: 0; }
.session-emp-name { flex: 1; font-weight: 500; }

/* ============================================================
   PSAQ
   ============================================================ */
/* TOC repliable */
.psaq-toc-card { padding: 0; }
.psaq-toc-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; cursor: pointer; font-size: var(--text-sm);
}
.psaq-toc-header:hover { background: var(--background-secondary); }
.psaq-toc-toggle { font-size: 12px; transition: transform 0.2s; }
.psaq-toc-open .psaq-toc-toggle { transform: rotate(90deg); }
.psaq-toc-body { display: none; padding: 0 16px 16px; }
.psaq-toc-open .psaq-toc-body { display: block; }

.psaq-toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px;
}
.psaq-toc-link {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; font-size: var(--text-sm);
  color: var(--foreground); text-decoration: none;
  border-radius: 4px;
}
.psaq-toc-link:hover { background: var(--background-secondary); }
.psaq-toc-code { font-weight: 600; min-width: 50px; color: var(--solva-600); font-size: var(--text-xs); }

/* Document sections */
.psaq-section {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}
.psaq-section:last-child { border-bottom: none; }
.psaq-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.psaq-section-header h2 { font-size: var(--text-xl); font-weight: 500; margin: 0; }

.psaq-section-content {
  font-size: var(--text-base); line-height: 1.7; min-height: 2rem;
}
.psaq-section-content p { margin-bottom: 0.75rem; }
.psaq-section-content h2 { font-size: var(--text-xl); font-weight: 600; margin: 1.5rem 0 0.75rem; }
.psaq-section-content h3 { font-size: var(--text-lg); font-weight: 600; margin: 1.25rem 0 0.5rem; }
.psaq-section-content ul, .psaq-section-content ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.psaq-section-content li { margin-bottom: 0.25rem; }

.psaq-empty { color: var(--muted-foreground); font-style: italic; }

.psaq-editing {
  border: 1px solid var(--solva-400);
  border-radius: var(--radius);
  padding: 0;
}
.psaq-editing .tiptap-toolbar { border-radius: var(--radius) var(--radius) 0 0; }
.psaq-editing #inline-editor-area {
  padding: 1.25rem; min-height: 200px;
  border: none; border-top: none;
}
.psaq-editing .ProseMirror { outline: none; min-height: 150px; }
.psaq-editing .ProseMirror p { margin-bottom: 0.75rem; }

/* Comments */
.psaq-section-comments { margin-top: 0.75rem; }
.psaq-comments-toggle {
  font-size: var(--text-sm); color: var(--solva-600);
  text-decoration: none; font-weight: 500;
}
.psaq-comments-toggle:hover { text-decoration: underline; }

/* Tiptap editor */
.tiptap-toolbar {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--background-secondary);
  flex-wrap: wrap;
}
.tiptap-toolbar button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  color: var(--foreground);
  transition: all 0.1s;
}
.tiptap-toolbar button:hover { background: var(--muted); }
.tiptap-toolbar button.is-active {
  background: var(--solva-100);
  color: var(--solva-800);
}
.tiptap-toolbar .separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 4px 4px;
  align-self: center;
}
.tiptap-toolbar-sep { width: 1px; background: var(--border); margin: 0 4px; }

.tiptap-content {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem;
  min-height: 300px;
  font-size: var(--text-base);
  line-height: 1.7;
}
.tiptap-content:focus-within { border-color: var(--solva-400); }
.tiptap-readonly { border-top: 1px solid var(--border); border-radius: var(--radius); background: var(--background-secondary); }

.tiptap-content .ProseMirror { outline: none; min-height: 80px; }
.tiptap-content .ProseMirror p { margin-bottom: 0.75rem; }
.tiptap-content .ProseMirror h2 { font-size: var(--text-xl); font-weight: 600; margin: 1.5rem 0 0.75rem; }
.tiptap-content .ProseMirror h3 { font-size: var(--text-lg); font-weight: 600; margin: 1.25rem 0 0.5rem; }
.tiptap-content .ProseMirror ul, .tiptap-content .ProseMirror ol { padding-left: 1.5rem; margin-bottom: 0.75rem; }
.tiptap-content .ProseMirror li { margin-bottom: 0.25rem; }

/* Tiptap rendered (lecture seule) */
.tiptap-rendered p { margin: 0 0 0.5rem 0; }
.tiptap-rendered ul, .tiptap-rendered ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.tiptap-rendered li { margin: 0.25rem 0; }
.tiptap-rendered blockquote { border-left: 3px solid var(--border); padding-left: 1rem; color: var(--muted-foreground); margin: 0.5rem 0; }
.tiptap-rendered h2 { font-size: var(--text-lg); margin: 1rem 0 0.5rem; }
.tiptap-rendered h3 { font-size: var(--text-base); font-weight: 600; margin: 0.75rem 0 0.5rem; }
.tiptap-rendered pre { background: var(--muted); padding: 0.75rem; border-radius: var(--radius); overflow-x: auto; }
.tiptap-rendered code { background: var(--muted); padding: 2px 4px; border-radius: 3px; font-size: var(--text-sm); }

/* Comments */
.psaq-comments { display: flex; flex-direction: column; gap: 0; }
.psaq-comment {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.psaq-comment:last-child { border-bottom: none; }
.psaq-comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.psaq-comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--solva-100);
  color: var(--solva-800);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.psaq-comment-author { font-weight: 500; font-size: var(--text-sm); }
.psaq-comment-date { font-size: var(--text-xs); color: var(--muted-foreground); margin-left: auto; }
.psaq-comment-content { font-size: var(--text-sm); padding-left: 36px; }

/* Full view sidebar */
.psaq-sidebar {
  position: fixed;
  left: 260px;
  top: 0;
  width: 220px;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--background);
  z-index: 5;
}
.psaq-sidebar-title { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; color: var(--muted-foreground); margin-bottom: 0.75rem; }
.psaq-sidebar-link {
  display: flex;
  gap: 6px;
  padding: 4px 8px;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-decoration: none;
  border-radius: 4px;
  margin-bottom: 2px;
}
.psaq-sidebar-link:hover { background: var(--background-secondary); color: var(--foreground); }
.psaq-sidebar-code { font-weight: 600; color: var(--solva-600); min-width: 42px; }

.psaq-main { margin-left: 480px !important; }
.psaq-section-card { margin-bottom: 1.5rem; }

@media (max-width: 1024px) {
  .psaq-sidebar { display: none; }
  .psaq-main { margin-left: 260px !important; }
}

/* ============================================================
   Placeholder (pages en construction)
   ============================================================ */
.placeholder-message {
  background: var(--muted);
  border-radius: var(--radius-lg);
  padding: 2rem;
  text-align: center;
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

/* ============================================================
   Print (FES detail)
   ============================================================ */
@media print {
  .sidebar, .page-header .btn, .page-header button { display: none !important; }
  .layout { display: block; }
  .main { margin-left: 0 !important; padding: 0 !important; max-width: 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  .page-header { margin-bottom: 1rem; }
  .page-title { font-size: 16pt; }
  body { font-size: 11pt; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1400px) {
  .main, .main.main-wide { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (max-width: 1280px) {
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; padding: 1rem; padding-top: 3rem; }
  .hamburger { display: block; }

  /* Tables — scroll horizontal auto sur toutes les tables dans .card */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Layout */
  .dashboard-stats { grid-template-columns: 1fr 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .group-cards { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .page-header > div { display: flex; flex-wrap: wrap; gap: 0.5rem; }

  /* Detail rows */
  .detail-row { flex-direction: column; gap: 2px; }
  .detail-label { width: auto; }

  /* Panels */
  .side-panel { width: 100%; }
  .ip-panel { width: 100%; }

  /* Login */
  .login-container { margin-top: 5vh; }

  /* Tiptap toolbar */
  .tiptap-toolbar { flex-wrap: wrap; }

  /* Filter bar */
  .filter-bar { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .dashboard-stats { grid-template-columns: 1fr; }
  .main { padding: 0.75rem; padding-top: 3.5rem; }
  .page-title { font-size: var(--text-xl); }
  .btn { font-size: var(--text-sm); padding: 6px 12px; }
}

/* Custom checkbox */
.checkbox-custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: var(--text-sm);
}
.checkbox-custom input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--background);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s ease;
}
.checkbox-custom input[type="checkbox"]:hover { border-color: var(--solva-400); }
.checkbox-custom input[type="checkbox"]:checked { background: var(--solva-600); border-color: var(--solva-600); }
.checkbox-custom input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Custom radio */
.radio-custom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: var(--text-sm);
}
.radio-custom input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--background);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s ease;
}
.radio-custom input[type="radio"]:hover { border-color: var(--solva-400); }
.radio-custom input[type="radio"]:checked { border-color: var(--solva-600); }
.radio-custom input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--solva-600);
}

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg, var(--radius));
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--background);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--solva-400);
  background: var(--solva-50, #f0f9ff);
}
.upload-zone p { margin: 0; color: var(--muted-foreground); font-size: var(--text-sm); }
.upload-zone .upload-icon { font-size: 2rem; margin-bottom: 0.5rem; color: var(--muted-foreground); }
.upload-zone .upload-link { color: var(--solva-600); font-weight: 500; text-decoration: underline; }
.upload-zone input[type="file"] { display: none; }
.upload-zone .file-list { margin-top: 1rem; text-align: left; }
.upload-zone .file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: var(--muted);
  border-radius: var(--radius);
  margin-top: 0.5rem;
  font-size: var(--text-sm);
}

/* Toggle OUI/NON style bouton */
.toggle-oui-non {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-oui-non label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 14px;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border-right: 1px solid var(--border);
  user-select: none;
}

.toggle-oui-non label:last-child {
  border-right: none;
}

.toggle-oui-non label:hover {
  background: var(--muted);
}

.toggle-oui-non input[type="radio"] {
  display: none;
}

.toggle-oui-non label.selected-oui {
  background: var(--success-bg);
  color: var(--success);
  font-weight: 600;
}

.toggle-oui-non label.selected-non {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 600;
}

/* Éditeur Tiptap — standalone (audit observations) */
.ProseMirror {
  cursor: text;
}

.ProseMirror:focus {
  outline: none;
  border-color: var(--solva-400);
  box-shadow: 0 0 0 2px rgba(29, 158, 117, 0.1);
}

.ProseMirror p {
  margin: 0 0 0.5rem 0;
}

.ProseMirror p.is-editor-empty:first-child::before {
  content: 'Saisissez vos observations...';
  color: var(--muted-foreground);
  pointer-events: none;
  float: left;
  height: 0;
}

/* Tiptap images */
.ProseMirror {
  overflow-wrap: break-word;
  word-break: break-word;
}

.ProseMirror ul,
.ProseMirror ol {
  padding-left: 1.2rem;
  margin: 0.25rem 0;
}

.ProseMirror li {
  margin: 0.15rem 0;
}

.ProseMirror li strong,
.ProseMirror li em,
.ProseMirror li s {
  display: inline;
}

.ProseMirror li p {
  margin: 0;
  display: inline;
}

.ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 0.5rem 0;
  cursor: pointer;
  display: inline-block;
}

.tiptap-rendered img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 0.5rem 0;
}

/* Image resize overlay */
.img-resize-overlay {
  position: absolute;
  pointer-events: none;
  border: 2px solid var(--solva-400);
  border-radius: 2px;
  z-index: 50;
}

.img-resize-handle {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 14px;
  height: 14px;
  background: var(--solva-600);
  border: 2px solid white;
  border-radius: 2px;
  cursor: nwse-resize;
  pointer-events: all;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.img-resize-handle:hover {
  background: var(--solva-800);
  transform: scale(1.2);
}

.img-delete-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: var(--danger);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.15s;
}

.img-resize-overlay:hover .img-delete-btn {
  opacity: 1;
}

.img-resize-size-label {
  position: absolute;
  bottom: -22px;
  right: 0;
  font-size: 10px;
  color: var(--solva-600);
  background: white;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--solva-200);
  pointer-events: none;
  font-weight: 600;
}
