:root {
  --beige: #FCF5E9;
  --beige-2: #F4EADA;
  --line: #E8DFD0;
  --ink: #3F3E3E;
  --ink-2: #6f6a63;
  --ink-3: #9b948a;
  --card: #FFFFFF;
  --coral: #D57956;
  --coral-dark: #b9603f;
  --green: #4E7438;
  --green-bg: #E6EFDD;
  --orange: #B7791F;
  --orange-bg: #FBEBD0;
  --blue: #2F6FA3;
  --blue-bg: #DCEBF7;
  --red: #B42318;
  --red-bg: #FBE1DE;
  --brown: #8B6F47;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(63, 62, 62, .05), 0 4px 16px rgba(63, 62, 62, .06);
  --font-ui: "Baloo 2", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: "Londrina Solid", "Baloo 2", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--beige);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.4;
  padding-inline: 16px;
  padding-block: 12px 48px;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { max-width: 540px; margin: 0 auto; }
.wrap.wide { max-width: 1180px; }

h1, h2, h3 { font-family: var(--font-title); font-weight: 400; letter-spacing: .02em; margin: 0; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 8px 16px; }
.top .hello { font-size: 15px; color: var(--ink-2); }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  background: var(--coral); color: #fff; font-weight: 600; font-size: 15px;
  box-shadow: 0 2px 0 var(--coral-dark);
  transition: transform .08s ease, background .15s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--coral-dark); }
.btn.ghost { background: var(--beige-2); color: var(--ink); box-shadow: none; }
.btn.ghost:hover { background: var(--line); }
.btn.link { background: none; color: var(--coral-dark); box-shadow: none; padding: 6px 8px; }
.btn.danger { background: none; color: var(--red); box-shadow: none; padding: 6px 8px; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 14px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--beige-2); display: inline-grid; place-items: center; font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: var(--line); }
:focus-visible { outline: 3px solid rgba(213, 121, 86, .45); outline-offset: 2px; }

