@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Outfit:wght@400;500;600;700&display=swap');
* { box-sizing: border-box; }
body { margin:0; background:#f4f1ea; color:#2b2620; font-family:'Outfit',sans-serif; }
a { color:inherit; text-decoration:none; }

.topbar { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:16px;
  padding:18px 32px; background:#fbfaf6; border-bottom:1px solid #ddd6c8; }
.brand { display:flex; align-items:center; gap:14px; }
.logo { width:46px; height:46px; border-radius:12px; background:linear-gradient(135deg,#1f6f54,#2d8f6c);
  color:#fff; display:flex; align-items:center; justify-content:center; font-weight:800; font-size:18px;
  font-family:'Fraunces',serif; letter-spacing:1px; }
.brand-title { font-family:'Fraunces',serif; font-size:21px; font-weight:600; }
.brand-sub { font-size:13px; color:#8a8275; margin-top:2px; }
.topbar-right { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.year-form { display:flex; align-items:center; gap:6px; background:#fff; border:1px solid #d3cbbb;
  border-radius:10px; padding:5px 10px; }
.year-form label { font-size:12px; color:#8a8275; font-weight:600; }
.year-form select { border:none; background:transparent; font-family:inherit; font-weight:700;
  font-size:14px; color:#1f6f54; cursor:pointer; }
.user { font-size:13px; color:#6b6358; }
.btn-ghost { padding:8px 15px; border:1px solid #d3cbbb; border-radius:9px; background:#fff;
  font-size:13px; font-weight:600; cursor:pointer; font-family:inherit; }
.btn-ghost:hover { background:#f0ede3; }

.mainnav { display:flex; gap:4px; padding:0 32px; background:#fbfaf6; border-bottom:1px solid #ddd6c8;
  flex-wrap:wrap; }
.mainnav a { padding:14px 18px; color:#8a8275; font-size:14px; font-weight:600;
  border-bottom:2px solid transparent; }
.mainnav a:hover { color:#1f6f54; }
.mainnav a.active { color:#1f6f54; border-bottom:2px solid #1f6f54; }

.container { max-width:1280px; margin:0 auto; padding:28px 32px; }
.footer { text-align:center; padding:24px; color:#8a8275; font-size:13px; }

.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:16px; margin-bottom:24px; }
.card { background:#fbfaf6; border:1px solid #e3ddd0; border-radius:14px; padding:20px 22px; }
.card .label { font-size:13px; color:#8a8275; font-weight:600; margin-bottom:8px; }
.card .value { font-size:26px; font-weight:700; font-family:'Fraunces',serif; }
.green { color:#1f6f54; } .red { color:#9a3b2f; } .gold { color:#7a6a3a; }

.panel { background:#fbfaf6; border:1px solid #e3ddd0; border-radius:14px; padding:24px; margin-bottom:16px; }
.panel h2 { font-family:'Fraunces',serif; font-size:17px; font-weight:600; margin:0 0 18px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width:760px){ .grid2 { grid-template-columns:1fr; } }

.bar-row { margin-bottom:14px; }
.bar-top { display:flex; justify-content:space-between; font-size:14px; margin-bottom:5px; }
.bar-track { height:10px; background:#e9e3d6; border-radius:6px; overflow:hidden; }
.bar-fill { height:100%; border-radius:6px; }

.barchart { display:flex; align-items:flex-end; justify-content:space-around; height:200px; gap:14px; }
.barcol { flex:1; display:flex; flex-direction:column; align-items:center; }
.barcol .v { font-size:12px; font-weight:700; color:#1f6f54; margin-bottom:6px; }
.barcol .f { width:55%; max-width:54px; background:linear-gradient(180deg,#2d8f6c,#1f6f54);
  border-radius:6px 6px 0 0; }
.barcol .l { margin-top:8px; font-size:13px; font-weight:600; color:#6b6358; }

table { width:100%; border-collapse:collapse; font-size:14px; }
.tablewrap { background:#fbfaf6; border:1px solid #e3ddd0; border-radius:14px; overflow:auto; }
th { padding:13px 12px; font-size:12px; font-weight:700; color:#8a8275; text-transform:uppercase;
  letter-spacing:.5px; border-bottom:1px solid #e3ddd0; background:#f4f1ea; text-align:center; }
th.l, td.l { text-align:left; }
td { padding:10px 12px; text-align:center; border-bottom:1px solid #ece6da; }
tr:hover td { background:#f7f4ec; }
.tag { display:inline-block; padding:3px 9px; background:#eef2ec; color:#1f6f54; border-radius:6px;
  font-weight:700; font-size:12px; }

.chip { min-width:54px; padding:6px 8px; border-radius:8px; border:1px solid transparent; font-size:13px;
  font-weight:700; cursor:pointer; font-family:inherit; }
.chip.paid { background:#e3f0e9; color:#1f6f54; border-color:#bcdcca; }
.chip.partial { background:#fbf2da; color:#9a7b1f; border-color:#ecd9a3; }
.chip.unpaid { background:#f6efe9; color:#b08968; border-color:#e6d8c9; }

.badge { display:inline-block; padding:4px 12px; border-radius:20px; font-size:12px; font-weight:700; }
.b-ok { background:#e3f0e9; color:#1f6f54; } .b-part { background:#fbf2da; color:#9a7b1f; }
.b-none { background:#f7e6e2; color:#9a3b2f; }

.toolbar { display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-bottom:18px; }
input[type=text], input[type=date], input[type=number], select.f, textarea {
  padding:10px 14px; border:1px solid #d3cbbb; border-radius:10px; background:#fff; font-size:14px;
  font-family:inherit; }
input[type=text]:focus, select:focus, input:focus { outline:2px solid #1f6f54; outline-offset:1px; }
.btn { padding:10px 18px; border:none; border-radius:10px; background:#1f6f54; color:#fff;
  font-size:14px; font-weight:700; cursor:pointer; font-family:inherit; }
.btn:hover { background:#1a5e47; }
.btn-sm { padding:5px 11px; font-size:12px; border-radius:7px; }
.link-print { color:#1f6f54; font-weight:600; }

.flash { padding:12px 16px; border-radius:10px; margin-bottom:18px; font-weight:600; }
.flash.ok { background:#e3f0e9; color:#1f6f54; } .flash.err { background:#f7e6e2; color:#9a3b2f; }

/* ----- Login ----- */
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; }
.login-card { background:#fbfaf6; border:1px solid #e3ddd0; border-radius:18px; padding:40px;
  width:340px; box-shadow:0 20px 50px rgba(60,50,30,.08); }
.login-card h1 { font-family:'Fraunces',serif; font-size:22px; margin:14px 0 4px; }
.login-card p { color:#8a8275; font-size:13px; margin:0 0 24px; }
.login-card label { display:block; font-size:13px; font-weight:600; margin:14px 0 6px; }
.login-card input { width:100%; }
.login-card .btn { width:100%; margin-top:22px; }

/* ----- Impression recu / bilan ----- */
.recu { max-width:640px; margin:30px auto; background:#fff; border:1px solid #ddd6c8; border-radius:14px;
  padding:40px; }
.recu h1 { font-family:'Fraunces',serif; font-size:24px; margin:0; }
.recu .num { color:#1f6f54; font-weight:700; margin-top:4px; }
.recu .row { display:flex; justify-content:space-between; padding:10px 0; border-bottom:1px solid #eee; }
.recu .row .k { color:#8a8275; }
.recu .total { font-size:22px; font-weight:700; color:#1f6f54; font-family:'Fraunces',serif; }
.recu .sign { margin-top:50px; display:flex; justify-content:space-between; font-size:13px; color:#6b6358; }
.print-actions { text-align:center; margin:20px; }
@media print {
  .topbar, .mainnav, .footer, .print-actions, .toolbar { display:none !important; }
  body { background:#fff; }
  .recu { border:none; margin:0; }
  .print-header { display:block !important; }
  .panel { border:none !important; background:transparent !important; padding:0 !important; }
  button, .btn, .btn-ghost { display:none !important; }
}

/* v4 : textarea, photo uploads dir */
textarea { font-family:inherit; padding:10px 14px; border:1px solid #d3cbbb; border-radius:10px; background:#fff; font-size:14px; resize:vertical; }

/* ============================================================
   RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 900px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .brand-title { font-size: 16px; }
  .brand-sub { font-size: 12px; }
  .logo { width:36px; height:36px; font-size:14px; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn-ghost { padding: 6px 10px; font-size: 13px; }

  .container { padding: 16px 12px; }
  .panel { padding: 16px; margin-bottom: 14px; }
  h2 { font-size: 20px; }

  /* Cartes stat : passent en 1 colonne */
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .cards .card { padding: 12px; }
  .cards .value { font-size: 22px; }

  /* Grids en une seule colonne */
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr !important; gap: 10px !important; }
  div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Toolbar : passe en colonne */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar > * { width: 100%; }
  .toolbar input, .toolbar select { width: 100% !important; box-sizing: border-box; }

  /* Boutons plus grands pour le toucher */
  .btn, .btn-ghost { padding: 10px 14px; font-size: 14px; min-height: 40px; }
  .btn-sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }

  /* Tableaux : conteneur scrollable */
  .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
  table { font-size: 13px; min-width: 500px; }
  table th, table td { padding: 8px 6px; }

  /* Nav mobile : hamburger + repli */
  .mainnav {
    padding: 0;
    position: relative;
    flex-wrap: wrap;
    max-height: 46px;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }
  .mainnav.open { max-height: 600px; }
  .mainnav::before {
    content: "☰ Menu";
    display: block;
    padding: 12px 16px;
    font-weight: 700;
    color: #1f6f54;
    cursor: pointer;
    width: 100%;
    background: #fbfaf6;
    border-bottom: 1px solid #ddd6c8;
  }
  .mainnav a { padding: 12px 16px; width: 100%; border-bottom: 1px solid #f0eadb; font-size: 15px; }
  .mainnav a.active { border-bottom: 1px solid #1f6f54; }

  /* Signatures, uploads : plus compact */
  canvas { max-width: 100% !important; }

  /* Formulaires : champs pleine largeur */
  input[type="text"], input[type="email"], input[type="date"], input[type="time"],
  input[type="number"], input[type="password"], input[type="file"], select, textarea {
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Flash */
  .flash { padding: 12px; font-size: 14px; }
}

@media (max-width: 500px) {
  .cards { grid-template-columns: 1fr; }
  .brand-title { font-size: 14px; }
  .topbar-right .btn-ghost { padding: 5px 8px; font-size: 12px; }
  .container { padding: 12px 8px; }
  .panel { padding: 12px; border-radius: 10px; }
  h2 { font-size: 18px; }
}

/* Onglets Parametres (desktop et mobile) */
.tabs-nav { display:flex; gap:2px; background:#fbfaf6; border-radius:10px; padding:4px; margin-bottom:16px; flex-wrap:wrap; }
.tabs-nav button {
  flex:1; min-width:120px; padding:10px 14px; border:0; background:transparent;
  font-family:inherit; font-size:14px; font-weight:600; color:#8a8275;
  border-radius:8px; cursor:pointer; transition:all 0.15s ease;
}
.tabs-nav button:hover { background:#f0eadb; color:#1f6f54; }
.tabs-nav button.active { background:#1f6f54; color:#fff; }
.tab-content { display:none; }
.tab-content.active { display:block; }
@media (max-width:900px) {
  .tabs-nav { flex-direction:column; }
  .tabs-nav button { flex:none; text-align:left; }
}
