/* ==========================================================================
   L-winner — feuille de style
   Couleurs KWK-COM : bleu profond et or, sur fond papier.
   ========================================================================== */

:root{
  --blue:#1F4E9C; --blue-dark:#16386F; --blue-soft:#EAF0FA; --blue-line:#C9D8F0;
  --gold:#B8860B; --gold-soft:#FBF3DF;
  --ink:#1A1D23; --slate:#5B6472; --mute:#8A93A2;
  --paper:#FFFFFF; --canvas:#F4F6FA; --line:#E3E7EE; --line-soft:#EFF2F7;
  --ok:#1E7A46; --ok-bg:#E6F5EC;
  --warn:#9A6B00; --warn-bg:#FDF3DD;
  --bad:#B3261E; --bad-bg:#FBEAEA;
  --info:#1F4E9C; --info-bg:#EAF0FA;
  --radius:12px; --radius-sm:8px;
  --shadow:0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg:0 8px 32px rgba(16,24,40,.12);
  --sans:'Inter','Segoe UI',system-ui,-apple-system,'Helvetica Neue',Arial,sans-serif;
  --serif:'Source Serif 4',Georgia,'Times New Roman',serif;
  --sidebar-w:250px;
}

*{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
body{
  margin:0; font-family:var(--sans); font-size:14.5px; line-height:1.55;
  color:var(--ink); background:var(--canvas);
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;
}
a{color:var(--blue); text-decoration:none;}
a:hover{text-decoration:underline;}
h1,h2,h3{margin:0; font-weight:700; letter-spacing:-.01em;}
.skip{position:absolute; left:-9999px;}
.skip:focus{left:12px; top:12px; background:#fff; padding:10px 14px; z-index:99; border-radius:8px;}

/* ---------- Structure ---------- */
.shell{display:flex; min-height:100vh;}
.sidebar{
  width:var(--sidebar-w); flex:0 0 var(--sidebar-w); background:var(--blue);
  color:#fff; display:flex; flex-direction:column; position:sticky; top:0; height:100vh;
  background-image:linear-gradient(180deg,#22539F 0%,#1A4285 100%);
}
.brand{display:flex; align-items:center; gap:12px; padding:20px 18px 18px;}
.brand-logo{width:44px; height:44px; object-fit:contain; flex:0 0 44px;
  background:#fff; border-radius:10px; padding:4px;}
.brand-text{display:flex; flex-direction:column; min-width:0;}
.brand-name{font-size:17px; font-weight:800; letter-spacing:-.02em; line-height:1.1;}
.brand-sub{font-size:11.5px; color:#BDD0EC; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.nav{display:flex; flex-direction:column; gap:2px; padding:8px 10px; flex:1; overflow-y:auto;}
.nav-link{
  display:flex; align-items:center; gap:11px; padding:10px 12px; border-radius:9px;
  color:#D7E3F5; font-size:14px; font-weight:500; transition:background .14s,color .14s;
}
.nav-link svg{width:19px; height:19px; flex:0 0 19px; opacity:.85;}
.nav-link:hover{background:rgba(255,255,255,.10); color:#fff; text-decoration:none;}
.nav-link.active{background:#fff; color:var(--blue); font-weight:650;}
.nav-link.active svg{opacity:1;}
.nav-link.small{font-size:13px; padding:7px 12px;}
.sidebar-foot{padding:12px 10px 16px; border-top:1px solid rgba(255,255,255,.14);}
.who{padding:2px 12px 8px; font-size:12px; color:#BDD0EC; overflow:hidden; text-overflow:ellipsis;}

.main-col{flex:1; min-width:0; display:flex; flex-direction:column;}
.topbar{
  position:sticky; top:0; z-index:15; background:rgba(255,255,255,.92);
  backdrop-filter:saturate(180%) blur(8px); border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:14px; padding:0 26px; min-height:62px;
}
.page-title{font-size:19px; font-weight:700; flex:1; min-width:0;}
.topbar-actions{display:flex; gap:8px; align-items:center; flex-wrap:wrap;}
.burger{display:none; background:none; border:none; padding:6px; cursor:pointer; color:var(--ink);}
.burger svg{width:22px; height:22px;}
.content{padding:26px; max-width:1240px; width:100%;}
.scrim{display:none; position:fixed; inset:0; background:rgba(12,18,32,.45); z-index:19;}

/* ---------- Éléments ---------- */
.card{background:var(--paper); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px 22px;}
.card + .card{margin-top:18px;}
.card-head{display:flex; align-items:center; justify-content:space-between; gap:12px;
  margin:-2px 0 16px; flex-wrap:wrap;}
.card-head h2{font-size:15.5px;}
.card-head .sub{font-size:12.5px; color:var(--slate); font-weight:500;}
.grid{display:grid; gap:18px;}
.grid.cols-4{grid-template-columns:repeat(4,1fr);}
.grid.cols-3{grid-template-columns:repeat(3,1fr);}
.grid.cols-2{grid-template-columns:repeat(2,1fr);}

.btn{
  display:inline-flex; align-items:center; gap:7px; font-family:var(--sans);
  font-size:13.5px; font-weight:600; padding:9px 15px; border-radius:9px;
  border:1px solid var(--line); background:#fff; color:var(--ink); cursor:pointer;
  transition:background .14s,border-color .14s,box-shadow .14s; text-decoration:none; line-height:1.2;
}
.btn:hover{background:#F8FAFD; border-color:#CBD4E3; text-decoration:none;}
.btn:focus-visible{outline:2px solid var(--gold); outline-offset:2px;}
.btn svg{width:16px; height:16px;}
.btn-primary{background:var(--blue); border-color:var(--blue); color:#fff;}
.btn-primary:hover{background:var(--blue-dark); border-color:var(--blue-dark);}
.btn-gold{background:var(--gold); border-color:var(--gold); color:#fff;}
.btn-gold:hover{background:#9C7009; border-color:#9C7009;}
.btn-danger{color:var(--bad); border-color:#F0CFCD;}
.btn-danger:hover{background:var(--bad-bg);}
.btn-sm{font-size:12.5px; padding:6px 11px; border-radius:8px;}
.btn[disabled]{opacity:.5; cursor:not-allowed;}

label.field{display:flex; flex-direction:column; gap:5px; font-size:12.5px;
  font-weight:600; color:var(--slate);}
input[type=text],input[type=email],input[type=password],input[type=number],
input[type=date],select,textarea{
  font-family:var(--sans); font-size:14px; color:var(--ink); background:#fff;
  border:1px solid var(--line); border-radius:8px; padding:9px 11px; width:100%;
  transition:border-color .14s, box-shadow .14s;
}
input:focus,select:focus,textarea:focus{outline:none; border-color:var(--blue);
  box-shadow:0 0 0 3px rgba(31,78,156,.12);}
textarea{resize:vertical; min-height:70px; line-height:1.5;}
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.form-grid .full{grid-column:1/-1;}
.form-actions{display:flex; gap:9px; flex-wrap:wrap; margin-top:18px;
  padding-top:16px; border-top:1px solid var(--line-soft);}
.hint{font-size:12.5px; color:var(--slate); line-height:1.55;}

table.data{width:100%; border-collapse:collapse;}
table.data th{font-size:11px; text-transform:uppercase; letter-spacing:.04em;
  color:var(--mute); font-weight:700; text-align:left; padding:9px 12px;
  border-bottom:1px solid var(--line); white-space:nowrap;}
table.data td{padding:12px; border-bottom:1px solid var(--line-soft); font-size:14px; vertical-align:middle;}
table.data tr:last-child td{border-bottom:none;}
table.data tbody tr:hover{background:#FAFBFE;}
table.data .num{text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap;}
table.data .actions{text-align:right; white-space:nowrap;}
.table-wrap{overflow-x:auto; margin:0 -22px -20px; padding:0 22px;}
.doc-num{font-weight:650; color:var(--blue); font-variant-numeric:tabular-nums;}

.pill{display:inline-block; padding:3px 10px; border-radius:20px; font-size:11.5px;
  font-weight:700; white-space:nowrap;}
.pill.ok{background:var(--ok-bg); color:var(--ok);}
.pill.warn{background:var(--warn-bg); color:var(--warn);}
.pill.bad{background:var(--bad-bg); color:var(--bad);}
.pill.info{background:var(--info-bg); color:var(--info);}
.pill.muted{background:#EEF0F4; color:var(--slate);}

.stat{background:var(--paper); border:1px solid var(--line); border-radius:var(--radius);
  padding:18px 20px; box-shadow:var(--shadow);}
.stat .label{font-size:12px; color:var(--slate); font-weight:600; text-transform:uppercase;
  letter-spacing:.04em;}
.stat .value{font-size:26px; font-weight:800; letter-spacing:-.02em; margin-top:6px;
  font-variant-numeric:tabular-nums;}
.stat .value.small{font-size:21px;}
.stat .meta{font-size:12.5px; color:var(--slate); margin-top:4px;}
.stat.accent{border-left:3px solid var(--blue);}
.stat.accent-gold{border-left:3px solid var(--gold);}
.stat.accent-bad{border-left:3px solid var(--bad);}
.stat.accent-ok{border-left:3px solid var(--ok);}

.flash{padding:11px 15px; border-radius:9px; font-size:13.5px; font-weight:600; margin-bottom:18px;}
.flash.ok{background:var(--ok-bg); color:var(--ok);}
.flash.err{background:var(--bad-bg); color:var(--bad);}
.flash.info{background:var(--info-bg); color:var(--info);}

.empty{text-align:center; padding:44px 16px; color:var(--slate);}
.empty svg{width:38px; height:38px; color:var(--blue-line); margin-bottom:10px;}
.empty p{margin:0 0 14px;}

.pager{display:flex; align-items:center; justify-content:center; gap:14px;
  margin-top:16px; padding-top:14px; border-top:1px solid var(--line-soft);}
.pager .hint{font-weight:600;}
.filters{display:flex; gap:10px; flex-wrap:wrap; align-items:end; margin-bottom:16px;}
.filters .field{min-width:150px;}
.filters input,.filters select{font-size:13.5px; padding:8px 10px;}

/* ---------- Connexion / installation ---------- */
body.centered{display:flex; align-items:center; justify-content:center; min-height:100vh;
  padding:24px; background:linear-gradient(160deg,#1F4E9C 0%,#16386F 55%,#0F2A55 100%);}
.auth-card{background:#fff; border-radius:16px; box-shadow:var(--shadow-lg);
  padding:34px 34px 30px; width:100%; max-width:430px;}
.auth-card.wide{max-width:640px;}
.auth-logo{display:block; width:88px; height:auto; margin:0 auto 16px;}
.auth-card h1{font-size:21px; text-align:center; margin-bottom:4px;}
.auth-card .sub{text-align:center; color:var(--slate); font-size:13.5px; margin:0 0 22px;}
.auth-card label.field{margin-bottom:14px;}
.auth-card .btn{width:100%; justify-content:center; padding:11px;}

/* ---------- Éditeur de document ---------- */
.doc-layout{display:grid; grid-template-columns:1fr 320px; gap:18px; align-items:start;}
.side-panel{position:sticky; top:80px;}
table.lines{width:100%; border-collapse:collapse;}
table.lines th{font-size:11px; text-transform:uppercase; letter-spacing:.04em; color:var(--mute);
  font-weight:700; text-align:left; padding:8px 8px; border-bottom:1px solid var(--line);}
table.lines th.num,table.lines td.num{text-align:right;}
table.lines td{padding:6px 8px; border-bottom:1px solid var(--line-soft); vertical-align:middle;}
table.lines input{padding:7px 9px; font-size:13.5px;}
table.lines input.qty,table.lines input.price{text-align:right;}
table.lines .line-total{font-variant-numeric:tabular-nums; font-weight:600; white-space:nowrap;}
.row-del{border:none; background:none; color:var(--bad); cursor:pointer; padding:4px 7px;
  border-radius:6px; font-size:17px; line-height:1;}
.row-del:hover{background:var(--bad-bg);}
.totals-box{border-top:2px solid var(--line); margin-top:14px; padding-top:12px;}
.totals-row{display:flex; justify-content:space-between; gap:16px; padding:5px 0; font-size:14px;}
.totals-row.final{border-top:1px solid var(--line); margin-top:8px; padding-top:12px;
  font-size:18px; font-weight:800; color:var(--blue);}
.totals-row .val{font-variant-numeric:tabular-nums;}

/* ---------- Facture imprimable ---------- */
.doc-toolbar{display:flex; gap:9px; flex-wrap:wrap; align-items:center; margin-bottom:20px;}
.doc-toolbar .spacer{flex:1;}
.sheet-wrap{display:flex; justify-content:center;}
.sheet{width:100%; max-width:820px; background:#fff; padding:46px 52px 38px;
  box-shadow:var(--shadow-lg); border-radius:4px;}
.sheet-head{display:flex; justify-content:space-between; align-items:flex-start; gap:24px;}
.sheet-logo{max-height:132px; max-width:290px; width:auto; display:block;}
.sheet-issuer{text-align:right; font-size:12.5px; color:var(--slate); line-height:1.6;}
.sheet-issuer .nm{font-size:16px; font-weight:700; color:var(--blue);}
.doc-title{font-family:var(--serif); font-size:38px; font-weight:700; color:var(--blue);
  margin:30px 0 0; letter-spacing:-.01em;}
.doc-meta{text-align:right; font-size:13.5px; line-height:1.85;}
.doc-meta .lbl{font-weight:700;}
.title-row{display:flex; justify-content:space-between; align-items:flex-end; gap:20px;}
.bill-to{background:#F5F7FA; border-radius:6px; padding:16px 20px; margin-top:26px;}
.bill-to .eyebrow{font-size:11px; text-transform:uppercase; letter-spacing:.06em;
  font-weight:700; color:var(--blue); margin-bottom:7px;}
.bill-to .nm{font-size:15px; font-weight:650;}
.bill-to .ln{font-size:13px; color:var(--slate); line-height:1.6;}
table.sheet-items{width:100%; border-collapse:collapse; margin-top:24px;}
table.sheet-items thead th{background:var(--blue); color:#fff; font-size:12px; font-weight:700;
  padding:10px 12px; text-align:left;}
table.sheet-items thead th.num{text-align:right;}
table.sheet-items tbody td{padding:10px 12px; border-bottom:1px solid var(--line);
  font-size:13.5px; vertical-align:top;}
table.sheet-items tbody tr:nth-child(even){background:#F7F9FC;}
table.sheet-items td.num{text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap;}
.sheet-totals{display:flex; justify-content:flex-end; margin-top:22px;}
.sheet-totals table{border-collapse:collapse; min-width:310px;}
.sheet-totals td{padding:8px 14px; font-size:13.5px;}
.sheet-totals td.lbl{text-align:right; color:var(--slate);}
.sheet-totals td.val{text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; min-width:130px;}
.sheet-totals tr.final td{background:var(--blue); color:#fff; font-weight:700; font-size:15px;}
.sheet-totals tr.due td{background:var(--warn-bg); color:var(--warn); font-weight:700;}
.in-words{margin-top:18px; font-size:13px; color:var(--slate);}
.in-words b{color:var(--ink);}
.pay-box{margin-top:26px; background:#F5F7FA; border-radius:6px; padding:16px 20px; font-size:13px; line-height:1.7;}
.pay-box .eyebrow{font-size:11px; text-transform:uppercase; letter-spacing:.06em;
  font-weight:700; color:var(--blue); margin-bottom:6px;}
.sheet-foot{margin-top:34px; border-top:2px solid var(--blue); padding-top:9px;
  text-align:center; font-size:10.5px; color:var(--slate); line-height:1.65;}
.sheet-foot .nm{font-weight:700; color:var(--blue); font-size:11.5px;}
.paid-stamp{display:inline-block; border:3px solid var(--ok); color:var(--ok);
  font-weight:800; font-size:15px; letter-spacing:.08em; padding:5px 16px;
  border-radius:6px; transform:rotate(-6deg); margin-top:14px;}

/* ---------- Graphique ---------- */
.chart{width:100%; height:190px; display:block;}
.chart .bar{fill:var(--blue); opacity:.88;}
.chart .bar:hover{opacity:1;}
.chart .axis{stroke:var(--line); stroke-width:1;}
.chart .lbl{font-size:10px; fill:var(--mute); font-family:var(--sans);}

/* ---------- Adaptatif ---------- */
@media (max-width:1080px){
  .grid.cols-4{grid-template-columns:repeat(2,1fr);}
  .doc-layout{grid-template-columns:1fr;}
  .side-panel{position:static;}
}
@media (max-width:820px){
  .sidebar{position:fixed; left:0; top:0; z-index:20; transform:translateX(-100%);
    transition:transform .22s ease;}
  body.nav-open .sidebar{transform:translateX(0);}
  body.nav-open .scrim{display:block;}
  .burger{display:inline-flex;}
  .content{padding:18px 16px;}
  .topbar{padding:0 16px;}
  .grid.cols-4,.grid.cols-3,.grid.cols-2{grid-template-columns:1fr;}
  .form-grid{grid-template-columns:1fr;}
  .sheet{padding:26px 20px;}
  .sheet-head{flex-direction:column; gap:14px;}
  .sheet-issuer{text-align:left;}
  .title-row{flex-direction:column; align-items:flex-start; gap:10px;}
  .doc-meta{text-align:left;}
  .table-wrap{margin:0 -16px -20px; padding:0 16px;}
}

/* ---------- Impression ---------- */
@media print{
  @page{size:A4; margin:12mm;}
  body{background:#fff; -webkit-print-color-adjust:exact; print-color-adjust:exact;
    text-rendering:geometricPrecision;}
  .sidebar,.topbar,.doc-toolbar,.scrim,.no-print,.flash{display:none !important;}
  .shell,.main-col{display:block;}
  .content{padding:0; max-width:100%;}
  .sheet-wrap{display:block;}
  .sheet{max-width:100%; box-shadow:none; border-radius:0; padding:0;}
  table.sheet-items thead{display:table-header-group;}
  table.sheet-items tr,.pay-box,.sheet-foot{break-inside:avoid;}
}