/* Compteur */
.balance { text-align: center; padding: 22px 18px 14px; position: relative; overflow: hidden; }
.balance .label { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.balance .value { font-family: var(--font-title); font-size: 56px; line-height: 1; margin: 6px 0 2px; }
.balance .sentence { font-size: 17px; font-weight: 600; }
.balance .foot { font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.tone-ahead { --tone: var(--blue); --tone-bg: var(--blue-bg); }
.tone-late { --tone: var(--orange); --tone-bg: var(--orange-bg); }
.tone-ok { --tone: var(--green); --tone-bg: var(--green-bg); }
.balance.tone-ahead, .balance.tone-late, .balance.tone-ok { background: linear-gradient(180deg, var(--tone-bg), #fff 75%); }
.balance .value, .balance .sentence { color: var(--tone); }
.spark { display: block; width: 100%; height: 64px; margin-top: 10px; }

/* Semaine */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.week-nav .title { text-align: center; }
.week-nav .title strong { display: block; font-size: 17px; }
.progress { height: 12px; background: var(--beige-2); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; position: relative; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .3s; }
.progress.over > span { background: var(--blue); }
.progress-legend { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); }

.days { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.day {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 8px 12px; cursor: pointer; min-height: 56px;
}
.day:hover { border-color: var(--coral); }
.day.today { border-color: var(--coral); box-shadow: inset 3px 0 0 var(--coral); }
.day.future { background: #fffdf9; }
.day .d { text-align: center; line-height: 1.05; }
.day .d .wd, .day .d .dn { display: block; }
.day .d .wd { font-size: 12px; text-transform: uppercase; color: var(--ink-2); letter-spacing: .05em; }
.day .d .dn { font-family: var(--font-title); font-size: 22px; }
.day .mid { min-width: 0; }
.day .mid .worked { font-weight: 700; font-size: 17px; }
.day .mid .sub { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .empty { color: var(--ink-3); font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 2px 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--beige-2); color: var(--ink);
}
.chip.ahead { background: var(--blue-bg); color: var(--blue); }
.chip.late { background: var(--orange-bg); color: var(--orange); }
.chip.ok { background: var(--green-bg); color: var(--green); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.abs { background: var(--abs, var(--beige-2)); color: var(--ink); }

/* Congés */
.cp-big { display: flex; align-items: baseline; gap: 8px; }
.cp-big .value { font-family: var(--font-title); font-size: 44px; line-height: 1; color: var(--blue); }
.stack { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--beige-2); margin: 12px 0 8px; }
.stack span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; background: var(--beige); border-radius: 10px; font-size: 14.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 14.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.sched { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.sched span { font-size: 12.5px; padding: 2px 8px; border-radius: 8px; background: var(--beige-2); }
.sched span.off { color: var(--ink-3); background: transparent; border: 1px dashed var(--line); }

/* Fenêtres (bottom sheet sur mobile) */
dialog.sheet {
  border: 0; padding: 0; width: min(560px, 100%); max-width: 100%; max-height: 92vh;
  border-radius: 20px; background: #fff; color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog.sheet.large { width: min(1000px, 100%); }
dialog.sheet::backdrop { background: rgba(40, 32, 24, .45); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100%; border-radius: 20px 20px 0 0; max-height: 94vh; }
}
.sheet-head { position: sticky; top: 0; background: #fff; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 10px; border-bottom: 1px solid var(--beige-2); }
.sheet-body { padding: 14px 18px 18px; }
.sheet-foot { position: sticky; bottom: 0; background: #fff; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--beige-2); }
.sheet-foot .spacer { flex: 1; }

/* Formulaires */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 120px; }
.row > .icon-btn, .row > .btn.link, .top .row > * { flex: 0 0 auto; }
input[type=text], input[type=number], input[type=date], input[type=time], input[type=password], select, textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; min-height: 46px;
}
input:focus, select:focus, textarea:focus { border-color: var(--coral); outline: none; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--coral); }

.slot { display: grid; grid-template-columns: 1fr auto 1fr 40px; align-items: center; gap: 8px; margin-bottom: 8px; }
.slot .arrow { color: var(--ink-3); }
.total-line { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--beige); border-radius: 12px; margin: 6px 0 14px; font-size: 16px; }
.total-line strong { font-family: var(--font-title); font-size: 26px; font-weight: 400; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.seg { display: inline-flex; background: var(--beige-2); border-radius: 999px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14.5px; color: var(--ink-2); }
.seg button[aria-pressed=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.types label { cursor: pointer; }
.types input { position: absolute; opacity: 0; pointer-events: none; }
.types span { display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1.5px solid var(--line); font-size: 14px; font-weight: 600; background: #fff; }
.types input:checked + span { border-color: var(--ink); background: var(--abs, var(--beige-2)); }
.types input:focus-visible + span { outline: 3px solid rgba(213, 121, 86, .45); }

.week-grid { display: grid; gap: 6px; }
.week-grid .wrow { display: grid; grid-template-columns: 1fr 110px; align-items: center; gap: 10px; }
.week-grid .wrow .lbl strong { display: block; }

.notice { padding: 10px 14px; border-radius: 12px; background: var(--beige); font-size: 14px; color: var(--ink-2); margin-bottom: 12px; }
.error { background: var(--red-bg); color: var(--red); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px);
}
.center-screen { min-height: 70vh; display: grid; place-items: center; text-align: center; }

/* ----- Admin ----- */
.alerts { display: grid; gap: 6px; }
.alert { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border-radius: 10px; background: var(--beige); font-size: 14.5px; border-left: 4px solid var(--line); cursor: pointer; }
.alert.red { border-color: var(--red); background: var(--red-bg); }
.alert.orange { border-color: #E8A838; background: #FDF3E1; }
.alert.blue { border-color: var(--blue); background: #EAF3FB; }
.alert.info { border-color: var(--line); }
.alert strong { white-space: nowrap; }

.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person { text-align: left; border: 0; cursor: pointer; margin: 0; display: grid; gap: 10px; }
.person:hover { box-shadow: 0 0 0 2px var(--coral), var(--shadow); }
.person .who { display: flex; align-items: center; gap: 10px; }
.dot { width: 14px; height: 14px; border-radius: 999px; flex: none; background: var(--c, var(--coral)); }
.person .who strong { font-size: 18px; }
.person .who .small { display: block; line-height: 1.2; }
.person .figures { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.person .fig { background: var(--beige); border-radius: 10px; padding: 6px 8px; }
.person .fig b { display: block; font-size: 16px; white-space: nowrap; }
.person .fig span { font-size: 12px; color: var(--ink-2); }
.diverge { position: relative; height: 10px; background: var(--beige-2); border-radius: 999px; }
.diverge::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink-3); }
.diverge span { position: absolute; top: 0; bottom: 0; border-radius: 999px; }

.table-wrap { overflow-x: auto; }
table.grid { border-collapse: separate; border-spacing: 3px; width: 100%; min-width: 760px; font-size: 14px; }
table.grid th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; text-align: center; padding: 4px; }
table.grid th:first-child { text-align: left; }
table.grid td { text-align: center; padding: 7px 4px; border-radius: 8px; background: var(--beige); white-space: nowrap; }
table.grid td.name { text-align: left; background: none; font-weight: 600; padding-left: 0; }
table.grid td.ok { background: var(--green-bg); }
table.grid td.more { background: var(--blue-bg); }
table.grid td.less { background: var(--orange-bg); }
table.grid td.off { background: transparent; color: var(--ink-3); }
table.grid td.absent { background: var(--abs); }
table.grid td .p { display: block; font-size: 11.5px; color: var(--ink-2); }
table.grid td.tot { background: #fff; font-weight: 700; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--beige-2); margin: 0 -18px 14px; padding: 0 18px; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; }
.tabs button[aria-selected=true] { color: var(--ink); border-color: var(--coral); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: minmax(0, 540px) minmax(0, 1fr); align-items: start; } }
.detail-grid .card { box-shadow: none; border: 1px solid var(--beige-2); }
.daychips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.daychips label { display: grid; gap: 3px; text-align: center; font-size: 12.5px; color: var(--ink-2); }
.daychips input { min-height: 40px; padding: 6px 2px; text-align: center; }

@media (max-width: 600px) {
  .top { flex-wrap: wrap; }
  .top > div:first-child { flex: 1 1 100%; }
  .alert { flex-direction: column; gap: 0; }
  .card-head { flex-wrap: wrap; }
}

/* ----- Onglets principaux ----- */
.main-tabs { display: flex; gap: 4px; background: var(--beige-2); border-radius: 999px; padding: 4px; margin: 0 0 14px; }
.main-tabs button { flex: 1; border: 0; background: none; border-radius: 999px; padding: 9px 12px; font-weight: 700; font-size: 15.5px; color: var(--ink-2); cursor: pointer; }
.main-tabs button[aria-selected=true] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.main-tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 12px; line-height: 20px; }
.wide .main-tabs { max-width: 460px; }

/* ----- Notes de frais ----- */
.expenses { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.expense { display: flex; gap: 10px; align-items: stretch; justify-content: space-between; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; }
.expense.refused { background: #fdf6f5; }
.expense.reimbursed { background: #fbfdf9; }
.expense-main { flex: 1; min-width: 0; display: grid; gap: 2px; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; }
.expense-main:disabled { cursor: default; color: inherit; }
.expense-top { display: flex; align-items: center; gap: 8px; }
.expense-top strong { font-size: 18px; }
.expense-desc { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; }
.expense-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 4px; }
@media (max-width: 480px) { .expense { flex-direction: column; } .expense-side { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: flex-start; } }
.receipt-pick img { display: block; max-width: 100%; max-height: 260px; margin: 0 auto 10px; border-radius: 12px; object-fit: contain; background: var(--beige); }
.receipt-view { display: grid; gap: 10px; justify-items: center; }
.receipt-view img { max-width: 100%; max-height: 75vh; border-radius: 10px; }
.receipt-view iframe { width: 100%; height: 75vh; border: 0; border-radius: 10px; background: var(--beige); }
.person-group { margin-bottom: 14px; }
.person-group .card-head .who { display: flex; align-items: center; gap: 8px; }
.person-group .card-head .row > *, .card-head .row > .btn { flex: 0 0 auto; }

/* Fenêtres : repli quand <dialog> n'est pas pris en charge */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(40, 32, 24, .45); z-index: 900; }
dialog.sheet.sheet-fallback { display: block; position: fixed; z-index: 901; left: 50%; top: 4vh; transform: translateX(-50%); margin: 0; overflow: auto; }
dialog.sheet { overflow: auto; }
@media (max-width: 600px) { dialog.sheet.sheet-fallback { top: auto; bottom: 0; } }

/* ----- Compteurs semaine / mois ----- */
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.counter { display: grid; gap: 4px; min-width: 0; }
.counter-title { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.counter-value strong { font-family: var(--font-title); font-weight: 400; font-size: 26px; }
.counter .progress { margin: 2px 0; height: 8px; }
@media (max-width: 380px) { .counters { grid-template-columns: 1fr; } }
.view-toggle { display: flex; width: max-content; margin: 0 auto 12px; }

/* ----- Calendrier du mois ----- */
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
.mhead { text-align: center; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); padding-bottom: 2px; }
.mday { min-height: 54px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 4px; display: grid; align-content: space-between; text-align: left; cursor: pointer; min-width: 0; }
.mday:hover { border-color: var(--coral); }
.mday.out { border: 0; background: none; cursor: default; }
.mday.today { box-shadow: inset 0 0 0 2px var(--coral); }
.mday.ok { background: var(--green-bg); }
.mday.more { background: var(--blue-bg); }
.mday.less { background: var(--orange-bg); }
.mday.absent { background: var(--abs); }
.mday.missing { border: 1.5px dashed #E8A838; }
.mday.rest { background: #fbf8f2; }
.mnum { font-size: 12px; color: var(--ink-2); }
.mval { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 420px) { .mday { min-height: 46px; padding: 3px; } .mval { font-size: 11px; } }

/* ----- Notes à lire ----- */
.notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.notes-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 9px 12px; border-radius: 10px; background: #FFF8E6; border-left: 4px solid var(--yellow, #ECBE2F); }
.notes-list .note-text { flex: 1; min-width: 0; font-size: 14.5px; cursor: pointer; }
.notes-list .note-text q { quotes: "« " " »"; }
