/* Budget Famille — même langage visuel que le logiciel de devis et factures */
:root{
  --primary:#6664DF; --primary-d:#5250C9; --active:#F0F2FE; --title:#263344; --search:#F4F8FB;
  --text:#41505F; --muted:#7C8A99; --line:#E6EBF1; --bg:#FAFBFD; --card:#fff;
  --green:#1FA971; --green-bg:#E7F7F0; --red:#E5484D; --red-bg:#FDECEC; --orange:#E8890C; --orange-bg:#FFF3E0;
  --radius:12px; --sidebar:236px;
}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;font:15px/1.45 Inter,"Segoe UI",system-ui,-apple-system,Roboto,sans-serif;color:var(--text);background:var(--bg)}
h1,h2,h3{color:var(--title);margin:0;letter-spacing:-.01em}
h1{font-size:24px;font-weight:700} h2{font-size:17px;font-weight:650} h3{font-size:15px;font-weight:650}
a{color:var(--primary);text-decoration:none}
button,input,select,textarea{font:inherit;color:inherit}
.muted{color:var(--muted)} .lead{margin:-4px 0 18px;max-width:70ch} .center{text-align:center;margin:18px 0}
.num{font-variant-numeric:tabular-nums} .pos{color:var(--green)} .neg{color:var(--red)}
[hidden]{display:none!important}
.ico{flex:none}

