*{box-sizing:border-box}
html,body{height:100%}
body{font-family:Arial,sans-serif;margin:0;background:linear-gradient(180deg,#f4f7ff 0%,#edf2fb 100%);color:#1d2433;overflow:hidden}
.auth-wrap{max-width:440px;margin:8vh auto;background:#fff;border-radius:8px;padding:24px;box-shadow:0 8px 24px rgba(0,0,0,.08)}
.field{margin-bottom:14px}
label{display:block;margin-bottom:6px;font-weight:700}
input,select,textarea{width:100%;padding:9px 10px;border:1px solid #cfd8ea;border-radius:8px;box-sizing:border-box;background:#fff;transition:border-color .16s ease, box-shadow .16s ease}
input:focus,select:focus,textarea:focus{outline:none;border-color:#4f7bff;box-shadow:0 0 0 3px rgba(79,123,255,.14)}
button{background:linear-gradient(180deg,#4374ff 0%,#2f62ff 100%);color:#fff;border:0;padding:10px 14px;border-radius:8px;cursor:pointer;font-weight:600;box-shadow:0 6px 14px rgba(47,98,255,.22)}
button:hover{filter:brightness(1.03)}
.btn-alt{background:#0f766e}
.error{background:#ffe8ea;color:#8b1f28;border:1px solid #f6c2c8;border-radius:6px;padding:10px;margin-bottom:12px}
.success{background:#e9f8ee;color:#145a2f;border:1px solid #b8e6c4;border-radius:6px;padding:10px;margin-bottom:12px}
.app-layout{display:flex;height:100vh;overflow:hidden}
.sidebar{width:220px;background:linear-gradient(180deg,#0f172a 0%,#111827 100%);color:#d1d5db;padding:14px;box-sizing:border-box;display:flex;flex-direction:column;border-right:1px solid rgba(255,255,255,.08)}
.brand{font-size:20px;color:#fff;margin-bottom:24px;font-weight:700;letter-spacing:.2px}
.menu{flex:1}
.menu a{display:block;color:#d1d5db;text-decoration:none;padding:10px 12px;border-radius:8px;margin-bottom:6px;border:1px solid transparent;transition:all .15s ease}
.menu a:hover{background:#1b2940;color:#fff;border-color:#2a3c59}
.menu a.active{background:#243756;color:#fff;border-color:#335082}
.sidebar-user{color:#9ca3af;font-size:12px;padding:10px 12px;border-top:1px solid #374151}
.main{flex:1;padding:12px;box-sizing:border-box;display:flex;flex-direction:column;min-height:0;overflow:hidden}
.topbar{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px}
.table-wrap{overflow-x:hidden;overflow-y:hidden;background:#fff;border:1px solid #dfe5f3;border-radius:10px;flex:1;min-height:0;box-shadow:0 8px 20px rgba(20,33,58,.06)}
.table-wrap form{height:100%;display:flex;flex-direction:column;min-height:0}
.table-wrap table{width:100%;border-collapse:collapse;font-size:13px;table-layout:fixed;display:flex;flex-direction:column;height:100%}
.table-wrap thead,.table-wrap tfoot{display:table;width:100%;table-layout:fixed}
.table-wrap tbody{display:block;overflow-y:auto;overflow-x:hidden;flex:1;min-height:0;width:100%}
.table-wrap tbody tr{display:table;width:100%;table-layout:fixed}
.table-wrap tbody{scrollbar-gutter:stable}
th{background:#eef2fb;text-align:left;padding:5px 6px;border:1px solid #d7deee;white-space:normal;word-break:break-word;color:#1b2a44}
td{padding:4px 6px;border:1px solid #edf1fa;white-space:normal;word-break:break-word}
.table-wrap thead input,.table-wrap thead select{width:100%;padding:6px;border:1px solid #ccd2df;border-radius:4px;box-sizing:border-box;margin:2px 0}
.table-wrap tbody tr:nth-child(even){background:#fbfcff}
.table-wrap tbody tr:hover{background:#eef4ff}
.text-right{text-align:right}
.actions{margin-bottom:8px;display:flex;gap:10px;align-items:center}
.actions .import-form{margin-left:auto;display:flex;gap:8px;align-items:center}
.empty-home{background:#fff;border:1px solid #dfe5f3;border-radius:8px;min-height:360px}
.kpi-wrap{display:grid;grid-template-columns:1fr 1fr;gap:12px;min-height:0;align-content:stretch;flex:1}
.kpi-cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.kpi-card{background:linear-gradient(180deg,#ffffff 0%,#f7faff 100%);border:1px solid #dfe5f3;border-radius:12px;padding:12px;box-shadow:0 8px 24px rgba(22,34,63,.06)}
.kpi-label{font-size:12px;color:#667085}
.kpi-value{font-size:24px;font-weight:700;color:#0f2647;margin-top:4px}
.kpi-table{background:#fff;border:1px solid #dfe5f3;border-radius:12px;overflow:hidden;box-shadow:0 8px 24px rgba(22,34,63,.05);display:flex;flex-direction:column;min-height:0;height:100%}
.kpi-panels{display:grid;grid-template-columns:1fr 1fr;gap:10px;flex:1;min-height:0}
.kpi-title{margin:0;padding:10px 12px;border-bottom:1px solid #dfe5f3;font-size:15px;color:#0f2647;background:linear-gradient(180deg,#f9fbff 0%,#f1f6ff 100%)}
.kpi-entreprise-block{display:flex;flex-direction:column;gap:8px;background:#fff;border:1px solid #dfe5f3;border-radius:12px;padding:10px;min-height:0;height:100%;box-shadow:0 10px 28px rgba(17,30,58,.07)}
.kpi-entreprise-title{margin:0;font-size:18px;color:#0f2647}
.kpi-table-scroll{flex:1;min-height:0;overflow:auto}
.kpi-table table{width:100%;border-collapse:collapse;font-size:13px;table-layout:fixed;display:table;height:auto}
.kpi-table thead{display:table-header-group;width:auto;table-layout:fixed}
.kpi-table tbody{display:table-row-group;width:auto}
.kpi-table tr{display:table-row;width:auto}
.kpi-table table th{position:sticky;top:0;z-index:2;background:#f5f8ff}
.kpi-table table tbody tr:nth-child(even){background:#fbfcff}
.kpi-table table tbody tr:hover{background:#eef4ff}
.echeances-wrap{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px;min-height:0;overflow:auto}
.echeance-card{background:#fff;border:1px solid #dfe5f3;border-radius:12px;box-shadow:0 8px 20px rgba(20,33,58,.06);display:flex;flex-direction:column;min-height:0}
.echeance-title{margin:0;padding:10px 10px 4px;font-size:16px;color:#0f2647}
.echeance-meta{padding:0 10px 8px;color:#667085;font-size:12px;border-bottom:1px solid #e6ebf6}
.echeance-table-scroll{flex:1;min-height:0;overflow:auto}
.echeance-table{width:100%;border-collapse:collapse;font-size:12px;table-layout:fixed}
.echeance-table th{position:sticky;top:0;z-index:2;background:#f5f8ff}
.controle-panel{display:flex;flex-direction:column;min-height:0;flex:1}
.modal-backdrop{display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:50}
.modal-backdrop.open{display:block}
.modal{max-width:980px;margin:2.5vh auto;background:#fff;border-radius:14px;padding:0;box-shadow:0 16px 40px rgba(0,0,0,.28);max-height:95vh;overflow:hidden;border:1px solid #dfe5f3}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:14px 16px;background:linear-gradient(180deg,#f8faff,#eef3ff);border-bottom:1px solid #dfe5f3}
.modal-head h2{margin:0;font-size:28px;font-weight:700;color:#0f2647}
.modal .field{margin-bottom:0}
.modal label{margin-bottom:4px;font-size:12px;color:#23314d}
.modal input,.modal select{padding:8px 10px;font-size:13px;border:1px solid #cdd7e8;border-radius:8px;background:#fff}
.depense-form-grid{padding:14px 16px 10px;display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:10px 12px;overflow:auto;max-height:calc(95vh - 78px)}
.depense-form-grid .span-2{grid-column:span 2}
.depense-form-grid .span-3{grid-column:span 3}
.depense-form-grid .span-4{grid-column:span 4}
.depense-form-grid .span-6{grid-column:span 6}
.depense-form-grid .span-12{grid-column:1 / -1}
.depense-form-grid .full-row{grid-column:1 / -1}
.depense-form-grid .actions-row{grid-column:1 / -1;display:flex;justify-content:flex-end;gap:8px;padding-top:6px}
.depense-form-grid .actions-row button{min-width:110px}
