:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #122033;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f766e;
  --primary-2: #115e59;
  --blue: #2563eb;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #dc2626;
  --amber-bg: #fff7ed;
  --red-bg: #fef2f2;
  --green-bg: #f0fdf4;
  --blue-bg: #eff6ff;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --font: Inter, Segoe UI, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #0f172a;
  color: #fff;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}
.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #14b8a6, #2563eb);
  font-weight: 800;
}
.brand h1 { font-size: 18px; margin: 0; line-height: 1.2; }
.brand p { margin: 2px 0 0; color: #cbd5e1; font-size: 12px; }
.nav { display: grid; gap: 7px; }
.nav button {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 12px 12px;
  border-radius: 12px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .16s ease;
}
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button.active { background: #fff; color: #0f172a; font-weight: 700; }
.nav small { margin-left: auto; background: rgba(255,255,255,.12); padding: 2px 8px; border-radius: 999px; }
.sidebar-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12px;
  color: #cbd5e1;
  line-height: 1.45;
}
.main {
  padding: 24px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar h2 { margin: 0; font-size: 27px; letter-spacing: -0.02em; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 18px; }
.card h3 { margin: 0 0 12px; font-size: 18px; }
.card h4 { margin: 0 0 10px; font-size: 15px; color: #334155; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-height: 114px;
}
.kpi .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.04em; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
.kpi.green { background: linear-gradient(180deg, #fff, #f0fdf4); }
.kpi.blue { background: linear-gradient(180deg, #fff, #eff6ff); }
.kpi.orange { background: linear-gradient(180deg, #fff, #fff7ed); }
.kpi.red { background: linear-gradient(180deg, #fff, #fef2f2); }
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #cbd5e1; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 9px; border-radius: 10px; font-size: 12px; }
.btn.warning { background: var(--orange); color: #fff; border-color: var(--orange); }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 700; color: #334155; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.inline-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 10px; text-align: left; vertical-align: top; }
th { background: #f8fafc; font-size: 12px; color: #475569; text-transform: uppercase; letter-spacing: .04em; }
td input, td select { width: 100%; border: 1px solid #dbe4ef; border-radius: 9px; padding: 7px 8px; }
tr:hover td { background: #fbfdff; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.warning, .badge.missing { background: #ffedd5; color: #9a3412; }
.badge.error { background: #fee2e2; color: #991b1b; }
.badge.blocking { background: #fecaca; color: #7f1d1d; }
.badge.closed { background: #dcfce7; color: #166534; }
.badge.validated { background: #dbeafe; color: #1e40af; }
.badge.draft { background: #f1f5f9; color: #334155; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 12px;
  font-weight: 800;
  color: #475569;
}
.tab.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.period-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}
.notice {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 14px;
  padding: 12px 14px;
  color: #475569;
  line-height: 1.45;
}
.notice strong { color: var(--text); }
.split {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 16px;
}
.denom-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.denom {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}
.denom label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: #475569; }
.denom input { margin: 8px auto 0; }
.denom .denom-qty {
  display: block;
  width: 74px;
  max-width: 100%;
  text-align: center;
  padding: 7px 6px;
  border: 1px solid #dbe4ef;
  border-radius: 10px;
  background: #fff;
}
.denom .denom-qty:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); outline: none; }
.denom div { font-weight: 800; margin-top: 7px; color: var(--primary); text-align: center; }
.summary-box {
  background: #0f172a;
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}
.summary-row { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: 9px; }
.summary-row:last-child { border-bottom: 0; padding-bottom: 0; }
.summary-row span:first-child { color: #cbd5e1; }
.summary-row strong { font-size: 17px; }
.bar-chart.monthly-chart { min-height: 300px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow-x: auto; }
.monthly-chart-svg { display: block; width: 100%; min-width: 900px; height: auto; }
.monthly-grid-line { stroke: #e2e8f0; stroke-width: 1; }
.monthly-axis-line { stroke: #94a3b8; stroke-width: 1.5; }
.monthly-axis-label { fill: #64748b; font-size: 11px; font-weight: 700; }
.monthly-month-label { fill: #475569; font-size: 12px; font-weight: 800; }
.monthly-value { fill: var(--text); font-size: 11px; font-weight: 800; }
.monthly-value.zero { fill: #94a3b8; font-weight: 600; }
.monthly-bar { fill: #0f766e; }
.monthly-bar.zero { fill: transparent; stroke: #cbd5e1; stroke-width: 2; }
.monthly-bar-group:hover .monthly-bar { filter: brightness(.92); }
.chart-note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.bar.alt { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.bar.neg { background: linear-gradient(180deg, #fb923c, #ea580c); }
.empty-state { padding: 26px; text-align: center; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.file-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 18px;
  padding: 24px;
  background: #fff;
  text-align: center;
}
.file-zone input { margin-top: 12px; }
.settings-list { display: grid; gap: 8px; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: #f1f5f9; border: 1px solid var(--line); padding: 7px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
.pill button { border: 0; background: transparent; color: var(--red); font-weight: 900; }
.print-only { display: none; }
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #0f172a;
  color: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-menu { display: none; }
@media (max-width: 1120px) {
  .kpi-grid, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .period-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .denom-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-menu { display: block; margin-bottom: 12px; }
  .main { padding: 14px; }
  .topbar { display: grid; }
  .kpi-grid, .grid.cols-2, .grid.cols-3, .grid.cols-4, .inline-fields, .period-box { grid-template-columns: 1fr; }
  .denom-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .toolbar { width: 100%; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .period-box, .tabs, .btn, .mobile-menu, .no-print { display: none !important; }
  .app-shell { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #d1d5db; break-inside: avoid; }
  .print-only { display: block; }
}


/* Correctif lisibilité des champs de saisie - version PC */
.field input,
.field select,
.field textarea,
td input,
td select,
td textarea {
  font-size: 15px;
  line-height: 1.35;
}

.field input,
.field select {
  min-height: 44px;
}

.field textarea {
  min-height: 104px;
  white-space: pre-wrap;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.entry-table {
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 0;
}

.entry-table th,
.entry-table td {
  vertical-align: middle;
  overflow: visible;
}

.income-table {
  min-width: 1180px;
}

.movement-table {
  min-width: 1280px;
}

.entry-table .col-activity,
.entry-table .col-type {
  min-width: 180px;
  width: 180px;
}

.entry-table .col-method {
  min-width: 145px;
  width: 145px;
}

.entry-table .col-money {
  min-width: 138px;
  width: 138px;
}

.entry-table .col-total {
  min-width: 140px;
  width: 140px;
  white-space: nowrap;
}

.entry-table .col-label,
.entry-table .col-reference,
.entry-table .col-comment {
  min-width: 240px;
}

.entry-table .col-action {
  min-width: 58px;
  width: 58px;
  text-align: center;
}

.table-select,
.money-input,
.table-textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.table-select,
.money-input {
  min-height: 42px;
  padding: 9px 10px;
}

.money-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-textarea {
  min-height: 56px;
  padding: 8px 10px;
  resize: vertical;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.table-select:focus,
.money-input:focus,
.table-textarea:focus,
.field-money-large:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,.12);
  outline: none;
}

.field-money-large {
  max-width: 260px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.denom {
  min-height: 112px;
}

.denom label {
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.denom .denom-qty {
  width: 64px;
  height: 38px;
  padding: 6px 5px;
  font-size: 15px;
  line-height: 1.2;
}

.denom div {
  min-height: 20px;
  word-break: keep-all;
}

@media (min-width: 1121px) {
  .denom-grid {
    grid-template-columns: repeat(5, minmax(122px, 1fr));
  }
}

@media (max-width: 1120px) {
  .entry-table .col-label,
  .entry-table .col-reference,
  .entry-table .col-comment {
    min-width: 220px;
  }
}


/* Page de connexion */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(20,184,166,.18), transparent 32%),
    radial-gradient(circle at 85% 18%, rgba(37,99,235,.16), transparent 30%),
    var(--bg);
}
.login-card {
  width: min(100%, 460px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.login-brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}
.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.login-notice {
  margin-bottom: 16px;
}
.login-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 14px;
  padding: 11px 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
.login-form {
  display: grid;
  gap: 4px;
}
.login-submit {
  width: 100%;
  justify-content: center;
  min-height: 46px;
  margin-top: 4px;
}
.login-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 16px 0 0;
  text-align: center;
}
.logout-btn {
  margin-top: 12px;
  width: 100%;
  justify-content: center;
  color: #0f172a;
}

/* Bas de page ReSource360 */
.app-footer {
  margin-top: 32px;
  padding: 18px 12px 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: center;
}
.app-footer a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}
.app-footer a:hover {
  text-decoration: underline;
}
.login-card .app-footer {
  margin-top: 20px;
  padding-bottom: 0;
}
@media print {
  .app-footer {
    display: block;
    color: #334155;
    border-top: 1px solid #cbd5e1;
  }
}
