:root { --green: #1F4E3D; --green2: #2e6b55; --brown: #5B2A22; --bg: #f4f6f4; --card: #fff; --line: #dfe5e1; --txt: #1d2321; --muted: #6b746f; --yellow: #FFF9DB; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; color: var(--txt); background: var(--bg); }
#app { display: flex; height: 100vh; }
#sidebar { width: 240px; background: var(--green); color: #fff; display: flex; flex-direction: column; padding: 16px 12px; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 14px; border-bottom: 1px solid rgba(255,255,255,.2); margin-bottom: 8px; }
.brand img { width: 52px; height: 52px; border-radius: 50%; background: #fff; object-fit: cover; }
.brand b { display: block; font-size: 13px; line-height: 1.2; } .brand small { opacity: .8; }
nav { display: flex; flex-direction: column; gap: 4px; }
.nav { background: transparent; color: #fff; border: 0; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.nav:hover { background: rgba(255,255,255,.12); } .nav.active { background: rgba(255,255,255,.22); font-weight: 600; }
.sidefoot { margin-top: auto; font-size: 12px; opacity: .85; display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; }
#content { flex: 1; overflow: auto; padding: 22px 28px; }
h1 { margin: 0 0 16px; font-size: 22px; color: var(--green); } h2 { margin: 0 0 10px; font-size: 15px; color: var(--green); }
.hidden { display: none !important; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kpi small { color: var(--muted); display: block; margin-bottom: 4px; } .kpi b { font-size: 18px; }
.pos { color: #1a7f37; } .neg { color: #b42318; }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
button:hover { background: #f0f3f1; }
button.primary { background: var(--green); color: #fff; border-color: var(--green); } button.primary:hover { background: var(--green2); }
button.danger { color: #b42318; border-color: #f1c5c0; } button.big { padding: 12px; font-size: 15px; margin-top: 8px; }
button.icon { padding: 4px 8px; font-size: 12px; margin-left: 4px; }
input, select { font: inherit; padding: 7px 9px; border: 1px solid #c9d2cc; border-radius: 7px; background: #fff; }
input:focus, select:focus { outline: 2px solid #9ec5b2; border-color: var(--green); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
label input, label select { color: var(--txt); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; } .toolbar h1 { margin: 0 12px 0 0; }
.toolbar input[type=search] { flex: 1; min-width: 180px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.summary { display: flex; gap: 18px; font-size: 13px; color: var(--muted); margin-bottom: 8px; } .summary b { color: var(--txt); }
.tablewrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: calc(100vh - 190px); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { position: sticky; top: 0; background: var(--green); color: #fff; text-align: left; padding: 8px 10px; font-weight: 600; white-space: nowrap; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid #eef1ef; vertical-align: middle; }
.tbl tr:hover td { background: #f6f9f7; } .tbl .r { text-align: right; white-space: nowrap; }
.tbl td.in { color: #1a7f37; font-weight: 600; } .tbl td.out { color: #b42318; font-weight: 600; }
.tbl td.neg { color: #b42318; }
.tag { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: 11px; background: #e8f0ec; color: var(--green); }
.tag.Banque { background: #e6edf7; color: #1f3f7a; }
.bar { height: 8px; background: #e6ebe8; border-radius: 4px; overflow: hidden; margin: 2px 0 8px; } .bar i { display: block; height: 100%; background: var(--green2); }
.topcat { display: flex; justify-content: space-between; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; } code { background: #eef1ef; padding: 2px 5px; border-radius: 4px; font-size: 12px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.dialog { background: #fff; border-radius: 12px; padding: 22px 24px; width: 680px; max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; } .span2 { grid-column: span 2; }
.actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; } .spacer { flex: 1; }
#toast { position: fixed; bottom: 20px; right: 20px; background: #1d2321; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 20; }

#tblJournal { table-layout: fixed; } #tblJournal th:nth-child(1){width:98px} #tblJournal th:nth-child(2){width:76px} #tblJournal th:nth-child(3){width:84px} #tblJournal th:nth-child(4){width:30%} #tblJournal th:nth-child(5){width:19%} #tblJournal th:nth-child(7),#tblJournal th:nth-child(8),#tblJournal th:nth-child(9){width:108px} #tblJournal th:nth-child(10){width:132px}
#tblJournal td { word-wrap: break-word; } #tblJournal td small { font-size: 11px; }
#tblLast td:first-child { white-space: nowrap; } .tag { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.kpi b { white-space: nowrap; font-size: 17px; }
#tblJournal td:first-child { white-space: nowrap; } #tblJournal td:nth-child(5){ font-size:12px; }

/* ---- v2 gestion ---- */
.login { position: fixed; inset: 0; background: linear-gradient(135deg, #1F4E3D, #2e6b55); display: flex; align-items: center; justify-content: center; }
.loginbox { background: #fff; border-radius: 14px; padding: 28px 32px; width: 380px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.loginbox img { width: 96px; height: 96px; border-radius: 50%; } .loginbox h1 { font-size: 18px; color: var(--brown); margin: 8px 0 2px; }
.loginbox label { text-align: left; } .loginbox form { margin-top: 14px; } .loginbox .small { font-size: 11.5px; margin-top: 14px; }
.err { color: #b42318; font-size: 13px; margin: 6px 0; }
.sidefoot .row { margin: 6px 0; } button.mini { padding: 4px 8px; font-size: 12px; background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.25); }
.nav small { display: block; font-size: 11px; opacity: .7; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); } .tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; padding: 8px 14px; color: var(--muted); } .tabs button.active { color: var(--green); border-bottom-color: var(--green); font-weight: 600; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; } .span3 { grid-column: span 3; }
.dialog.wide { width: 900px; }
.tbl td.actions { white-space: nowrap; text-align: right; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.ok { background: #e3f5e8; color: #1a7f37; } .badge.warn { background: #fff3cd; color: #8a6d00; } .badge.bad { background: #fde8e6; color: #b42318; } .badge.info { background: #e6edf7; color: #1f3f7a; }
.perm-table td { text-align: center; } .perm-table td:first-child { text-align: left; font-weight: 600; } .perm-table input { width: 18px; height: 18px; }
.readonly-note { background: var(--yellow); border: 1px solid #e8d98a; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.kpis.k4 { grid-template-columns: repeat(4, 1fr); } .kpis.k5 { grid-template-columns: repeat(5, 1fr); }
.calc { background: #f2f2f2 !important; color: #444; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; margin: 0 0 10px; } legend { color: var(--green); font-weight: 600; font-size: 13px; padding: 0 6px; }
.help { font-size: 12px; color: var(--muted); margin: -6px 0 10px; }

/* ---- écrans étroits (tablette / téléphone) ---- */
@media (max-width: 900px) {
  #app { flex-direction: column; height: auto; min-height: 100vh; }
  #sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 10px; gap: 6px; }
  .brand { border: 0; padding: 0 8px 0 0; margin: 0; } .brand img { width: 36px; height: 36px; } .brand small { display: none; }
  nav { flex-direction: row; flex-wrap: wrap; gap: 2px; } .nav { padding: 6px 9px; font-size: 13px; }
  .sidefoot { margin: 0 0 0 auto; flex-direction: row; align-items: center; gap: 8px; padding: 0; } .sidefoot > div:first-child { display: none; }
  #content { padding: 12px; } .two { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, 1fr) !important; }
  .grid, .grid3 { grid-template-columns: 1fr; } .span2, .span3 { grid-column: span 1; } .dialog, .dialog.wide { width: 96vw; padding: 14px; max-height: 92vh; overflow: auto; }
  .tablewrap { max-height: none; } .toolbar h1 { width: 100%; }
}