/* ---------- structure ---------- */
.app{display:grid;grid-template-columns:var(--sidebar) 1fr;min-height:100vh}
.sidebar{position:sticky;top:0;height:100vh;background:#fff;border-right:1px solid var(--line);display:flex;flex-direction:column;padding:18px 12px;z-index:30}
.brand{display:flex;gap:10px;align-items:center;padding:4px 8px 18px}
.brand strong{display:block;color:var(--title);font-size:15px;line-height:1.2} .brand small{color:var(--muted);font-size:12px}
.brand-mark{width:34px;height:34px;border-radius:10px;background:var(--primary);color:#fff;display:grid;place-items:center;font-weight:800}
.menu{display:flex;flex-direction:column;gap:2px}
.menu a{display:flex;gap:11px;align-items:center;padding:9px 10px;border-radius:9px;color:var(--text);font-weight:500}
.menu a:hover{background:var(--search)} .menu a.active{background:var(--active);color:var(--primary);font-weight:650}
.menu-bottom{margin-top:auto;border-top:1px solid var(--line);padding-top:10px}
.main{min-width:0}
.content{padding:26px 32px 90px;max-width:1280px;margin:0 auto}
.topbar{display:none}
.scrim{display:none}
.fab{display:none}
.page-head{display:flex;justify-content:space-between;align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:20px}
.head-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}

/* ---------- boutons & champs ---------- */
.btn{display:inline-flex;gap:8px;align-items:center;justify-content:center;border:1px solid transparent;border-radius:10px;padding:9px 16px;font-weight:600;cursor:pointer;background:#fff;transition:background .15s,border-color .15s}
.btn-primary{background:var(--primary);color:#fff} .btn-primary:hover{background:var(--primary-d)}
.btn-ghost{border-color:var(--line);color:var(--title)} .btn-ghost:hover{background:var(--search)}
.btn-danger{color:var(--red);border-color:#F6CACB} .btn-danger:hover{background:var(--red-bg)}
.btn-sm{padding:6px 11px;font-size:13px} .btn-block{width:100%}
.btn:disabled{opacity:.55;cursor:default}
.icon-btn{display:inline-grid;place-items:center;width:38px;height:38px;border:0;border-radius:10px;background:transparent;color:var(--title);cursor:pointer}
.icon-btn:hover{background:var(--search)} .icon-btn.light{color:#fff;background:rgba(0,0,0,.35)}
:focus-visible{outline:2px solid var(--primary);outline-offset:2px}
.field{display:flex;flex-direction:column;gap:5px;margin-bottom:14px}
.field>span{font-size:13px;font-weight:600;color:var(--title)}
input[type=text],input[type=number],input[type=date],input[type=password],input[type=search],input[type=email],select,textarea{width:100%;padding:9px 12px;border:1px solid var(--line);border-radius:10px;background:#fff;min-height:40px}
input:focus,select:focus,textarea:focus{outline:2px solid var(--active);border-color:var(--primary)}
textarea{min-height:70px;resize:vertical}
input[type=color]{width:44px;height:40px;padding:2px;border:1px solid var(--line);border-radius:10px;background:#fff}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:12px} .row3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.inline{display:flex;gap:8px;align-items:center}
.search{position:relative;flex:1;min-width:220px}
.search .ico{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--muted)}
.search input{background:var(--search);border-color:transparent;padding-left:38px}
.tabs{display:inline-flex;background:var(--search);border-radius:10px;padding:3px}
.tabs button{border:0;background:transparent;padding:6px 14px;border-radius:8px;cursor:pointer;font-weight:600;color:var(--muted)}
.tabs button.on{background:#fff;color:var(--primary);box-shadow:0 1px 3px rgba(38,51,68,.12)}
.seg{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:16px}
.seg button{border:1px solid var(--line);background:#fff;border-radius:10px;padding:10px;cursor:pointer;font-weight:650}
.seg button.on.exp{background:var(--red-bg);border-color:#F6CACB;color:var(--red)} .seg button.on.inc{background:var(--green-bg);border-color:#BDE7D5;color:var(--green)}

/* ---------- cartes & grilles ---------- */
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:18px 20px}
.card-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;gap:10px}
.grid{display:grid;gap:16px}
.g4{grid-template-columns:repeat(4,1fr)} .g3{grid-template-columns:repeat(3,1fr)} .g2{grid-template-columns:1.25fr 1fr}
.stat{padding:16px 18px}
.stat small{color:var(--muted);font-weight:600;display:block;margin-bottom:6px}
.stat strong{display:block;font-size:24px;color:var(--title);letter-spacing:-.02em;font-variant-numeric:tabular-nums}
.stat em{font-style:normal;font-size:12.5px;color:var(--muted)}
.chip{display:inline-flex;align-items:center;gap:5px;padding:2px 9px;border-radius:99px;font-size:12px;font-weight:650;background:var(--active);color:var(--primary)}
.chip.green{background:var(--green-bg);color:var(--green)} .chip.red{background:var(--red-bg);color:var(--red)} .chip.orange{background:var(--orange-bg);color:var(--orange)}
.dot{width:10px;height:10px;border-radius:50%;display:inline-block;flex:none}
.badge-ico{width:38px;height:38px;border-radius:11px;display:grid;place-items:center;font-size:19px;flex:none}
.empty{text-align:center;padding:38px 16px;color:var(--muted)} .empty h3{margin-bottom:6px}
.alert{padding:10px 14px;border-radius:10px;margin-bottom:14px;font-size:14px} .alert-error{background:var(--red-bg);color:#B42328} .alert-warn{background:var(--orange-bg);color:#9A5B05} .alert-ok{background:var(--green-bg);color:#157A52}
.skeleton{height:220px;border-radius:var(--radius);background:linear-gradient(90deg,#EEF2F6,#F8FAFC,#EEF2F6);background-size:200% 100%;animation:sk 1.4s infinite}
@keyframes sk{to{background-position:-200% 0}}

/* ---------- barres de progression ---------- */
.bar{height:8px;border-radius:99px;background:#EDF1F6;overflow:hidden} .bar>i{display:block;height:100%;border-radius:99px;background:var(--primary);transition:width .4s}
.bar.ok>i{background:var(--green)} .bar.warn>i{background:var(--orange)} .bar.over>i{background:var(--red)}
.bcat{display:grid;grid-template-columns:38px 1fr auto;gap:12px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)} .bcat:last-child{border:0}
.bcat .top{display:flex;justify-content:space-between;gap:8px;margin-bottom:6px;font-weight:600;color:var(--title)}
.bcat .top span:last-child{font-weight:500;color:var(--muted);font-size:13px}
.bamt{width:112px} .bamt input{text-align:right}

/* ---------- mois ---------- */
.month-bar{display:inline-flex;align-items:center;background:#fff;border:1px solid var(--line);border-radius:10px}
.month-bar button{border:0;background:transparent;width:36px;height:38px;cursor:pointer;color:var(--title);display:grid;place-items:center;border-radius:10px}
.month-bar button:hover{background:var(--search)}
.month-bar span{min-width:128px;text-align:center;font-weight:650;color:var(--title);text-transform:capitalize}

/* ---------- transactions ---------- */
.filters{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
.filters-row select{width:auto;min-width:150px}
.summary-strip{display:flex;gap:22px;flex-wrap:wrap;padding:6px 2px 14px;color:var(--muted);font-size:14px} .summary-strip b{color:var(--title)}
.tx-list{background:#fff;border:1px solid var(--line);border-radius:var(--radius);overflow:hidden}
.day-head{display:flex;justify-content:space-between;padding:9px 18px;background:var(--search);font-size:13px;font-weight:650;color:var(--muted);text-transform:capitalize}
.tx{display:grid;grid-template-columns:38px minmax(0,1fr) 170px 120px 118px;gap:14px;align-items:center;padding:11px 18px;border-top:1px solid var(--line);cursor:pointer}
.tx:hover{background:#FBFCFF}
.tx .t1{font-weight:600;color:var(--title);white-space:nowrap;overflow:hidden;text-overflow:ellipsis} .tx .t2{font-size:13px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tx .who{font-size:13px;color:var(--muted)} .tx .amt{text-align:right;font-weight:700;font-variant-numeric:tabular-nums}
.tx .cat-col{font-size:13px} .tx .clip{color:var(--muted);vertical-align:-3px;margin-left:4px}

/* ---------- panneau latéral ---------- */
.overlay{position:fixed;inset:0;background:rgba(38,51,68,.38);z-index:60;animation:fade .15s}
.panel{position:fixed;top:0;right:0;bottom:0;width:min(470px,100vw);background:#fff;z-index:61;display:flex;flex-direction:column;box-shadow:-12px 0 40px rgba(38,51,68,.16);animation:slide .22s}
.panel-head{display:flex;justify-content:space-between;align-items:center;padding:16px 20px;border-bottom:1px solid var(--line)}
.panel-body{padding:20px;overflow:auto;flex:1}
.panel-foot{padding:14px 20px calc(14px + env(safe-area-inset-bottom));border-top:1px solid var(--line);display:flex;gap:10px;justify-content:space-between}
.panel-foot .right{display:flex;gap:10px;margin-left:auto}
@keyframes slide{from{transform:translateX(30px);opacity:0}} @keyframes fade{from{opacity:0}}
.receipt-prev{display:block;width:100%;max-height:220px;object-fit:contain;background:var(--search);border-radius:10px;margin-bottom:14px}
#toasts{position:fixed;left:50%;bottom:22px;transform:translateX(-50%);z-index:90;display:flex;flex-direction:column;gap:8px;align-items:center;width:max-content;max-width:92vw}
.toast{background:var(--title);color:#fff;padding:10px 16px;border-radius:10px;box-shadow:0 6px 24px rgba(38,51,68,.3);font-weight:500}
.toast.error{background:#B42328}

/* ---------- graphiques ---------- */
.donut-wrap{display:flex;gap:22px;align-items:center;flex-wrap:wrap}
.legend{flex:1;min-width:200px;display:flex;flex-direction:column;gap:7px}
.legend div{display:flex;align-items:center;gap:9px;font-size:14px} .legend .nm{flex:1;color:var(--title);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.legend .pc{color:var(--muted);font-size:12.5px;width:40px;text-align:right}
.bars-svg text{font-size:11px;fill:var(--muted)}
.lg-dot{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted);margin-left:14px}
.list-row{display:flex;gap:12px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)} .list-row:last-child{border:0}
.list-row .grow{flex:1;min-width:0} .list-row .grow b{display:block;color:var(--title);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.list-row small{color:var(--muted)}
.table-wrap{overflow-x:auto}
.tbl{width:100%;border-collapse:collapse;font-size:13.5px;font-variant-numeric:tabular-nums} .tbl th,.tbl td{padding:8px 10px;text-align:right;border-bottom:1px solid var(--line);white-space:nowrap}
.tbl th:first-child,.tbl td:first-child{text-align:left;position:sticky;left:0;background:#fff} .tbl th{color:var(--muted);font-weight:600;font-size:12.5px}
.tbl tfoot td{font-weight:700;color:var(--title)}

/* ---------- récurrents / objectifs ---------- */
.rec-row{display:grid;grid-template-columns:38px minmax(0,1fr) 150px 120px 90px;gap:14px;align-items:center;padding:12px 18px;border-top:1px solid var(--line);cursor:pointer} .rec-row:first-child{border-top:0}
.rec-row:hover{background:#FBFCFF}
.goal-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px}
.goal .gtop{display:flex;gap:12px;align-items:center;margin-bottom:14px} .goal .gamt{display:flex;justify-content:space-between;margin:10px 0 4px;font-variant-numeric:tabular-nums}
.goal .gamt b{color:var(--title);font-size:19px}
.goal .actions{display:flex;gap:8px;margin-top:14px}

/* ---------- réglages ---------- */
.settings{display:grid;grid-template-columns:210px 1fr;gap:26px;align-items:start}
.ssn-group{display:flex;flex-direction:column;gap:2px;position:sticky;top:20px}
.ssn-group a{padding:9px 12px;border-radius:9px;color:var(--text);font-weight:500} .ssn-group a:hover{background:var(--search)} .ssn-group a.active{background:var(--active);color:var(--primary);font-weight:650}
.ssn-body .card{margin-bottom:16px} .ssn-body h2{margin-bottom:4px} .ssn-body .sub{color:var(--muted);margin:0 0 16px}
.item-row{display:flex;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--line)} .item-row:first-of-type{border-top:0}
.item-row .grow{flex:1;min-width:0} .item-row .grow small{display:block;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.swatches{display:flex;gap:8px;flex-wrap:wrap}
.swatches button{width:30px;height:30px;border-radius:50%;border:3px solid #fff;box-shadow:0 0 0 1px var(--line);cursor:pointer}
.swatches button.on{box-shadow:0 0 0 2px var(--title)}
.emoji-pick{display:flex;gap:6px;flex-wrap:wrap}
.emoji-pick button{width:36px;height:36px;border-radius:9px;border:1px solid var(--line);background:#fff;font-size:18px;cursor:pointer} .emoji-pick button.on{border-color:var(--primary);background:var(--active)}
.preview-table{max-height:340px;overflow:auto;border:1px solid var(--line);border-radius:10px;margin-top:12px}

/* ---------- scanner ---------- */
.dropzone{text-align:center;padding:34px 20px;border:2px dashed #CFD6F7;background:#FBFBFF} .dropzone.over{background:var(--active);border-color:var(--primary)}
.dz-icon{width:64px;height:64px;border-radius:18px;background:var(--active);color:var(--primary);display:grid;place-items:center;margin:0 auto 12px}
.dropzone p{max-width:56ch;margin:6px auto 18px} .dz-actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-bottom:12px}
.scan-results{display:flex;flex-direction:column;gap:14px;margin-top:18px}
.scan-card{display:grid;grid-template-columns:150px 1fr;gap:18px;background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:16px}
.scan-card.saved{opacity:.6} .scan-thumb{width:100%;max-height:230px;object-fit:cover;object-position:top;border-radius:10px;background:var(--search);cursor:zoom-in}
.scan-card .fields{display:grid;grid-template-columns:1fr 1fr;gap:10px 12px} .scan-card .fields .field{margin:0} .scan-card .full{grid-column:1/-1}
.scan-card .acts{display:flex;gap:8px;justify-content:flex-end;margin-top:12px;grid-column:1/-1;flex-wrap:wrap}
.scan-status{display:flex;gap:10px;align-items:center;color:var(--muted);padding:20px 0}
.spin{width:20px;height:20px;border:3px solid var(--active);border-top-color:var(--primary);border-radius:50%;animation:rot .8s linear infinite} @keyframes rot{to{transform:rotate(360deg)}}
details.raw summary{cursor:pointer;color:var(--primary);font-weight:600;font-size:13px} details.raw pre{white-space:pre-wrap;background:var(--search);padding:10px;border-radius:8px;font-size:12px;max-height:200px;overflow:auto}
.sticky-bar{position:sticky;bottom:14px;margin-top:16px;display:flex;justify-content:space-between;align-items:center;gap:12px;background:var(--title);color:#fff;padding:10px 12px 10px 18px;border-radius:14px;box-shadow:0 10px 30px rgba(38,51,68,.3)}
.cam{position:fixed;inset:0;background:#000;z-index:80;display:flex;flex-direction:column}
.cam video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.cam-frame{position:absolute;inset:11% 7% 24%;border:2px solid rgba(255,255,255,.85);border-radius:16px;box-shadow:0 0 0 100vmax rgba(0,0,0,.35);pointer-events:none}
.cam-top{position:absolute;top:0;left:0;right:0;display:flex;justify-content:space-between;align-items:center;padding:calc(12px + env(safe-area-inset-top)) 14px 12px;color:#fff;font-weight:650}
.cam-bottom{position:absolute;bottom:0;left:0;right:0;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:12px;padding:16px 16px calc(18px + env(safe-area-inset-bottom));background:linear-gradient(transparent,rgba(0,0,0,.6))}
.cam-bottom .btn{justify-self:end}
.shutter{width:70px;height:70px;border-radius:50%;border:5px solid #fff;background:rgba(255,255,255,.25);cursor:pointer} .shutter:active{background:#fff}
.cam-thumbs{display:flex;gap:6px;overflow:hidden} .cam-thumbs img{width:42px;height:56px;object-fit:cover;border-radius:6px;border:2px solid #fff}
.cam-msg{position:absolute;left:20px;right:20px;top:40%;background:#fff;padding:18px;border-radius:14px;text-align:center}

/* ---------- connexion ---------- */
.login-body{display:grid;place-items:center;min-height:100vh;padding:20px;background:var(--active)}
.login-card{background:#fff;width:min(400px,100%);padding:28px;border-radius:16px;box-shadow:0 16px 50px rgba(38,51,68,.12)} .login-card h1{font-size:21px;margin:6px 0} .login-card p{margin:0 0 18px}

/* ---------- mobile ---------- */
@media (max-width:1050px){.g4{grid-template-columns:repeat(2,1fr)} .g2,.g3{grid-template-columns:1fr}}
@media (max-width:860px){
  .app{grid-template-columns:1fr}
  .sidebar{position:fixed;left:0;top:0;bottom:0;width:272px;transform:translateX(-102%);transition:transform .22s;box-shadow:12px 0 40px rgba(38,51,68,.2)}
  .sidebar.open{transform:none} .scrim.show{display:block;position:fixed;inset:0;background:rgba(38,51,68,.4);z-index:25}
  .topbar{display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:#fff;border-bottom:1px solid var(--line);padding:calc(6px + env(safe-area-inset-top)) 10px 6px;z-index:20}
  .content{padding:18px 14px 96px} .page-head h1{font-size:21px} .page-head{margin-bottom:14px}
  .fab{display:grid;place-items:center;position:fixed;right:16px;bottom:calc(18px + env(safe-area-inset-bottom));width:56px;height:56px;border-radius:50%;background:var(--primary);color:#fff;box-shadow:0 8px 22px rgba(102,100,223,.5);z-index:40}
  body:has(.cam:not([hidden])) .fab{display:none}
  .head-actions{width:100%} .head-actions .btn-primary{flex:1}
  .g4{grid-template-columns:1fr 1fr} .stat strong{font-size:20px}
  .tx{grid-template-columns:38px minmax(0,1fr) auto;gap:11px;padding:11px 14px} .tx .cat-col,.tx .who{display:none}
  .rec-row{grid-template-columns:38px minmax(0,1fr) auto;padding:12px 14px} .rec-row .hide-m{display:none}
  .settings{grid-template-columns:1fr} .ssn-group{flex-direction:row;overflow-x:auto;position:static;gap:4px;padding-bottom:4px} .ssn-group a{white-space:nowrap}
  .scan-card{grid-template-columns:1fr} .scan-thumb{max-height:170px}
  .row3{grid-template-columns:1fr 1fr} .bamt{width:92px}
  .filters-row select{flex:1;min-width:120px}
}
@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
