/* TuneKey / Autoclé — styles */
:root {
  --brand: #2196f3; --brand-dark: #0b5394;
  --bg: #f3f6fa; --card: #fff; --text: #1d2939; --muted: #667085; --line: #e4e7ec;
  --green: #12b76a; --red: #e5484d; --orange: #f79009; --blue: #2e90fa; --grey: #98a2b3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .6rem; }
.muted { color: var(--muted); } .small { font-size: .85em; } .center { text-align: center; } .r { text-align: right; } .right { text-align: right; margin-top: 1rem; }
.nowrap { white-space: nowrap; } .mt { margin-top: .8rem; } .pos { color: var(--green); } .neg { color: var(--red); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: .45rem; font-weight: 800; letter-spacing: -.01em; font-size: 1.15rem; color: inherit; }
.logo svg { width: 34px; height: 22px; flex: none; }
.logo.big { font-size: 1.7rem; } .logo.big svg { width: 48px; height: 30px; }

/* ---------- Layout ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; background: #fff; border-bottom: 3px solid var(--brand); }
.topbrand { color: var(--brand-dark); } .topbrand:hover { text-decoration: none; }
.topright { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.switch { border: 1px solid var(--c); color: var(--c); padding: .25rem .7rem; border-radius: 999px; font-weight: 600; font-size: .85rem; }
.switch:hover { background: var(--c); color: #fff; text-decoration: none; }
.me { font-weight: 600; color: var(--text); }
.burger { display: none; background: none; border: 0; font-size: 1.4rem; cursor: pointer; padding: .3rem; }
.sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 230px; background: #fff; border-right: 1px solid var(--line); padding: .8rem .6rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; z-index: 15; }
.sidebar a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 8px; color: var(--text); font-weight: 500; }
.sidebar a svg { width: 20px; height: 20px; fill: var(--muted); flex: none; }
.sidebar a:hover { background: var(--bg); text-decoration: none; }
.sidebar a.active { background: var(--brand); color: #fff; }
.sidebar a.active svg { fill: #fff; }
.sidefoot { margin-top: auto; padding: .6rem .75rem; font-size: .8rem; color: var(--muted); display: flex; flex-direction: column; gap: .3rem; }
.sidefoot a { padding: 0; }
.main { margin-left: 230px; padding: 1.4rem 1.6rem 3rem; max-width: 1400px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Cartes / grilles ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1rem; min-width: 0; }
.card.narrow { max-width: 480px; }
.cardhead { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .6rem; }
.cardhead h2 { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; align-items: start; }
.grid2.wide-left { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.kpis.small3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem 1.1rem; border-left: 4px solid var(--brand); display: flex; flex-direction: column; gap: .15rem; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi b { font-size: 1.35rem; }
.kpi small { color: var(--muted); }
.kpi.warn { border-left-color: var(--orange); }

/* ---------- Tableaux ---------- */
.tablewrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: .5rem .5rem; border-bottom: 1px solid var(--line); }
.table td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th.r { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table tr.grand td { font-weight: 700; border-top: 2px solid var(--text); }
.table tr.inactive td { opacity: .5; }
.table th.cur, .table td.cur { background: color-mix(in srgb, var(--brand) 7%, transparent); }
.lines input, .lines select { width: 100%; }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: .35rem .8rem; margin: 0 0 1rem; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
.note { background: #fffbea; border-left: 3px solid var(--orange); padding: .6rem .8rem; border-radius: 6px; }
.pager { display: flex; gap: .3rem; margin-top: .8rem; flex-wrap: wrap; }
.pager a { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 6px; }
.pager a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.b-green, .b-st-termine { background: #dcfae6; color: #067647; }
.b-red, .b-st-absent { background: #fee4e2; color: #b42318; }
.b-orange, .b-st-prevu { background: #fef0c7; color: #93370d; }
.b-blue, .b-st-confirme { background: #d1e9ff; color: #175cd3; }
.b-grey, .b-st-annule { background: #f2f4f7; color: #475467; }

/* ---------- Formulaires ---------- */
.form label, .authbox label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 600; color: #344054; margin-bottom: .8rem; flex: 1; min-width: 0; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.row { display: flex; gap: .9rem; flex-wrap: wrap; }
.row > label { min-width: 160px; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #d0d5dd; border-radius: 8px; padding: .5rem .65rem; background: #fff; width: 100%; min-width: 0; }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 40px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
input.locked, input[readonly] { background: #f2f4f7; color: var(--muted); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem .2rem; margin: 0 0 1rem; }
legend { font-weight: 700; font-size: .85rem; padding: 0 .4rem; }
.formactions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input, .toolbar select { width: auto; }
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar label.inl { display: flex; align-items: center; gap: .3rem; font-size: .9rem; }
.weeklabel { margin: 0 .5rem; }
form.inline { display: inline; }
.rowform { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.rowform input { width: auto; flex: 1; min-width: 110px; }
.totals { margin: 1rem 0 1rem auto; max-width: 340px; display: flex; flex-direction: column; gap: .4rem; }
.totals div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.totals input { max-width: 150px; text-align: right; }
.totals .grand { font-size: 1.25rem; border-top: 2px solid var(--text); padding-top: .4rem; }
.tabs { display: flex; gap: .2rem; background: #fff; border-radius: 8px; padding: 3px; box-shadow: var(--shadow); }
.tabs a { padding: .35rem .8rem; border-radius: 6px; color: var(--text); }
.tabs a.active { background: var(--brand); color: #fff; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid #d0d5dd; background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fda29b; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; }
.mini { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: .8rem; color: var(--text); list-style: none; }
.mini:hover { background: var(--bg); text-decoration: none; }
summary.mini::-webkit-details-marker, summary.btn::-webkit-details-marker { display: none; }
summary { cursor: pointer; list-style: none; }
details.pop { display: inline-block; position: relative; }
.popform { position: absolute; right: 0; top: 32px; z-index: 10; background: #fff; box-shadow: 0 8px 24px rgba(16,24,40,.18); border-radius: var(--radius); padding: 1rem; width: 380px; max-width: 86vw; text-align: left; }
.popform label { display: flex; flex-direction: column; gap: .25rem; font-size: .8rem; font-weight: 600; margin-bottom: .6rem; flex: 1; }
.popform label.check { flex-direction: row; }

/* ---------- Messages ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.flash-ok { background: #dcfae6; color: #067647; }
.flash-err { background: #fee4e2; color: #b42318; }
.flash-warn { background: #fef0c7; color: #93370d; }
.flash-info { background: #d1e9ff; color: #175cd3; }

/* ---------- Rendez-vous ---------- */
.rdvlist { list-style: none; margin: 0; padding: 0; }
.rdvlist li { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.rdvlist li .badge { margin-left: auto; }
.rdvlist.compact li { padding: .3rem 0; }
.rdvlist li.st-annule, .rdvlist li.st-absent { opacity: .55; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.day { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); min-height: 220px; padding: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.day.today { outline: 2px solid var(--brand); }
.dayhead { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .3rem; }
.dayhead a { font-weight: 700; font-size: 1.1rem; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.dayhead a:hover { background: var(--brand); color: #fff; text-decoration: none; }
.ev { border-left: 4px solid var(--orange); background: #fffaeb; border-radius: 6px; padding: .35rem .45rem; font-size: .83rem; }
.ev a { color: var(--text); display: block; }
.ev a:hover { text-decoration: none; }
.ev small { display: block; color: var(--muted); }
.ev.st-confirme { border-color: var(--blue); background: #eff8ff; }
.ev.st-termine { border-color: var(--green); background: #ecfdf3; }
.ev.st-annule, .ev.st-absent { border-color: var(--grey); background: #f9fafb; opacity: .6; }
.evact { display: flex; gap: .2rem; margin-top: .3rem; flex-wrap: wrap; }
.evact .mini { height: 22px; min-width: 22px; font-size: .7rem; }

/* ---------- Mini graphique ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: .5rem; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bar i { display: block; width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar span { font-size: .7rem; color: var(--muted); }

/* ---------- Connexion / choix ---------- */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); }
.authbox { background: #fff; padding: 2rem; border-radius: 16px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.authbox.wide { max-width: 520px; }
.authbox h1 { margin-bottom: 1rem; }
.authlogos { display: flex; flex-direction: column; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.choose { width: 100%; max-width: 860px; color: #fff; }
.choose h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.4rem; }
.choose .muted { color: rgba(255,255,255,.8); }
.choosegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.2rem; margin-bottom: 1.5rem; }
.choosecard { display: flex; flex-direction: column; gap: .6rem; padding: 2rem 1.6rem; border-radius: 16px; color: #fff; background: linear-gradient(135deg, var(--c), var(--c2)); box-shadow: 0 14px 35px rgba(0,0,0,.25); border: 2px solid rgba(255,255,255,.5); transition: transform .15s; }
.choosecard:hover { transform: translateY(-3px); text-decoration: none; }
.choosecard small { opacity: .85; }

/* ---------- Facture ---------- */
body.print { background: #e9edf2; }
.printbar { max-width: 820px; margin: 1rem auto; display: flex; gap: .5rem; }
.invoice { max-width: 820px; margin: 0 auto 2rem; background: #fff; padding: 2.4rem; box-shadow: var(--shadow); border-top: 8px solid var(--brand); }
.invoice header { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; }
.invoice header h1 { color: var(--brand-dark); font-size: 1.8rem; }
.invoice .logo { color: var(--brand-dark); }
.billto { display: flex; gap: 3rem; background: #f6f8fb; padding: 1rem 1.2rem; border-radius: 8px; margin-bottom: 1.4rem; }
.invoice .table th { background: var(--brand); color: #fff; }
.sign { display: flex; justify-content: space-between; margin: 2.5rem 0 3rem; color: var(--muted); }
.invoice footer { text-align: center; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .8rem; }
@media print {
  body.print { background: #fff; }
  .noprint { display: none !important; }
  .invoice { box-shadow: none; margin: 0; padding: 0; max-width: none; }
  .invoice .table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .invoice, .billto { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .burger { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 30px rgba(0,0,0,.2); }
  body.nav-open .sidebar { transform: none; }
  .main { margin-left: 0; padding: 1rem 1rem 3rem; }
  .grid2, .grid2.wide-left { grid-template-columns: minmax(0, 1fr); }
  .topright .me, .topright .muted { display: none; }
  .logo { font-size: 1rem; }
}
@media (max-width: 560px) {
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; }
  .kpis, .kpis.small3 { grid-template-columns: minmax(0, 1fr); }
  .row > label { min-width: 100%; }
  .invoice { padding: 1.2rem; }
  .invoice header, .billto { flex-direction: column; gap: 1rem; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { margin-top: .4rem; }
  .table th, .table td { padding: .45rem .35rem; }
}
